Search in sources :

Example 6 with FTPUtils

use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class FileDownload method testUpload2.

@Test
public void testUpload2() throws Exception {
    // 管理员可以上传文件
    FTPUtils util = getUtil("admin", "admin");
    boolean result = util.uploadFile("/Test", new File("G:\\jfxrt.jar"), System.currentTimeMillis() + ".jar");
    Assert.assertTrue(result);
}
Also used : FTPUtils(com.cas.sim.tis.util.FTPUtils) File(java.io.File) Test(org.junit.Test)

Example 7 with FTPUtils

use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class FileDownload method testDirectory.

@Test
public void testDirectory() throws Exception {
    FTPUtils util = getUtil("anonymous", "");
    boolean success = util.connect("Test001/Test002");
    Assert.assertFalse(success);
}
Also used : FTPUtils(com.cas.sim.tis.util.FTPUtils) Test(org.junit.Test)

Example 8 with FTPUtils

use of com.cas.sim.tis.util.FTPUtils in project TeachingInSimulation by ScOrPiOzzy.

the class ClientConfig method buildFtpClient.

@Bean
public FTPUtils buildFtpClient() {
    FTPUtils util = new FTPUtils();
    FTPClient client = new FTPClient();
    util.setFtpClient(client);
    util.setHost(ftpAddress);
    util.setPort(ftpPort);
    util.setUsername("admin");
    util.setPassword("admin");
    try {
        SocketTest.test(ftpAddress, ftpPort);
    } catch (RuntimeException e) {
        throw e;
    }
    return util;
}
Also used : FTPUtils(com.cas.sim.tis.util.FTPUtils) FTPClient(org.apache.commons.net.ftp.FTPClient) Bean(org.springframework.context.annotation.Bean)

Aggregations

FTPUtils (com.cas.sim.tis.util.FTPUtils)8 Test (org.junit.Test)5 File (java.io.File)3 FTPClient (org.apache.commons.net.ftp.FTPClient)3 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Bean (org.springframework.context.annotation.Bean)1 StopWatch (org.springframework.util.StopWatch)1