ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/juli/TestThreadNameCache.java

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

      
    
Rootfs path

      
    
Size
2341 (2.3 KB)
MD5
8a766cb4bcd40cd1a216f4327323b319
SHA1
4ebeb79da376209ca027fb13b72bc710d87d6c2b
SHA256
87381ef8c016b42f200aff804b1fc9e65142cee578ce2b54826b9480d373155c
SHA512

      
    
SHA1_git
29784a12fe5957b290672e78a0a89288dea9682c
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestThreadNameCache.java | 2.3 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.juli; import java.lang.reflect.Method; import java.util.concurrent.CountDownLatch; import org.junit.Assert; import org.junit.Test; public class TestThreadNameCache { private Integer threadId; @Test public void testCache() throws Exception { final String THREAD_NAME = "t-TestThreadNameCache"; final CountDownLatch threadIdLatch = new CountDownLatch(1); final CountDownLatch cacheLatch = new CountDownLatch(1); OneLineFormatter olf = new OneLineFormatter(); Method getThreadName = olf.getClass().getDeclaredMethod("getThreadName", long.class); getThreadName.setAccessible(true); Thread thread = new Thread() { @SuppressWarnings("deprecation") @Override public void run() { setName(THREAD_NAME); threadId = Integer.valueOf((int) getId()); threadIdLatch.countDown(); try { cacheLatch.await(); } catch (InterruptedException ex) { throw new RuntimeException(ex); } } }; thread.start(); threadIdLatch.await(); Object name = getThreadName.invoke(olf, threadId); cacheLatch.countDown(); Assert.assertEquals(THREAD_NAME, name); thread.join(); name = getThreadName.invoke(olf, threadId); Assert.assertEquals(THREAD_NAME, name); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
48.97
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