Package org.apache.sandesha

Examples of org.apache.sandesha.RMMessageContext


        ClientStorageManager csm = new ClientStorageManager();

        csm.setTemporaryOutSequence("seqid1", "uuid:aaaa-bbbb-cccc");
        csm.setApprovedOutSequence("uuid:aaaa-bbbb-cccc", "approved1");

        RMMessageContext msg1;
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);
       
        //Acknowledging messages 1,2 and 4 (without 3)
        csm.setAcknowledged("approved1", 1);
        csm.setAcknowledged("approved1", 2);
        csm.setAcknowledged("approved1", 4);
       
        //Waiting for little more than re-transmission interval
        try {
            Thread.sleep(Constants.RETRANSMISSION_INTERVAL + 100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //Only message no. 3 should be re-transmitted
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        assertEquals(msg1.getMessageID(), "rmsg3");
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);
    }
View Full Code Here


   
    public void setUp() throws QueueException {

        SandeshaQueue sq = SandeshaQueue.getInstance(Constants.CLIENT);
        ClientStorageManager csm = new ClientStorageManager();
        RMMessageContext msg = new RMMessageContext();
       
        //Creating a new outgoing sequence.
        sq.createNewOutgoingSequence("seqid1");
       
        //Adding messages to the outgoing sequence.
       
        //Adding message 1
        long nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 1);
        msg.setMessageID("rmsg1");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);
        sq.addMessageToOutgoingSequence("seqid1", msg);

        //Adding message 2
        nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 2);
        msg = new RMMessageContext();
        msg.setMessageID("rmsg2");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);
        sq.addMessageToOutgoingSequence("seqid1", msg);

        //Adding message 3
        nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 3);
        msg = new RMMessageContext();
        msg.setMessageID("rmsg3");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);

        //Adding message 4
        sq.addMessageToOutgoingSequence("seqid1", msg);
        nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 4);
        msg = new RMMessageContext();
        msg.setMessageID("rmsg4");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);
        sq.addMessageToOutgoingSequence("seqid1", msg);
    }
View Full Code Here

    //For testing weather messages are re-transmitted correctly
    public void testRetransmission() {

        SandeshaQueue sq = SandeshaQueue.getInstance(Constants.SERVER);
        ServerStorageManager csm = new ServerStorageManager();
        RMMessageContext msg1;

//approving the out sequence
        csm.setTemporaryOutSequence("seqid1", "uuid:aaaa-bbbb-cccc");
        csm.setApprovedOutSequence("uuid:aaaa-bbbb-cccc", "approved1");

//messages should be returned (since the out sequence is approved)
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);

//Waiting for little more than re-transmission interval
        try {
            Thread.sleep(Constants.RETRANSMISSION_INTERVAL + 100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);

//Again waiting for little more than re-transmission interval :)
        try {
            Thread.sleep(Constants.RETRANSMISSION_INTERVAL + 100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //Messages should be returned once again
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);

    }
View Full Code Here

        ServerStorageManager csm = new ServerStorageManager();

        csm.setTemporaryOutSequence("seqid1", "uuid:aaaa-bbbb-cccc");
        csm.setApprovedOutSequence("uuid:aaaa-bbbb-cccc", "approved1");

        RMMessageContext msg1;
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);
       
        //Acknowledging messages 1,2 and 4 (without 3)
        csm.setAcknowledged("approved1", 1);
        csm.setAcknowledged("approved1", 2);
        csm.setAcknowledged("approved1", 4);
       
        //Waiting for little more than re-transmission interval
        try {
            Thread.sleep(Constants.RETRANSMISSION_INTERVAL + 100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //Only message no. 3 should be re-transmitted
        msg1 = csm.getNextMessageToSend();
        assertNotNull(msg1);
        msg1.setLocked(false);
        assertEquals(msg1.getMessageID(), "rmsg3");
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);
    }
View Full Code Here

    //For testing weather getNextMsgToSend method works correctly
    public void testNextMsgToSend() {
        SandeshaQueue sq = SandeshaQueue.getInstance(Constants.SERVER);
        ServerStorageManager csm = new ServerStorageManager();
        RMMessageContext msg1;
       
        //Next message to sent should be null (before approving outsequence)
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);
        msg1 = csm.getNextMessageToSend();
