Package org.jmock

Examples of org.jmock.Mock.proxy()


            }
        });

        _server = new MockBpelServer() {
            protected MessageExchangeContext createMessageExchangeContext() {
                return (MessageExchangeContext) partner.proxy();
            }
        };
        _server.deploy(new File(new URI(this.getClass().getResource("/recovery").toString())));
        _management = new BpelManagementFacadeImpl(_server._server,_server._store);
    }
View Full Code Here


    public void testCallsAreDispatchedBetweenObjects() throws Exception {
        Mock fooMock = mock(Foo.class);
        Mock barMock = mock(Bar.class);

        Object foobar = Dispatching.object(new Class[]{Foo.class, Bar.class}, new Object[]{
                fooMock.proxy(), barMock.proxy()}, getFactory());

        fooMock.expects(once()).method("getSomething").withNoArguments().will(returnValue("some thing"));
        barMock.expects(once()).method("doSomething").with(eq("some thing"));

        assertEquals("some thing", ((Foo)foobar).getSomething());
View Full Code Here

    public void testOnlyFirstOfMethodsWithSameSignaturesIsCalled() throws Exception {
        Mock fooMock = mock(Foo.class);
        Mock fooMimicMock = mock(FooMimic.class);

        Object foo = Dispatching.object(new Class[]{Foo.class, FooMimic.class}, new Object[]{
                fooMock.proxy(), fooMimicMock.proxy()}, getFactory());

        fooMock.expects(once()).method("getSomething").withNoArguments().will(returnValue("some thing"));
        // should be fooMimicMock ...
        fooMock.expects(once()).method("getSomething").withNoArguments().will(returnValue("some thing"));
View Full Code Here

    public void testMethodsWithSameNameButDifferentSignatureAreDistinct() throws Exception {
        Mock barMock = mock(Bar.class);
        Mock barSimilarMock = mock(BarSimilar.class);

        Object bar = Dispatching.object(new Class[]{Bar.class, BarSimilar.class}, new Object[]{
                barMock.proxy(), barSimilarMock.proxy()}, getFactory());

        barMock.expects(once()).method("doSomething").with(eq("some thing"));
        barSimilarMock.expects(once()).method("doSomething").with(eq(1));

        ((Bar)bar).doSomething("some thing");
View Full Code Here

    public void testOneDelegateCanMatchMultipleTypes() throws Exception {
        Mock fooBarMock = mock(FooBar.class);

        Object foobar = Dispatching.object(
                new Class[]{Foo.class, Bar.class}, new Object[]{fooBarMock.proxy()}, getFactory());

        fooBarMock.expects(once()).method("doSomething").with(eq("some thing"));
        fooBarMock.expects(once()).method("getSomething").withNoArguments().will(returnValue("some thing"));

        assertEquals("some thing", ((Foo)foobar).getSomething());
View Full Code Here

    public void testReturnedElementIsResetted() throws Exception {
        final Mock mockResetter = mock(Resetter.class);
        mockResetter.expects(once()).method("reset").will(returnValue(true));

        final Pool pool = new Pool(Identifiable.class, (Resetter)mockResetter.proxy(), getFactory());
        pool.add(createIdentifiables(1));
        Object borrowed = pool.get();
        ((Poolable)borrowed).returnInstanceToPool();
    }
View Full Code Here

    public void testAllTypesMustBeMatchedByOneDelegate() throws Exception {
        Mock fooMock = mock(Foo.class);

        try {
            Dispatching.object(new Class[]{Foo.class, Bar.class}, new Object[]{fooMock.proxy()}, getFactory());
            fail("DispatchingException expected");
        } catch (final DispatchingException e) {
            assertEquals(Bar.class, e.getType());
        }
    }
View Full Code Here

    public void testGarbageCollectedElementIsResetted() throws Exception {
        final Mock mockResetter = mock(Resetter.class);
        mockResetter.expects(once()).method("reset").will(returnValue(true));

        final Pool pool = new Pool(Identifiable.class, (Resetter)mockResetter.proxy(), getFactory());
        pool.add(createIdentifiables(1));
        Object borrowed = pool.get();
        assertNotNull(borrowed);
        borrowed = null;
        System.gc();
View Full Code Here

    }

    public void testHashCodeIsDifferentForEachProxy() throws Exception {
        Mock fooMock = mock(Foo.class);

        Object proxy1 = Dispatching.object(new Class[]{Foo.class}, new Object[]{fooMock.proxy()}, getFactory());
        Object proxy2 = Dispatching.object(new Class[]{Foo.class}, new Object[]{fooMock.proxy()}, getFactory());

        assertFalse(proxy1.hashCode() == proxy2.hashCode());
    }
View Full Code Here

    public void testHashCodeIsDifferentForEachProxy() throws Exception {
        Mock fooMock = mock(Foo.class);

        Object proxy1 = Dispatching.object(new Class[]{Foo.class}, new Object[]{fooMock.proxy()}, getFactory());
        Object proxy2 = Dispatching.object(new Class[]{Foo.class}, new Object[]{fooMock.proxy()}, getFactory());

        assertFalse(proxy1.hashCode() == proxy2.hashCode());
    }

    public void testStringRepresentationContainsImplementedTypes() throws Exception {
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.