Skip to content

Commit

Permalink
SpotBugs - remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Oct 16, 2020
1 parent 1b27eec commit e2d9d6a
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class TestGetConnection extends DefaultTestCase {
@Test
public void testGetConnection() throws Exception {
Connection con = this.datasource.getConnection();
Assert.assertTrue("Connection should implement javax.sql.PooledConnection",con instanceof PooledConnection);
Connection actual = ((PooledConnection)con).getConnection();
Assert.assertNotNull("Connection delegate should not be null.",actual);
System.out.println("Actual connection:"+actual.getClass().getName());
Expand Down
2 changes: 0 additions & 2 deletions test/jakarta/el/TestImportHandlerStandardPackages.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ public void testClassListsAreComplete() throws Exception {
f.setAccessible(true);
Object obj = f.get(null);

Assert.assertTrue("Not Map", obj instanceof Map);

@SuppressWarnings("unchecked")
Map<String,Set<String>> standardPackageName = (Map<String, Set<String>>) obj;

Expand Down
1 change: 0 additions & 1 deletion test/jakarta/el/TestResourceBundleELResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void bug53001() {

// Check that the method expression does return the keys
Object result2 = me.invoke(context, null);
Assert.assertTrue(result2 instanceof Enumeration);
@SuppressWarnings("unchecked")
Enumeration<String> e = (Enumeration<String>) result2;

Expand Down
2 changes: 0 additions & 2 deletions test/org/apache/catalina/loader/TestWebappClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public void testGetURLs() throws Exception {

ClassLoader cl = ctx.getLoader().getClassLoader();

Assert.assertTrue(cl instanceof URLClassLoader);

try (URLClassLoader ucl = (URLClassLoader) cl) {
URL[] urls = ucl.getURLs();
Assert.assertEquals(expected.length, urls.length);
Expand Down
2 changes: 0 additions & 2 deletions test/org/apache/el/lang/TestELSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ public void testCoerceToType14() {
PropertyEditorManager.registerEditor(TesterType.class, TesterTypeEditorNoError.class);
Object result = ELManager.getExpressionFactory().coerceToType(
"Foo", TesterType.class);
Assert.assertTrue(result instanceof TesterType);
Assert.assertEquals("Foo", ((TesterType) result).getValue());
}

Expand All @@ -224,7 +223,6 @@ public void testCoerceToType15() {
PropertyEditorManager.registerEditor(TesterType.class, TesterTypeEditorError.class);
Object result = ELManager.getExpressionFactory().coerceToType(
"Foo", TesterType.class);
Assert.assertTrue(result instanceof TesterType);
Assert.assertEquals("Foo", ((TesterType) result).getValue());
}

Expand Down
2 changes: 0 additions & 2 deletions test/org/apache/el/stream/TestCollectionOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ public void testMap02() {
"beans.stream().filter(b->b.valLong > 1).map(b->[b.name, b.valLong]).toList()",
List.class);

Assert.assertTrue(result instanceof List);

@SuppressWarnings("unchecked")
List<List<Object>> list = (List<List<Object>>) result;

Expand Down
2 changes: 0 additions & 2 deletions test/org/apache/jasper/compiler/TestTagPluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ public void testBug54240() throws Exception {

Node n = nodes.getNode(0);
Assert.assertNotNull(n);
Assert.assertTrue(n instanceof Node.CustomTag);

Node.CustomTag t = (Node.CustomTag)n;
Assert.assertNotNull(t.getAtSTag());

Node.Nodes sTag = c.getAtSTag();
Node scriptlet = sTag.getNode(0);
Assert.assertNotNull(scriptlet);
Assert.assertTrue(scriptlet instanceof Node.Scriptlet);
Node.Scriptlet s = (Node.Scriptlet)scriptlet;
Assert.assertEquals("//Just a comment", s.getText());
}
Expand Down
24 changes: 8 additions & 16 deletions test/org/apache/tomcat/util/buf/TestUDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,17 @@

public class TestUDecoder {

@Test
public void testURLDecodeStringInvalid() {
@Test(expected = IllegalArgumentException.class)
public void testURLDecodeStringInvalid01() {
// %n rather than %nn should throw an IAE according to the Javadoc
Exception exception = null;
try {
UDecoder.URLDecode("%5xxxxx", StandardCharsets.UTF_8);
} catch (Exception e) {
exception = e;
}
Assert.assertTrue(exception instanceof IllegalArgumentException);
UDecoder.URLDecode("%5xxxxx", StandardCharsets.UTF_8);
}


@Test(expected = IllegalArgumentException.class)
public void testURLDecodeStringInvalid02() {
// Edge case trying to trigger ArrayIndexOutOfBoundsException
exception = null;
try {
UDecoder.URLDecode("%5", StandardCharsets.UTF_8);
} catch (Exception e) {
exception = e;
}
Assert.assertTrue(exception instanceof IllegalArgumentException);
UDecoder.URLDecode("%5", StandardCharsets.UTF_8);
}


Expand Down

0 comments on commit e2d9d6a

Please sign in to comment.