Package io.s4.message

Examples of io.s4.message.Response


  @Test
  @SuppressWarnings("deprecation")
  public void testReplayWithNoMatch()
  {
    final Request req = request();
    final Response res = response();
    final CaptureLastCallFilter captureFilter = new CaptureLastCallFilter();
    final FilterChain fc = getFilterChain()
            .addFirst(captureFilter);

    FilterUtil.fireUntypedRequestResponse(fc, req, res);
View Full Code Here


  @Test
  public void testReplayWithMatch()
  {
    final Request req = request();
    final Response res = response();
    final CaptureLastCallFilter captureFilter = new CaptureLastCallFilter();
    final FilterChain fc = getFilterChain().addFirst(captureFilter);

    // Record a response for the request we will fire
    getDb().record(req, res);
View Full Code Here

  @Test
  @SuppressWarnings("deprecation")
  public void testChainBuildRpcResponseFromResponseBuilder()
  {
    final Response res = new RpcResponseBuilder()
            .setEntity(new byte[] {1,2,3,4})
            .build()
            .responseBuilder()
              .setEntity(new byte[] {5,6,7,8})
              .build();

    Assert.assertEquals(new byte[] {5,6,7,8}, res.getEntity().copyBytes());
  }
View Full Code Here

  }

  @Test
  public void testChainBuildRestResponseFromResponseBuilder()
  {
    final Response res = new RestResponseBuilder()
            .setEntity(new byte[] {1,2,3,4})
            .setHeader("k1", "v1")
            .setStatus(300)
            .build()
            .responseBuilder()
              .setEntity(new byte[] {5,6,7,8})
              .build();

    Assert.assertEquals(new byte[] {5,6,7,8}, res.getEntity().copyBytes());

    Assert.assertTrue(res instanceof RestResponse);
    final RestResponse restRes = (RestResponse)res;
    Assert.assertEquals("v1", restRes.getHeader("k1"));
    Assert.assertEquals(300, restRes.getStatus());
View Full Code Here

        reqIn = new FileInputStream(DirectoryDbUtil.requestFileName(dir, id));
        final Request req = DirectoryDbUtil.isRestId(id) ? serializer.readRestRequest(reqIn)
                                                         : serializer.readRpcRequest(reqIn);

        resIn = new FileInputStream(DirectoryDbUtil.responseFileName(dir, id));
        final Response res = DirectoryDbUtil.isRestId(id) ? serializer.readRestResponse(resIn)
                                                          : serializer.readRpcResponse(resIn);

        db.put(canonicalize(req), res);
      }
      catch (IOException e)
View Full Code Here

  @Test
  @SuppressWarnings("deprecation")
  public void testInitialCapture()
  {
    final Request req = request();
    final Response res = response();

    Assert.assertNull(getDb().replay(req));

    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req, res);
View Full Code Here

  @SuppressWarnings("deprecation")
  public void testTwoDifferentRequests()
  {
    final Request req1 = request();
    final Request req2 = req1.requestBuilder().setEntity("This is a different request".getBytes()).build();
    final Response res1 = response();
    final Response res2 = res1.responseBuilder().setEntity("This is a different response".getBytes()).build();

    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req1, res1);
    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req2, res2);

    // Should have created two separate entries
View Full Code Here

  @Test
  @SuppressWarnings("deprecation")
  public void testSameRequestDifferentResponses()
  {
    final Request req = request();
    final Response res1 = response();
    final Response res2 = res1.responseBuilder().setEntity("This is a different response".getBytes()).build();

    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req, res1);
    FilterUtil.fireUntypedRequestResponse(getFilterChain(), req, res2);

    // Last one wins
View Full Code Here

        return null;
    }

    private void clientInit(ByteArrayIOChannel io) throws IOException {
        String uuid = UUID.randomUUID().toString();
        Info proto = clientStub.getProtocolInfo();

        HashMap<String, Object> info = new HashMap<String, Object>();
        info.put("uuid", uuid);
        info.put("protocol", proto);
View Full Code Here

                }
                listByPartitionNumber.add(partitionInfo);
            }

            for (int partitionId : pInfoMap.keySet()) {
                EventWrapper eventWrapper = new EventWrapper(streamName,
                                                             event,
                                                             pInfoMap.get(partitionId));
                counts[partitionId]++;
                eventEmitter.emit(partitionId, eventWrapper);
            }
View Full Code Here

TOP

Related Classes of io.s4.message.Response

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.