Remove System.out/.err Calls From All Tests

This commit is contained in:
Gary Russell
2016-04-14 16:22:45 -04:00
parent e5bf0187eb
commit 4027b38da8
32 changed files with 164 additions and 89 deletions

View File

@@ -277,7 +277,7 @@ public class MessagingAnnotationsWithBeanAnnotationTests {
@Filter(inputChannel = "skippedChannel5")
@Profile("foo")
public MessageHandler skippedMessageHandler() {
return System.out::println;
return m -> { };
}
@Bean

View File

@@ -23,6 +23,8 @@ import static org.mockito.Mockito.verify;
import java.lang.reflect.Field;
import java.util.UUID;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
@@ -43,6 +45,8 @@ import org.springframework.util.StopWatch;
*/
public class MessageIdGenerationTests {
private final Log logger = LogFactory.getLog(getClass());
@Test
public void testCustomIdGenerationWithParentRegistrar() throws Exception {
ClassPathXmlApplicationContext parent = new ClassPathXmlApplicationContext("MessageIdGenerationTests-context-withGenerator.xml", this.getClass());
@@ -155,6 +159,7 @@ public class MessageIdGenerationTests {
Field idGeneratorField = ReflectionUtils.findField(MessageHeaders.class, "idGenerator");
ReflectionUtils.makeAccessible(idGeneratorField);
ReflectionUtils.setField(idGeneratorField, null, new IdGenerator() {
@Override
public UUID generateId() {
return TimeBasedUUIDGenerator.generateId();
}
@@ -167,12 +172,12 @@ public class MessageIdGenerationTests {
watch.stop();
double timebasedGeneratorElapsedTime = watch.getTotalTimeSeconds();
System.out.println("Generated " + times + " messages using default UUID generator " +
logger.info("Generated " + times + " messages using default UUID generator " +
"in " + defaultGeneratorElapsedTime + " seconds");
System.out.println("Generated " + times + " messages using Timebased UUID generator " +
logger.info("Generated " + times + " messages using Timebased UUID generator " +
"in " + timebasedGeneratorElapsedTime + " seconds");
System.out.println("Time-based ID generator is " + defaultGeneratorElapsedTime / timebasedGeneratorElapsedTime + " times faster");
logger.info("Time-based ID generator is " + defaultGeneratorElapsedTime / timebasedGeneratorElapsedTime + " times faster");
}
private void assertDestroy() throws Exception {
@@ -183,6 +188,7 @@ public class MessageIdGenerationTests {
public static class SampleIdGenerator implements IdGenerator {
@Override
public UUID generateId() {
return UUID.nameUUIDFromBytes(((System.currentTimeMillis() - System.nanoTime()) + "").getBytes());
}

View File

@@ -26,13 +26,15 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.channel.DirectChannel;
@@ -48,26 +50,33 @@ import org.springframework.util.StopWatch;
* @author Oleg Zhurakousky
* @author Gunnar Hillert
* @author Artem Bilan
* @author Gary Russell
*/
public class MessageHistoryIntegrationTests {
private final Log logger = LogFactory.getLog(getClass());
@Test
public void testNoHistoryAwareMessageHandler() {
ApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithoutHistoryWriter.xml", MessageHistoryIntegrationTests.class);
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithoutHistoryWriter.xml",
MessageHistoryIntegrationTests.class);
Map<String, ConsumerEndpointFactoryBean> cefBeans = ac.getBeansOfType(ConsumerEndpointFactoryBean.class);
for (ConsumerEndpointFactoryBean cefBean : cefBeans.values()) {
DirectFieldAccessor bridgeAccessor = new DirectFieldAccessor(cefBean);
String handlerClassName = bridgeAccessor.getPropertyValue("handler").getClass().getName();
assertFalse("org.springframework.integration.config.MessageHistoryWritingMessageHandler".equals(handlerClassName));
}
ac.close();
}
@Test
public void testMessageHistoryWithHistoryWriter() {
ApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriter.xml", MessageHistoryIntegrationTests.class);
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriter.xml",
MessageHistoryIntegrationTests.class);
SampleGateway gateway = ac.getBean("sampleGateway", SampleGateway.class);
DirectChannel endOfThePipeChannel = ac.getBean("endOfThePipeChannel", DirectChannel.class);
MessageHandler handler = Mockito.spy(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) {
Iterator<Properties> historyIterator = message.getHeaders().get(MessageHistory.HEADER_NAME, MessageHistory.class).iterator();
@@ -140,14 +149,17 @@ public class MessageHistoryIntegrationTests {
Mockito.verify(handler, Mockito.times(1)).handleMessage(Mockito.any(Message.class));
assertNotNull(result);
//assertEquals("hello", result);
ac.close();
}
@Test
public void testMessageHistoryWithoutHistoryWriter() {
ApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithoutHistoryWriter.xml", MessageHistoryIntegrationTests.class);
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithoutHistoryWriter.xml",
MessageHistoryIntegrationTests.class);
SampleGateway gateway = ac.getBean("sampleGateway", SampleGateway.class);
DirectChannel endOfThePipeChannel = ac.getBean("endOfThePipeChannel", DirectChannel.class);
MessageHandler handler = Mockito.spy(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) {
assertNull(message.getHeaders().get(MessageHistory.HEADER_NAME, MessageHistory.class));
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
@@ -157,16 +169,20 @@ public class MessageHistoryIntegrationTests {
endOfThePipeChannel.subscribe(handler);
gateway.echo("hello");
Mockito.verify(handler, Mockito.times(1)).handleMessage(Mockito.any(Message.class));
ac.close();
}
@Test
public void testMessageHistoryParser() {
ApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriterNamespace.xml", MessageHistoryIntegrationTests.class);
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext(
"messageHistoryWithHistoryWriterNamespace.xml", MessageHistoryIntegrationTests.class);
SampleGateway gateway = ac.getBean("sampleGateway", SampleGateway.class);
DirectChannel endOfThePipeChannel = ac.getBean("endOfThePipeChannel", DirectChannel.class);
MessageHandler handler = Mockito.spy(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) {
Iterator<Properties> historyIterator = message.getHeaders().get(MessageHistory.HEADER_NAME, MessageHistory.class).iterator();
Iterator<Properties> historyIterator = message.getHeaders()
.get(MessageHistory.HEADER_NAME, MessageHistory.class).iterator();
assertTrue(historyIterator.hasNext());
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
replyChannel.send(message);
@@ -175,14 +191,17 @@ public class MessageHistoryIntegrationTests {
endOfThePipeChannel.subscribe(handler);
gateway.echo("hello");
Mockito.verify(handler, Mockito.times(1)).handleMessage(Mockito.any(Message.class));
ac.close();
}
@Test
public void testMessageHistoryParserWithNamePatterns() {
ApplicationContext ac = new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriterNamespaceAndPatterns.xml", MessageHistoryIntegrationTests.class);
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext(
"messageHistoryWithHistoryWriterNamespaceAndPatterns.xml", MessageHistoryIntegrationTests.class);
SampleGateway gateway = ac.getBean("sampleGateway", SampleGateway.class);
DirectChannel endOfThePipeChannel = ac.getBean("endOfThePipeChannel", DirectChannel.class);
MessageHandler handler = Mockito.spy(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) {
Iterator<Properties> historyIterator = message.getHeaders().get(MessageHistory.HEADER_NAME, MessageHistory.class).iterator();
assertTrue(historyIterator.hasNext());
@@ -199,21 +218,26 @@ public class MessageHistoryIntegrationTests {
endOfThePipeChannel.subscribe(handler);
gateway.echo("hello");
Mockito.verify(handler, Mockito.times(1)).handleMessage(Mockito.any(Message.class));
ac.close();
}
@Test(expected = BeanCreationException.class)
public void testMessageHistoryMoreThanOneNamespaceFail() {
new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriterNamespace-fail.xml", MessageHistoryIntegrationTests.class);
new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriterNamespace-fail.xml",
MessageHistoryIntegrationTests.class).close();
}
@Test @Ignore
public void testMessageHistoryWithHistoryPerformance() {
ApplicationContext acWithHistory = new ClassPathXmlApplicationContext("perfWithMessageHistory.xml", MessageHistoryIntegrationTests.class);
ApplicationContext acWithoutHistory = new ClassPathXmlApplicationContext("perfWithoutMessageHistory.xml", MessageHistoryIntegrationTests.class);
ConfigurableApplicationContext acWithHistory = new ClassPathXmlApplicationContext("perfWithMessageHistory.xml",
MessageHistoryIntegrationTests.class);
ConfigurableApplicationContext acWithoutHistory = new ClassPathXmlApplicationContext(
"perfWithoutMessageHistory.xml", MessageHistoryIntegrationTests.class);
SampleGateway gatewayHistory = acWithHistory.getBean("sampleGateway", SampleGateway.class);
DirectChannel endOfThePipeChannelHistory = acWithHistory.getBean("endOfThePipeChannel", DirectChannel.class);
endOfThePipeChannelHistory.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message)
throws MessageRejectedException, MessageHandlingException,
MessageDeliveryException {
@@ -225,6 +249,7 @@ public class MessageHistoryIntegrationTests {
SampleGateway gateway = acWithoutHistory.getBean("sampleGateway", SampleGateway.class);
DirectChannel endOfThePipeChannel = acWithoutHistory.getBean("endOfThePipeChannel", DirectChannel.class);
endOfThePipeChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message)
throws MessageRejectedException, MessageHandlingException,
MessageDeliveryException {
@@ -239,14 +264,16 @@ public class MessageHistoryIntegrationTests {
gatewayHistory.echo("hello");
}
stopWatch.stop();
System.out.println("Elapsed time with history 10000 calls: " + stopWatch.getTotalTimeSeconds());
logger.info("Elapsed time with history 10000 calls: " + stopWatch.getTotalTimeSeconds());
stopWatch = new StopWatch();
stopWatch.start();
for (int i = 0; i < 10000; i++) {
gateway.echo("hello");
}
stopWatch.stop();
System.out.println("Elapsed time without history 10000 calls: " + stopWatch.getTotalTimeSeconds());
logger.info("Elapsed time without history 10000 calls: " + stopWatch.getTotalTimeSeconds());
acWithHistory.close();
acWithoutHistory.close();
}
public interface SampleGateway {

View File

@@ -131,7 +131,6 @@ public class ExponentialMovingAverageRateTests {
Thread.sleep(22L);
history.increment();
Thread.sleep(18L);
// System.err.println(history);
assertTrue("Standard deviation should be non-zero: " + history, history.getStandardDeviation() > 0);
}

View File

@@ -20,6 +20,9 @@ import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CacheFactory;
import com.gemstone.gemfire.cache.Region;
@@ -39,6 +42,8 @@ import com.gemstone.gemfire.cache.server.CacheServer;
*/
public class CacheServerProcess {
private static final Log logger = LogFactory.getLog(CacheServerProcess.class);
private CacheServerProcess() {
super();
}
@@ -49,7 +54,7 @@ public class CacheServerProcess {
props.setProperty("name", "CacheServer");
props.setProperty("log-level", "info");
System.out.println("\nConnecting to the distributed system and creating the cache.");
logger.info("Connecting to the distributed system and creating the cache.");
Cache cache = new CacheFactory(props).create();
@@ -58,15 +63,15 @@ public class CacheServerProcess {
.setScope(Scope.DISTRIBUTED_ACK)
.create("test");
System.out.println("Test region, " + region.getFullPath() + ", created in cache.");
logger.info("Test region, " + region.getFullPath() + ", created in cache.");
// Start Cache Server.
CacheServer server = cache.addCacheServer();
server.setPort(40404);
System.out.println("Starting server");
logger.info("Starting server");
server.start();
ForkUtil.createControlFile(CacheServerProcess.class.getName());
System.out.println("Waiting for shutdown");
logger.info("Waiting for shutdown");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
bufferedReader.readLine();

View File

@@ -24,6 +24,9 @@ import java.io.OutputStream;
import java.io.PrintStream;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Utility for forking Java processes. Modified from the SGF version for SI
*
@@ -35,6 +38,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
*/
public class ForkUtil {
private static final Log logger = LogFactory.getLog(ForkUtil.class);
private static String TEMP_DIR = System.getProperty("java.io.tmpdir");
private ForkUtil() {
@@ -61,7 +66,7 @@ public class ForkUtil {
throw new IllegalStateException("Cannot start command " + cmdArray, ioe);
}
System.out.println("Started fork");
logger.info("Started fork");
final Process p = proc;
final BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
@@ -77,7 +82,7 @@ public class ForkUtil {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
System.out.println("Stopping fork...");
logger.info("Stopping fork...");
run.set(false);
if (p != null) {
p.destroy();
@@ -89,7 +94,7 @@ public class ForkUtil {
catch (InterruptedException e) {
// ignore
}
System.out.println("Fork stopped");
logger.info("Fork stopped");
}
});
@@ -144,7 +149,7 @@ public class ForkUtil {
}
}
if (controlFileExists(className)) {
System.out.println("Started cache server");
logger.info("Started cache server");
}
else {
throw new RuntimeException("could not fork cache server");

View File

@@ -547,7 +547,6 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
mapper.toHeaders(httpHeaders);
}
watch.stop();
System.out.println(watch.getTotalTimeMillis());
}

View File

@@ -32,7 +32,7 @@ public class SyslogdTests {
public static void main(String[] args) throws Exception {
AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("SyslogdTests-context.xml", SyslogdTests.class);
System.out.println("Hit enter to terminate");
// System . out . println("Hit enter to terminate");
System.in.read();
ctx.close();
}

View File

@@ -375,7 +375,6 @@ Certificate fingerprints:
@Override
public boolean onMessage(Message<?> message) {
// System.out.println("Server" + message);
messages.add(message);
latch.countDown();
return false;
@@ -392,7 +391,6 @@ Certificate fingerprints:
@Override
public boolean onMessage(Message<?> message) {
// System.out.println("Client" + message);
return false;
}
@@ -424,7 +422,6 @@ Certificate fingerprints:
@Override
public boolean onMessage(Message<?> message) {
// System.out.println("Server:" + message);
messages.add(message);
try {
replier.send(message);
@@ -454,7 +451,6 @@ Certificate fingerprints:
@Override
public boolean onMessage(Message<?> message) {
// System.out.println("Client:" + message);
messages.add(message);
latch.countDown();
return false;

View File

@@ -32,7 +32,7 @@ public class SyslogdTests {
public static void main(String[] args) throws Exception {
AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("SyslogdTests-context.xml", SyslogdTests.class);
System.out.println("Hit enter to terminate");
// System . out . println("Hit enter to terminate");
System.in.read();
ctx.close();
}

View File

@@ -254,7 +254,6 @@ public class MessageGroupQueueTests {
public void run() {
try {
boolean offered = queue.offer(new GenericMessage<String>("Hi-2"), 2, TimeUnit.SECONDS);
System.out.println(offered);
booleanHolder2.set(offered);
}
catch (Exception e) {
@@ -269,7 +268,6 @@ public class MessageGroupQueueTests {
public void run() {
try {
boolean offered = queue.offer(new GenericMessage<String>("Hi-3"), 2, TimeUnit.SECONDS);
System.out.println(offered);
booleanHolder3.set(offered);
}
catch (Exception e) {

View File

@@ -84,7 +84,6 @@ public class JdbcMessageHandlerParserTests {
public void testMapPayloadOutboundChannelAdapter() {
setUp("handlingMapPayloadJdbcOutboundChannelAdapterTest.xml", getClass());
assertTrue(context.containsBean("jdbcAdapter"));
System.out.println(context.getBean("jdbcAdapter").getClass().getName());
Message<?> message = MessageBuilder.withPayload(Collections.singletonMap("foo", "bar")).build();
channel.send(message);
Map<String, Object> map = this.jdbcTemplate.queryForMap("SELECT * from FOOS");

View File

@@ -34,14 +34,15 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
@@ -94,6 +95,7 @@ public class MySqlJdbcMessageStoreMultipleChannelTests {
@After
public void afterTest() {
new TransactionTemplate(this.transactionManager).execute(new TransactionCallback<Void>() {
@Override
public Void doInTransaction(TransactionStatus status) {
final int deletedGroupToMessageRows = jdbcTemplate.update("delete from INT_GROUP_TO_MESSAGE");
final int deletedMessages = jdbcTemplate.update("delete from INT_MESSAGE");
@@ -112,6 +114,7 @@ public class MySqlJdbcMessageStoreMultipleChannelTests {
public void testSendAndActivateTransactionalSend() throws Exception {
new TransactionTemplate(this.transactionManager).execute(new TransactionCallback<Void>() {
@Override
public Void doInTransaction(TransactionStatus status) {
requestChannel.send(MessageBuilder.withPayload("Hello ").build());
return null;
@@ -135,9 +138,6 @@ public class MySqlJdbcMessageStoreMultipleChannelTests {
ArrayList<Object> res = new ArrayList<Object>();
res.add(message);
res.add(message);
System.out.println("Split Complete");
return res;
}
}

View File

@@ -37,6 +37,8 @@ import javax.jms.TextMessage;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.command.ActiveMQDestination;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Rule;
import org.junit.Test;
@@ -44,7 +46,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.gateway.RequestReplyExchanger;
import org.springframework.integration.jms.ActiveMQMultiContextTests;
import org.springframework.integration.jms.config.ActiveMqTestUtils;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.integration.test.support.LongRunningIntegrationTest;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jms.connection.CachingConnectionFactory;
@@ -54,12 +55,15 @@ import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.jms.listener.SessionAwareMessageListener;
import org.springframework.jms.support.converter.SimpleMessageConverter;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.support.GenericMessage;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMultiContextTests {
private final Log logger = LogFactory.getLog(getClass());
private final SimpleMessageConverter converter = new SimpleMessageConverter();
@Rule
@@ -78,6 +82,7 @@ public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMulti
new Thread(new Runnable() {
@Override
public void run() {
final Message requestMessage = jmsTemplate.receive(requestDestination);
Destination replyTo = null;
@@ -89,6 +94,7 @@ public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMulti
}
jmsTemplate.send(replyTo, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
try {
TextMessage message = session.createTextMessage();
@@ -123,6 +129,7 @@ public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMulti
dmlc.setDestination(requestDestination);
dmlc.setMessageListener(new SessionAwareMessageListener<Message>() {
@Override
public void onMessage(Message message, Session session) {
Destination replyTo = null;
try {
@@ -224,6 +231,7 @@ public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMulti
for (int i = 0; i < testNumbers; i++) {
final int y = i;
executor.execute(new Runnable() {
@Override
public void run() {
try {
@@ -259,12 +267,12 @@ public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMulti
}
private void print(AtomicInteger failures, AtomicInteger timeouts, AtomicInteger missmatches, long echangesProcessed) {
System.out.println("============================");
System.out.println(echangesProcessed + " exchanges processed");
System.out.println("Failures: " + failures.get());
System.out.println("Timeouts: " + timeouts.get());
System.out.println("Missmatches: " + missmatches.get());
System.out.println("============================");
logger.info("============================");
logger.info(echangesProcessed + " exchanges processed");
logger.info("Failures: " + failures.get());
logger.info("Timeouts: " + timeouts.get());
logger.info("Missmatches: " + missmatches.get());
logger.info("============================");
}
public static class MyRandomlySlowService {
@@ -272,9 +280,6 @@ public class RequestReplyScenariosWithTempReplyQueuesTests extends ActiveMQMulti
List<Integer> list = new ArrayList<Integer>();
public String secho(String value) throws Exception {
int i = random.nextInt(2000);
// if (i >= 2000){
// System.out.println("SLEEPIING: " + i);
// }
Thread.sleep(i);
return value;
}

View File

@@ -121,7 +121,6 @@ public class DynamicRouterTests {
for (int i = 0; i < 1000000000; i++) {
this.nullChannel.send(null);
}
System.out.println(this.nullChannel.getSendRate());
}
}

View File

@@ -26,6 +26,7 @@ import javax.management.ObjectName;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -49,7 +50,7 @@ public class MBeanAutoDetectTests {
public void testRouterMBeanExistsWhenDefinedFirst() throws Exception {
context = new ClassPathXmlApplicationContext("MBeanAutoDetectFirstTests-context.xml", getClass());
server = context.getBean(MBeanServer.class);
// System.err.println(server.queryNames(new ObjectName("test.MBeanAutoDetectFirst:*"), null));
// System . err.println(server.queryNames(new ObjectName("test.MBeanAutoDetectFirst:*"), null));
Set<ObjectName> names = server.queryNames(
new ObjectName("test.MBeanAutoDetectFirst:type=ExpressionEvaluatingRouter,*"), null);
assertEquals(1, names.size());
@@ -60,7 +61,7 @@ public class MBeanAutoDetectTests {
public void testRouterMBeanExistsWhenDefinedSecond() throws Exception {
context = new ClassPathXmlApplicationContext("MBeanAutoDetectSecondTests-context.xml", getClass());
server = context.getBean(MBeanServer.class);
// System.err.println(server.queryNames(new ObjectName("test.MBeanAutoDetectFirst:*"), null));
// System . err.println(server.queryNames(new ObjectName("test.MBeanAutoDetectFirst:*"), null));
Set<ObjectName> names = server.queryNames(
new ObjectName("test.MBeanAutoDetectFirst:type=ExpressionEvaluatingRouter,*"), null);
assertEquals(1, names.size());

View File

@@ -62,8 +62,8 @@ public class MBeanRegistrationTests {
@Test
public void testExporterMBeanRegistration() throws Exception {
// System.err.println(server.queryNames(new ObjectName("*:type=*MBeanExporter,*"), null));
// System.err.println(Arrays.asList(server.getMBeanInfo(server.queryNames(new ObjectName("*:type=*Handler,*"), null).iterator().next()).getAttributes()));
// System . err.println(server.queryNames(new ObjectName("*:type=*MBeanExporter,*"), null));
// System . err.println(Arrays.asList(server.getMBeanInfo(server.queryNames(new ObjectName("*:type=*Handler,*"), null).iterator().next()).getAttributes()));
Set<ObjectName> names = server.queryNames(new ObjectName("test.MBeanRegistration:type=IntegrationMBeanExporter,name=integrationMbeanExporter,*"), null);
assertEquals(1, names.size());
names = server.queryNames(new ObjectName("test.MBeanRegistration:*,name=org.springframework.integration.MyGateway"), null);
@@ -73,13 +73,11 @@ public class MBeanRegistrationTests {
@Test
@Ignore // re-instate this if Spring decides to look for @ManagedResource on super classes
public void testServiceActivatorMBeanHasTrackableComponent() throws Exception {
System.err.println(server.queryNames(new ObjectName("test.MBeanRegistration:*"), null));
Set<ObjectName> names = server.queryNames(new ObjectName("test.MBeanRegistration:type=ServiceActivatingHandler,name=service,*"), null);
Map<String, MBeanOperationInfo> infos = new HashMap<String, MBeanOperationInfo>();
for (MBeanOperationInfo info : server.getMBeanInfo(names.iterator().next()).getOperations()) {
infos.put(info.getName(), info);
}
System.err.println(infos);
assertNotNull(infos.get("setShouldTrack"));
}

View File

@@ -59,7 +59,7 @@ public class MethodInvokerTests {
@Test
public void testHandlerMBeanRegistration() throws Exception {
Set<ObjectName> names = server.queryNames(new ObjectName("test.MethodInvoker:type=MessageHandler,*"), null);
// System.err.println(names);
// System . err.println(names);
// the router and the error handler...
assertEquals(2, names.size());
underscores.subscribe(new MessageHandler() {

View File

@@ -46,7 +46,7 @@ public class PollingAdapterMBeanTests {
@Test
public void testMessageSourceMBeanExists() throws Exception {
// System.err.println(server.queryNames(new ObjectName("*:type=MessageSource,*"), null));
// System . err.println(server.queryNames(new ObjectName("*:type=MessageSource,*"), null));
Set<ObjectName> names = server.queryNames(new ObjectName("test.PollingAdapterMBean:type=MessageSource,*"), null);
assertEquals(1, names.size());
}

View File

@@ -67,7 +67,7 @@ public class RouterMBeanTests {
@Test
public void testRouterMBeanExists() throws Exception {
// System.err.println(server.queryNames(new ObjectName("test.RouterMBean:*"), null));
// System . err.println(server.queryNames(new ObjectName("test.RouterMBean:*"), null));
Set<ObjectName> names = server.queryNames(
new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
assertEquals(1, names.size());
@@ -75,7 +75,7 @@ public class RouterMBeanTests {
@Test
public void testInputChannelMBeanExists() throws Exception {
// System.err.println(server.queryNames(new ObjectName("test.RouterMBean:type=MessageChannel,*"), null));
// System . err.println(server.queryNames(new ObjectName("test.RouterMBean:type=MessageChannel,*"), null));
Set<ObjectName> names = server.queryNames(
new ObjectName("test.RouterMBean:type=MessageChannel,name=testChannel,*"), null);
assertEquals(1, names.size());
@@ -90,7 +90,7 @@ public class RouterMBeanTests {
@Test
public void testRouterMBeanOnlyRegisteredOnce() throws Exception {
// System.err.println(server.queryNames(new ObjectName("*:type=MessageHandler,*"), null));
// System . err.println(server.queryNames(new ObjectName("*:type=MessageHandler,*"), null));
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBean:type=MessageHandler,name=ptRouter,*"), null);
assertEquals(1, names.size());
// INT-3896

View File

@@ -46,7 +46,7 @@ public class RouterMBeanVanillaTests {
@Test
public void testHandlerMBeanRegistration() throws Exception {
// System.err.println(server.queryNames(new ObjectName("test.RouterMBeanVanilla:*"), null));
// System . err.println(server.queryNames(new ObjectName("test.RouterMBeanVanilla:*"), null));
Set<ObjectName> names = server.queryNames(new ObjectName("test.RouterMBeanVanilla:type=ExpressionEvaluatingRouter,*"), null);
// The router is exposed...
assertEquals(1, names.size());

View File

@@ -16,20 +16,26 @@
package org.springframework.integration.sftp;
import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.stereotype.Component;
import java.io.File;
/**
* @author Josh Long
* @author Gary Russell
*/
@Component("sftpAnnouncer")
public class SftpFileAnnouncer {
private final Log logger = LogFactory.getLog(getClass());
@ServiceActivator
public void announceFile(File file) {
System.out.println("New file from the remote host has arrived: " + file.getAbsolutePath());
logger.info("New file from the remote host has arrived: " + file.getAbsolutePath());
}
}

View File

@@ -22,9 +22,9 @@ import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.support.MessageBuilder;
/**
* @author Oleg Zhurakousky
@@ -45,9 +45,7 @@ public class SftpOutboundTransferSample {
inputChannel.send(message);
Thread.sleep(2000);
}
System.out.println("Done");
ac.stop();
ac.close();
}
}

View File

@@ -70,7 +70,6 @@ public class ConsoleInboundChannelAdapterParserTests {
Charset readerCharset = Charset.forName(((InputStreamReader) reader).getEncoding());
assertEquals(Charset.defaultCharset(), readerCharset);
Message<?> message = source.receive();
System.out.println(message);
assertNotNull(message);
assertEquals("foo", message.getPayload());
}

View File

@@ -18,6 +18,9 @@ package org.springframework.integration.twitter.ignored;
import java.util.Collection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.history.MessageHistory;
import org.springframework.messaging.Message;
import org.springframework.social.twitter.api.DirectMessage;
@@ -33,36 +36,37 @@ import org.springframework.stereotype.Component;
@Component
public class TwitterAnnouncer {
private final Log logger = LogFactory.getLog(getClass());
public void dm(DirectMessage directMessage) {
System.out.println("A direct message has been received from " +
logger.info("A direct message has been received from " +
directMessage.getSender().getScreenName() + " with text " + directMessage.getText());
}
public void search(Message<?> search) {
MessageHistory history = MessageHistory.read(search);
System.out.println(history);
Tweet tweet = (Tweet) search.getPayload();
System.out.println("A search item was received " +
logger.info("A search item was received " +
tweet.getCreatedAt() + " with text " + tweet.getText());
}
public void mention(Tweet s) {
System.out.println("A tweet mentioning (or replying) to you was received having text "
logger.info("A tweet mentioning (or replying) to you was received having text "
+ s.getFromUser() + "-" + s.getText() + " from " + s.getSource());
}
public void searchResult(Collection<Tweet> tweets) {
if (tweets.size() == 0) {
System.out.println("No results");
logger.info("No results");
}
for (Tweet s : tweets) {
System.out.println("Search result: "
logger.info("Search result: "
+ s.getFromUser() + "-" + s.getText() + " from " + s.getSource());
}
}
public void updates(Tweet t) {
System.out.println("Received timeline update: " + t.getText() + " from " + t.getSource());
logger.info("Received timeline update: " + t.getText() + " from " + t.getSource());
}
}

View File

@@ -18,8 +18,11 @@ package org.springframework.integration.twitter.inbound;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.messaging.Message;
@@ -28,9 +31,11 @@ import org.springframework.social.twitter.api.impl.TwitterTemplate;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public class DirectMessageReceivingMessageSourceTests {
private final Log logger = LogFactory.getLog(getClass());
@SuppressWarnings("unchecked")
@Test @Ignore
@@ -39,7 +44,6 @@ public class DirectMessageReceivingMessageSourceTests {
pf.setLocation(new ClassPathResource("sample.properties"));
pf.afterPropertiesSet();
Properties prop = pf.getObject();
System.out.println(prop);
TwitterTemplate template = new TwitterTemplate(prop.getProperty("z_oleg.oauth.consumerKey"),
prop.getProperty("z_oleg.oauth.consumerSecret"),
prop.getProperty("z_oleg.oauth.accessToken"),
@@ -50,8 +54,9 @@ public class DirectMessageReceivingMessageSourceTests {
Message<DirectMessage> message = (Message<DirectMessage>) tSource.receive();
if (message != null) {
DirectMessage tweet = message.getPayload();
System.out.println(tweet.getSender().getScreenName() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
logger.info(tweet.getSender().getScreenName() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
}
}
}
}

View File

@@ -29,6 +29,8 @@ import java.util.Date;
import java.util.List;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
import org.junit.Test;
@@ -54,6 +56,8 @@ import org.springframework.social.twitter.api.impl.TwitterTemplate;
*/
public class SearchReceivingMessageSourceTests {
private final Log logger = LogFactory.getLog(getClass());
private static final String SEARCH_QUERY = "#springsource";
@SuppressWarnings("unchecked")
@@ -63,7 +67,6 @@ public class SearchReceivingMessageSourceTests {
pf.setLocation(new ClassPathResource("sample.properties"));
pf.afterPropertiesSet();
Properties prop = pf.getObject();
System.out.println(prop);
TwitterTemplate template = new TwitterTemplate(prop.getProperty("z_oleg.oauth.consumerKey"),
prop.getProperty("z_oleg.oauth.consumerSecret"),
prop.getProperty("z_oleg.oauth.accessToken"),
@@ -75,7 +78,7 @@ public class SearchReceivingMessageSourceTests {
Message<Tweet> message = (Message<Tweet>) tSource.receive();
if (message != null) {
Tweet tweet = message.getPayload();
System.out.println(tweet.getFromUser() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
logger.info(tweet.getFromUser() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
}
}
}

View File

@@ -29,6 +29,8 @@ import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Before;
import org.junit.Test;
@@ -45,19 +47,22 @@ import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.PollableChannel;
import org.springframework.social.twitter.api.SearchMetadata;
import org.springframework.social.twitter.api.SearchOperations;
import org.springframework.social.twitter.api.SearchParameters;
import org.springframework.social.twitter.api.SearchResults;
import org.springframework.social.twitter.api.Tweet;
import org.springframework.social.twitter.api.UserOperations;
import org.springframework.social.twitter.api.SearchParameters;
import org.springframework.social.twitter.api.impl.TwitterTemplate;
/**
* @author Gunnar Hillert
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
*/
public class SearchReceivingMessageSourceWithRedisTests extends RedisAvailableTests {
private final Log logger = LogFactory.getLog(getClass());
private SourcePollingChannelAdapter twitterSearchAdapter;
private AbstractTwitterMessageSource<?> twitterMessageSource;
@@ -86,6 +91,7 @@ public class SearchReceivingMessageSourceWithRedisTests extends RedisAvailableTe
this.metadataStore.put(metadataKey, "-1");
this.twitterMessageSource.afterPropertiesSet();
context.close();
}
/**

View File

@@ -18,8 +18,11 @@ package org.springframework.integration.twitter.inbound;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.messaging.Message;
@@ -29,9 +32,11 @@ import org.springframework.social.twitter.api.impl.TwitterTemplate;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public class TimelineReceivingMessageSourceTests {
private final Log logger = LogFactory.getLog(getClass());
@SuppressWarnings("unchecked")
@Test @Ignore
@@ -40,7 +45,6 @@ public class TimelineReceivingMessageSourceTests {
pf.setLocation(new ClassPathResource("sample.properties"));
pf.afterPropertiesSet();
Properties prop = pf.getObject();
System.out.println(prop);
TwitterTemplate template = new TwitterTemplate(prop.getProperty("z_oleg.oauth.consumerKey"),
prop.getProperty("z_oleg.oauth.consumerSecret"),
prop.getProperty("z_oleg.oauth.accessToken"),
@@ -51,8 +55,9 @@ public class TimelineReceivingMessageSourceTests {
Message<Tweet> message = (Message<Tweet>) tSource.receive();
if (message != null) {
Tweet tweet = message.getPayload();
System.out.println(tweet.getFromUser() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
logger.info(tweet.getFromUser() + " - " + tweet.getText() + " - " + tweet.getCreatedAt());
}
}
}
}

View File

@@ -20,16 +20,18 @@ import java.util.Properties;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.messaging.Message;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.twitter.core.TwitterHeaders;
import org.springframework.messaging.Message;
import org.springframework.social.twitter.api.impl.TwitterTemplate;
/**
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Gary Russell
*/
public class DirectMessageSendingMessageHandlerTests {
@@ -39,7 +41,6 @@ public class DirectMessageSendingMessageHandlerTests {
pf.setLocation(new ClassPathResource("sample.properties"));
pf.afterPropertiesSet();
Properties prop = pf.getObject();
System.out.println(prop);
TwitterTemplate template = new TwitterTemplate(prop.getProperty("spring_eip.oauth.consumerKey"),
prop.getProperty("spring_eip.oauth.consumerSecret"),
prop.getProperty("spring_eip.oauth.accessToken"),

View File

@@ -16,7 +16,10 @@
package org.springframework.integration.xmpp.ignore;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jivesoftware.smack.packet.Message;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.stereotype.Component;
@@ -25,11 +28,14 @@ import org.springframework.stereotype.Component;
*
* @author Josh Long
* @author Mark Fisher
* @author Gary Russell
* @since 2.0
*/
@Component
public class XmppMessageConsumer {
private final Log logger = LogFactory.getLog(getClass());
@ServiceActivator
public void consume(Object input) throws Throwable {
String text = null;
@@ -43,8 +49,8 @@ public class XmppMessageConsumer {
throw new IllegalArgumentException(
"expected either a Smack Message or a String, but received: " + input);
}
System.out.println("================================================================================");
System.out.println("message: " + text);
logger.info("================================================================================");
logger.info("message: " + text);
}
}

View File

@@ -150,6 +150,11 @@
<!-- value="Please use AssertJ imports." /> -->
<!-- <property name="ignoreComments" value="true" /> -->
<!-- </module> -->
<module name="Regexp">
<property name="format" value="System.(out|err).print" />
<property name="illegalPattern" value="true" />
<property name="message" value="System.out or .err" />
</module>
<module name="Regexp">
<property name="format" value="[ \t]+$" />
<property name="illegalPattern" value="true" />