org.apache.olingo.odata2.api.exception.ODataMessageException Java Examples

The following examples show how to use org.apache.olingo.odata2.api.exception.ODataMessageException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ODataExceptionWrapper.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) {
  errorContext.setErrorCode(toHandleException.getErrorCode());
  MessageReference messageReference = toHandleException.getMessageReference();
  Message localizedMessage = messageReference == null ? null : extractEntity(messageReference);
  if (localizedMessage != null) {
    errorContext.setMessage(localizedMessage.getText());
    errorContext.setLocale(localizedMessage.getLocale());
  }
  if (toHandleException instanceof ODataHttpException) {
    errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus());
  } else if (toHandleException instanceof EntityProviderException) {
    if(toHandleException instanceof EntityProviderProducerException){
      /*
       * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result 
       * in a 500 internal server error
       */
      errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR);
    }else{
      errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
    }
  } else if (toHandleException instanceof BatchException) {
    errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
  }

}
 
Example #2
Source File: Expander.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Deleguates to the expand() method of AbstractEntitySet or AbstractEntity.
 * @param context of query to expand.
 * @return data.
 * @throws ODataMessageException Olingo exception occured.
 */
private List<Map<String, Object>> getData(WriteCallbackContext context)
{
   try
   {
      String navlink_name = context.getNavigationProperty().getName();
      if (this.entity != null)
      {
         return this.entity.expand(navlink_name, this.serviceRoot.toString());
      }
      else
      {
         Map<String, Object> key = context.extractKeyFromEntryData();
         return this.entitySet.expand(navlink_name, this.serviceRoot.toString(), feed, key);
      }
   }
   catch(ODataMessageException ex)
   {
      // rethrow programmatic exception
      throw new RuntimeException(ex);
   }
}
 
Example #3
Source File: AtomEntrySerializerTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void verifyRootCause(final Class<?> class1, final String key, final ODataMessageException e) {

    Throwable thrownException = e;
    Throwable lastFoundException = null;
    if (e.getClass().equals(class1)) {
      lastFoundException = e;
    }

    while (thrownException.getCause() != null) {
      thrownException = thrownException.getCause();
      if (thrownException.getClass().equals(class1)) {
        lastFoundException = thrownException;
      }
    }

    if (lastFoundException != null) {
      ODataMessageException msgException = (ODataMessageException) lastFoundException;
      assertEquals(key, msgException.getMessageReference().getKey());
    } else {
      fail("Exception of class: " + class1.getCanonicalName() + " in stacktrace not found.");
    }
  }
 
Example #4
Source File: XmlEntityDeserializerTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void readAndExpectException(final EdmEntitySet entitySet, final InputStream reqContent, final boolean merge,
    final MessageReference messageReference) throws ODataMessageException {
  try {
    EntityStream stream = new EntityStream();
    stream.setContent(reqContent);
    stream.setReadProperties(DeserializerProperties.init().build());

    // execute
    XmlEntityDeserializer xec = new XmlEntityDeserializer();
    ODataEntry result =
        xec.readEntry(entitySet, stream);
    assertNotNull(result);
    Assert.fail("Expected exception with MessageReference '" + messageReference.getKey() + "' was not thrown.");
  } catch (ODataMessageException e) {
    assertEquals(messageReference.getKey(), e.getMessageReference().getKey());
    // assertEquals(messageReference.getContent(), e.getMessageReference().getContent());
    throw e;
  }
}
 
Example #5
Source File: MessageReferenceTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddMoreContent() {
  String content = "content";
  ODataMessageException e = new UriNotMatchingException(
      UriNotMatchingException.ENTITYNOTFOUND.addContent(content).addContent("content_2"));
  assertEquals(2, e.getMessageReference().getContent().size());
  assertTrue(e.getMessageReference().getContent().contains("content"));
  assertTrue(e.getMessageReference().getContent().contains("content_2"));

  ODataMessageException e2 =
      new UriNotMatchingException(UriNotMatchingException.ENTITYNOTFOUND.addContent("content_3"));
  assertEquals(2, e.getMessageReference().getContent().size());
  assertTrue(e.getMessageReference().getContent().contains("content"));
  assertTrue(e.getMessageReference().getContent().contains("content_2"));
  assertEquals(1, e2.getMessageReference().getContent().size());
  assertTrue(e2.getMessageReference().getContent().contains("content_3"));
}
 
