@Test
 public void testExplicitModeDefaultPort() {
   FTPSConnectionPoint cp = new FTPSConnectionPoint();
   cp.setExplicit(true);
   assertEquals(
       "Default explicit port doesn't match", IFTPSConstants.FTP_PORT_DEFAULT, cp.getPort());
 }
 @Test
 public void testImplicitModeDefaultPort() {
   FTPSConnectionPoint cp = new FTPSConnectionPoint();
   cp.setExplicit(false);
   assertEquals(
       "Default implicit port doesn't match", IFTPSConstants.FTPS_IMPLICIT_PORT, cp.getPort());
 }
示例#3
0
  @Override
  public boolean load15Data(String data) {
    String[] items = data.split(IConnectionPoint15Constants.DELIMITER);

    if (items.length < 7) {
      return false;
    }

    setName(items[0]);
    setHost(items[1]);
    if (items[2] == null || "".equals(items[2])) { // $NON-NLS-1$
      setPath(Path.ROOT);
    } else {
      setPath(new Path(items[2]));
    }
    setLogin(items[3]);
    setPassword(items[4].toCharArray());
    setPassiveMode(items[5].equals(Boolean.TRUE.toString()));
    setId(items[6]);

    if (items.length >= 10) {
      setPort(Integer.parseInt(items[9]));
    }
    if (items.length >= 12) {
      setExplicit(items[11].equals(Boolean.TRUE.toString()));
    }
    return true;
  }
  private static void createAndTestConnectionPoint(
      String name,
      String host,
      int port,
      String login,
      char[] password,
      IPath path,
      String encoding,
      boolean passiveMode,
      String timezone,
      String transferType,
      boolean explicit,
      boolean noSSLSessionResumption,
      boolean validateCertificate) {
    FTPSConnectionPoint cp = new FTPSConnectionPoint();
    cp.setName(name);
    cp.setHost(host);
    cp.setPort(port);
    cp.setLogin(login);
    cp.setPassword(password);
    cp.setPassiveMode(passiveMode);
    cp.setPath(path);
    cp.setTimezone(timezone);
    cp.setTransferType(transferType);
    cp.setEncoding(encoding);
    cp.setExplicit(explicit);
    cp.setNoSSLSessionResumption(noSSLSessionResumption);
    cp.setValidateCertificate(validateCertificate);

    XMLMemento root = XMLMemento.createWriteRoot("root");
    IMemento memento = root.createChild("item");
    cp.saveState(memento);

    cp = new FTPSConnectionPoint();
    cp.loadState(memento);
    assertEquals("Name doesn't match", name, cp.getName());
    assertEquals("Host doesn't match", host, cp.getHost());
    assertEquals("Port doesn't match", port, cp.getPort());
    assertEquals("Login doesn't match", login, cp.getLogin());
    assertEquals("Password should not be persistent", null, cp.getPassword());
    assertEquals("Passive mode doesn't match", passiveMode, cp.isPassiveMode());
    assertEquals("Path doesn't match", path, cp.getPath());
    assertEquals("Timezone doesn't match", timezone, cp.getTimezone());
    assertEquals("Transfer type doesn't match", transferType, cp.getTransferType());
    assertEquals("Encoding doesn't match", encoding, cp.getEncoding());
    assertEquals("Explicit mode doesn't match", explicit, cp.isExplicit());
    assertEquals(
        "No SSL resumption mode doesn't match",
        noSSLSessionResumption,
        cp.isNoSSLSessionResumption());
    assertEquals(
        "Validate certificate mode doesn't match", validateCertificate, cp.isValidateCertificate());
  }