You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2020/11/20 00:43:22 UTC
[cxf] branch 3.4.x-fixes updated: CXF-8376: Misleading Error
Message From UriBuilder.path(Method) (#727)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/3.4.x-fixes by this push:
new adfe7ef CXF-8376: Misleading Error Message From UriBuilder.path(Method) (#727)
adfe7ef is described below
commit adfe7ef368ad63d97b03d5a167c6dd6bffb444a3
Author: James Carman <jw...@gmail.com>
AuthorDate: Thu Nov 19 17:59:44 2020 -0500
CXF-8376: Misleading Error Message From UriBuilder.path(Method) (#727)
Signed-off-by: James Carman <jw...@gmail.com>
---
.../main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java | 2 +-
.../java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java | 11 ++++++++++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
index e07af26..78ec975 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
@@ -517,7 +517,7 @@ public class UriBuilderImpl extends UriBuilder implements Cloneable {
}
Path ann = method.getAnnotation(Path.class);
if (ann == null) {
- throw new IllegalArgumentException("Method '" + method.getClass().getCanonicalName() + "."
+ throw new IllegalArgumentException("Method '" + method.getDeclaringClass().getCanonicalName() + "."
+ method.getName() + "' is not annotated with Path");
}
// path(String) decomposes multi-segment path when necessary
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
index 995090e..fb72e80 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
@@ -37,13 +37,18 @@ import org.apache.cxf.jaxrs.resources.BookStore;
import org.apache.cxf.jaxrs.resources.UriBuilderWrongAnnotations;
import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class UriBuilderImplTest {
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
@Test
public void testFromUriRelativePath() throws Exception {
UriBuilder builder = UriBuilder.fromUri("path");
@@ -854,8 +859,12 @@ public class UriBuilderImplTest {
new UriBuilderImpl().path((Method)null).build();
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testAddPathMethodNoAnnotation() throws Exception {
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage(
+ String.format("Method '%s.getBook' is not annotated with Path",
+ BookStore.class.getCanonicalName()));
Method noAnnot = BookStore.class.getMethod("getBook", String.class);
new UriBuilderImpl().path(noAnnot).build();
}