Skip to content

Commit

Permalink
AC.close() in file and ftp tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Bilan committed May 29, 2014
1 parent 4b9d65f commit 3b12f7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void runDemo() throws Exception{
assertTrue(new File(TestSuite.FTP_ROOT_DIR + File.separator + "b.txt").exists());

LOGGER.info("Successfully transfered file 'a.txt' and 'b.txt' to a remote FTP location.");

ctx.close();
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
*/
package org.springframework.integration.samples.mongodb.util;

import com.mongodb.MongoClient;

import org.springframework.data.mongodb.MongoDbFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;

import com.mongodb.Mongo;
/**
*
* @author Oleg Zhurakousky
*/
public class DemoUtils {

public static MongoDbFactory prepareMongoFactory(String... additionalCollectionToDrop) throws Exception{
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new Mongo(), "test");
MongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(new MongoClient(), "test");
MongoTemplate template = new MongoTemplate(mongoDbFactory);
template.dropCollection("messages");
template.dropCollection("data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.messaging.PollableChannel;

Expand Down Expand Up @@ -42,13 +43,14 @@ public void testSequentialFileProcessing() throws Exception {
out.close();
}
logger.info("Populated directory with files");
Thread.sleep(5000);
Thread.sleep(2000);
logger.info("Starting Spring Integration Sequential File processing");
ApplicationContext ac = new ClassPathXmlApplicationContext("META-INF/spring/integration/sequentialFileProcessing-config.xml");
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("META-INF/spring/integration/sequentialFileProcessing-config.xml");
PollableChannel filesOutChannel = ac.getBean("filesOutChannel", PollableChannel.class);
for (int i = 0; i < fileCount; i++) {
logger.info("Finished processing " + filesOutChannel.receive(20000).getPayload());
logger.info("Finished processing " + filesOutChannel.receive(10000).getPayload());
}
ac.stop();
}
@Test
public void testConcurrentFileProcessing() throws Exception {
Expand All @@ -63,10 +65,11 @@ public void testConcurrentFileProcessing() throws Exception {
logger.info("Populated directory with files");
Thread.sleep(2000);
logger.info("Starting Spring Integration Sequential File processing");
ApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/concurrentFileProcessing-config.xml");
ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/concurrentFileProcessing-config.xml");
PollableChannel filesOutChannel = ac.getBean("filesOutChannel", PollableChannel.class);
for (int i = 0; i < fileCount; i++) {
logger.info("Finished processing " + filesOutChannel.receive(10000).getPayload());
}
ac.stop();
}
}

0 comments on commit 3b12f7e

Please sign in to comment.