Search in sources :

Example 6 with UserAccount

use of org.mockftpserver.fake.UserAccount in project irida by phac-nml.

the class ExportUploadServiceTest method testUploadSubmissionNoBaseDirectory.

@Test(expected = UploadException.class)
public void testUploadSubmissionNoBaseDirectory() throws UploadException, IOException {
    NcbiExportSubmission submission = createFakeSubmission();
    String ftpHost = "localhost";
    String ftpUser = "test";
    String ftpPassword = "password";
    String baseDirectory = "/home/test/submit/Test";
    FakeFtpServer server = new FakeFtpServer();
    server.addUserAccount(new UserAccount(ftpUser, ftpPassword, "/home/test"));
    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry("/home/test"));
    server.setFileSystem(fileSystem);
    // finds an open port
    server.setServerControlPort(0);
    ExportUploadService exportUploadService = new ExportUploadService(null, null, new TestEmailController());
    try {
        server.start();
        int ftpPort = server.getServerControlPort();
        exportUploadService.setConnectionDetails(ftpHost, ftpPort, ftpUser, ftpPassword, baseDirectory);
        String xml = "<xml></xml>";
        exportUploadService.uploadSubmission(submission, xml);
    } finally {
        server.stop();
    }
}
Also used : NcbiExportSubmission(ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission) FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) UnixFakeFileSystem(org.mockftpserver.fake.filesystem.UnixFakeFileSystem) FileSystem(org.mockftpserver.fake.filesystem.FileSystem) UnixFakeFileSystem(org.mockftpserver.fake.filesystem.UnixFakeFileSystem) TestEmailController(ca.corefacility.bioinformatics.irida.service.impl.TestEmailController) DirectoryEntry(org.mockftpserver.fake.filesystem.DirectoryEntry) UserAccount(org.mockftpserver.fake.UserAccount) Test(org.junit.Test)

Aggregations

UserAccount (org.mockftpserver.fake.UserAccount)6 FileSystem (org.mockftpserver.fake.filesystem.FileSystem)6 Test (org.junit.Test)5 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)5 DirectoryEntry (org.mockftpserver.fake.filesystem.DirectoryEntry)5 UnixFakeFileSystem (org.mockftpserver.fake.filesystem.UnixFakeFileSystem)5 NcbiExportSubmission (ca.corefacility.bioinformatics.irida.model.NcbiExportSubmission)4 TestEmailController (ca.corefacility.bioinformatics.irida.service.impl.TestEmailController)4 FileEntry (org.mockftpserver.fake.filesystem.FileEntry)3 NcbiBioSampleFiles (ca.corefacility.bioinformatics.irida.model.export.NcbiBioSampleFiles)2 Set (java.util.Set)2 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)1 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)1 LocalizeResource (co.cask.cdap.internal.app.runtime.distributed.LocalizeResource)1 File (java.io.File)1 URI (java.net.URI)1 Before (org.junit.Before)1 WindowsFakeFileSystem (org.mockftpserver.fake.filesystem.WindowsFakeFileSystem)1