Example usage for org.apache.commons.net.ftp FTPReply isPositiveCompletion

List of usage examples for org.apache.commons.net.ftp FTPReply isPositiveCompletion

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPReply isPositiveCompletion.

Prototype

public static boolean isPositiveCompletion(int reply) 

Source Link

Document

Determine if a reply code is a positive completion response.

Usage

From source file:org.apache.ftpserver.clienttests.DirectoryTest.java

public void testMkdir() throws Exception {
    assertFalse(TEST_DIR1.exists());//from   w w  w  .  j a  va 2 s  . com

    assertTrue(FTPReply.isPositiveCompletion(client.mkd(TEST_DIR1.getName())));

    assertTrue(TEST_DIR1.exists());
}

From source file:org.apache.ftpserver.clienttests.DirectoryTest.java

/**
 * FTPSERVER-233, we should not recursively create directories  
 *//*from   ww w  .  j a  v a  2 s.c  om*/
public void testMkdirDouble() throws Exception {
    assertFalse(TEST_DIR1.exists());
    assertFalse(TEST_DIR_IN_DIR1.exists());

    assertFalse(
            FTPReply.isPositiveCompletion(client.mkd(TEST_DIR1.getName() + '/' + TEST_DIR_IN_DIR1.getName())));

    assertFalse(TEST_DIR1.exists());
    assertFalse(TEST_DIR_IN_DIR1.exists());
}

From source file:org.apache.ftpserver.clienttests.DirectoryTest.java

public void testMkdirDoubleFirstExists() throws Exception {
    TEST_DIR1.mkdirs();/*from w ww .j a  v  a  2 s. c om*/
    assertTrue(TEST_DIR1.exists());
    assertFalse(TEST_DIR_IN_DIR1.exists());

    assertTrue(
            FTPReply.isPositiveCompletion(client.mkd(TEST_DIR1.getName() + '/' + TEST_DIR_IN_DIR1.getName())));

    assertTrue(TEST_DIR1.exists());
    assertTrue(TEST_DIR_IN_DIR1.exists());
}

From source file:org.apache.ftpserver.clienttests.ListTest.java

public void testMLST() throws Exception {
    TEST_FILE1.createNewFile();//www .  ja  va 2s .  c o  m

    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("MLST " + TEST_FILE1.getName())));

    String[] reply = client.getReplyString().split("\\r\\n");

    assertEquals("Size=0;Modify=" + DateUtils.getFtpDate(TEST_FILE1.lastModified()) + ";Type=file; "
            + TEST_FILE1.getName(), reply[1]);
}

From source file:org.apache.ftpserver.clienttests.ListTest.java

public void testOPTSMLST() throws Exception {
    TEST_FILE1.createNewFile();/*  ww  w  .j ava  2  s .  c o  m*/

    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("OPTS MLST Size;Modify")));
    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("MLST " + TEST_FILE1.getName())));

    String[] reply = client.getReplyString().split("\\r\\n");

    assertEquals(
            "Size=0;Modify=" + DateUtils.getFtpDate(TEST_FILE1.lastModified()) + "; " + TEST_FILE1.getName(),
            reply[1]);
}

From source file:org.apache.ftpserver.clienttests.ListTest.java

public void testOPTSMLSTCaseInsensitive() throws Exception {
    TEST_FILE1.createNewFile();/*from  ww  w.j  a v  a2s .  c o  m*/

    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("OPTS MLST size;Modify")));
    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("MLST " + TEST_FILE1.getName())));

    String[] reply = client.getReplyString().split("\\r\\n");

    assertEquals(
            "Size=0;Modify=" + DateUtils.getFtpDate(TEST_FILE1.lastModified()) + "; " + TEST_FILE1.getName(),
            reply[1]);
}

From source file:org.apache.ftpserver.clienttests.ListTest.java

/**
 * "Facts requested that are not/* w  w w.j  a  v a 2 s  .c  om*/
 * supported, or that are inappropriate to the file or directory being
 * listed should simply be omitted from the MLSx output."
 * 
 * http://tools.ietf.org/html/rfc3659#section-7.9
 */
public void testOPTSMLSTUnknownFact() throws Exception {
    TEST_FILE1.createNewFile();

    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("OPTS MLST Foo;Size")));

    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("MLST " + TEST_FILE1.getName())));

    String[] reply = client.getReplyString().split("\\r\\n");

    assertEquals("Size=0; " + TEST_FILE1.getName(), reply[1]);
}

From source file:org.apache.ftpserver.clienttests.ListTest.java

/**
 * "Facts requested that are not//from w ww . ja va 2 s . c  om
 * supported, or that are inappropriate to the file or directory being
 * listed should simply be omitted from the MLSx output."
 * 
 * http://tools.ietf.org/html/rfc3659#section-7.9
 */
public void testOPTSMLSTNoFacts() throws Exception {
    TEST_FILE1.createNewFile();

    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("OPTS MLST")));

    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("MLST " + TEST_FILE1.getName())));

    String[] reply = client.getReplyString().split("\\r\\n");

    assertEquals(" " + TEST_FILE1.getName(), reply[1]);
}

From source file:org.apache.ftpserver.clienttests.LoginTest.java

public void testLoginWithAccount() throws Exception {
    assertTrue(client.login(ADMIN_USERNAME, ADMIN_PASSWORD));

    assertTrue(FTPReply.isPositiveCompletion(client.acct("FOO")));
}

From source file:org.apache.ftpserver.clienttests.LoginTest.java

public void testLoginWithEmptyCorrectPassword() throws Exception {
    assertTrue(FTPReply.isPositiveIntermediate(client.user("testuser3")));
    assertTrue(FTPReply.isPositiveCompletion(client.sendCommand("PASS")));
}