Package com.bj58.spat.gaea.protocol.sdp

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol


*/
public class PathMatcherTest {

    @Test
    public void test() {
        PathMatcher pathMatcher = new AntPathMatcher();

        String pattern = "/{a}/{b}/{c}";

        String sample = "/aa/bb/cc";

        Assert.assertTrue(pathMatcher.match(pattern, sample));

    }
View Full Code Here


    }


    @Test
    public void testPathMatch(){
        PathMatcher pathMatcher = new AntPathMatcher();
        String registeredPath = "/me/hello/{name}";
        String url = "/me/hello/renjun";
        Assert.assertTrue(pathMatcher.match(registeredPath, url));

        Map<String, String> values = pathMatcher.extractUriTemplateVariables(registeredPath, url);
        Assert.assertEquals(1, values.size());
        Assert.assertEquals("renjun", values.get("name"));

        System.out.println("OK testpathMatch");
View Full Code Here

        InputStream in = new BufferedInputStream(request.getInputStream());
        String content_type = request.getContentType();

        File tempDir = new File(config.getLocation());

        MultiPartInputStreamParser mpis = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        mpis.setDeleteOnExit(true);
        return mpis;
    }
View Full Code Here

        InputStream in = new BufferedInputStream(super.getInputStream());
        String content_type = super.getContentType();

        File tempDir = new File(config.getLocation());

        multiParser = new MultiPartInputStreamParser(in, content_type, config, tempDir);
        multiParser.setDeleteOnExit(true);

        Collection<Part> parts = multiParser.getParts();

        int keyCount = queryStrings.size();
View Full Code Here

*/
public class EnterpriseUserTest {

  @Test
  public void TestUser() throws Exception {
    SESUser user = new SESUser();
    user.setUserID(1L);
    user.setState(1);

    Serializer serializer = new Serializer();
    byte[] buffer = serializer.Serialize(user);
    assertNotNull(buffer);
    Object obj = serializer.Derialize(buffer, SimpleClass.class);
View Full Code Here

      }
    }
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes());
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

      }
    }
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message,boolean bool,byte[] key) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes(bool,key));
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes());
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

   *
   * @param sfe
   * @return
   */
  public static ExceptionProtocol createError(ServiceFrameException sfe) {
    ExceptionProtocol error = new ExceptionProtocol();
    if (sfe != null) {
      if (sfe.getState() == null) {
        sfe.setState(ErrorState.OtherException);
      }
      error.setErrorCode(sfe.getState().getStateNum());

      StringBuilder sbError = new StringBuilder();
      sbError.append("error num:");
      sbError.append(System.nanoTime());
      sbError.append("--state:");
      sbError.append(sfe.getState().toString());
     
      sbError.append("--fromIP:");
      if(sfe.getFromIP()!= null) {
        sbError.append(sfe.getFromIP());
      }
      sbError.append("--toIP:");
      if(sfe.getToIP()!= null) {
        sbError.append(sfe.getToIP());
      }
     
      sbError.append("--Message:");

      if (sfe.getMessage() != null) {
        sbError.append(sfe.getMessage());
      }

      sbError.append(getStackTrace(sfe));

      error.setErrorMsg(sbError.toString());
      error.setFromIP(sfe.getFromIP());
      error.setToIP(sfe.getToIP());
    }
    return error;
  }
View Full Code Here

   * @param fromIP
   * @param toIP
   * @return
   */
  public static ExceptionProtocol createError(ErrorState state, String fromIP, String toIP) {
    ExceptionProtocol error = new ExceptionProtocol();
    if (state == null) {
      state = ErrorState.OtherException;
    }
    error.setErrorCode(state.getStateNum());
    error.setErrorMsg("error num:" + System.nanoTime() + "--state:"
        + state.toString());
    error.setFromIP(fromIP);
    error.setToIP(toIP);
    return error;
  }
View Full Code Here

TOP

Related Classes of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

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.