Example #6
Source File: TechnicalScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public EntitySet getEntitySet(final String entityContainer, final String name) throws ODataMessageException {
  if (ENTITY_CONTAINER_1.equals(entityContainer)) {
    if (ES_KEY_IS_STRING.equals(name)) {
      return new EntitySet().setName(name).setEntityType(ET_KEY_IS_STRING);
    } else if (ES_KEY_IS_INTEGER.equals(name)) {
      return new EntitySet().setName(name).setEntityType(ET_KEY_IS_INTEGER);
    } else if (ES_COMPLEX_KEY.equals(name)) {
      return new EntitySet().setName(name).setEntityType(ET_COMPLEX_KEY);
    } else if (ES_ALL_TYPES.equals(name)) {
      return new EntitySet().setName(name).setEntityType(ET_ALL_TYPES);
    } else if (ES_STRING_FACETS.equals(name)) {
      return new EntitySet().setName(name).setEntityType(ET_STRING_FACETS);
    }
  }

  return null;
}
 
Example #7
Source File: ODataExceptionWrapper.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void enhanceContextWithMessageException(final ODataMessageException toHandleException) {
  errorContext.setErrorCode(toHandleException.getErrorCode());
  MessageReference messageReference = toHandleException.getMessageReference();
  Message localizedMessage = messageReference == null ? null : extractEntity(messageReference);
  if (localizedMessage != null) {
    errorContext.setMessage(localizedMessage.getText());
    errorContext.setLocale(localizedMessage.getLocale());
  }
  if (toHandleException instanceof ODataHttpException) {
    errorContext.setHttpStatus(((ODataHttpException) toHandleException).getHttpStatus());
  } else if (toHandleException instanceof EntityProviderException) {
    if(toHandleException instanceof EntityProviderProducerException){
      /*
       * As per OLINGO-763 serializer exceptions are produced by the server and must therefore result 
       * in a 500 internal server error
       */
      errorContext.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR);
    }else{
      errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
    }
  } else if (toHandleException instanceof BatchException) {
    errorContext.setHttpStatus(HttpStatusCodes.BAD_REQUEST);
  }

}
 
Example #8
Source File: AtomEntryProducerTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private void verifyRootCause(final Class<?> class1, final String key, final ODataMessageException e) {

    Throwable thrownException = e;
    Throwable lastFoundException = null;
    if (e.getClass().equals(class1)) {
      lastFoundException = e;
    }

    while (thrownException.getCause() != null) {
      thrownException = thrownException.getCause();
      if (thrownException.getClass().equals(class1)) {
        lastFoundException = thrownException;
      }
    }

    if (lastFoundException != null) {
      ODataMessageException msgException = (ODataMessageException) lastFoundException;
      assertEquals(key, msgException.getMessageReference().getKey());
    } else {
      fail("Exception of class: " + class1.getCanonicalName() + " in stacktrace not found.");
    }
  }
 
Example #9
Source File: TechnicalScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public List<Schema> getSchemas() throws ODataMessageException {
  final Schema schema = new Schema();
  schema.setNamespace(NAMESPACE_1);

  schema.setEntityTypes(Arrays.asList(
      getEntityType(ET_KEY_IS_STRING),
      getEntityType(ET_KEY_IS_INTEGER),
      getEntityType(ET_COMPLEX_KEY),
      getEntityType(ET_ALL_TYPES)));

  schema.setComplexTypes(Arrays.asList(getComplexType(CT_ALL_TYPES)));

  final EntityContainer entityContainer = new EntityContainer();
  entityContainer.setName(ENTITY_CONTAINER_1).setDefaultEntityContainer(true);
  entityContainer.setEntitySets(Arrays.asList(
      getEntitySet(ENTITY_CONTAINER_1, ES_KEY_IS_STRING),
      getEntitySet(ENTITY_CONTAINER_1, ES_KEY_IS_INTEGER),
      getEntitySet(ENTITY_CONTAINER_1, ES_COMPLEX_KEY),
      getEntitySet(ENTITY_CONTAINER_1, ES_ALL_TYPES),
      getEntitySet(ENTITY_CONTAINER_1, ES_STRING_FACETS)));

  schema.setEntityContainers(Arrays.asList(entityContainer));

  return Arrays.asList(schema);
}
 