View Full Code Here

        ServerStorageManager csm = new ServerStorageManager();
       
        //setting temporary out sequence
        csm.setTemporaryOutSequence("seqid1", "uuid:aaaa-bbbb-cccc");

        RMMessageContext msg1;
       
        //the message should be null since the out sequence has not been approved
        msg1 = csm.getNextMessageToSend();
        assertNull(msg1);
       
View Full Code Here

        SandeshaQueue sq = SandeshaQueue.getInstance(Constants.SERVER);
        ServerStorageManager csm = new ServerStorageManager();
       
        //Addign a create sequence request message (this will be added to the priority
        //area of the storage)
        RMMessageContext createSeqReq1 = new RMMessageContext();
        createSeqReq1.setMessageType(Constants.MSG_TYPE_CREATE_SEQUENCE_REQUEST);
        createSeqReq1.setMessageID("temp1");

        csm.addCreateSequenceRequest(createSeqReq1);

        RMMessageContext msg1;
        ServerStorageManager csm1 = new ServerStorageManager();

        //create sequence message should be returned
        msg1 = csm1.getNextMessageToSend();
        assertNotNull(msg1);
       
        //other messages should not be returned since the out sequence has not been approved.
        msg1 = csm1.getNextMessageToSend();
        assertNull(msg1);

        //Addign a acknowledgement message (this will be added to the priority
        //area of the storage)
        RMMessageContext ack1 = new RMMessageContext();
        ack1.setMessageID("msgack1");
        csm.addAcknowledgement(ack1);

        //ack message should be returned
        msg1 = csm1.getNextMessageToSend();
        assertNotNull(msg1);
View Full Code Here

    public void setUp() throws QueueException {

        SandeshaQueue sq = SandeshaQueue.getInstance(Constants.SERVER);
        ServerStorageManager csm = new ServerStorageManager();
        RMMessageContext msg = new RMMessageContext();
       
        //Creating a new outgoing sequence.
        sq.createNewOutgoingSequence("seqid1");
       
        //Adding messages to the outgoing sequence.
       
        //Adding message 1
        long nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 1);
        msg.setMessageID("rmsg1");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);
        sq.addMessageToOutgoingSequence("seqid1", msg);

        //Adding message 2
        nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 2);
        msg = new RMMessageContext();
        msg.setMessageID("rmsg2");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);
        sq.addMessageToOutgoingSequence("seqid1", msg);

        //Adding message 3
        nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 3);
        msg = new RMMessageContext();
        msg.setMessageID("rmsg3");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);

        //Adding message 4
        sq.addMessageToOutgoingSequence("seqid1", msg);
        nextMsgNo = csm.getNextMessageNumber("seqid1");
        assertEquals(nextMsgNo, 4);
        msg = new RMMessageContext();
        msg.setMessageID("rmsg4");
        msg.setSequenceID("seqid1");
        msg.setMsgNumber(nextMsgNo);
        sq.addMessageToOutgoingSequence("seqid1", msg);
    }
View Full Code Here

    protected void setUp() throws Exception {

    }

    public void testValidateNoAddressingHeaders() throws Exception {
        RMMessageContext rmMsgCtx = getRMMessageContext("server/validation/NoAddrHeadersMsg.xml");
        try {
            MessageValidator.validate(rmMsgCtx, false);
        } catch (AxisFault af) {
            assertEquals(af.getFaultString(), Constants.FaultMessages.NO_ADDRESSING_HEADERS);
        }
View Full Code Here

    }


    public void testValidateNoRMHeaders() throws Exception {

        RMMessageContext rmMsgCtx = getRMMessageContext("server/validation/NoRMHeadersMsg.xml");
        MessageContext msgCtx = rmMsgCtx.getMsgContext();
        AddressingHeaders addrHeaders = new AddressingHeaders(rmMsgCtx.getMsgContext().getRequestMessage().getSOAPEnvelope());
        msgCtx.setProperty(org.apache.axis.message.addressing.Constants.ENV_ADDRESSING_REQUEST_HEADERS,
                addrHeaders);
        rmMsgCtx.setMsgContext(msgCtx);

        try {
            MessageValidator.validate(rmMsgCtx, false);
        } catch (AxisFault af) {
            assertEquals(af.getFaultString(), Constants.FaultMessages.NO_RM_HEADES);
View Full Code Here

TOP

Related Classes of org.apache.sandesha.RMMessageContext

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.