ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/el/util/TestReflectionUtil.java

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

      
    
Rootfs path

      
    
Size
3076 (3.0 KB)
MD5
0f03aaa5ef59ee68efb83927cd55c904
SHA1
7c778b15c7f059c90b8e97f962cd1843c297b14b
SHA256
2c4d2e5d476d908c1134d59e45e71ee259f0d30e7faf52c7a20f45481be7a4ec
SHA512

      
    
SHA1_git
6eded2877f49baaa0a6926cd82aac517652328be
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestReflectionUtil.java | 3.0 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.el.util; import jakarta.el.ELContext; import jakarta.el.ExpressionFactory; import jakarta.el.MethodExpression; import jakarta.el.MethodNotFoundException; import org.junit.Assert; import org.junit.Test; import org.apache.jasper.el.ELContextImpl; public class TestReflectionUtil { private static final Tester BASE = new Tester(); /* * Expect failure as it is not possible to identify which method named * "testA()" is intended. */ @Test(expected=MethodNotFoundException.class) public void testBug54370a() { ReflectionUtil.getMethod(null, BASE, "testA", new Class[] {null, String.class}, new Object[] {null, ""}); } /* * Expect failure as it is not possible to identify which method named * "testB()" is intended. Note: In EL null can always be coerced to a valid * value for a primitive. */ @Test(expected=MethodNotFoundException.class) public void testBug54370b() { ReflectionUtil.getMethod(null, BASE, "testB", new Class[] {null, String.class}, new Object[] {null, ""}); } @Test public void testBug54370c() { ReflectionUtil.getMethod(null, BASE, "testC", new Class[] {null}, new Object[] {null}); } @Test public void testBug54370d() { ReflectionUtil.getMethod(null, BASE, "testD", new Class[] {null}, new Object[] {null}); } @Test public void testStaticMethodOnInstance() { ExpressionFactory factory = ExpressionFactory.newInstance(); ELContext context = new ELContextImpl(); MethodExpression methodExpression = factory.createMethodExpression(context, "${\"1\".format(2)}", String.class, new Class<?>[] {}); try { methodExpression.invoke(context, null); } catch (IllegalArgumentException iae) { // Ensure correct IllegalArgumentException is thrown String msg = iae.getMessage(); Assert.assertTrue(msg, msg.contains("[format]")); return; } Assert.fail("No exception"); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
37.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