public void test() throws Throwable {
    DefaultFtpServer server =
        (DefaultFtpServer)
            createServer(
                "<db-user-manager  encrypt-passwords=\"salted\">"
                    + "<data-source>"
                    + "    <beans:bean class=\"org.hsqldb.jdbc.jdbcDataSource\">"
                    + "        <beans:property name=\"database\" value=\"jdbc:hsqldb:mem:foo\" />"
                    + "        <beans:property name=\"user\" value=\"sa\" />"
                    + "        <beans:property name=\"password\" value=\"\" />"
                    + "    </beans:bean>"
                    + "</data-source>"
                    + "<insert-user>INSERT USER</insert-user>"
                    + "<update-user>UPDATE USER</update-user>"
                    + "<delete-user>DELETE USER</delete-user>"
                    + "<select-user>SELECT USER</select-user>"
                    + "<select-all-users>SELECT ALL USERS</select-all-users>"
                    + "<is-admin>IS ADMIN</is-admin>"
                    + "<authenticate>AUTHENTICATE</authenticate>"
                    + "</db-user-manager>");

    DbUserManager um = (DbUserManager) server.getUserManager();
    assertTrue(um.getDataSource() instanceof jdbcDataSource);
    assertTrue(um.getPasswordEncryptor() instanceof SaltedPasswordEncryptor);

    assertEquals("INSERT USER", um.getSqlUserInsert());
    assertEquals("UPDATE USER", um.getSqlUserUpdate());
    assertEquals("DELETE USER", um.getSqlUserDelete());
    assertEquals("SELECT USER", um.getSqlUserSelect());
    assertEquals("SELECT ALL USERS", um.getSqlUserSelectAll());
    assertEquals("IS ADMIN", um.getSqlUserAdmin());
    assertEquals("AUTHENTICATE", um.getSqlUserAuthenticate());
  }
  public void test() throws Throwable {
    System.setProperty("port2", "3333");

    FileSystemXmlApplicationContext ctx =
        new FileSystemXmlApplicationContext(
            "src/test/resources/spring-config/config-property-placeholder.xml");

    DefaultFtpServer server = (DefaultFtpServer) ctx.getBean("server");

    assertEquals(2222, server.getListener("listener0").getPort());
    assertEquals(3333, server.getListener("listener1").getPort());
  }
Exemplo n.º 3
0
  @Test
  public void portChangeTest() {
    when(ftpServerFactory.createServer()).thenReturn(server);
    when(server.getListener(DEFAULT_LISTENER)).thenReturn(defaultListener);
    when(defaultListener.getActiveSessions()).thenReturn(sessions);

    ftpServerStarter.init();

    assertEquals(8021, ftpServerStarter.getPort());

    when(server.isSuspended()).thenReturn(true);

    ftpServerStarter.setPort(8022);
    assertEquals(8022, ftpServerStarter.getPort());
  }