public ShortcircuitServiceConnection(IAsyncResultHandler<IApiConnectionResponse> handler) {
      responseHandler = handler;

      response = new ApiResponse();
      response.setCode(HttpURLConnection.HTTP_OK);
      response.setHeaders(new HeaderMap());
    }
コード例 #2
0
    /**
     * @see
     *     io.apiman.test.policies.IPolicyTestBackEndApi#invoke(io.apiman.gateway.engine.beans.ApiRequest,
     *     byte[])
     */
    @Override
    public PolicyTestBackEndApiResponse invoke(ApiRequest request, byte[] requestBody) {
      ApiResponse apiResponse = new ApiResponse();
      apiResponse.setCode(200);
      apiResponse.setMessage("OK"); // $NON-NLS-1$
      apiResponse.getHeaders().put("Date", new Date().toString()); // $NON-NLS-1$
      apiResponse.getHeaders().put("Server", "apiman.policy-test"); // $NON-NLS-1$ //$NON-NLS-2$
      apiResponse.getHeaders().put("Content-Type", "text/plain"); // $NON-NLS-1$ //$NON-NLS-2$

      int payloadSize = 20;
      String payloadSizeHeader = request.getHeaders().get("X-Payload-Size");
      if (payloadSizeHeader != null) {
        payloadSize = new Integer(payloadSizeHeader);
      }

      byte[] payloadData = new byte[payloadSize];
      Arrays.fill(payloadData, (byte) 80);
      String payload = new String(payloadData);
      PolicyTestBackEndApiResponse response =
          new PolicyTestBackEndApiResponse(apiResponse, payload);
      return response;
    }