Package org.apache.ftpserver.ftplet

Examples of org.apache.ftpserver.ftplet.Configuration


    public void testConfigListeners() throws Exception {
        Properties props = new Properties();
        props.setProperty("config.listeners.foo1.class", NioListener.class.getName());
        props.setProperty("config.listeners.foo2.class", NioListener.class.getName());
       
        Configuration config = new PropertiesConfiguration(props);
       
        ConfigurableFtpServerContext ctx = new ConfigurableFtpServerContext(config);
       
        assertNotNull(ctx.getListener("foo1"));
        assertTrue(ctx.getListener("foo1") instanceof NioListener);
View Full Code Here


    public static void main(String args[]) {

        try {

            // get configuration
            Configuration config = getConfiguration(args);
            if(config == null) {
                return;
            }

            // create root configuration object
View Full Code Here

    /**
     * Get the configuration object.
     */
    private static Configuration getConfiguration(String[] args) throws Exception {

        Configuration config = null;
        FileInputStream in = null;
        try {
            if(args.length == 0) {
                System.out.println("Using default configuration....");
                config = EmptyConfiguration.INSTANCE;
View Full Code Here

        assertFalse(config.isEmpty());
        assertTrue(config.subset("empty").isEmpty());
    }

    public void testGetBoolean() throws Exception {
        Configuration config = this.config.subset("socket-factory");
       
        assertTrue(config.getBoolean("booltrue"));
        assertFalse(config.getBoolean("boolfalse"));
       
        // non boolean value, should return false
        assertFalse(config.getBoolean("address"));
       
        // missing parameter, must throw exception
        try{
            config.getBoolean("dummy");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }

        assertTrue(config.getBoolean("dummy", true));
        assertTrue(config.getBoolean("booltrue", false));
    }
View Full Code Here

        assertTrue(config.getBoolean("dummy", true));
        assertTrue(config.getBoolean("booltrue", false));
    }
   
    public void testGetInt() throws Exception {
        Configuration config = this.config.subset("socket-factory");

        assertEquals(21, config.getInt("port"));
        assertEquals(123, config.getInt("dummy", 123));
        assertEquals(21, config.getInt("port", 123));
       
        // non integer value, must throw exception
        try{
            config.getInt("address");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }

        // missing parameter, must throw exception
        try{
            config.getInt("dummy");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }
    }
View Full Code Here

            // OK
        }
    }

    public void testGetLong() throws Exception {
        Configuration config = this.config.subset("socket-factory");
       
        assertEquals(21, config.getLong("port"));
        assertEquals(123, config.getLong("dummy", 123));
        assertEquals(21, config.getLong("port", 123));
       
        // non long value, must throw exception
        try{
            config.getLong("address");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }
       
        // missing parameter, must throw exception
        try{
            config.getLong("dummy");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }
    }
View Full Code Here

            // OK
        }
    }
   
    public void testGetString() throws Exception {
        Configuration config = this.config.subset("socket-factory");

        assertEquals("localhost", config.getString("address"));
        assertEquals("localhost", config.getString("address", "foo"));
        assertEquals("localhost", config.getString("dummy", "localhost"));
       
        // missing parameter, must throw exception
        try{
            config.getString("dummy");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }
    }
View Full Code Here

            // OK
        }
    }

    public void testGetDouble() throws Exception {
        Configuration config = this.config.subset("socket-factory");
       
        assertEquals(21D, config.getDouble("port"), 0.001);
        assertEquals(123D, config.getDouble("dummy", 123), 0.001);
        assertEquals(21D, config.getDouble("port", 123), 0.001);
        assertEquals(1.234, config.getDouble("double"), 0.001);
       
        // non double value, must throw exception
        try{
            config.getDouble("address");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }
       
        // missing parameter, must throw exception
        try{
            config.getDouble("dummy");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }
    }
View Full Code Here

            // OK
        }
    }
   
    public void testSubset() throws Exception {
        Configuration subConfig = config.subset("socket-factory");
        assertEquals("localhost", subConfig.getString("address"));
       
        Configuration subSubConfig = subConfig.subset("ssl");
        assertEquals("TLS", subSubConfig.getString("ssl-protocol"));
    }
View Full Code Here

        Configuration subSubConfig = subConfig.subset("ssl");
        assertEquals("TLS", subSubConfig.getString("ssl-protocol"));
    }

    public void testGetStringForSubConfig() {
        Configuration subConfig = config.subset("socket-factory");
        try{
            subConfig.getString("ssl");
            fail("Must throw FtpException");
        } catch(FtpException e) {
            // OK
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.ftplet.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.