ARTEMIS-2732 Logging cleanup

This commit is contained in:
Clebert Suconic 2020-04-23 15:55:23 -04:00
parent 77d250bec8
commit ca4c4068df
12 changed files with 41 additions and 35 deletions

View File

@ -83,6 +83,7 @@ import org.apache.activemq.artemis.utils.Wait;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -101,6 +102,7 @@ import static org.junit.Assert.fail;
* Test to validate that the CLI doesn't throw improper exceptions when invoked.
*/
public class ArtemisTest extends CliTestBase {
private static final Logger log = Logger.getLogger(ArtemisTest.class);
@Before
@Override
@ -135,10 +137,9 @@ public class ArtemisTest extends CliTestBase {
int writes = 2;
int tries = 5;
long totalAvg = SyncCalculation.syncTest(temporaryFolder.getRoot(), 4096, writes, tries, true, true, true, "file.tmp", 1, JournalType.NIO);
System.out.println();
System.out.println("TotalAvg = " + totalAvg);
log.debug("TotalAvg = " + totalAvg);
long nanoTime = SyncCalculation.toNanos(totalAvg, writes, false);
System.out.println("nanoTime avg = " + nanoTime);
log.debug("nanoTime avg = " + nanoTime);
assertEquals(0, LibaioContext.getTotalMaxIO());
}
@ -222,7 +223,7 @@ public class ArtemisTest extends CliTestBase {
byte[] contents = Files.readAllBytes(bootstrapFile.toPath());
String cfgText = new String(contents);
System.out.println("confg: " + cfgText);
log.debug("confg: " + cfgText);
config = parseXml(bootstrapFile);
webElem = (Element) config.getElementsByTagName("web").item(0);
@ -353,7 +354,7 @@ public class ArtemisTest extends CliTestBase {
listCmd.execute(context);
String result = context.getStdout();
System.out.println("output1:\n" + result);
log.debug("output1:\n" + result);
//default only one user admin with role amq
assertTrue(result.contains("\"admin\"(amq)"));
@ -370,7 +371,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output2:\n" + result);
log.debug("output2:\n" + result);
assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("\"guest\"(admin)"));
@ -389,7 +390,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output3:\n" + result);
log.debug("output3:\n" + result);
assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("\"guest\"(admin)"));
@ -413,7 +414,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output4:\n" + result);
log.debug("output4:\n" + result);
assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("\"guest\"(admin)"));
@ -428,7 +429,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output5:\n" + result);
log.debug("output5:\n" + result);
assertTrue(result.contains("\"admin\"(amq)"));
assertFalse(result.contains("\"guest\"(admin)"));
@ -444,7 +445,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output6:\n" + result);
log.debug("output6:\n" + result);
assertTrue(result.contains("\"admin\"(amq)"));
assertFalse(result.contains("\"guest\"(admin)"));
@ -464,7 +465,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output7:\n" + result);
log.debug("output7:\n" + result);
assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("Total: 1"));
@ -477,7 +478,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output8:\n" + result);
log.debug("output8:\n" + result);
assertTrue(result.contains("Total: 0"));
}
@ -695,7 +696,7 @@ public class ArtemisTest extends CliTestBase {
listCmd.execute(context);
String result = context.getStdout();
System.out.println("output1:\n" + result);
log.debug("output1:\n" + result);
//default only one user admin with role amq
assertTrue(result.contains("\"admin\"(amq)"));
@ -709,7 +710,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output8:\n" + result);
log.debug("output8:\n" + result);
assertTrue(result.contains("Total: 0"));
@ -740,7 +741,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext();
listCmd.execute(context);
result = context.getStdout();
System.out.println("output2:\n" + result);
log.debug("output2:\n" + result);
assertTrue(result.contains("Total: 4"));
assertTrue(result.contains("\"guest\"(admin)"));
@ -871,7 +872,7 @@ public class ArtemisTest extends CliTestBase {
mask.setPassword(password1);
String result = (String) mask.execute(context);
System.out.println(context.getStdout());
log.debug(context.getStdout());
assertEquals(encrypt1, result);
context = new TestActionContext();
@ -879,7 +880,7 @@ public class ArtemisTest extends CliTestBase {
mask.setPassword(password1);
mask.setHash(true);
result = (String) mask.execute(context);
System.out.println(context.getStdout());
log.debug(context.getStdout());
DefaultSensitiveStringCodec codec = mask.getCodec();
codec.verify(password1.toCharArray(), result);
@ -888,7 +889,7 @@ public class ArtemisTest extends CliTestBase {
mask.setPassword(password1);
mask.setKey(newKey);
result = (String) mask.execute(context);
System.out.println(context.getStdout());
log.debug(context.getStdout());
assertEquals(encrypt2, result);
}
@ -1541,7 +1542,7 @@ public class ArtemisTest extends CliTestBase {
for (String r : roles) {
String storedUsers = (String) roleConfig.getProperty(r);
System.out.println("users in role: " + r + " ; " + storedUsers);
log.debug("users in role: " + r + " ; " + storedUsers);
List<String> userList = StringUtil.splitStringList(storedUsers, ",");
assertTrue(userList.contains(user));
}

View File

@ -18,19 +18,21 @@ package org.apache.activemq.cli.test;
import org.apache.activemq.artemis.cli.commands.util.HashUtil;
import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
import org.jboss.logging.Logger;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class HashUtilTest {
private static final Logger log = Logger.getLogger(HashUtilTest.class);
@Test
public void testDefaultHashFormat() throws Exception {
final String password = "helloworld";
String hash = HashUtil.tryHash(new TestActionContext(), password);
String hashStr = PasswordMaskingUtil.unwrap(hash);
System.out.println("hashString: " + hashStr);
log.debug("hashString: " + hashStr);
String[] parts = hashStr.split(":");
assertEquals(3, parts.length);
//first part should be able to convert to an int

View File

@ -26,10 +26,12 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.Test;
public class OrderedExecutorSanityTest {
private static final Logger log = Logger.getLogger(OrderedExecutorSanityTest.class);
@Test
public void shouldExecuteTasksInOrder() throws InterruptedException {
@ -175,7 +177,7 @@ public class OrderedExecutorSanityTest {
long elapsed = (end - start);
System.out.println("execution " + i + " in " + TimeUnit.NANOSECONDS.toMillis(elapsed) + " milliseconds");
log.info("execution " + i + " in " + TimeUnit.NANOSECONDS.toMillis(elapsed) + " milliseconds");
}
} finally {
executorService.shutdown();

View File

@ -82,7 +82,6 @@ public class ClientThreadPoolsTest {
ActiveMQClient.getGlobalThreadPool().execute(new Runnable() {
@Override
public void run() {
System.err.println("Hello!");
try {
inUse.countDown();
neverLeave.await();
@ -114,7 +113,6 @@ public class ClientThreadPoolsTest {
ActiveMQClient.getGlobalThreadPool().execute(new Runnable() {
@Override
public void run() {
System.err.println("Hello!");
try {
inUse.countDown();
neverLeave.await();

View File

@ -70,6 +70,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>

View File

@ -52,6 +52,11 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>

View File

@ -27,9 +27,6 @@ import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.Test;
/**
* @version $Revision: 1.2 $
*/
public class SelectorParserTest {
private static final Logger log = Logger.getLogger(SelectorParserTest.class);

View File

@ -26,9 +26,6 @@ import org.apache.activemq.artemis.selector.impl.SelectorParser;
import org.junit.Assert;
import org.junit.Test;
/**
* @version $Revision: 1.7 $
*/
public class SelectorTest {
class MockMessage implements Filterable {

View File

@ -17,7 +17,7 @@
# Additional logger names to configure (root logger is always configured)
# Root logger option
loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.audit
loggers=org.jboss.logging,org.apache.activemq.artemis.core.server,org.apache.activemq.artemis.utils,org.apache.activemq.artemis.journal,org.apache.activemq.artemis.jms,org.apache.activemq.artemis.ra,org.apache.activemq.artemis.tests.unit,org.apache.activemq.artemis.tests.integration,org.apache.activemq.artemis.jms.tests,org.apache.activemq.cli.test,org.apache.activemq.audit
# Root logger level
logger.level=INFO
@ -28,6 +28,7 @@ logger.org.apache.activemq.artemis.utils.level=INFO
logger.org.apache.activemq.artemis.jms.level=INFO
logger.org.apache.activemq.artemis.ra.level=INFO
logger.org.apache.activemq.cli.test.level=DEBUG
logger.org.apache.activemq.artemis.tests.integration.level=DEBUG
logger.org.apache.activemq.artemis.tests.level=DEBUG
logger.org.apache.activemq.artemis.tests.unit.level=DEBUG

View File

@ -55,7 +55,7 @@ public class RandomUtilDistributionTest {
@Test
public void testDistribution() throws Exception {
int numberOfStarts = 50;
int iterations = 10;
int iterations = 1;
int value = 0;
for (int i = 0; i < iterations; i++) {

View File

@ -18,7 +18,6 @@ package org.apache.activemq.artemis.tests.unit.util;
import org.apache.activemq.artemis.core.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl;
import org.apache.activemq.artemis.tests.unit.UnitTestLogger;
import org.apache.activemq.artemis.utils.MemorySize;
import org.jboss.logging.Logger;
import org.junit.Assert;

View File

@ -44,12 +44,10 @@ import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClas
import org.apache.activemq.artemis.tests.unit.util.deserialization.pkg1.TestClass2;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.Test;
public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase {
private static final Logger log = Logger.getLogger(ObjectInputStreamWithClassLoaderTest.class);
// Constants -----------------------------------------------------
@ -509,7 +507,8 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase {
try {
Object deserializedObj = ois.readObject();
log.debug("Deserialized Object " + deserializedObj);
// cannot use logging here, as this test is playing with classLoading here.
System.out.println("Deserialized Object " + deserializedObj);
myAssertNotSame(originalProxy, deserializedObj);
myAssertNotSame(originalProxy.getClass(), deserializedObj.getClass());