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

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

      
    
Rootfs path

      
    
Size
3652 (3.6 KB)
MD5
84d53559b2a2473d90777904bad89ad0
SHA1
4e2a4b22eed4a62f91b00aa94b425b18368ee892
SHA256
9f5bc0a45661781ec9a023393ea77df973ff94c20d5b243d306cd1b6a2928ad0
SHA512

      
    
SHA1_git
7c548756a5cf7ef5967b30434a8be2464a77c44e
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestSynchronizedQueue.java | 3.6 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 TestSynchronizedQueue { public void testPollEmpty() { SynchronizedQueue<Object> queue = new SynchronizedQueue<>(); Assert.assertNull(queue.poll()); } @Test public void testOfferPollOrder() { SynchronizedQueue<Object> queue = new SynchronizedQueue<>(); Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); Object o4 = new Object(); queue.offer(o1); queue.offer(o2); queue.offer(o3); queue.offer(o4); Assert.assertSame(queue.poll(), o1); Assert.assertSame(queue.poll(), o2); Assert.assertSame(queue.poll(), o3); Assert.assertSame(queue.poll(), o4); Assert.assertNull(queue.poll()); } @Test public void testExpandOfferPollOrder() { SynchronizedQueue<Object> queue = new SynchronizedQueue<>(); Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); Object o4 = new Object(); for (int i = 0; i < 300; i++) { queue.offer(o1); queue.offer(o2); queue.offer(o3); queue.offer(o4); } for (int i = 0; i < 300; i++) { Assert.assertSame(queue.poll(), o1); Assert.assertSame(queue.poll(), o2); Assert.assertSame(queue.poll(), o3); Assert.assertSame(queue.poll(), o4); } Assert.assertNull(queue.poll()); } @Test public void testExpandOfferPollOrder2() { SynchronizedQueue<Object> queue = new SynchronizedQueue<>(); Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); Object o4 = new Object(); for (int i = 0; i < 100; i++) { queue.offer(o1); queue.offer(o2); queue.offer(o3); queue.offer(o4); } for (int i = 0; i < 50; i++) { Assert.assertSame(queue.poll(), o1); Assert.assertSame(queue.poll(), o2); Assert.assertSame(queue.poll(), o3); Assert.assertSame(queue.poll(), o4); } for (int i = 0; i < 200; i++) { queue.offer(o1); queue.offer(o2); queue.offer(o3); queue.offer(o4); } for (int i = 0; i < 250; i++) { Assert.assertSame(queue.poll(), o1); Assert.assertSame(queue.poll(), o2); Assert.assertSame(queue.poll(), o3); Assert.assertSame(queue.poll(), o4); } Assert.assertNull(queue.poll()); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
29.46
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