1
0

Merge pull request #84 from arturobernalg/feature/simplify_assert

Simplify assert with simpler and equivalent calls.
This commit is contained in:
Bruno P. Kinoshita
2022-04-23 12:45:08 +12:00
committed by GitHub
7 changed files with 24 additions and 18 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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