Package org.apache.olingo.odata2.api.uri

Examples of org.apache.olingo.odata2.api.uri.PathInfo


  public void testCallbackPathInfoAvailable() throws Exception {
    ODataContextImpl context = getMockedContext("http://localhost:80/test", "ODataServiceRoot");
    ODataErrorCallback errorCallback = new ODataErrorCallback() {
      @Override
      public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException {
        PathInfo pathInfo = context.getPathInfo();
        assertEquals("ODataServiceRoot", pathInfo.getServiceRoot().toString());
        assertEquals("http://localhost:80/test", pathInfo.getRequestUri().toString());
        return ODataResponse.entity("bla").status(HttpStatusCodes.BAD_REQUEST).contentHeader("text/html").build();
      }
    };
    when(context.getServiceFactory()).thenReturn(new MapperServiceFactory(errorCallback));
View Full Code Here


      + "\"response\":{\"status\":{\"code\":200,\"info\":\"OK\"}}}";

  private ODataContext mockContext(final ODataHttpMethod method) throws ODataException {
    ODataContext context = mock(ODataContext.class);
    when(context.getHttpMethod()).thenReturn(method.name());
    PathInfo pathInfo = mock(PathInfo.class);
    when(pathInfo.getRequestUri()).thenReturn(URI.create("http://test/entity"));
    when(pathInfo.getServiceRoot()).thenReturn(URI.create("http://test/"));
    when(context.getPathInfo()).thenReturn(pathInfo);
    when(context.getRuntimeMeasurements()).thenReturn(null);
    return context;
  }
View Full Code Here

    prefixMap.put("at", TombstoneCallback.NAMESPACE_TOMBSTONE);
    XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(prefixMap));
  }

  protected ODataContext createContextMock() throws ODataException {
    PathInfo pathInfo = mock(PathInfo.class);
    when(pathInfo.getServiceRoot()).thenReturn(BASE_URI);
    ODataContext ctx = mock(ODataContext.class);
    when(ctx.getPathInfo()).thenReturn(pathInfo);
    return ctx;
  }
View Full Code Here

      } else {
        currentLineNumber++;
        throw new BatchException(BatchException.INVALID_REQUEST_LINE.addContent(scanner.next()).addContent(
            currentLineNumber));
      }
      PathInfo pathInfo = parseRequestUri(uri);
      Map<String, String> queryParameters = parseQueryParameters(uri);
      if (isChangeSet) {
        if (!HTTP_CHANGESET_METHODS.contains(method)) {
          throw new BatchException(BatchException.INVALID_CHANGESET_METHOD.addContent(currentLineNumber));
        }
View Full Code Here

  public void setServiceRootURI(final String uriString) throws URISyntaxException {
    uri = new URI(uriString);
  }

  public PathInfo mock() {
    PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
    EasyMock.expect(pathInfo.getODataSegments()).andReturn(pathSegments);
    EasyMock.expect(pathInfo.getServiceRoot()).andReturn(uri);

    EasyMock.replay(pathInfo);
    return pathInfo;

  }
View Full Code Here

    return paging;
  }

  private PathInfo getLocalPathInfo() {
    PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
    EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
    EasyMock.expect(pathInfo.getRequestUri()).andStubReturn(getRequestURI());
    EasyMock.replay(pathInfo);
    return pathInfo;
  }
View Full Code Here

  }

  @Before
  public void setUp() throws Exception {
    mockedContext = mock(ODataContext.class);
    PathInfo uriInfo = mock(PathInfo.class);
    when(uriInfo.getServiceRoot()).thenReturn(new URI("http://localhost/"));
    when(mockedContext.getPathInfo()).thenReturn(uriInfo);

    processor.setContext(mockedContext);
  }
View Full Code Here

    ODataResponseBuilder responseBuilder =
        ODataResponse.entity("bla").status(HttpStatusCodes.BAD_REQUEST).contentHeader("text/html");

    if (context.getRequestUri() != null) {
      responseBuilder.header("RequestUri", context.getRequestUri().toASCIIString());
      PathInfo pathInfo = context.getPathInfo();
      if (pathInfo == null) {
        responseBuilder.header("PathInfo", "NULL");
      } else {
        responseBuilder.header("PathInfo", "TRUE");
        responseBuilder.header("PathInfo.oDataSegments", pathInfo.getODataSegments().toString());
        responseBuilder.header("PathInfo.precedingSegments", pathInfo.getPrecedingSegments().toString());
        responseBuilder.header("PathInfo.requestUri", pathInfo.getRequestUri().toString());
        responseBuilder.header("PathInfo.serviceRoot", pathInfo.getServiceRoot().toString());
      }
    }

    Map<String, List<String>> requestHeaders = context.getRequestHeaders();
    if (requestHeaders != null && requestHeaders.entrySet() != null) {
View Full Code Here

    return csb.getInputStream();
  }

  private InputStream wrapInHtml(final List<DebugInfo> parts) throws IOException {
    StringWriter writer = new StringWriter();
    PathInfo pathInfo = null;
    try {
      pathInfo = context.getPathInfo();
    } catch (final ODataException e) {}

    writer.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n")
        .append("  \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n")
        .append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n")
        .append("<head>\n")
        .append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n")
        .append("<title>")
        .append(pathInfo == null ? "" :
            escapeHtml(pathInfo.getServiceRoot().relativize(pathInfo.getRequestUri()).getPath()))
        .append("</title>\n")
        .append("<style type=\"text/css\">\n")
        .append("body { font-family: Arial, sans-serif; font-size: 13px;\n")
        .append("       line-height: 16px; margin: 0;\n")
        .append("       background-color: #eeeeee; color: #333333; }\n")
View Full Code Here

    EasyMock.replay(objODataContext);
    return objODataContext;
  }

  private PathInfo getLocalPathInfo() {
    PathInfo pathInfo = EasyMock.createMock(PathInfo.class);
    EasyMock.expect(pathInfo.getServiceRoot()).andStubReturn(getLocalURI());
    EasyMock.replay(pathInfo);
    return pathInfo;
  }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.uri.PathInfo

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.