Examples of Expectation


Examples of org.hibernate.jdbc.Expectation

      // Remove all the old entries

      try {
        int offset = 1;
        PreparedStatement st = null;
        Expectation expectation = Expectations.appropriateExpectation( getDeleteAllCheckStyle() );
        boolean callable = isDeleteAllCallable();
        boolean useBatch = expectation.canBeBatched();
        String sql = getSQLDeleteString();
        if ( useBatch ) {
          if ( callable ) {
            st = session.getBatcher().prepareBatchCallableStatement( sql );
          }
          else {
            st = session.getBatcher().prepareBatchStatement( sql );
          }
        }
        else {
          if ( callable ) {
            st = session.getBatcher().prepareCallableStatement( sql );
          }
          else {
            st = session.getBatcher().prepareStatement( sql );
          }
        }


        try {
          offset+= expectation.prepare( st );

          writeKey( st, id, offset, session );
          if ( useBatch ) {
            session.getBatcher().addToBatch( expectation );
          }
          else {
            expectation.verifyOutcome( st.executeUpdate(), st, -1 );
          }
        }
        catch ( SQLException sqle ) {
          if ( useBatch ) {
            session.getBatcher().abortBatch( sqle );
View Full Code Here

Examples of org.hibernate.jdbc.Expectation

            final Object entry = entries.next();
            if ( collection.entryExists( entry, i ) ) {
              int offset = 1;
              PreparedStatement st = null;
              Expectation expectation = Expectations.appropriateExpectation( getInsertCheckStyle() );
              boolean callable = isInsertCallable();
              boolean useBatch = expectation.canBeBatched();
              String sql = getSQLInsertRowString();

              if ( useBatch ) {
                if ( callable ) {
                  st = session.getBatcher().prepareBatchCallableStatement( sql );
                }
                else {
                  st = session.getBatcher().prepareBatchStatement( sql );
                }
              }
              else {
                if ( callable ) {
                  st = session.getBatcher().prepareCallableStatement( sql );
                }
                else {
                  st = session.getBatcher().prepareStatement( sql );
                }
              }


              try {
                offset+= expectation.prepare( st );

                //TODO: copy/paste from insertRows()
                int loc = writeKey( st, id, offset, session );
                if ( hasIdentifier ) {
                  loc = writeIdentifier( st, collection.getIdentifier(entry, i), loc, session );
                }
                if ( hasIndex /*&& !indexIsFormula*/ ) {
                  loc = writeIndex( st, collection.getIndex(entry, i, this), loc, session );
                }
                loc = writeElement(st, collection.getElement(entry), loc, session );

                if ( useBatch ) {
                  session.getBatcher().addToBatch( expectation );
                }
                else {
                  expectation.verifyOutcome( st.executeUpdate(), st, -1 );
                }

                collection.afterRowInsert( this, entry, i );
                count++;
              }
View Full Code Here

Examples of org.jbehave.core.mock.Expectation

    public Expectation stubs(String methodName) {
        return expects(methodName).zeroOrMoreTimes();
    }

    public Expectation expects(String methodName) {
        Expectation expects = new Expectation(this, methodName);
        expectations.add(expects);
        return expects.once();
    }
View Full Code Here

Examples of org.mockserver.mock.Expectation

            HttpRequest httpRequest = httpRequestSerializer.deserialize(IOStreamUtils.readInputStreamToString(httpServletRequest));
            logFilter.clear(httpRequest);
            mockServerMatcher.clear(httpRequest);
            httpServletResponse.setStatus(HttpStatusCode.ACCEPTED_202.code());
        } else if (requestPath.equals("/expectation")) {
            Expectation expectation = expectationSerializer.deserialize(IOStreamUtils.readInputStreamToString(httpServletRequest));
            mockServerMatcher.when(expectation.getHttpRequest(), expectation.getTimes()).thenRespond(expectation.getHttpResponse(false)).thenForward(expectation.getHttpForward()).thenCallback(expectation.getHttpCallback());
            httpServletResponse.setStatus(HttpStatusCode.CREATED_201.code());
        } else if (requestPath.equals("/retrieve")) {
            Expectation[] expectations = logFilter.retrieve(httpRequestSerializer.deserialize(IOStreamUtils.readInputStreamToString(httpServletRequest)));
            IOStreamUtils.writeToOutputStream(expectationSerializer.serialize(expectations).getBytes(), httpServletResponse);
            httpServletResponse.setStatus(HttpStatusCode.OK_200.code());
View Full Code Here

Examples of org.mockserver.mock.Expectation

     * @param httpRequest the http request that must be matched for this expectation to respond
     * @param times       the number of times to respond when this http is matched
     * @return an Expectation object that can be used to specify the response
     */
    public ForwardChainExpectation when(HttpRequest httpRequest, Times times) {
        return new ForwardChainExpectation(this, new Expectation(httpRequest, times));
    }
View Full Code Here

Examples of org.mockserver.mock.Expectation

        // when
        ForwardChainExpectation forwardChainExpectation = mockServerClient.when(httpRequest);
        forwardChainExpectation.respond(httpResponse);

        // then
        Expectation expectation = forwardChainExpectation.getExpectation();
        assertTrue(expectation.matches(httpRequest));
        assertSame(httpResponse, expectation.getHttpResponse(false));
        assertEquals(Times.unlimited(), expectation.getTimes());
    }
View Full Code Here

Examples of org.mockserver.mock.Expectation

        // when
        ForwardChainExpectation forwardChainExpectation = mockServerClient.when(httpRequest);
        forwardChainExpectation.forward(httpForward);

        // then
        Expectation expectation = forwardChainExpectation.getExpectation();
        assertTrue(expectation.matches(httpRequest));
        assertSame(httpForward, expectation.getHttpForward());
        assertEquals(Times.unlimited(), expectation.getTimes());
    }
View Full Code Here

Examples of org.mockserver.mock.Expectation

        // when
        ForwardChainExpectation forwardChainExpectation = mockServerClient.when(httpRequest);
        forwardChainExpectation.callback(httpCallback);

        // then
        Expectation expectation = forwardChainExpectation.getExpectation();
        assertTrue(expectation.matches(httpRequest));
        assertSame(httpCallback, expectation.getHttpCallback());
        assertEquals(Times.unlimited(), expectation.getTimes());
    }
View Full Code Here

Examples of org.mockserver.mock.Expectation

        // given
        MockHttpServletRequest httpServletRequest = new MockHttpServletRequest("PUT", "/expectation");
        MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();
        HttpRequest httpRequest = mock(HttpRequest.class);
        Times times = mock(Times.class);
        Expectation expectation = new Expectation(httpRequest, times).thenRespond(new HttpResponse());

        String requestBytes = "requestBytes";
        httpServletRequest.setContent(requestBytes.getBytes());
        when(mockExpectationSerializer.deserialize(requestBytes)).thenReturn(expectation);
        when(mockMockServerMatcher.when(same(httpRequest), same(times))).thenReturn(expectation);
View Full Code Here

Examples of org.mockserver.mock.Expectation

    @Test
    public void shouldResetMockServer() throws IOException {
        // given
        MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();
        MockHttpServletRequest httpServletRequest = new MockHttpServletRequest("PUT", "/reset");
        Expectation expectation = new Expectation(new HttpRequest(), Times.unlimited()).thenRespond(new HttpResponse());

        String requestBytes = "requestBytes";
        httpServletRequest.setContent(requestBytes.getBytes());
        when(mockExpectationSerializer.deserialize(requestBytes)).thenReturn(expectation);
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.