Examples of ExpressionParserException


Examples of org.apache.olingo.odata2.api.uri.expression.ExpressionParserException

    MessageReference msgRef = ExpressionParserException.LEFT_SIDE_NOT_A_PROPERTY.create();

    msgRef.addContent(token.getPosition() + 1);
    msgRef.addContent(expression);

    return new ExpressionParserException(msgRef);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.uri.expression.ExpressionParserException

      msgRef.addContent(expression);
    } catch (EdmException e) {
      throw ExpressionParserInternalError.createERROR_ACCESSING_EDM(e);
    }

    return new ExpressionParserException(msgRef);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.uri.expression.ExpressionParserException

      msgRef.addContent(expression);
    } catch (EdmException e) {
      throw ExpressionParserInternalError.createERROR_ACCESSING_EDM(e);
    }

    return new ExpressionParserException(msgRef);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.uri.expression.ExpressionParserException

  @Test
  public void uriWithException() throws Exception {
    final ODataContext context = mockContext(ODataHttpMethod.GET);
    final ODataResponse wrappedResponse = mockResponse(HttpStatusCodes.OK, null, null);

    ExpressionParserException exception = mock(ExpressionParserException.class);
    when(exception.getMessageReference()).thenReturn(ExpressionParserException.COMMON_ERROR);
    when(exception.getStackTrace()).thenReturn(new StackTraceElement[] {
        new StackTraceElement("class", "method", "file", 42) });
    CommonExpression filterTree = mock(CommonExpression.class);
    when(filterTree.getUriLiteral()).thenReturn("wrong");
    when(exception.getFilterTree()).thenReturn(filterTree);

    ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), exception,
        ODataDebugResponseWrapper.ODATA_DEBUG_JSON).wrapResponse();
    String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
    assertEquals(EXPECTED.replace("}}}", "}},\"server\":{"
        + "\"uri\":{\"error\":{\"expression\":\"wrong\"}},"
        + "\"stacktrace\":{\"exceptions\":[{\"class\":\"" + exception.getClass().getName() + "\","
        + "\"message\":\"Error while parsing a ODATA expression.\","
        + "\"invocation\":{\"class\":\"class\",\"method\":\"method\",\"line\":42}}],"
        + "\"stacktrace\":[{\"class\":\"class\",\"method\":\"method\",\"line\":42}]}}}"),
        entity);

    response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), exception,
        ODataDebugResponseWrapper.ODATA_DEBUG_HTML).wrapResponse();
    entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
    assertTrue(entity.contains("wrong"));
    assertTrue(entity.contains(exception.getClass().getName()));
    assertTrue(entity.contains("42"));
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.uri.expression.ExpressionParserException

    // URI
    Throwable candidate = exception;
    while (candidate != null && !(candidate instanceof ExpressionParserException)) {
      candidate = candidate.getCause();
    }
    final ExpressionParserException expressionParserException = (ExpressionParserException) candidate;
    if (uriInfo != null
        && (uriInfo.getFilter() != null || uriInfo.getOrderBy() != null
            || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty())
        || expressionParserException != null && expressionParserException.getFilterTree() != null) {
      parts.add(new DebugInfoUri(uriInfo, expressionParserException));
    }

    // runtime measurements
    if (context.getRuntimeMeasurements() != null) {
View Full Code Here

Examples of org.apache.olingo.odata2.api.uri.expression.ExpressionParserException

    UriInfo uriInfo = mock(UriInfo.class);
    FilterExpression filter = mock(FilterExpression.class);
    when(filter.getExpressionString()).thenReturn("wrong");
    when(uriInfo.getFilter()).thenReturn(filter);
    ExpressionParserException exception = mock(ExpressionParserException.class);
    when(exception.getMessageReference()).thenReturn(ExpressionParserException.COMMON_ERROR);
    when(exception.getStackTrace()).thenReturn(new StackTraceElement[] {
        new StackTraceElement("class", "method", "file", 42) });
    CommonExpression filterTree = mock(CommonExpression.class);
    when(filterTree.getUriLiteral()).thenReturn("wrong");
    when(exception.getFilterTree()).thenReturn(filterTree);

    final ODataResponse response =
        new ODataDebugResponseWrapper(context, wrappedResponse, uriInfo, exception,
            ODataDebugResponseWrapper.ODATA_DEBUG_JSON)
            .wrapResponse();
    String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
    assertEquals(EXPECTED.replace("}}}",
        "}},\"uri\":{\"error\":{\"filter\":\"wrong\"},\"filter\":null},"
            + "\"stacktrace\":{\"exceptions\":[{\"class\":\"" + exception.getClass().getName() + "\","
            + "\"message\":\"Error while parsing a ODATA expression.\","
            + "\"invocation\":{\"class\":\"class\",\"method\":\"method\",\"line\":42}}],"
            + "\"stacktrace\":[{\"class\":\"class\",\"method\":\"method\",\"line\":42}]}}"),
        entity);
  }
View Full Code Here

Examples of org.apache.olingo.odata2.api.uri.expression.ExpressionParserException

    UriInfo uriInfo = mock(UriInfo.class);
    FilterExpression filter = mock(FilterExpression.class);
    when(filter.getExpressionString()).thenReturn("wrong");
    when(uriInfo.getFilter()).thenReturn(filter);
    ExpressionParserException exception = mock(ExpressionParserException.class);
    when(exception.getMessageReference()).thenReturn(ExpressionParserException.COMMON_ERROR);
    when(exception.getStackTrace()).thenReturn(new StackTraceElement[] {
        new StackTraceElement("class", "method", "file", 42) });
    CommonExpression filterTree = mock(CommonExpression.class);
    when(filterTree.getUriLiteral()).thenReturn("wrong");
    when(exception.getFilterTree()).thenReturn(filterTree);

    final ODataResponse response =
        new ODataDebugResponseWrapper(context, wrappedResponse, uriInfo, exception)
            .wrapResponse();
    String entity = StringHelper.inputStreamToString((InputStream) response.getEntity());
    assertEquals(EXPECTED.replace("}}}",
        "}},\"uri\":{\"error\":{\"filter\":\"wrong\"},\"filter\":null},"
            + "\"stacktrace\":{\"exceptions\":[{\"class\":\"" + exception.getClass().getName() + "\","
            + "\"message\":\"Error while parsing a ODATA expression.\","
            + "\"invocation\":{\"class\":\"class\",\"method\":\"method\",\"line\":42}}],"
            + "\"stacktrace\":[{\"class\":\"class\",\"method\":\"method\",\"line\":42}]}}"),
        entity);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.