Example #10
Source File: ODataExceptionTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void messagesOfODataMessageExceptions() {
  ODataMessageTextVerifier.TestClass(ODataMessageException.class);

  ODataMessageTextVerifier.TestClass(UriNotMatchingException.class);
  ODataMessageTextVerifier.TestClass(UriSyntaxException.class);
  ODataMessageTextVerifier.TestClass(ExceptionVisitExpression.class);

  ODataMessageTextVerifier.TestClass(EdmLiteralException.class);
  ODataMessageTextVerifier.TestClass(EdmException.class);
  ODataMessageTextVerifier.TestClass(EdmSimpleTypeException.class);

  ODataMessageTextVerifier.TestClass(EntityProviderException.class);

  ODataMessageTextVerifier.TestClass(ODataHttpException.class);
  ODataMessageTextVerifier.TestClass(ODataBadRequestException.class);
  ODataMessageTextVerifier.TestClass(ODataConflictException.class);
  ODataMessageTextVerifier.TestClass(ODataForbiddenException.class);
  ODataMessageTextVerifier.TestClass(ODataNotFoundException.class);
  ODataMessageTextVerifier.TestClass(ODataMethodNotAllowedException.class);
  ODataMessageTextVerifier.TestClass(ODataNotAcceptableException.class);
  ODataMessageTextVerifier.TestClass(ODataPreconditionFailedException.class);
  ODataMessageTextVerifier.TestClass(ODataPreconditionRequiredException.class);
  ODataMessageTextVerifier.TestClass(ODataServiceUnavailableException.class);
  ODataMessageTextVerifier.TestClass(ODataUnsupportedMediaTypeException.class);
  ODataMessageTextVerifier.TestClass(ODataNotImplementedException.class);

  ODataMessageTextVerifier.TestClass(ExpressionParserException.class);
  ODataMessageTextVerifier.TestClass(FilterParserExceptionImpl.class);
  ODataMessageTextVerifier.TestClass(ExpressionParserInternalError.class);
  ODataMessageTextVerifier.TestClass(TokenizerException.class);
  ODataMessageTextVerifier.TestClass(TokenizerExpectError.class);
}
 
Example #11
Source File: MessageReferenceTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddContentMoreThanOnce() {
  String content = "content";
  ODataMessageException e = new UriNotMatchingException(UriNotMatchingException.ENTITYNOTFOUND.addContent(content));
  assertEquals(1, e.getMessageReference().getContent().size());

  ODataMessageException e2 = new UriNotMatchingException(UriNotMatchingException.ENTITYNOTFOUND.addContent(content));
  assertEquals(1, e.getMessageReference().getContent().size());
  assertEquals(1, e2.getMessageReference().getContent().size());
}
 
Example #12
Source File: MessageReferenceTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddContent() {
  String content = "content";
  ODataMessageException e = new UriNotMatchingException(UriNotMatchingException.ENTITYNOTFOUND.addContent(content));

  assertEquals(1, e.getMessageReference().getContent().size());
}
 
Example #13
Source File: ParserTool.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the message text of the thrown exception serialized is {@paramref messageText}
 * 
 * @param messageText
 * Expected message text
 * @return this
 */
public ParserTool aExMsgText(final String messageText) {
  String info = "aExMessageText(" + expression + ")-->";

  aExType(ODataMessageException.class);

  info = "  " + info + "Expected: '" + messageText + "' Actual: '" + getExceptionText() + "'";
  assertEquals(info, messageText, getExceptionText());

  return this;
}
 
Example #14
Source File: ParserTool.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that all place holders in the message text definition of the
 * thrown exception are provided with content
 * 
 * @return ParserTool
 */
public ParserTool aExMsgContentAllSet() {
  String info = "aExMessageTextNoEmptyTag(" + expression + ")-->";

  aExType(ODataMessageException.class);

  info = "  " + info + "Messagetext: '" + getExceptionText() + "contains [%";
  assertFalse(info, getExceptionText().contains("[%"));

  return this;
}
 
Example #15
Source File: ParserTool.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that the message text of the thrown exception is not empty
 * 
 * @return ParserTool
 */
public ParserTool aExMsgNotEmpty() {
  String info = "aExMsgNotEmpty(" + expression + ")-->";

  aExType(ODataMessageException.class);

  info = "  " + info + "check if Messagetext is empty";
  assertFalse(info, getExceptionText().isEmpty());

  return this;
}
 
Example #16
Source File: ParserTool.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public ParserTool aExKey(final MessageReference expressionExpectedAtPos) {
  String info = "GetExceptionType(" + expression + ")-->";

  aExType(ODataMessageException.class);

  assertEquals(info, expressionExpectedAtPos.getKey(),
      ((ODataMessageException) curException).getMessageReference().getKey());
  return this;
}
 
