Examples of SmppSimulatorSessionHandler


Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        server.start(2776);
        logger.info("SMPP simulator server started");

        // wait for a session
        logger.info("Waiting for the first smsc session within 30 seconds");
        SmppSimulatorSessionHandler smscSession = server.pollNextSession(30000);

        logger.info("Successfully got an new session!");

        System.out.println("Press any key to shutdown simulator server");
        System.in.read();
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        registerServerBindProcessor();
        clearAllServerSessions();

        // bind and get the simulator session
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration);
        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        // register a generic nack will come next
        simulator0.setPduProcessor(new SmppSimulatorPduProcessor() {
            @Override
            public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu pdu) throws Exception {
                session.addPduToWriteOnNextPduReceived(((PduRequest)pdu).createGenericNack(SmppConstants.STATUS_SYSERR));
                return true;
            }
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        registerServerBindProcessor();
        clearAllServerSessions();

        // bind and get the simulator session
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration);
        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        // create an enquire link response back -- we should skip it and wait for a response instead
        simulator0.setPduProcessor(new SmppSimulatorPduProcessor() {
            @Override
            public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu pdu) throws Exception {
                EnquireLink enquireLink = new EnquireLink();
                enquireLink.setSequenceNumber(pdu.getSequenceNumber());
                session.addPduToWriteOnNextPduReceived(enquireLink);
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        registerServerBindProcessor();
        clearAllServerSessions();

        // bind and get the simulator session
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration);
        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        // create an enquire link response back -- we should skip it and wait for a response instead
        simulator0.setPduProcessor(new SmppSimulatorPduProcessor() {
            @Override
            public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu pdu) throws Exception {
                session.addPduToWriteOnNextPduReceived(((PduRequest)pdu).createResponse());
                return true;
            }
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        // change window size to 3
        configuration.setWindowSize(3);

        // bind and get the simulator session
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration);
        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        // make sure the processor is null
        simulator0.setPduProcessor(null);

        try {
//            try {
                // create the requests and response we plan on sending
                EnquireLink el0 = new EnquireLink();
                EnquireLink el1 = new EnquireLink();
                EnquireLink el2 = new EnquireLink();
                EnquireLink el3 = new EnquireLink();
                el0.setSequenceNumber(0x7000);
                el1.setSequenceNumber(0x4541);
                el2.setSequenceNumber(0x5414);
                el3.setSequenceNumber(0x2414);
                EnquireLinkResp el0Resp = el0.createResponse();
                EnquireLinkResp el1Resp = el1.createResponse();
                EnquireLinkResp el2Resp = el2.createResponse();
                EnquireLinkResp el3Resp = el3.createResponse();

                // this request should be permitted (with window size = 2)
                WindowFuture future0 = session.sendRequestPdu(el0, 3000, true);
                WindowFuture future1 = session.sendRequestPdu(el1, 3000, true);
                WindowFuture future2 = session.sendRequestPdu(el2, 3000, true);

                Assert.assertEquals(3, session.getSendWindow().getSize());

                try {
                    // window size of 3 is now filled up, this one should timeout
                    session.sendRequestPdu(el3, 100, true);
                    Assert.fail();
                } catch (SmppTimeoutException e) {
                    Assert.assertNotNull(e.getCause());
                    Assert.assertEquals(OfferTimeoutException.class, e.getCause().getClass());
                }

                Assert.assertEquals(3, session.getSendWindow().getSize());

                // now the smsc will send a response back to the second request
                simulator0.sendPdu(el1Resp);

                // wait for the response to make its way back in
                future1.await();

                // there should be 1 slot free now in the window
                Assert.assertEquals(2, session.getSendWindow().getSize());

                // this request should now succeed
                WindowFuture future3 = session.sendRequestPdu(el3, 3000, true);

                // send back responses for everything that's missing
                simulator0.sendPdu(el2Resp);
                simulator0.sendPdu(el0Resp);
                simulator0.sendPdu(el3Resp);

                // make sure they all finished
                future0.await();
                future1.await();
                future2.await();
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        // bind and get the simulator session
        PollableSmppSessionHandler sessionHandler = new PollableSmppSessionHandler();
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration, sessionHandler);

        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        simulator0.setPduProcessor(null);

        try {
            Assert.assertEquals(0, sessionHandler.getReceivedPduRequests().size());

            // send 1 byte
            logger.debug("Sending 1 byte");
            simulator0.getChannel().write(BufferHelper.createBuffer("00")).await();

            // nothing received yet
            Assert.assertEquals(0, sessionHandler.getReceivedPduRequests().size());

            // send 14 more bytes
            logger.debug("Sending 14 more bytes");
            simulator0.getChannel().write(BufferHelper.createBuffer("00001000000015000000000a342e")).await();

            // send 1 more byte
            logger.debug("Sending 1 more bytes");
            simulator0.getChannel().write(BufferHelper.createBuffer("e7")).await();

            // we should have received a PDU request, poll for it
            PduRequest pdu0 = sessionHandler.getReceivedPduRequests().poll(2000, TimeUnit.MILLISECONDS);
            Assert.assertNotNull(pdu0);
            Assert.assertEquals(SmppConstants.CMD_ID_ENQUIRE_LINK, pdu0.getCommandId());
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        // bind and get the simulator session
        PollableSmppSessionHandler sessionHandler = new PollableSmppSessionHandler();
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration, sessionHandler);

        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        simulator0.setPduProcessor(new SmppSimulatorPduProcessor() {
            @Override
            public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu pdu) throws Exception {
                session.addPduToWriteOnNextPduReceived(((PduRequest)pdu).createResponse());
                return true;
            }
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        // bind and get the simulator session
        PollableSmppSessionHandler sessionHandler = new PollableSmppSessionHandler();
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration, sessionHandler);

        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        simulator0.setPduProcessor(null);

        try {
            EnquireLink el0 = new EnquireLink();
            el0.setSequenceNumber(0x1000);
            EnquireLinkResp el0Resp = el0.createResponse();

            // send asynchronously (no response will be received yet)
            session.sendRequestPdu(el0, 2000, false);

            // send the response back -- this should be routed as n ExpectedPduResponse....
            simulator0.sendPdu(el0Resp);

            // we should have received a PDU response
            PduAsyncResponse asyncpdu0 = sessionHandler.getReceivedExpectedPduResponses().poll(1000, TimeUnit.MILLISECONDS);
            PduResponse pdu0 = asyncpdu0.getResponse();
            Assert.assertNotNull("Unable to receive expected PDU response -- perhaps it was routed incorrectly?", pdu0);
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        // bind and get the simulator session
        PollableSmppSessionHandler sessionHandler = new PollableSmppSessionHandler();
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration, sessionHandler);

        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        simulator0.setPduProcessor(null);

        try {
            // send some bytes that should trigger a MAJOR issue during parsing
            simulator0.getChannel().write(BufferHelper.createBuffer("F000001000000015000000000a342ee7")).await();

            // we should have received an Unrecoverable exception, poll for it
            Throwable t = sessionHandler.getThrowables().poll(2000, TimeUnit.MILLISECONDS);
            logger.debug("polled for exception: {}", t.getMessage());
View Full Code Here

Examples of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

        // bind and get the simulator session
        PollableSmppSessionHandler sessionHandler = new PollableSmppSessionHandler();
        DefaultSmppSession session = (DefaultSmppSession)bootstrap.bind(configuration, sessionHandler);

        SmppSimulatorSessionHandler simulator0 = server.pollNextSession(1000);
        simulator0.setPduProcessor(null);

        try {
            // send some bytes that should trigger a MAJOR issue during parsing
            simulator0.getChannel().write(BufferHelper.createBuffer("0000001180000004000000000a342ee139")).await();

            // we should have received an Unrecoverable exception, poll for it
            Throwable t = sessionHandler.getThrowables().poll(2000, TimeUnit.MILLISECONDS);
            logger.debug("polled for exception: {}", t.getMessage());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.