1
0

Simplify assert with simpler and equivalent calls.

This commit is contained in:
Arturo Bernal
2022-04-23 01:24:04 +02:00
parent e511c56844
commit 073350edf6
7 changed files with 24 additions and 18 deletions

View File

@@ -167,7 +167,10 @@ under the License.
<role>Avalon logging abstraction</role> <role>Avalon logging abstraction</role>
</roles> </roles>
</contributor> </contributor>
<contributor>
<name>Arturo Bernal</name>
<email>arturobernalg@yahoo.com</email>
</contributor>
</contributors> </contributors>
<scm> <scm>

View File

@@ -196,7 +196,7 @@ public class LoadTestCase extends TestCase{
fail("AppClassLoader failed "); fail("AppClassLoader failed ");
} }
assertTrue( "app isolated" ,testObjCls.getClassLoader() == appLoader ); assertSame("app isolated", testObjCls.getClassLoader(), appLoader);
return testObjCls; return testObjCls;

View File

@@ -254,8 +254,8 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
assertTrue(logger.isLoggable(Level.INFO)); assertTrue(logger.isLoggable(Level.INFO));
assertTrue(logger.isLoggable(Level.CONFIG)); assertTrue(logger.isLoggable(Level.CONFIG));
assertTrue(logger.isLoggable(Level.FINE)); assertTrue(logger.isLoggable(Level.FINE));
assertTrue(!logger.isLoggable(Level.FINER)); assertFalse(logger.isLoggable(Level.FINER));
assertTrue(!logger.isLoggable(Level.FINEST)); assertFalse(logger.isLoggable(Level.FINEST));
} }
@@ -288,7 +288,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
assertTrue(log.isWarnEnabled()); assertTrue(log.isWarnEnabled());
assertTrue(log.isInfoEnabled()); assertTrue(log.isInfoEnabled());
assertTrue(log.isDebugEnabled()); assertTrue(log.isDebugEnabled());
assertTrue(!log.isTraceEnabled()); assertFalse(log.isTraceEnabled());
} }
@@ -324,7 +324,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
record.getThrown()); record.getThrown());
} }
} }
assertTrue(!records.hasNext()); assertFalse(records.hasNext());
handler.flush(); handler.flush();
} }

View File

@@ -16,6 +16,8 @@
*/ */
package org.apache.commons.logging.pathable; package org.apache.commons.logging.pathable;
import static org.junit.Assert.assertNotEquals;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -143,9 +145,8 @@ public class ParentFirstTestCase extends TestCase {
// (context, child, parent). // (context, child, parent).
final ClassLoader systemLoader = ClassLoader.getSystemClassLoader(); final ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
assertNotNull("System classloader is null", systemLoader); assertNotNull("System classloader is null", systemLoader);
assertFalse("System classloader has unexpected type", assertNotEquals("System classloader has unexpected type", PathableClassLoader.class.getName(),
PathableClassLoader.class.getName().equals( systemLoader.getClass().getName());
systemLoader.getClass().getName()));
// junit classes should be visible; their classloader is not // junit classes should be visible; their classloader is not
// in the hierarchy of parent classloaders for this class, // in the hierarchy of parent classloaders for this class,

View File

@@ -17,6 +17,8 @@
package org.apache.commons.logging.security; package org.apache.commons.logging.security;
import static org.junit.Assert.assertNotEquals;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@@ -125,8 +127,8 @@ public class SecurityForbiddenTestCase extends TestCase
final Object factoryTable = factoryField.get(null); final Object factoryTable = factoryField.get(null);
assertNotNull(factoryTable); assertNotNull(factoryTable);
final String ftClassName = factoryTable.getClass().getName(); final String ftClassName = factoryTable.getClass().getName();
assertTrue("Custom hashtable unexpectedly used", assertNotEquals("Custom hashtable unexpectedly used",
!CustomHashtable.class.getName().equals(ftClassName)); CustomHashtable.class.getName(), ftClassName);
assertEquals(0, mySecurityManager.getUntrustedCodeCount()); assertEquals(0, mySecurityManager.getUntrustedCodeCount());
} catch(final Throwable t) { } catch(final Throwable t) {

View File

@@ -183,7 +183,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
assertTrue(log.isErrorEnabled()); assertTrue(log.isErrorEnabled());
assertTrue(log.isFatalEnabled()); assertTrue(log.isFatalEnabled());
assertTrue(log.isInfoEnabled()); assertTrue(log.isInfoEnabled());
assertTrue(!log.isTraceEnabled()); assertFalse(log.isTraceEnabled());
assertTrue(log.isWarnEnabled()); assertTrue(log.isWarnEnabled());
// Can we retrieve the current log level? // Can we retrieve the current log level?
@@ -200,7 +200,7 @@ public class CustomConfigTestCase extends DefaultConfigTestCase {
/** Hook for subclassses */ /** Hook for subclassses */
protected void checkShowDateTime() { protected void checkShowDateTime() {
assertTrue(!((DecoratedSimpleLog) log).getShowDateTime()); assertFalse(((DecoratedSimpleLog) log).getShowDateTime());
} }
/** Hook for subclasses */ /** Hook for subclasses */

View File

@@ -187,11 +187,11 @@ public class DefaultConfigTestCase extends TestCase {
log.getClass().getName()); log.getClass().getName());
// Can we call level checkers with no exceptions? // Can we call level checkers with no exceptions?
assertTrue(!log.isDebugEnabled()); assertFalse(log.isDebugEnabled());
assertTrue(log.isErrorEnabled()); assertTrue(log.isErrorEnabled());
assertTrue(log.isFatalEnabled()); assertTrue(log.isFatalEnabled());
assertTrue(log.isInfoEnabled()); assertTrue(log.isInfoEnabled());
assertTrue(!log.isTraceEnabled()); assertFalse(log.isTraceEnabled());
assertTrue(log.isWarnEnabled()); assertTrue(log.isWarnEnabled());
// Can we retrieve the current log level? // Can we retrieve the current log level?
@@ -202,7 +202,7 @@ public class DefaultConfigTestCase extends TestCase {
((DecoratedSimpleLog) log).getDateTimeFormat()); ((DecoratedSimpleLog) log).getDateTimeFormat());
assertEquals("DecoratedLogger", assertEquals("DecoratedLogger",
((DecoratedSimpleLog) log).getLogName()); ((DecoratedSimpleLog) log).getLogName());
assertTrue(!((DecoratedSimpleLog) log).getShowDateTime()); assertFalse(((DecoratedSimpleLog) log).getShowDateTime());
assertTrue(((DecoratedSimpleLog) log).getShowShortName()); assertTrue(((DecoratedSimpleLog) log).getShowShortName());
} }
@@ -217,11 +217,11 @@ public class DefaultConfigTestCase extends TestCase {
log.getClass().getName()); log.getClass().getName());
// Can we call level checkers with no exceptions? // Can we call level checkers with no exceptions?
assertTrue(!log.isDebugEnabled()); assertFalse(log.isDebugEnabled());
assertTrue(log.isErrorEnabled()); assertTrue(log.isErrorEnabled());
assertTrue(log.isFatalEnabled()); assertTrue(log.isFatalEnabled());
assertTrue(log.isInfoEnabled()); assertTrue(log.isInfoEnabled());
assertTrue(!log.isTraceEnabled()); assertFalse(log.isTraceEnabled());
assertTrue(log.isWarnEnabled()); assertTrue(log.isWarnEnabled());
// Can we retrieve the current log level? // Can we retrieve the current log level?