Package com.mockobjects.dynamic

Examples of com.mockobjects.dynamic.Mock


        tx.commit();
    }

    public void testRollback() throws Exception
    {
        Mock mockPTM = new Mock(PlatformTransactionManager.class);
        Mock mockTS = new Mock(TransactionStatus.class);
        mockPTM.expectAndReturn("getTransaction", C.same(null), mockTS.proxy());
        mockPTM.expect("rollback", C.same(mockTS.proxy()));
        mockTS.expect("setRollbackOnly");

        SpringTransactionFactory factory = new SpringTransactionFactory();
        factory.setManager((PlatformTransactionManager)mockPTM.proxy());

        Transaction tx = factory.beginTransaction(muleContext);
View Full Code Here


    }

    public void testDestinationNotTopic() throws Exception
    {
        // prepare the mock
        Mock mock = new Mock(Queue.class);
        Queue queue = (Queue) mock.proxy();

        assertFalse(resolver.isTopic(queue));
        mock.verify();
    }
View Full Code Here

    }

    public void testDestinationTopic() throws Exception
    {
        // prepare the mock
        Mock mock = new Mock(Topic.class);
        Topic topic = (Topic) mock.proxy();

        assertTrue(resolver.isTopic(topic));
        mock.verify();
    }
View Full Code Here

        HttpsConnector httpsConnector = new HttpsConnector(muleContext);
        httpsConnector.setSslHandshakeTimeout(1000);

        Map properties = Collections.emptyMap();

        Mock mockEndpoint = new Mock(InboundEndpoint.class);
        mockEndpoint.expectAndReturn("getConnector", httpsConnector);
        mockEndpoint.expectAndReturn("getEncoding", new DefaultMuleConfiguration().getDefaultEncoding());
        mockEndpoint.expectAndReturn("getProperties", properties);
        mockEndpoint.expectAndReturn("getProperties", properties);
        InboundEndpoint inboundEndpoint = (InboundEndpoint) mockEndpoint.proxy();

        Mock mockService = new Mock(Service.class);
        mockService.expectAndReturn("getResponseRouter", null);
        mockService.expectAndReturn("getInboundRouter", new ServiceCompositeMessageSource());
        Service service = (Service) mockService.proxy();

        MockHttpsMessageReceiver messageReceiver = new MockHttpsMessageReceiver(httpsConnector, service, inboundEndpoint);
        return messageReceiver;
    }
View Full Code Here

    public void testNoLocalCalledForDurableTopic() throws Exception
    {
        Jms11Support jmsSupport = new Jms11Support(new JmsConnector(muleContext));

        Mock mockTopic = new Mock(Topic.class);
        Topic topic = (Topic)mockTopic.proxy();

        String durableName = "durableName";
        boolean noLocal = true;

        FullConstraintMatcher matcher = new FullConstraintMatcher(new Constraint[]{C.eq(topic),
            C.eq(durableName), C.IS_NULL, C.IS_TRUE});

        Mock mockSession = new Mock(Session.class);
        mockSession.expect("createDurableSubscriber", matcher);

        jmsSupport.createConsumer((Session)mockSession.proxy(), topic, null, noLocal, durableName, true, getTestInboundEndpoint("test"));

        mockTopic.verify();
        mockSession.verify();
    }
View Full Code Here

    public void testNoLocalCalledForNonDurableTopic() throws Exception
    {
        Jms11Support jmsSupport = new Jms11Support(new JmsConnector(muleContext));

        Mock mockTopic = new Mock(Topic.class);
        Topic topic = (Topic)mockTopic.proxy();

        boolean noLocal = true;

        FullConstraintMatcher matcher = new FullConstraintMatcher(new Constraint[]{C.eq(topic), C.IS_NULL,
            C.IS_TRUE});

        Mock mockSession = new Mock(Session.class);
        mockSession.expect("createConsumer", matcher);

        jmsSupport.createConsumer((Session)mockSession.proxy(), topic, null, noLocal, null, true, getTestInboundEndpoint("test"));

        mockTopic.verify();
        mockSession.verify();
    }
