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.PropertiesConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder; import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Configurations; import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.jboss.logging.Logger;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; 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. * Test to validate that the CLI doesn't throw improper exceptions when invoked.
*/ */
public class ArtemisTest extends CliTestBase { public class ArtemisTest extends CliTestBase {
private static final Logger log = Logger.getLogger(ArtemisTest.class);
@Before @Before
@Override @Override
@ -135,10 +137,9 @@ public class ArtemisTest extends CliTestBase {
int writes = 2; int writes = 2;
int tries = 5; int tries = 5;
long totalAvg = SyncCalculation.syncTest(temporaryFolder.getRoot(), 4096, writes, tries, true, true, true, "file.tmp", 1, JournalType.NIO); long totalAvg = SyncCalculation.syncTest(temporaryFolder.getRoot(), 4096, writes, tries, true, true, true, "file.tmp", 1, JournalType.NIO);
System.out.println(); log.debug("TotalAvg = " + totalAvg);
System.out.println("TotalAvg = " + totalAvg);
long nanoTime = SyncCalculation.toNanos(totalAvg, writes, false); long nanoTime = SyncCalculation.toNanos(totalAvg, writes, false);
System.out.println("nanoTime avg = " + nanoTime); log.debug("nanoTime avg = " + nanoTime);
assertEquals(0, LibaioContext.getTotalMaxIO()); assertEquals(0, LibaioContext.getTotalMaxIO());
} }
@ -222,7 +223,7 @@ public class ArtemisTest extends CliTestBase {
byte[] contents = Files.readAllBytes(bootstrapFile.toPath()); byte[] contents = Files.readAllBytes(bootstrapFile.toPath());
String cfgText = new String(contents); String cfgText = new String(contents);
System.out.println("confg: " + cfgText); log.debug("confg: " + cfgText);
config = parseXml(bootstrapFile); config = parseXml(bootstrapFile);
webElem = (Element) config.getElementsByTagName("web").item(0); webElem = (Element) config.getElementsByTagName("web").item(0);
@ -353,7 +354,7 @@ public class ArtemisTest extends CliTestBase {
listCmd.execute(context); listCmd.execute(context);
String result = context.getStdout(); String result = context.getStdout();
System.out.println("output1:\n" + result); log.debug("output1:\n" + result);
//default only one user admin with role amq //default only one user admin with role amq
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
@ -370,7 +371,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output2:\n" + result); log.debug("output2:\n" + result);
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("\"guest\"(admin)")); assertTrue(result.contains("\"guest\"(admin)"));
@ -389,7 +390,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output3:\n" + result); log.debug("output3:\n" + result);
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("\"guest\"(admin)")); assertTrue(result.contains("\"guest\"(admin)"));
@ -413,7 +414,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output4:\n" + result); log.debug("output4:\n" + result);
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("\"guest\"(admin)")); assertTrue(result.contains("\"guest\"(admin)"));
@ -428,7 +429,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output5:\n" + result); log.debug("output5:\n" + result);
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
assertFalse(result.contains("\"guest\"(admin)")); assertFalse(result.contains("\"guest\"(admin)"));
@ -444,7 +445,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output6:\n" + result); log.debug("output6:\n" + result);
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
assertFalse(result.contains("\"guest\"(admin)")); assertFalse(result.contains("\"guest\"(admin)"));
@ -464,7 +465,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output7:\n" + result); log.debug("output7:\n" + result);
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
assertTrue(result.contains("Total: 1")); assertTrue(result.contains("Total: 1"));
@ -477,7 +478,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output8:\n" + result); log.debug("output8:\n" + result);
assertTrue(result.contains("Total: 0")); assertTrue(result.contains("Total: 0"));
} }
@ -695,7 +696,7 @@ public class ArtemisTest extends CliTestBase {
listCmd.execute(context); listCmd.execute(context);
String result = context.getStdout(); String result = context.getStdout();
System.out.println("output1:\n" + result); log.debug("output1:\n" + result);
//default only one user admin with role amq //default only one user admin with role amq
assertTrue(result.contains("\"admin\"(amq)")); assertTrue(result.contains("\"admin\"(amq)"));
@ -709,7 +710,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output8:\n" + result); log.debug("output8:\n" + result);
assertTrue(result.contains("Total: 0")); assertTrue(result.contains("Total: 0"));
@ -740,7 +741,7 @@ public class ArtemisTest extends CliTestBase {
context = new TestActionContext(); context = new TestActionContext();
listCmd.execute(context); listCmd.execute(context);
result = context.getStdout(); result = context.getStdout();
System.out.println("output2:\n" + result); log.debug("output2:\n" + result);
assertTrue(result.contains("Total: 4")); assertTrue(result.contains("Total: 4"));
assertTrue(result.contains("\"guest\"(admin)")); assertTrue(result.contains("\"guest\"(admin)"));
@ -871,7 +872,7 @@ public class ArtemisTest extends CliTestBase {
mask.setPassword(password1); mask.setPassword(password1);
String result = (String) mask.execute(context); String result = (String) mask.execute(context);
System.out.println(context.getStdout()); log.debug(context.getStdout());
assertEquals(encrypt1, result); assertEquals(encrypt1, result);
context = new TestActionContext(); context = new TestActionContext();
@ -879,7 +880,7 @@ public class ArtemisTest extends CliTestBase {
mask.setPassword(password1); mask.setPassword(password1);
mask.setHash(true); mask.setHash(true);
result = (String) mask.execute(context); result = (String) mask.execute(context);
System.out.println(context.getStdout()); log.debug(context.getStdout());
DefaultSensitiveStringCodec codec = mask.getCodec(); DefaultSensitiveStringCodec codec = mask.getCodec();
codec.verify(password1.toCharArray(), result); codec.verify(password1.toCharArray(), result);
@ -888,7 +889,7 @@ public class ArtemisTest extends CliTestBase {
mask.setPassword(password1); mask.setPassword(password1);
mask.setKey(newKey); mask.setKey(newKey);
result = (String) mask.execute(context); result = (String) mask.execute(context);
System.out.println(context.getStdout()); log.debug(context.getStdout());
assertEquals(encrypt2, result); assertEquals(encrypt2, result);
} }
@ -1541,7 +1542,7 @@ public class ArtemisTest extends CliTestBase {
for (String r : roles) { for (String r : roles) {
String storedUsers = (String) roleConfig.getProperty(r); 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, ","); List<String> userList = StringUtil.splitStringList(storedUsers, ",");
assertTrue(userList.contains(user)); 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.cli.commands.util.HashUtil;
import org.apache.activemq.artemis.utils.PasswordMaskingUtil; import org.apache.activemq.artemis.utils.PasswordMaskingUtil;
import org.jboss.logging.Logger;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
public class HashUtilTest { public class HashUtilTest {
private static final Logger log = Logger.getLogger(HashUtilTest.class);
@Test @Test
public void testDefaultHashFormat() throws Exception { public void testDefaultHashFormat() throws Exception {
final String password = "helloworld"; final String password = "helloworld";
String hash = HashUtil.tryHash(new TestActionContext(), password); String hash = HashUtil.tryHash(new TestActionContext(), password);
String hashStr = PasswordMaskingUtil.unwrap(hash); String hashStr = PasswordMaskingUtil.unwrap(hash);
System.out.println("hashString: " + hashStr); log.debug("hashString: " + hashStr);
String[] parts = hashStr.split(":"); String[] parts = hashStr.split(":");
assertEquals(3, parts.length); assertEquals(3, parts.length);
//first part should be able to convert to an int //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.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.logging.Logger;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class OrderedExecutorSanityTest { public class OrderedExecutorSanityTest {
private static final Logger log = Logger.getLogger(OrderedExecutorSanityTest.class);
@Test @Test
public void shouldExecuteTasksInOrder() throws InterruptedException { public void shouldExecuteTasksInOrder() throws InterruptedException {
@ -175,7 +177,7 @@ public class OrderedExecutorSanityTest {
long elapsed = (end - start); 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 { } finally {
executorService.shutdown(); executorService.shutdown();

View File

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

View File

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

View File

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

View File

@ -27,9 +27,6 @@ import org.jboss.logging.Logger;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
/**
* @version $Revision: 1.2 $
*/
public class SelectorParserTest { public class SelectorParserTest {
private static final Logger log = Logger.getLogger(SelectorParserTest.class); 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.Assert;
import org.junit.Test; import org.junit.Test;
/**
* @version $Revision: 1.7 $
*/
public class SelectorTest { public class SelectorTest {
class MockMessage implements Filterable { class MockMessage implements Filterable {

View File

@ -17,7 +17,7 @@
# Additional logger names to configure (root logger is always configured) # Additional logger names to configure (root logger is always configured)
# Root logger option # 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 # Root logger level
logger.level=INFO 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.jms.level=INFO
logger.org.apache.activemq.artemis.ra.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.integration.level=DEBUG
logger.org.apache.activemq.artemis.tests.level=DEBUG logger.org.apache.activemq.artemis.tests.level=DEBUG
logger.org.apache.activemq.artemis.tests.unit.level=DEBUG logger.org.apache.activemq.artemis.tests.unit.level=DEBUG

View File

@ -55,7 +55,7 @@ public class RandomUtilDistributionTest {
@Test @Test
public void testDistribution() throws Exception { public void testDistribution() throws Exception {
int numberOfStarts = 50; int numberOfStarts = 50;
int iterations = 10; int iterations = 1;
int value = 0; int value = 0;
for (int i = 0; i < iterations; i++) { 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.message.impl.CoreMessage;
import org.apache.activemq.artemis.core.server.impl.MessageReferenceImpl; 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.apache.activemq.artemis.utils.MemorySize;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.junit.Assert; 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.unit.util.deserialization.pkg1.TestClass2;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader; import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
import org.jboss.logging.Logger;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase { public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase {
private static final Logger log = Logger.getLogger(ObjectInputStreamWithClassLoaderTest.class);
// Constants ----------------------------------------------------- // Constants -----------------------------------------------------
@ -509,7 +507,8 @@ public class ObjectInputStreamWithClassLoaderTest extends ActiveMQTestBase {
try { try {
Object deserializedObj = ois.readObject(); 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, deserializedObj);
myAssertNotSame(originalProxy.getClass(), deserializedObj.getClass()); myAssertNotSame(originalProxy.getClass(), deserializedObj.getClass());