This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new c294871 CXF-8376: Misleading Error Message From
UriBuilder.path(Method) (#727)
c294871 is described below
commit c29487177f932bb2d74dee0d3a4ac701cfbc9a89
Author: James Carman <[email protected]>
AuthorDate: Thu Nov 19 17:59:44 2020 -0500
CXF-8376: Misleading Error Message From UriBuilder.path(Method) (#727)
Signed-off-by: James Carman <[email protected]>
---
.../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();
}