public void testBasicConsume_WithTrailingSlash() throws Exception {
   if (areTestsEnabled()) {
     MockMessageListener listener = new MockMessageListener();
     RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
     String destination = getDestinationString() + "/";
     ConfiguredConsumeDestination ccd = new ConfiguredConsumeDestination(destination);
     ccd.setConfiguredThreadName("testBasicConsume_WithTrailingSlash");
     ftpConsumer.setDestination(ccd);
     ftpConsumer.registerAdaptrisMessageListener(listener);
     ftpConsumer.setOlderThan(DEFAULT_QUIET_PERIOD);
     ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
     StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
     start(sc);
     int count = 1;
     try {
       RelaxedFtpProducer producer = createFtpProducer();
       producer.setDestination(new ConfiguredProduceDestination(destination));
       produce(new StandaloneProducer(createConnection(), producer), count);
       waitForMessages(listener, count);
       assertMessages(listener.getMessages(), count);
     } catch (Exception e) {
       log.error(e.getMessage(), e);
       throw e;
     } finally {
       stop(sc);
     }
   }
 }
  public void testConsumeWithFilter() throws Exception {
    if (areTestsEnabled()) {
      MockMessageListener listener = new MockMessageListener();
      RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
      ConfiguredConsumeDestination ccd =
          new ConfiguredConsumeDestination(getDestinationString(), "*.txt");
      ccd.setConfiguredThreadName("testConsumeWithFilter");
      ftpConsumer.setDestination(ccd);
      ftpConsumer.setOlderThan(DEFAULT_QUIET_PERIOD);

      ftpConsumer.setFileFilterImp("org.apache.oro.io.GlobFilenameFilter");
      ftpConsumer.registerAdaptrisMessageListener(listener);
      ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
      StandaloneConsumer sc = new StandaloneConsumer(createConnection(), ftpConsumer);
      start(sc);

      int count = 1;
      try {
        RelaxedFtpProducer ftpProducer = createFtpProducer();
        MetadataFileNameCreator mfc = new MetadataFileNameCreator();
        mfc.setDefaultName(new GuidGenerator().getUUID() + ".txt");
        mfc.setMetadataKey(new GuidGenerator().getUUID());
        ftpProducer.setFileNameCreator(mfc);
        produce(new StandaloneProducer(createConnection(), ftpProducer), count);
        waitForMessages(listener, count);

        assertMessages(listener.getMessages(), count);
      } finally {
        stop(sc);
      }
    }
  }
 public void testConsume_WithEncoder() throws Exception {
   if (areTestsEnabled()) {
     MockMessageListener listener = new MockMessageListener();
     RelaxedFtpConsumer ftpConsumer = new RelaxedFtpConsumer();
     ConfiguredConsumeDestination ccd = new ConfiguredConsumeDestination(getDestinationString());
     ccd.setConfiguredThreadName("testCasualBasicConsume");
     ftpConsumer.setDestination(ccd);
     ftpConsumer.registerAdaptrisMessageListener(listener);
     ftpConsumer.setOlderThan(DEFAULT_QUIET_PERIOD);
     ftpConsumer.setPoller(new QuartzCronPoller("*/1 * * * * ?"));
     ftpConsumer.setEncoder(new MimeEncoder());
     FileTransferConnection consumeConnection = createConnection();
     consumeConnection.setCacheConnection(true);
     StandaloneConsumer sc = new StandaloneConsumer(consumeConnection, ftpConsumer);
     start(sc);
     int count = 1;
     try {
       FileTransferConnection produceConnection = createConnection();
       produceConnection.setCacheConnection(true);
       RelaxedFtpProducer producer = createFtpProducer();
       producer.setEncoder(new MimeEncoder());
       produce(new StandaloneProducer(produceConnection, producer), count);
       waitForMessages(listener, count);
       assertMessages(listener.getMessages(), count);
     } catch (Exception e) {
       log.error(e.getMessage(), e);
       throw e;
     } finally {
       stop(sc);
     }
   }
 }
 protected RelaxedFtpProducer createFtpProducer() throws Exception {
   RelaxedFtpProducer p = new RelaxedFtpProducer();
   ConfiguredProduceDestination d = new ConfiguredProduceDestination(getDestinationString());
   p.setDestination(d);
   return p;
 }