Ejemplo n.º 1
1
    public void setExpectations(Expectations expectations) {
      try {
        expectations.allowing(mock).getCanonicalFile();
        expectations.will(expectations.returnValue(mock));
      } catch (IOException th) {
        // ignore
      }
      expectations.allowing(mock).isFile();
      expectations.will(expectations.returnValue(isFile));
      expectations.allowing(mock).getName();
      expectations.will(expectations.returnValue(name));
      expectations.allowing(mock).exists();
      expectations.will(expectations.returnValue(true));

      ArrayList<File> mockChildren = new ArrayList<File>(children.size());
      for (MockFile child : children) {
        mockChildren.add(child.getMock());
        child.setExpectations(expectations);
      }
      expectations.allowing(mock).listFiles();
      expectations.will(
          expectations.returnValue(mockChildren.toArray(new File[mockChildren.size()])));
    }
  private void oneOfUnconditionalWrappedResponseRequiredCheck(Expectations exp) {
    exp.allowing(serverSession).getAttribute(BridgeSession.LOCAL_ADDRESS);
    exp.will(returnValue(localAddress));
    exp.allowing(serverSession).getReadHeader("X-Origin");
    exp.will(returnValue(null));
    exp.allowing(serverSession).getReadHeader("X-Next-Protocol");
    exp.will(returnValue(null));
    exp.allowing(serverSession).getParameter(".knp");
    exp.will(returnValue(null));
    exp.allowing(serverSession).getParameter(".kv");
    exp.will(returnValue("10.05"));
    exp.allowing(serverSession).getParameter(".kl");
    exp.will(returnValue("Y"));
    exp.allowing(serverSession).getParameter(".kac");
    exp.will(returnValue(null));
    ((IoSession) exp.allowing(serverSession)).getLocalAddress();
    exp.will(returnValue(localAddress));
    exp.allowing(serverSession).getLocalAddress();
    exp.will(returnValue(localAddress));
    exp.allowing(localAddress).getOption(ResourceAddress.NEXT_PROTOCOL);
    exp.will(returnValue("httpxe/1.1"));
    exp.allowing(serverSession).getMethod();
    exp.will(returnValue(HttpMethod.POST));

    exp.allowing(serverSession).setMethod(HttpMethod.POST);
    exp.allowing(serverSession).getFilterChain();
    exp.will(returnValue(filterChain));
    exp.allowing(filterChain)
        .addBefore(
            exp.with(Expectations.any(String.class)),
            exp.with(Expectations.any(String.class)),
            exp.with(Expectations.any(org.apache.mina.core.filterchain.IoFilter.class)));
  }
 private void oneOfIsEmulatedWebSocketRequest(
     Expectations exp, HttpRequestMessage expectedRequest) {
   exp.allowing(serverSession).getRequestURI();
   exp.will(returnValue(expectedRequest.getRequestURI()));
 }