Example #17
Source File: UriParserTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void parseWrongUri(final String uri, final MessageReference exceptionContext) {
  try {
    parse(uri);
    fail("Expected UriParserException not thrown");
  } catch (ODataMessageException e) {
    assertNotNull(e);
    assertEquals(exceptionContext.getKey(), e.getMessageReference().getKey());
  }
}
 
Example #18
Source File: UriParserTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void wrongGetKey(final EdmEntitySet entitySet, final String link, final String serviceRoot,
    final MessageReference exceptionContext) throws ODataException {
  try {
    new UriParserImpl(null).getKeyFromEntityLink(entitySet, link,
        serviceRoot == null ? null : URI.create(serviceRoot));
    fail("Expected UriParserException not thrown");
  } catch (ODataMessageException e) {
    assertNotNull(e);
    assertEquals(exceptionContext.getKey(), e.getMessageReference().getKey());
  }
}
 
Example #19
Source File: TechnicalScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Association getAssociation(final FullQualifiedName association) throws ODataMessageException {
  if (ASSOCIATION_ET1_ET2.equals(association)) {
    return new Association().setName(ASSOCIATION_ET1_ET2.getName())
        .setEnd1(new AssociationEnd()
            .setMultiplicity(EdmMultiplicity.ZERO_TO_ONE)
            .setRole(ROLE_1)
            .setType(ET_KEY_IS_STRING))
        .setEnd2(new AssociationEnd()
            .setMultiplicity(EdmMultiplicity.MANY)
            .setRole(ROLE_2)
            .setType(ET_KEY_IS_INTEGER));
  }
  return null;
}
 
Example #20
Source File: TechnicalScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public EntityContainerInfo getEntityContainerInfo(final String name) throws ODataMessageException {
  if ((name == null) || ENTITY_CONTAINER_1.equals(name)) {
    return new EntityContainerInfo().setName(ENTITY_CONTAINER_1).setDefaultEntityContainer(true);
  }

  return null;
}
 
Example #21
Source File: TechnicalScenarioEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public AssociationSet getAssociationSet(final String entityContainer, final FullQualifiedName association,
    final String sourceEntitySetName, final String sourceEntitySetRole) throws ODataMessageException {
  if (ENTITY_CONTAINER_1.equals(entityContainer)) {
    if (ASSOCIATION_ET1_ET2.equals(association)) {
      final AssociationSetEnd end1 = new AssociationSetEnd().setRole(ROLE_1).setEntitySet(ES_KEY_IS_STRING);
      final AssociationSetEnd end2 = new AssociationSetEnd().setRole(ROLE_2).setEntitySet(ES_KEY_IS_INTEGER);

      return new AssociationSet().setName("AssociationSet").setEnd1(end1).setEnd2(end2);
    }
  }
  return null;
}
 
Example #22
Source File: UriParserTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void wrongGetKey(final EdmEntitySet entitySet, final String link, final String serviceRoot,
    final MessageReference exceptionContext) throws ODataException {
  try {
    new UriParserImpl(null).getKeyFromEntityLink(entitySet, link,
        serviceRoot == null ? null : URI.create(serviceRoot));
    fail("Expected UriParserException not thrown");
  } catch (ODataMessageException e) {
    assertNotNull(e);
    assertEquals(exceptionContext.getKey(), e.getMessageReference().getKey());
  }
}
 
Example #23
Source File: UriParserTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void parseWrongUri(final String uri, final MessageReference exceptionContext) {
  try {
    parse(uri);
    fail("Expected UriParserException not thrown");
  } catch (ODataMessageException e) {
    assertNotNull(e);
    assertEquals(exceptionContext.getKey(), e.getMessageReference().getKey());
  }
}
 
Example #24
Source File: ODataParser.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public SearchCondition<T> parse(String searchExpression) throws SearchParseException {
    try {
        final T condition = conditionClass.newInstance();
        final FilterExpression expression = parser.parseFilterString(searchExpression);
        final FilterExpressionVisitor visitor = new FilterExpressionVisitor(condition);
        return (SearchCondition< T >)expression.accept(visitor);
    } catch (ODataMessageException | ODataApplicationException
        | InstantiationException | IllegalAccessException ex) {
        throw new SearchParseException(ex);
    }
}
 
Example #25
Source File: MessageServiceTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testThreeParametersPerAddContentForTwo() throws Exception {
  MessageReference context = MessageReference.create(ODataMessageException.class, "TWO_REPLACEMENTS")
      .addContent("first").addContent("second").addContent("third");
  Message ms = MessageService.getMessage(DEFAULT_LANGUAGE, context);

  assertEquals("First was [first] and second was [second]!", ms.getText());
}
 
