Package org.jmock.lib.action

Examples of org.jmock.lib.action.CustomAction


            allowing (managementContext).registerMBean(with(any(Object.class)), with(equal(           
                    new ObjectName("Test:BrokerName=BrokerNC,Type=Topic,Destination=ActiveMQ.Advisory.Connection"))));
           
            atLeast(maxReconnects - 1).of (managementContext).registerMBean(with(any(Object.class)), with(new NetworkBridgeObjectNameMatcher<ObjectName>(
                        new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkBridge,NetworkConnectorName=localhost,Name=localhost/127.0.0.1_"
                            + proxy.getUrl().getPort())))); will(new CustomAction("signal register network mbean") {
                                public Object invoke(Invocation invocation) throws Throwable {
                                    LOG.info("Mbean Registered: " + invocation.getParameter(0));
                                    mbeanRegistered.release();
                                    return new ObjectInstance((ObjectName)invocation.getParameter(0), "dscription");
                                }
                            });
            atLeast(maxReconnects - 1).of (managementContext).unregisterMBean(with(new NetworkBridgeObjectNameMatcher<ObjectName>(
                    new ObjectName("Test:BrokerName=BrokerNC,Type=NetworkBridge,NetworkConnectorName=localhost,Name=localhost/127.0.0.1_"
                            + proxy.getUrl().getPort())))); will(new CustomAction("signal unregister network mbean") {
                                public Object invoke(Invocation invocation) throws Throwable {
                                    LOG.info("Mbean Unregistered: " + invocation.getParameter(0));
                                    mbeanUnregistered.release();
                                    return null;
                                }
View Full Code Here


                allowing(velocityEngine).getTemplate(TEXT_BODY_RESOURCE);
                will(returnValue(textBodyTemplate));

                allowing(velocityEngine).evaluate(with(any(VelocityContext.class)), with(any(StringWriter.class)),
                        with(any(String.class)), with(equal(SUBJECT_TEMPLATE)));
                will(new CustomAction("Render subject")
                {
                    public Object invoke(final Invocation inv) throws Throwable
                    {
                        ((StringWriter) inv.getParameter(1)).append(SUBJECT_RENDERED);
                        return true;
                    }
                });

                allowing(textBodyTemplate).merge(with(any(VelocityContext.class)), with(any(StringWriter.class)));
                will(new CustomAction("Render text body")
                {
                    public Object invoke(final Invocation inv) throws Throwable
                    {
                        ((StringWriter) inv.getParameter(1)).append(TEXT_BODY_RENDERED);
                        return null;
                    }
                });

                allowing(htmlBodyTemplate).merge(with(any(VelocityContext.class)), with(any(StringWriter.class)));
                will(new CustomAction("Render HTML body")
                {
                    public Object invoke(final Invocation inv) throws Throwable
                    {
                        ((StringWriter) inv.getParameter(1)).append(HTML_BODY_RENDERED);
                        return null;
View Full Code Here

                    {
                        return (notNull ? contextWithPrincipalMatcher : contextWithNullPrincipalMatcher)
                                .matches(inTestObject.getActionContext());
                    }
                }));
                will(new CustomAction("execute task handler execution")
                {
                    @Override
                    public Object invoke(final Invocation inInvocation) throws Throwable
                    {
                        userActionRequests.add(userActionRequest);
View Full Code Here

                    protected boolean isMatch(final TaskHandlerActionContext inTestObject)
                    {
                        return contextMatcher.matches(inTestObject.getActionContext());
                    }
                }));
                will(new CustomAction("execute task handler execution")
                {
                    @Override
                    public Object invoke(final Invocation inInvocation) throws Throwable
                    {
                        userActionRequests.add(userActionRequest);
View Full Code Here

                 * callback on the proxy, leaving it to the test class to
                 * control when the callback is called. It is set it up like
                 * this to imitate the asynchronous nature of rpc
                 */

                will(new CustomAction(
                        "Instead of call the success method on the callback, set the callback on the proxy")
                {
                    public Object invoke(final Invocation invocation)
                            throws Throwable
                    {
View Full Code Here

        mockery.checking(new Expectations()
        {
            {
                oneOf(messageProcessor).execute(with(same(message)), with(any(List.class)));
                will(new CustomAction("simulate error")
                {
                    @Override
                    public Object invoke(final Invocation inInvocation) throws Throwable
                    {
                        ((List<Message>) inInvocation.getParameter(1)).add(responseMessage);
View Full Code Here

                allowing(velocityEngine).getTemplate(TEXT_BODY_RESOURCE);
                will(returnValue(textBodyTemplate));

                allowing(velocityEngine).evaluate(with(any(VelocityContext.class)), with(any(StringWriter.class)),
                        with(any(String.class)), with(equal(SUBJECT_TEMPLATE)));
                will(new CustomAction("Render subject")
                {
                    public Object invoke(final Invocation inv) throws Throwable
                    {
                        assertVelocityContext(inv);
                        ((StringWriter) inv.getParameter(1)).append(SUBJECT_RENDERED);
                        return true;
                    }
                });

                allowing(textBodyTemplate).merge(with(any(VelocityContext.class)), with(any(StringWriter.class)));
                will(new CustomAction("Render text body")
                {
                    public Object invoke(final Invocation inv) throws Throwable
                    {
                        assertVelocityContext(inv);
                        ((StringWriter) inv.getParameter(1)).append(TEXT_BODY_RENDERED);
                        return null;
                    }
                });

                allowing(htmlBodyTemplate).merge(with(any(VelocityContext.class)), with(any(StringWriter.class)));
                will(new CustomAction("Render HTML body")
                {
                    public Object invoke(final Invocation inv) throws Throwable
                    {
                        assertVelocityContext(inv);
                        ((StringWriter) inv.getParameter(1)).append(HTML_BODY_RENDERED);
View Full Code Here

                one(action1).contextualise(executionContext);
                inSequence(sequence);

                one(action1).execute(task);
                will(new CustomAction("Add action to actions list") {
                    public Object invoke(Invocation invocation) throws Throwable {
                        task.getActions().add(action2);
                        return null;
                    }
                });
View Full Code Here

                    will( returnValue( type ) );
                    atLeast( 1 ).of( attributeInfo ).isWritable();
                    will( returnValue( true ) );
                    one( con ).setAttribute( with( equal( new ObjectName( "a:type=x" ) ) ),
                                             (Attribute) with( a( Attribute.class ) ) );
                    will( doAll( new CustomAction( "SetAttribute" )
                    {

                        public Object invoke( Invocation invocation )
                            throws Throwable
                        {
View Full Code Here

TOP

Related Classes of org.jmock.lib.action.CustomAction

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.