Add Debug for Amqp Channel Tests
This commit is contained in:
@@ -39,6 +39,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.integration.amqp.config.AmqpChannelFactoryBean;
|
||||
import org.springframework.integration.amqp.rule.BrokerRunning;
|
||||
import org.springframework.integration.test.support.LogAdjustingTestSupport;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
@@ -58,7 +59,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)
|
||||
public class ChannelTests {
|
||||
public class ChannelTests extends LogAdjustingTestSupport {
|
||||
|
||||
@ClassRule
|
||||
public static final BrokerRunning brokerIsRunning = BrokerRunning.isRunning();
|
||||
@@ -69,6 +70,10 @@ public class ChannelTests {
|
||||
@Autowired
|
||||
private CachingConnectionFactory factory;
|
||||
|
||||
public ChannelTests() {
|
||||
super("org.springframework.integration", "org.springframework.integration.amqp", "org.springframework.amqp");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pubSubLostConnectionTest() throws Exception {
|
||||
final CyclicBarrier latch = new CyclicBarrier(2);
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package org.springframework.integration.test.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.log4j.Level;
|
||||
@@ -41,21 +45,37 @@ public class LogAdjustingTestSupport {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private final Logger loggerToAdjust = LogManager.getLogger("org.springframework.integration");
|
||||
private final Collection<Logger> loggersToAdjust = new ArrayList<Logger>();
|
||||
|
||||
private Level oldCategory;
|
||||
private final Collection<Level> oldCategories = new ArrayList<Level>();
|
||||
|
||||
|
||||
public LogAdjustingTestSupport() {
|
||||
this("org.springframework.integration");
|
||||
}
|
||||
|
||||
public LogAdjustingTestSupport(String... loggersToAdjust) {
|
||||
for (String loggerToAdjust : loggersToAdjust) {
|
||||
this.loggersToAdjust.add(LogManager.getLogger(loggerToAdjust));
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
this.oldCategory = loggerToAdjust.getEffectiveLevel();
|
||||
this.loggerToAdjust.setLevel(Level.TRACE);
|
||||
for (Logger loggerToAdjust : this.loggersToAdjust) {
|
||||
this.oldCategories.add(loggerToAdjust.getEffectiveLevel());
|
||||
loggerToAdjust.setLevel(Level.TRACE);
|
||||
}
|
||||
this.logger.debug("!!!! Starting test: " + this.testName.getMethodName() + " !!!!");
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
logger.debug("!!!! Finished test: " + this.testName.getMethodName() + " !!!!");
|
||||
this.loggerToAdjust.setLevel(this.oldCategory);
|
||||
Iterator<Level> oldCategory = this.oldCategories.iterator();
|
||||
for (Logger loggerToAdjust : this.loggersToAdjust) {
|
||||
loggerToAdjust.setLevel(oldCategory.next());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
*/
|
||||
package org.springframework.integration.test.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.log4j.Level;
|
||||
@@ -45,21 +49,37 @@ public class LogAdjustingTestSupport {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private final Logger loggerToAdjust = LogManager.getLogger("org.springframework.integration");
|
||||
private final Collection<Logger> loggersToAdjust = new ArrayList<Logger>();
|
||||
|
||||
private Level oldCategory;
|
||||
private final Collection<Level> oldCategories = new ArrayList<Level>();
|
||||
|
||||
|
||||
public LogAdjustingTestSupport() {
|
||||
this("org.springframework.integration");
|
||||
}
|
||||
|
||||
public LogAdjustingTestSupport(String... loggersToAdjust) {
|
||||
for (String loggerToAdjust : loggersToAdjust) {
|
||||
this.loggersToAdjust.add(LogManager.getLogger(loggerToAdjust));
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void beforeTest() {
|
||||
this.oldCategory = loggerToAdjust.getEffectiveLevel();
|
||||
this.loggerToAdjust.setLevel(Level.TRACE);
|
||||
for (Logger loggerToAdjust : this.loggersToAdjust) {
|
||||
this.oldCategories.add(loggerToAdjust.getEffectiveLevel());
|
||||
loggerToAdjust.setLevel(Level.TRACE);
|
||||
}
|
||||
this.logger.debug("!!!! Starting test: " + this.testName.getMethodName() + " !!!!");
|
||||
}
|
||||
|
||||
@After
|
||||
public void afterTest() {
|
||||
logger.debug("!!!! Finished test: " + this.testName.getMethodName() + " !!!!");
|
||||
this.loggerToAdjust.setLevel(this.oldCategory);
|
||||
Iterator<Level> oldCategory = this.oldCategories.iterator();
|
||||
for (Logger loggerToAdjust : this.loggersToAdjust) {
|
||||
loggerToAdjust.setLevel(oldCategory.next());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user