Repository: olingo-odata2 Updated Branches: refs/heads/master 6c7a67425 -> 973af5555
[OLINGO-1153]Common Exception thrown for Naming issues Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/973af555 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/973af555 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/973af555 Branch: refs/heads/master Commit: 973af55553803cc283f4a990a652f4eca3736c21 Parents: 6c7a674 Author: Archana Rai <[email protected]> Authored: Wed Jul 26 14:49:43 2017 +0530 Committer: Archana Rai <[email protected]> Committed: Wed Jul 26 14:49:43 2017 +0530 ---------------------------------------------------------------------- .../java/org/apache/olingo/odata2/api/edm/EdmException.java | 4 +++- .../olingo/odata2/core/edm/provider/EdmNamedImplProv.java | 2 +- odata2-lib/odata-core/src/main/resources/i18n.properties | 1 + .../olingo/odata2/core/edm/provider/EdmNamedImplProvTest.java | 7 +++++++ 4 files changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/973af555/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmException.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmException.java b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmException.java index 7e6f6fb..bc43ac8 100644 --- a/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmException.java +++ b/odata2-lib/odata-api/src/main/java/org/apache/olingo/odata2/api/edm/EdmException.java @@ -39,7 +39,9 @@ public class EdmException extends ODataMessageException { public static final MessageReference MUSTBENAVIGATIONPROPERTY = createMessageReference(EdmException.class, "MUSTBENAVIGATIONPROPERTY"); public static final MessageReference MUSTBEPROPERTY = createMessageReference(EdmException.class, "MUSTBEPROPERTY"); - + public static final MessageReference NAMINGERROR = + createMessageReference(EdmException.class, "NAMINGERROR"); + public EdmException(final MessageReference messageReference) { super(messageReference); } http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/973af555/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java index 8f12183..a764ec1 100644 --- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java +++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProv.java @@ -70,6 +70,6 @@ public abstract class EdmNamedImplProv implements EdmNamed { if (matcher.matches()) { return name; } - throw new EdmException(EdmException.COMMON); + throw new EdmException(EdmException.NAMINGERROR.addContent(name)); } } http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/973af555/odata2-lib/odata-core/src/main/resources/i18n.properties ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/main/resources/i18n.properties b/odata2-lib/odata-core/src/main/resources/i18n.properties index 23a906b..000ad1b 100644 --- a/odata2-lib/odata-core/src/main/resources/i18n.properties +++ b/odata2-lib/odata-core/src/main/resources/i18n.properties @@ -76,6 +76,7 @@ org.apache.olingo.odata2.api.edm.EdmException.MUSTBEPROPERTY=The found typed val org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.COMMON=An exception occurred. org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.LITERAL_KIND_MISSING=The literal kind is missing. org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.LITERAL_KIND_NOT_SUPPORTED=The literal kind '%1$s' is not supported. +org.apache.olingo.odata2.api.edm.EdmException.NAMINGERROR= '%1$s' name pattern not valid. org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.LITERAL_NULL_NOT_ALLOWED=The metadata do not allow a null literal. org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.LITERAL_ILLEGAL_CONTENT=The literal '%1$s' is not formatted properly. org.apache.olingo.odata2.api.edm.EdmSimpleTypeException.LITERAL_FACETS_NOT_MATCHED=The metadata constraints '%2$s' do not match the literal '%1$s'. http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/973af555/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProvTest.java ---------------------------------------------------------------------- diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProvTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProvTest.java index 9a6fe72..6a1c6ac 100644 --- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProvTest.java +++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/edm/provider/EdmNamedImplProvTest.java @@ -26,10 +26,15 @@ import org.apache.olingo.odata2.api.edm.EdmSimpleTypeKind; import org.apache.olingo.odata2.api.edm.provider.EdmProvider; import org.apache.olingo.odata2.api.edm.provider.SimpleProperty; import org.apache.olingo.odata2.testutil.fit.BaseTest; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; public class EdmNamedImplProvTest extends BaseTest { + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + @Test(expected = EdmException.class) public void testPropertySimple() throws Exception { @@ -48,6 +53,8 @@ public class EdmNamedImplProvTest extends BaseTest { SimpleProperty propertySimple = new SimpleProperty().setName("1_PropertyName").setType(EdmSimpleTypeKind.String); new EdmSimplePropertyImplProv(edmImplProv, propertySimple); + expectedEx.expect(RuntimeException.class); + expectedEx.expectMessage("'Prop;ertyName' name pattern not valid."); } @Test