View Full Code Here

    public void testNoLocalNotCalledForQueue() throws Exception
    {
        Jms11Support jmsSupport = new Jms11Support(new JmsConnector(muleContext));

        Mock mockQueue = new Mock(Queue.class);
        Queue queue = (Queue)mockQueue.proxy();

        boolean noLocal = true;

        FullConstraintMatcher matcher = new FullConstraintMatcher(new Constraint[]{C.eq(queue), C.IS_NULL});

        Mock mockSession = new Mock(Session.class);
        mockSession.expect("createConsumer", matcher);

        jmsSupport.createConsumer((Session)mockSession.proxy(), queue, null, noLocal, null, false, getTestInboundEndpoint("test"));

        mockQueue.verify();
        mockSession.verify();
    }
View Full Code Here

    public void testDurableWithQueueThrowsException() throws Exception
    {
        Jms11Support jmsSupport = new Jms11Support(new JmsConnector(muleContext));

        Mock mockQueue = new Mock(Queue.class);
        Queue queue = (Queue)mockQueue.proxy();

        String durableName = "durableName";
        boolean noLocal = true;

        Mock mockSession = new Mock(Session.class);

        try
        {
            jmsSupport.createConsumer((Session)mockSession.proxy(), queue, null, noLocal, durableName, false, getTestInboundEndpoint("test"));
        }
        catch (JMSException jmsex)
        {
            // expected
            assertEquals("Wrong exception text.",
                "A durable subscriber name was set but the destination was not a Topic", jmsex.getMessage());
        }

        mockQueue.verify();
        mockSession.verify();
    }
View Full Code Here

    }

    public void testForwardingStrategy() throws Exception
    {
        ForwardingCatchAllStrategy strategy = new ForwardingCatchAllStrategy();
        Mock endpoint = MuleTestUtils.getMockOutboundEndpoint();
        Mock dispatcher = new Mock(MessageDispatcher.class);
        Mock connector = MuleTestUtils.getMockConnector();
        MuleEvent event = getTestEvent("UncaughtEvent");
        strategy.setEndpoint((OutboundEndpoint) endpoint.proxy());

        endpoint.expect("process", C.isA(DefaultMuleEvent.class));

        strategy.process(event);

        endpoint.verify();
        dispatcher.verify();
        connector.verify();

        assertNotNull(strategy.getEndpoint());
    }
View Full Code Here

    public void testForwardingStrategyWithTransform() throws Exception
    {
        ForwardingCatchAllStrategy strategy = new ForwardingCatchAllStrategy();
        strategy.setSendTransformed(true);
        Mock endpoint = MuleTestUtils.getMockOutboundEndpoint();
        Mock dispatcher = new Mock(MessageDispatcher.class);
        Mock connector = MuleTestUtils.getMockConnector();
        MuleEvent event = getTestEvent("UncaughtEvent");
        strategy.setEndpoint((OutboundEndpoint) endpoint.proxy());

        endpoint.expectAndReturn("getTransformers", CollectionUtils.singletonList(new TestEventTransformer()));
        endpoint.expectAndReturn("getTransformers", CollectionUtils.singletonList(new TestEventTransformer()));
        endpoint.expect("process", new Constraint()
        {
            public boolean eval(Object object)
            {
                if (object instanceof MuleEvent)
                {
                    return "Transformed Test Data".equals(((MuleEvent) object).getMessage().getPayload());
                }
                return false;
            }
        });

        strategy.process(event);

        endpoint.verify();
        dispatcher.verify();
        connector.verify();

        assertNotNull(strategy.getEndpoint());
    }
View Full Code Here

TOP

Related Classes of com.mockobjects.dynamic.Mock

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.