Package org.jmock.api

Examples of org.jmock.api.Action


        final HttpServletResponse response = context.mock(HttpServletResponse.class);
        final Map<Object, Object> headers = new HashMap<Object, Object>();
        context.checking(new Expectations() {
            {
                allowing(response).setHeader(with(any(String.class)), with(any(String.class)));
                will(new Action(){

                    public void describeTo(Description desc) {
                        desc.appendText("Setting header ");
                    }

                    public Object invoke(Invocation invocation) throws Throwable {
                        headers.put(invocation.getParameter(0), invocation.getParameter(1));
                        return null;
                    }
                   
                });
            }
        });

        String clearMessage =  "TestMessage2";
        final String message = topologyRequestValidator.encodeMessage(clearMessage);
        topologyRequestValidator.trustMessage(response, request, message);
       
        final HttpMethod method = context.mock(HttpMethod.class);
        context.checking(new Expectations(){
            {
                allowing(method).getResponseHeader(with(any(String.class)));
                will(new Action() {
                    public void describeTo(Description desc) {
                        desc.appendText("Getting header ");
                    }

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


        context.checking(new Expectations() {
            {
                allowing(resourceResolverFactory)
                        .getAdministrativeResourceResolver(null);
                will(new Action() {

                    public Object invoke(Invocation invocation)
                            throws Throwable {
                      return new MockedResourceResolver(repositoryOrNull);
                    }
View Full Code Here

   
    private void setProvider(final TestProvider provider) throws Exception {
        final BundleContext bundleContext = mockery.mock(BundleContext.class);
        final ComponentContext componentContext = mockery.mock(ComponentContext.class);
       
        final Action storeStatus = new Action() {
            public void describeTo(Description d) {
                d.appendText("Store HTTP response values");
            }

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

        if(mockContainer == null) {
            mockContainer = getService(DomainObjectContainer.class);
            context.checking(new Expectations() {
                {
                    allowing(mockContainer).newTransientInstance(with(Expectations.<Class<?>>anything()));
                    will(new Action() {
                       
                        @SuppressWarnings("rawtypes")
                        public Object invoke(Invocation invocation) throws Throwable {
                            Class cls = (Class) invocation.getParameter(0);
                            return scenarioExecution.injectServices(cls.newInstance());
View Full Code Here

     * This {@link Action} can only be set for expectations to invoke a method
     * accepting a single string argument.  This string argument is taken to be an
     * identifier for the object (and is used in the caching of that object in memory)
     */
    public Action finds(final Class<?> cls) {
        return new Action() {
           
            @Override
            public Object invoke(Invocation invocation) throws Throwable {
                if(invocation.getParameterCount() != 1) {
                    throw new IllegalArgumentException("intended for action of findByXxx");
View Full Code Here

    public static Action returnArgument(final int i) {
        return JMockActions.returnArgument(i);
    }

    public static Action returnNewTransientInstance() {
        return new Action(){
   
            @Override
            public void describeTo(Description description) {
                description.appendText("new transient instance");
            }
View Full Code Here

        if(mockContainer == null) {
            mockContainer = getService(DomainObjectContainer.class);
            context.checking(new Expectations() {
                {
                    allowing(mockContainer).newTransientInstance(with(Expectations.<Class<?>>anything()));
                    will(new Action() {
                       
                        @SuppressWarnings("rawtypes")
                        public Object invoke(Invocation invocation) throws Throwable {
                            Class cls = (Class) invocation.getParameter(0);
                            return scenarioExecution.injectServices(cls.newInstance());
View Full Code Here

        }
        service(SimpleObjects.class).create(UUID.randomUUID().toString());
    }
   
    private Action addToInMemoryDB() {
        return new Action() {
           
            @Override
            public Object invoke(Invocation invocation) throws Throwable {
                final InMemoryDB inMemoryDB = getVar("isis", "in-memory-db", InMemoryDB.class);
                final String name = (String)invocation.getParameter(0);
View Full Code Here

    public static Matcher<ConfigurationUpdateReport> matchingUpdateReport(ConfigurationUpdateReport expected) {
        return new PropertyMatcher<ConfigurationUpdateReport>(expected);
    }

    public static Action updateReportTo(final ConfigurationUpdateStatus status) {
        return new Action() {
            public void describeTo(Description description) {
                description.appendText("Updates " + ConfigurationUpdateReport.class.getSimpleName() + " to " + status);
            }

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

      }
    };
  }

  private Action checkDocumentExists(final String path, final boolean shouldExist) {
    return new Action() {
      public void describeTo(Description desc) {
        desc.appendText("check that document '" + path + "' " + (shouldExist ? "exists" : "does not exist"));
      }

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

TOP

Related Classes of org.jmock.api.Action

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.