@Test
  public void testNotTooOldFilter() throws Exception {
    fakeFtpServer.start();
    int port = fakeFtpServer.getServerControlPort();
    context
        .getRouteDefinitions()
        .get(0)
        .adviceWith(
            context,
            new AdviceWithRouteBuilder() {
              @Override
              public void configure() throws Exception {
                replaceFromWith(
                    "ftp://[email protected]:"
                        + port
                        + "?password=password&filter=#notTooOld&passiveMode=true");
                weaveByType(ToDefinition.class).selectFirst().replace().to("mock:end");
              }
            });
    MockEndpoint end = context.getEndpoint("mock:end", MockEndpoint.class);
    end.expectedMessageCount(1);

    end.assertIsSatisfied();

    // Make sure that the received file has the correct file name
    String fileName =
        (String) end.getReceivedExchanges().get(0).getIn().getHeader(Exchange.FILE_NAME_ONLY);
    assertEquals(fileName, "DMI1.nc");

    fakeFtpServer.stop();
  }
Beispiel #2
0
  @Before
  public void setUp() throws FileSystemException {

    fsLocal = new DefaultOpalFileSystem("res:opal-file-system");
    fsLocalRoot = fsLocal.getRoot();

    // MockFtpServer blocks the execution of this test under the unix environment, so this test
    // will be run on Windows until we find a solution...
    if (runningOsIsWindows()) {

      mockFtpServer = new FakeFtpServer();
      mockFtpServer.addUserAccount(new UserAccount("user", "password", "c:/"));

      FileSystem fileSystem = new WindowsFakeFileSystem();
      fileSystem.add(new DirectoryEntry("c:/temp"));
      fileSystem.add(new FileEntry("c:/temp/file1.txt"));
      fileSystem.add(new FileEntry("c:/temp/file2.txt", "this is the file content"));
      mockFtpServer.setFileSystem(fileSystem);

      mockFtpServer.start();

      fsFtp = new DefaultOpalFileSystem("ftp://*****:*****@localhost:21");
      fsFtpRoot = fsFtp.getRoot();
    }
  }
  @Before
  public void setup() {
    fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.setServerControlPort(10021);
    fakeFtpServer.addUserAccount(new UserAccount("user", "pass", "/"));

    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry("/"));

    fakeFtpServer.setFileSystem(fileSystem);

    fakeFtpServer.start();
  }
 // Setup a basic environment before running the tests
 @Before
 public void setUp() {
   fakeFtpServer = new FakeFtpServer();
   fakeFtpServer.setServerControlPort(0);
   fakeFtpServer.addUserAccount(new UserAccount("user", "password", "/target/test-classes"));
   FileSystem fileSystem = new UnixFakeFileSystem();
   FileEntry dmi1 = new FileEntry("/target/test-classes/DMI1.nc");
   dmi1.setLastModified(new Date());
   fileSystem.add(dmi1);
   FileEntry dmi2 = new FileEntry("/target/test-classes/DMI2.nc");
   dmi2.setLastModified(new GregorianCalendar(2011, 9, 30).getTime());
   fileSystem.add(dmi2);
   fakeFtpServer.setFileSystem(fileSystem);
 }
Beispiel #5
0
 @After
 public void cleanUp() {
   if (mockFtpServer != null) {
     mockFtpServer.stop();
   }
 }