Example #26
Source File: ODataExceptionWrapper.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public ODataResponse wrapInExceptionResponse(final Exception exception) {
  try {
    final Exception toHandleException = extractException(exception);
    fillErrorContext(toHandleException);
    if (toHandleException instanceof ODataApplicationException) {
      enhanceContextWithApplicationException((ODataApplicationException) toHandleException);
    } else if (toHandleException instanceof ODataMessageException) {
      enhanceContextWithMessageException((ODataMessageException) toHandleException);
    }

    ODataResponse oDataResponse;
    if (callback != null) {
      oDataResponse = handleErrorCallback(callback);
    } else {
      oDataResponse = EntityProvider.writeErrorDocument(errorContext);
    }
    if (!oDataResponse.containsHeader(org.apache.olingo.odata2.api.commons.HttpHeaders.CONTENT_TYPE)) {
      oDataResponse = ODataResponse.fromResponse(oDataResponse).contentHeader(contentType).build();
    }
    return oDataResponse;
  } catch (Exception e) {
    ODataResponse response = ODataResponse.entity("Exception during error handling occured!")
        .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString())
        .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build();
    return response;
  }
}
 
Example #27
Source File: ODataExceptionWrapper.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public ODataResponse wrapInExceptionResponse(final Exception exception) {
  try {
    final Exception toHandleException = extractException(exception);
    fillErrorContext(toHandleException);
    if (toHandleException instanceof ODataApplicationException) {
      enhanceContextWithApplicationException((ODataApplicationException) toHandleException);
    } else if (toHandleException instanceof ODataRuntimeApplicationException) {
      enhanceContextWithRuntimeApplicationException((ODataRuntimeApplicationException) toHandleException);
    } else if (toHandleException instanceof ODataMessageException) {
      enhanceContextWithMessageException((ODataMessageException) toHandleException);
    }

    ODataResponse oDataResponse;
    if (callback != null) {
      oDataResponse = handleErrorCallback(callback);
    } else {
      oDataResponse = EntityProvider.writeErrorDocument(errorContext);
    }
    if (!oDataResponse.containsHeader(org.apache.olingo.odata2.api.commons.HttpHeaders.CONTENT_TYPE)) {
      oDataResponse = ODataResponse.fromResponse(oDataResponse).contentHeader(contentType).build();
    }
    return oDataResponse;
  } catch (Exception e) {
    ODataResponse response = ODataResponse.entity("Exception during error handling occured!")
        .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString())
        .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build();
    return response;
  }
}
 
Example #28
Source File: ODataSubLocator.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private Response returnException(final ODataMessageException messageException) {
  ODataContextImpl context = new ODataContextImpl(request, serviceFactory);
  context.setRequest(request);
  context.setAcceptableLanguages(request.getAcceptableLanguages());
  context.setPathInfo(request.getPathInfo());
  context.setServiceFactory(serviceFactory);
  context.setParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT, httpRequest);
  ODataExceptionWrapper exceptionWrapper =
      new ODataExceptionWrapper(context, request.getQueryParameters(), request.getAcceptHeaders());
  ODataResponse response =
      exceptionWrapper.wrapInExceptionResponse(messageException);
  return RestUtil.convertResponse(response);
}
 
Example #29
Source File: XmlEntityConsumerTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private void readAndExpectException(final EdmEntitySet entitySet, final InputStream reqContent, final boolean merge,
    final MessageReference messageReference) throws ODataMessageException {
  try {
    XmlEntityConsumer xec = new XmlEntityConsumer();
    ODataEntry result =
        xec.readEntry(entitySet, reqContent, EntityProviderReadProperties.init().mergeSemantic(merge).build());
    assertNotNull(result);
    Assert.fail("Expected exception with MessageReference '" + messageReference.getKey() + "' was not thrown.");
  } catch (ODataMessageException e) {
    assertEquals(messageReference.getKey(), e.getMessageReference().getKey());
    // assertEquals(messageReference.getContent(), e.getMessageReference().getContent());
    throw e;
  }
}
 
Example #30
Source File: MessageServiceTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testResourceBundleException() throws Exception {
  MessageReference context = MessageReference.create(ODataMessageException.class, "COMMON");
  Message ms = MessageService.getMessage(null, context);

  assertEquals(
      "MessageService could not be created because of exception 'IllegalArgumentException with message " +
          "'Parameter locale MUST NOT be NULL.'.",
      ms.getText());
}