Package com.cloudhopper.smpp.impl

Examples of com.cloudhopper.smpp.impl.DefaultSmppServer


  configuration.setSslConfiguration(sslConfig);
        return configuration;
    }

    private DefaultSmppServer createSmppServer(SmppServerConfiguration configuration) {
        DefaultSmppServer smppServer = new DefaultSmppServer(configuration, serverHandler);
        return smppServer;
    }
View Full Code Here


    }

    @Test
    public void serverOverSSLButClientIsNotSSL() throws Exception {
        // server is SSL, client is not!
        DefaultSmppServer server0 = createSmppServer(createServerConfigurationWeakSSL());
        server0.start();

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationNoSSL();
        // verify that the bad connection is detected earlier than the 30 second timeouts
        sessionConfig0.setConnectTimeout(30000);
        sessionConfig0.setBindTimeout(30000);

        long start = System.currentTimeMillis();
        try {
            // this should fail
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.fail();
        } catch (SmppChannelException e) {
            long stop = System.currentTimeMillis();
            Assert.assertNotNull(e);
            logger.info("Expected exception: " + e.getMessage());
            Assert.assertTrue((stop-start) < 30000);
        } finally {
            server0.destroy();
        }
    }
View Full Code Here

    }

    @Test
    public void clientOverSSLButServerIsNotSSL() throws Exception {
        // server is not SSL, client is SSL
        DefaultSmppServer server0 = createSmppServer(createServerConfigurationNoSSL());
        server0.start();

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationWeakSSL();
        // the server immediately closed the connection and there is a workaround
        // enabled to detect this closure much faster than a 30 second connect timeout
        // we set these to be longer than normal to verify the bind fails in less
        // time than these settings are set for
        sessionConfig0.setConnectTimeout(30000);
        sessionConfig0.setBindTimeout(30000);
        long start = System.currentTimeMillis();
        try {
            // this should fail
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.fail();
        } catch (SmppChannelException e) {
            long stop = System.currentTimeMillis();
            Assert.assertNotNull(e);
            logger.info("Expected exception: " + e.getMessage());
            // workaround for this unit test is working correctly since the
            // connection close event should be caught earlier than the connectTimeout
            Assert.assertTrue((stop-start) < 30000);
        } finally {
            server0.destroy();
        }
    }
View Full Code Here

    }

    @Test
    public void bindOverSSL() throws Exception {
        // both server and client are SSL
        DefaultSmppServer server0 = createSmppServer(createServerConfigurationWeakSSL());
        server0.start();

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationWeakSSL();

        try {
            // this should actually work
            SmppSession session0 = client0.bind(sessionConfig0);
            Thread.sleep(200);

            Assert.assertEquals(1, serverHandler.sessions.size());
            Assert.assertEquals(1, server0.getChannels().size());

            SmppServerSession serverSession0 = serverHandler.sessions.iterator().next();
            Assert.assertEquals(true, serverSession0.isBound());
            Assert.assertEquals(SmppBindType.TRANSCEIVER, serverSession0.getBindType());
            Assert.assertEquals(SmppSession.Type.SERVER, serverSession0.getLocalType());
            Assert.assertEquals(SmppSession.Type.CLIENT, serverSession0.getRemoteType());

            serverSession0.close();
      Thread.sleep(200);
            Assert.assertEquals(0, serverHandler.sessions.size());
            Assert.assertEquals(0, server0.getChannels().size());
            Assert.assertEquals(false, serverSession0.isBound());
        } finally {
            server0.destroy();
        }
    }
View Full Code Here

    }

    @Test
    public void enquireLinkOverSSL() throws Exception {
        // both server and client are SSL
        DefaultSmppServer server0 = createSmppServer(createServerConfigurationWeakSSL());
        server0.start();

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationWeakSSL();

        try {
            SmppSession session0 = client0.bind(sessionConfig0);
            Thread.sleep(100);

            // send encrypted enquire link; receive encrypted response.
            EnquireLinkResp enquireLinkResp = session0.enquireLink(new EnquireLink(), 1000);

            Assert.assertEquals(0, enquireLinkResp.getCommandStatus());
            Assert.assertEquals("OK", enquireLinkResp.getResultMessage());
        } finally {
            server0.destroy();
        }
    }
View Full Code Here

    @Test
    @Ignore
    public void trustedClientSSL() throws Exception {
        // both server and client are SSL with compatible certificate.
        DefaultSmppServer server0 = createSmppServer(createServerConfigurationStrongSSL());
        server0.start();

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationStrongSSL();

        try {
            // this should work
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.assertNotNull(session0);
        } catch (Exception e) {
            Assert.fail();
        } finally {
            server0.destroy();
        }
    }
View Full Code Here

    @Test
    @Ignore
    public void untrustedClientSSL() throws Exception {
        // both server and client are SSL. But the client is certificateless.
        // server has activated trust manager that refuses untrusted clients.
        DefaultSmppServer server0 = createSmppServer(createServerConfigurationStrongSSL());
        server0.start();

        DefaultSmppClient client0 = new DefaultSmppClient();
        SmppSessionConfiguration sessionConfig0 = createClientConfigurationWeakSSL();
        try {
            // this should fail
            SmppSession session0 = client0.bind(sessionConfig0);
            Assert.fail();
        } catch (Exception e) {
            Assert.assertNotNull(e);
            logger.info("Expected exception: " + e.getMessage());
        } finally {
            server0.destroy();
        }
    }
View Full Code Here

  sslConfig.setTrustStorePassword("changeit");
  configuration.setUseSsl(true);
  configuration.setSslConfiguration(sslConfig);

        // create a server, start it up
        DefaultSmppServer smppServer = new DefaultSmppServer(configuration, new DefaultSmppServerHandler(), executor, monitorExecutor);

        logger.info("Starting SMPP server...");
        smppServer.start();
        logger.info("SMPP server started");

        System.out.println("Press any key to stop server");
        System.in.read();

        logger.info("Stopping SMPP server...");
        smppServer.stop();
        logger.info("SMPP server stopped");
       
        logger.info("Server counters: {}", smppServer.getCounters());
    }
View Full Code Here

        SmppServerConfiguration configuration = new SmppServerConfiguration();
        configuration.setPort(2776);
        configuration.setMaxConnectionSize(10);
        configuration.setNonBlockingSocketsEnabled(false);
       
        SmppServer smppServer = new DefaultSmppServer(configuration, new DefaultSmppServerHandler());

        logger.info("About to start SMPP server");
        smppServer.start();
        logger.info("SMPP server started");

        System.out.println("Press any key to stop server");
        System.in.read();

        logger.info("SMPP server stopping");
        smppServer.stop();
        logger.info("SMPP server stopped");
    }
View Full Code Here

        configuration.setDefaultWindowWaitTimeout(configuration.getDefaultRequestExpiryTimeout());
        configuration.setDefaultSessionCountersEnabled(true);
        configuration.setJmxEnabled(true);
       
        // create a server, start it up
        DefaultSmppServer smppServer = new DefaultSmppServer(configuration, new DefaultSmppServerHandler(), executor, monitorExecutor);

        logger.info("Starting SMPP server...");
        smppServer.start();
        logger.info("SMPP server started");

        System.out.println("Press any key to stop server");
        System.in.read();

        logger.info("Stopping SMPP server...");
        smppServer.stop();
        logger.info("SMPP server stopped");
       
        logger.info("Server counters: {}", smppServer.getCounters());
    }
View Full Code Here

TOP

Related Classes of com.cloudhopper.smpp.impl.DefaultSmppServer

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.