ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/naming/TestEnvEntry.java

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

      
    
Rootfs path

      
    
Size
4326 (4.2 KB)
MD5
6e8cd15450076335b85edc07df3843f2
SHA1
3c9d54b4bc2792be2e6d1cc9178e99f4283476c6
SHA256
e5b0d67427435388bbe4a37173df2addc49465b6190f549c7e4d85820a57e76e
SHA512

      
    
SHA1_git
094e1dc233c50fcb909062cf151bc249dbf6e999
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestEnvEntry.java | 4.2 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.naming; import java.io.File; import jakarta.servlet.http.HttpServletResponse; import org.junit.Assert; import org.junit.Test; import org.apache.catalina.Context; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; import org.apache.tomcat.util.buf.ByteChunk; public class TestEnvEntry extends TomcatBaseTest { @Test public void testEnvEntryBasic() throws Exception { doTestJndiLookup("env-entry/basic", "basic-value"); } @Test public void testEnvEntryValid() throws Exception { doTestJndiLookup("env-entry/valid", "valid"); } @Test public void testEnvEntryInvalid() throws Exception { doTestJndiLookup("env-entry/invalid", "Not Found"); } @Test public void testEnvEntryInjectField() throws Exception { doTestJndiInjection("property1", "inject-value-1"); } @Test public void testEnvEntryInjectProperty() throws Exception { doTestJndiInjection("property2", "inject-value-2"); } @Test public void testEnvEntryInjectFieldNoType() throws Exception { doTestJndiInjection("property3", "inject-value-3"); } @Test public void testEnvEntryInjectionNoValue() throws Exception { doTestJndiLookup("env-entry/injectNoValue", "Not Found"); } @Test public void testEnvEntryLookup() throws Exception { doTestJndiLookup("env-entry/lookup", "basic-value"); } @Test public void testEnvEntryLookupCircular() throws Exception { doTestJndiLookup("env-entry/circular1", "Naming Error"); } @Test public void testEnvEntryLookupInvalid() throws Exception { doTestJndiLookup("env-entry/lookup-invalid", "Naming Error"); } private void doTestJndiLookup(String jndiName, String expected) throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File("test/webapp-fragments"); tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); tomcat.enableNaming(); tomcat.start(); ByteChunk out = new ByteChunk(); int rc = getUrl("http://localhost:" + getPort() + "/test/jndi.jsp?jndiName=" + jndiName, out, null); Assert.assertEquals(HttpServletResponse.SC_OK, rc); // JSP has leading and trailing white-space String result = out.toString().trim(); Assert.assertEquals(expected, result); } private void doTestJndiInjection(String injectionName, String expected) throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File("test/webapp-fragments"); Context context = tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); Tomcat.addServlet(context, "InjectionServlet", "org.apache.naming.TesterInjectionServlet"); context.addServletMappingDecoded("/injection", "InjectionServlet"); tomcat.enableNaming(); tomcat.start(); ByteChunk out = new ByteChunk(); int rc = getUrl("http://localhost:" + getPort() + "/test/injection?injectionName=" + injectionName, out, null); Assert.assertEquals(HttpServletResponse.SC_OK, rc); // JSP has leading and trailing white-space String result = out.toString().trim(); Assert.assertEquals(expected, result); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
27.42
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