Examples of IMocksControl


Examples of org.easymock.classextension.IMocksControl

        assertNotNull(s.getLastMessage());
    }
   
    public void testAddAck() {
        RMPropertiesImpl rmps = new RMPropertiesImpl();
        IMocksControl control = createNiceControl();
       
        DestinationSequence seq = control.createMock(DestinationSequence.class);
        SequenceAcknowledgement ack = control.createMock(SequenceAcknowledgement.class);
        seq.getAcknowledgment();
        expectLastCall().andReturn(ack);
       
        DestinationSequence otherSeq = control.createMock(DestinationSequence.class);
        SequenceAcknowledgement otherAck = control.createMock(SequenceAcknowledgement.class);
        otherSeq.getAcknowledgment();
        expectLastCall().andReturn(otherAck);
       
        control.replay();
       
        rmps.addAck(seq);
        rmps.addAck(otherSeq);
       
        control.verify();
       
        Collection<SequenceAcknowledgement> acks = rmps.getAcks();
        assertEquals(2, acks.size());
        Iterator<SequenceAcknowledgement> it = acks.iterator();
        assertSame(ack, it.next());
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

            store.removeMessages(sid1, msgNrs, false);
        }
    }
   
    private Identifier setupDestinationSequence(String s) throws IOException, SQLException {
        IMocksControl control = EasyMock.createNiceControl();
        DestinationSequence seq = control.createMock(DestinationSequence.class);
       
        Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
        sid.setValue(s);
        EndpointReferenceType epr = RMUtils.createReference(Names.WSA_ANONYMOUS_ADDRESS);
       
           
        SequenceAcknowledgement ack = RMUtils.getWSRMFactory().createSequenceAcknowledgement();
        AcknowledgementRange range =
            RMUtils.getWSRMFactory().createSequenceAcknowledgementAcknowledgementRange();
        range.setLower(BigInteger.ONE);
        range.setUpper(BigInteger.ONE);
        ack.getAcknowledgementRange().add(range);
        BigInteger lmn = null;
       
        if ("sequence2".equals(s)) {
            range =
                RMUtils.getWSRMFactory().createSequenceAcknowledgementAcknowledgementRange();
            range.setLower(new BigInteger("3"));
            range.setUpper(BigInteger.TEN);
            ack.getAcknowledgementRange().add(range);
            lmn = BigInteger.TEN;
        }
       
        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
        EasyMock.expect(seq.getAcksTo()).andReturn(epr);
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
        EasyMock.expect(seq.getLastMessageNr()).andReturn(lmn);
        InputStream is = RMUtils.getPersistenceUtils().getAcknowledgementAsInputStream(ack);
        EasyMock.expect(seq.getAcknowledgmentAsStream()).andReturn(is);
        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
       
        control.replay();
        store.createDestinationSequence(seq);          
        store.beginTransaction();
        store.updateDestinationSequence(seq);
       
        store.commit();
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

       
        return sid;
    }
   
    private Identifier setupSourceSequence(String s) throws IOException, SQLException {
        IMocksControl control = EasyMock.createNiceControl();
        SourceSequence seq = control.createMock(SourceSequence.class);
       
        Identifier sid = RMUtils.getWSRMFactory().createIdentifier();
        sid.setValue(s);     
           
        Date expiry = null;
        Identifier osid = null;
        BigInteger cmn = BigInteger.ONE;
        boolean lm = false;
       
        if ("sequence2".equals(s)) {
            expiry = new Date(System.currentTimeMillis() + 3600 * 1000);
            osid = RMUtils.getWSRMFactory().createIdentifier();
            osid.setValue("offeringSequence");
            cmn = BigInteger.TEN;
            lm = true;           
        }
       
        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
        EasyMock.expect(seq.getExpiry()).andReturn(expiry);
        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(osid);
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
        EasyMock.expect(seq.getCurrentMessageNr()).andReturn(cmn);
        EasyMock.expect(seq.isLastMessage()).andReturn(lm);
        EasyMock.expect(seq.getIdentifier()).andReturn(sid);
       
        control.replay();
        store.createSourceSequence(seq);          
        store.beginTransaction();
        store.updateSourceSequence(seq);       
        store.commit();
       
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

        return sid;
    }
   
    public void setupMessage(Identifier sid, BigInteger mn, boolean outbound)
        throws IOException, SQLException, SOAPException  {
        IMocksControl control = EasyMock.createNiceControl();
        RMMessage msg = control.createMock(RMMessage.class);
        EasyMock.expect(msg.getMessageNr()).andReturn(mn);
             
        MessageContext ctx = new GenericMessageContext();
        ctx.put("a", "astring");
        ctx.put("b", Boolean.TRUE);
        ctx.put("c", new Integer(Integer.MIN_VALUE));
        ctx.put("d", mn);
        ctx.put("e", this);
        InputStream mis = RMHandlerTest.class.getResourceAsStream("resources/GreetMeDocLiteralRequest.xml");
        SOAPBindingImpl binding = new SOAPBindingImpl(false);
        SOAPMessage smsg = binding.getMessageFactory().createMessage(null, mis);
        ctx.put(SOAP_MSG_KEY, smsg);
        InputStream cis = RMUtils.getPersistenceUtils().getContextAsInputStream(ctx);
        EasyMock.expect(msg.getContextAsStream()).andReturn(cis);
       
        control.replay();
        store.beginTransaction();
        store.storeMessage(sid, msg, outbound);       
        store.commit();
    }
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

    public void tearDown() {
        RMStoreFactory.theStore = null;
    }
   
    public void testStoreCreationFailure() {
        IMocksControl control = EasyMock.createNiceControl();     
        StoreType s = control.createMock(StoreType.class);
        s.getStoreClass();
        EasyMock.expectLastCall().andReturn("org.objectweb.celtix.bus.ws.rm.persistence.no.such.StoreClass");
        control.replay();
       
        RMStoreFactory factory = new RMStoreFactory();
        try {
            factory.createStore(s);
            fail("Expected RMStoreException was not thrown.");
        } catch (RMStoreException ex) {
            assert ex.getCause() instanceof ClassNotFoundException;
        }
        control.verify();
    }
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

        }
        control.verify();
    }
   
    public void testStoreCreationNoParams() {
        IMocksControl control = EasyMock.createNiceControl();
        Configuration c = control.createMock(Configuration.class);       
        StoreType s = control.createMock(StoreType.class);
        c.getObject(StoreType.class, "store");
        EasyMock.expectLastCall().andReturn(s);
        s.getStoreClass();
        EasyMock.expectLastCall().andReturn("org.objectweb.celtix.bus.ws.rm.persistence.file.RMFileStore");
        s.getInitParam();
        EasyMock.expectLastCall().andReturn(new ArrayList<StoreInitParamType>());
        control.replay();
       
        RMStoreFactory factory = new RMStoreFactory();
        RMStore store = factory.getStore(c);
        assert store instanceof RMFileStore;
  
        control.verify();
    }
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

  
        control.verify();
    }
   
    public void testStoreCreationWithParams() {
        IMocksControl control = EasyMock.createNiceControl();
        Configuration c = control.createMock(Configuration.class)
        StoreType s = RMUtils.getWSRMConfFactory().createStoreType();
        s.setStoreClass("org.objectweb.celtix.bus.ws.rm.persistence.file.RMFileStore");
        StoreInitParamType param = RMUtils.getWSRMConfFactory().createStoreInitParamType();
        param.setParamName(RMFileStore.FILE_STORE_DIR);
        param.setParamValue("dbs/rm");
        s.getInitParam().add(param);
        param = RMUtils.getWSRMConfFactory().createStoreInitParamType();
        param.setParamName("prop2");
        param.setParamValue("val2");
        s.getInitParam().add(param);
        c.getObject(StoreType.class, "store");
        EasyMock.expectLastCall().andReturn(s);
        control.replay();
       
        RMStoreFactory factory = new RMStoreFactory();
        RMStore store = factory.getStore(c);
        assert store instanceof RMFileStore;
       
        control.verify();
    }
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

        // but verify the operation is idempotent
        store.createTables();    
    }

    public void testCreateDeleteSrcSequences() {
        IMocksControl control = EasyMock.createNiceControl();
        RMSourceSequence seq = control.createMock(RMSourceSequence.class);
        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
        sid1.setValue("sequence1");
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
        EasyMock.expect(seq.getExpiry()).andReturn(null);
        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
       
        control.replay();
        store.createSourceSequence(seq);  
        control.verify();
       
        control.reset();
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
        EasyMock.expect(seq.getExpiry()).andReturn(null);
        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(null);
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
       
        control.replay();
        try {
            store.createSourceSequence(seq)
            fail("Expected RMStoreException was not thrown.");
        } catch (RMStoreException ex) {
            SQLException se = (SQLException)ex.getCause();
            // duplicate key value
            assertEquals("23505", se.getSQLState());
        }
        control.verify();
       
        control.reset();
        Identifier sid2 = RMUtils.getWSRMFactory().createIdentifier();
        sid2.setValue("sequence2");
        EasyMock.expect(seq.getIdentifier()).andReturn(sid2)
        EasyMock.expect(seq.getExpiry()).andReturn(new Date());
        Identifier sid3 = RMUtils.getWSRMFactory().createIdentifier();
        sid3.setValue("offeringSequence3");
        EasyMock.expect(seq.getOfferingSequenceIdentifier()).andReturn(sid3);
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
       
        
        control.replay();
        store.createSourceSequence(seq);  
        control.verify();
           
        store.removeSourceSequence(sid1);
        store.removeSourceSequence(sid2);
       
        // deleting once again is a no-op
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

        store.removeSourceSequence(sid2);
      
    }
   
    public void testCreateDeleteDestSequences() {
        IMocksControl control = EasyMock.createNiceControl();
        RMDestinationSequence seq = control.createMock(RMDestinationSequence.class);
        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
        sid1.setValue("sequence1");
        EndpointReferenceType epr = RMUtils.createReference(Names.WSA_ANONYMOUS_ADDRESS);
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
        EasyMock.expect(seq.getAcksTo()).andReturn(epr);       
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
       
        control.replay();
        store.createDestinationSequence(seq);  
        control.verify();
       
        control.reset();
        EasyMock.expect(seq.getIdentifier()).andReturn(sid1);
        EasyMock.expect(seq.getAcksTo()).andReturn(epr);       
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(SERVER_ENDPOINT_ID);
       
        control.replay();
        try {
            store.createDestinationSequence(seq)
            fail("Expected RMStoreException was not thrown.");
        } catch (RMStoreException ex) {
            SQLException se = (SQLException)ex.getCause();
            // duplicate key value
            assertEquals("23505", se.getSQLState());
        }
        control.verify();
       
        control.reset();
        Identifier sid2 = RMUtils.getWSRMFactory().createIdentifier();
        sid2.setValue("sequence2");
        EasyMock.expect(seq.getIdentifier()).andReturn(sid2);
        epr = RMUtils.createReference(NON_ANON_ACKS_TO);
        EasyMock.expect(seq.getAcksTo()).andReturn(epr);
        EasyMock.expect(seq.getEndpointIdentifier()).andReturn(CLIENT_ENDPOINT_ID);
       
        control.replay();
        store.createDestinationSequence(seq);  
        control.verify();
           
        store.removeDestinationSequence(sid1);
        store.removeDestinationSequence(sid2);
       
        // deleting once again is a no-op
View Full Code Here

Examples of org.easymock.classextension.IMocksControl

        store.removeDestinationSequence(sid2);
      
    }
   
    public void testCreateDeleteMessages() throws IOException, SQLException  {
        IMocksControl control = EasyMock.createNiceControl();
        RMMessage msg = control.createMock(RMMessage.class);
        Identifier sid1 = RMUtils.getWSRMFactory().createIdentifier();
        sid1.setValue("sequence1");
        EasyMock.expect(msg.getMessageNr()).andReturn(BigInteger.ONE).times(2);
        InputStream is = new ByteArrayInputStream(new byte[89]);
        EasyMock.expect(msg.getContextAsStream()).andReturn(is).times(2);
       
        control.replay();
        store.beginTransaction();
        store.storeMessage(sid1, msg, true);
        store.storeMessage(sid1, msg, false);
        store.commit();
        control.verify();
       
        control.reset();
        EasyMock.expect(msg.getMessageNr()).andReturn(BigInteger.ONE);
        EasyMock.expect(msg.getContextAsStream()).andReturn(is);
       
        control.replay();
        store.beginTransaction();
        try {
            store.storeMessage(sid1, msg, true);
        } catch (SQLException ex) {
            assertEquals("23505", ex.getSQLState());
        }
        store.abort();
        control.verify();
       
        control.reset();
        EasyMock.expect(msg.getMessageNr()).andReturn(BigInteger.TEN).times(2);
        EasyMock.expect(msg.getContextAsStream()).andReturn(is).times(2);
       
        control.replay();
        store.beginTransaction();
        store.storeMessage(sid1, msg, true);
        store.storeMessage(sid1, msg, false);
        store.commit();
        control.verify();
       
        Collection<BigInteger> messageNrs = new ArrayList<BigInteger>();
        messageNrs.add(BigInteger.ZERO);
        messageNrs.add(BigInteger.TEN);
        messageNrs.add(BigInteger.ONE);
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.