ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/collections/TestSynchronizedStack.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/tomcat/util/collections/TestSynchronizedStack.java
Status
scanned
Type
file
Name
TestSynchronizedStack.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
3518 (3.4 KB)
MD5
14c8a2b44427068181abbc482455c542
SHA1
b1627d7233d2892791bcb4c3b0b7e9cd57a7ce14
SHA256
d8480b57f2c3da3467d4eeb380dc5805fdb8647d4776fbe209c8106a369ad2dc
SHA512

      
    
SHA1_git
e51e462f262880ba1e4547c054aea7bcac163db9
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestSynchronizedStack.java | 3.4 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tomcat.util.collections; import org.junit.Assert; import org.junit.Test; public class TestSynchronizedStack { @Test public void testPopEmpty() { SynchronizedStack<Object> stack = new SynchronizedStack<>(); Assert.assertNull(stack.pop()); } @Test public void testPushPopOrder() { SynchronizedStack<Object> stack = new SynchronizedStack<>(); Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); Object o4 = new Object(); stack.push(o1); stack.push(o2); stack.push(o3); stack.push(o4); Assert.assertSame(stack.pop(), o4); Assert.assertSame(stack.pop(), o3); Assert.assertSame(stack.pop(), o2); Assert.assertSame(stack.pop(), o1); Assert.assertNull(stack.pop()); } @Test public void testExpandPushPopOrder() { SynchronizedStack<Object> stack = new SynchronizedStack<>(); Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); Object o4 = new Object(); for (int i = 0; i < 300; i++) { stack.push(o1); stack.push(o2); stack.push(o3); stack.push(o4); } for (int i = 0; i < 300; i++) { Assert.assertSame(stack.pop(), o4); Assert.assertSame(stack.pop(), o3); Assert.assertSame(stack.pop(), o2); Assert.assertSame(stack.pop(), o1); } Assert.assertNull(stack.pop()); } @Test public void testLimit() { SynchronizedStack<Object> stack = new SynchronizedStack<>(2,2); Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); Object o4 = new Object(); stack.push(o1); stack.push(o2); stack.push(o3); stack.push(o4); Assert.assertSame(stack.pop(), o2); Assert.assertSame(stack.pop(), o1); Assert.assertNull(stack.pop()); } @Test public void testLimitExpand() { SynchronizedStack<Object> stack = new SynchronizedStack<>(1,3); Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); Object o4 = new Object(); stack.push(o1); stack.push(o2); stack.push(o3); stack.push(o4); Assert.assertSame(stack.pop(), o3); Assert.assertSame(stack.pop(), o2); Assert.assertSame(stack.pop(), o1); Assert.assertNull(stack.pop()); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
30.13
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9