ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/startup/TestStrictServletComplianceAttributes.java

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

      
    
Rootfs path

      
    
Size
3957 (3.9 KB)
MD5
1ece5a4b8dd122863b64893f46fe1752
SHA1
533913e81084e27593e1b7fc495eed584526fba7
SHA256
066370a7405e9863adbc578427e23c2b73f3b6ef6c170cae565619ac7134147c
SHA512

      
    
SHA1_git
478d588cf652ab1e15dd183c04bd9c18a6f9371a
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestStrictServletComplianceAttributes.java | 3.9 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.catalina.startup; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; import org.apache.catalina.Context; import org.apache.catalina.Globals; import org.apache.catalina.Manager; import org.apache.catalina.session.ManagerBase; /** * Tests STRICT_SERVLET_COMPLIANCE sets the attributes it is documented to set. */ public class TestStrictServletComplianceAttributes extends TomcatBaseTest { private static final String STRICT_SERVLET_COMPLIANCE = "org.apache.catalina.STRICT_SERVLET_COMPLIANCE"; private static String originalPropertyValue; @BeforeClass public static void setup() { originalPropertyValue = System.getProperty(STRICT_SERVLET_COMPLIANCE); System.setProperty(STRICT_SERVLET_COMPLIANCE, "true"); // If Globals was already initialised in the same JVM (during the tests run through IDE), // before the test sets the value to true, skip. boolean globalsStrict = Globals.STRICT_SERVLET_COMPLIANCE; Assume.assumeTrue("Globals was initialised before setting the property", globalsStrict); } @AfterClass public static void restoreStrictServletCompliance() { if (originalPropertyValue == null) { System.clearProperty(STRICT_SERVLET_COMPLIANCE); } else { System.setProperty(STRICT_SERVLET_COMPLIANCE, originalPropertyValue); } } @Test public void contextFlagsSetWhenStrictComplianceIsEnabled() { Context ctx = getProgrammaticRootContextWithManager(); Assert.assertTrue("xmlValidation should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getXmlValidation()); Assert.assertTrue("xmlNamespaceAware should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getXmlNamespaceAware()); Assert.assertTrue("tldValidation should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getTldValidation()); Assert.assertFalse("useRelativeRedirects should be false under STRICT_SERVLET_COMPLIANCE.", ctx.getUseRelativeRedirects()); Assert.assertTrue("alwaysAccessSession should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getAlwaysAccessSession()); Assert.assertTrue("contextGetResourceRequiresSlash should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getContextGetResourceRequiresSlash()); Assert.assertTrue("dispatcherWrapsSameObject should be true under STRICT_SERVLET_COMPLIANCE.", ctx.getDispatcherWrapsSameObject()); Assert.assertFalse("All extension mapped servlets should be checked against welcome files under STRICT_SERVLET_COMPLIANCE.", ctx.isResourceOnlyServlet("jsp")); Manager manager = ctx.getManager(); if (manager instanceof ManagerBase managerBase) { Assert.assertTrue("ManagerBase.sessionActivityCheck should be true under STRICT", managerBase.getSessionActivityCheck()); Assert.assertTrue("ManagerBase.sessionLastAccessAtStart should be true under STRICT", managerBase.getSessionLastAccessAtStart()); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
28.61
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