Package com.cloudhopper.smpp.simulator

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);

        // close the session (we initiated it)
        session.close();

        Assert.assertEquals(0, sessionHandler.getClosedCount());
View Full Code Here


        // 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);

        // close the session (we initiated it)
        session.unbind(100);

        Assert.assertEquals(0, sessionHandler.getClosedCount());
View Full Code Here

        // 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() {
            public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu pdu) throws Exception {
                // close the channel
                channel.close().await(1000);
                return true;
            }
View Full Code Here

        // 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);

        Assert.assertEquals(SmppSession.Type.CLIENT, session.getLocalType());
        Assert.assertEquals(SmppSession.Type.SERVER, session.getRemoteType());
        Assert.assertEquals(true, session.isBound());
        Assert.assertEquals(false, session.isBinding());
View Full Code Here

        // 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);

        simulator0.getChannel().close().awaitUninterruptibly(1000);

        // NOTE: this test sometimes fails if the close hasn't been received yet
        Thread.sleep(500);

        Assert.assertEquals(1, sessionHandler.getClosedCount());
View Full Code Here

        // 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 {
            // NOTE: send enquireLink but receive an unbind resp (with same sequence #)
            EnquireLink el0 = new EnquireLink();
            el0.setSequenceNumber(0x1000);

            UnbindResp ubResp = new UnbindResp();
            ubResp.setSequenceNumber(el0.getSequenceNumber());

            // schedule this response on the simulator
            simulator0.addPduToWriteOnNextPduReceived(ubResp);

            // send asynchronously (no response will be received yet)
            PduResponse pdu0 = session.sendRequestAndGetResponse(el0, 2000);
            logger.debug("{}", pdu0);
View Full Code Here

        // 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 {
            // NOTE: send enquireLink but receive an unbind resp (with same sequence #)
            EnquireLink el0 = new EnquireLink();
            el0.setSequenceNumber(0x1000);

            UnbindResp ubResp = new UnbindResp();
            ubResp.setSequenceNumber(el0.getSequenceNumber());

            // schedule this response on the simulator
            simulator0.addPduToWriteOnNextPduReceived(ubResp);

            PduResponse pdu0 = null;
            try {
                EnquireLinkResp el0Resp = session.enquireLink(el0, 200);
                Assert.fail();
View Full Code Here

        // 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 {
            // NOTE: send enquireLink but receive an unbind resp (with same sequence #)
            EnquireLink el0 = new EnquireLink();
            el0.setSequenceNumber(0x1000);

            UnbindResp ubResp = new UnbindResp();
            ubResp.setSequenceNumber(el0.getSequenceNumber());

            // schedule this response on the simulator
            simulator0.addPduToWriteOnNextPduReceived(ubResp);

            // send this PDU asynchronously
            session.sendRequestPdu(el0, 200, false);

            // wait for an expected pdu response
View Full Code Here

        // 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(0x1001);
            EnquireLinkResp el0Resp = el0.createResponse();

            // send a request and wait for a response that never shows up
            WindowFuture future = session.sendRequestPdu(el0, 50, true);
            Assert.assertFalse(future.await());
            // a call to cancel() is usually done in sendRequestPduAndGetResponse
            // but for this test we'll manually need to call it here
            future.cancel();

            Assert.assertEquals(WindowFuture.CALLER_WAITING_TIMEOUT, future.getCallerStateHint());
           
            // send a response now after the caller would have timed out
            simulator0.sendPdu(el0Resp);

            // we should have received an unexpected PDU response
            Assert.assertEquals(0, sessionHandler.getReceivedPduRequests().size());
            Assert.assertEquals(0, sessionHandler.getReceivedExpectedPduResponses().size());
            PduResponse pdu0 = sessionHandler.getReceivedUnexpectedPduResponses().poll(1000, TimeUnit.MILLISECONDS);
View Full Code Here

        // 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 a response to a request that was NEVER sent
            simulator0.sendPdu(el0Resp);

            // we should have received a PDU response
            PduResponse pdu0 = sessionHandler.getReceivedUnexpectedPduResponses().poll(1000, TimeUnit.MILLISECONDS);
            Assert.assertNotNull("Unable to receive unexpected PDU response -- perhaps it was routed incorrectly?", pdu0);
            Assert.assertEquals(SmppConstants.CMD_ID_ENQUIRE_LINK_RESP, pdu0.getCommandId());
View Full Code Here

TOP

Related Classes of com.cloudhopper.smpp.simulator.SmppSimulatorSessionHandler

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.