Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

RESTEASY-789

  • Loading branch information...
commit 1a967e1ab1567a984f1035192dd8bc697510b583 1 parent 97d793c
@liweinan liweinan authored
View
12 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/Add.java
@@ -0,0 +1,12 @@
+package org.jboss.resteasy.jsapi.testing;
+import javax.ws.rs.Path;
+
+/**
+ * 11 01 2012
+ *
+ * @author <a href="mailto:l.weinan@gmail.com">Weinan Li</a>
+ */
+@Path("/add")
+public interface Add extends Operation {
+
+}
View
13 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/AddImpl.java
@@ -0,0 +1,13 @@
+package org.jboss.resteasy.jsapi.testing;
+/**
+ * 11 01 2012
+ *
+ * @author <a href="mailto:l.weinan@gmail.com">Weinan Li</a>
+ */
+public class AddImpl implements Add {
+
+ @Override
+ public Integer operate(Integer operand1, Integer operand2) {
+ return operand1 + operand2;
+ }
+}
View
11 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/Minus.java
@@ -0,0 +1,11 @@
+package org.jboss.resteasy.jsapi.testing;
+import javax.ws.rs.Path;
+
+/**
+ * 11 01 2012
+ *
+ * @author <a href="mailto:l.weinan@gmail.com">Weinan Li</a>
+ */
+@Path("minus")
+public interface Minus extends Operation{
+}
View
13 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/MinusImpl.java
@@ -0,0 +1,13 @@
+package org.jboss.resteasy.jsapi.testing;
+/**
+ * 11 01 2012
+ *
+ * @author <a href="mailto:l.weinan@gmail.com">Weinan Li</a>
+ */
+public class MinusImpl implements Minus {
+
+ @Override
+ public Integer operate(Integer operand1, Integer operand2) {
+ return operand1 - operand2;
+ }
+}
View
18 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/Operation.java
@@ -0,0 +1,18 @@
+package org.jboss.resteasy.jsapi.testing;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * 11 01 2012
+ *
+ * @author <a href="mailto:l.weinan@gmail.com">Weinan Li</a>
+ */
+public interface Operation {
+ @GET
+ @Path("/{operand1}/{operand2}")
+ @Produces(MediaType.TEXT_PLAIN)
+ public Integer operate(@PathParam("operand1") Integer operand1, @PathParam("operand2") Integer operand2);
+}
View
159 ...teasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/SmokeTestResource.java
@@ -1,84 +1,75 @@
-package org.jboss.resteasy.jsapi.testing;
-
-import javax.ws.rs.CookieParam;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-/**
- * @author Weinan Li
- * @created_at 08 24 2012
- */
-@Path("/smoke")
-public class SmokeTestResource {
- @Path("{id}")
- @GET
- @Produces("text/plain")
- public String testPathParam(@PathParam("id") String id) {
- return id;
- }
-
- @POST
- public String testFormParam(@FormParam("key") String[] values) {
- String val = "";
- for (String _val : values) {
- val += _val + "::";
- }
- return val;
- }
-
- @Path("/post2")
- @POST
- public String testFormParam2(@FormParam("key") String val) {
- return val;
- }
-
- @GET
- public String testQueryParam(@QueryParam("key") String[] values) {
- String val = "";
- for (String _val : values) {
- val += _val + "::";
- }
- return val;
- }
-
- @Path("/cookie")
- @GET
- public String testCookieParam(@CookieParam("username") String key) {
- return key;
- }
-
- @GET
- @Path("/matrix")
- public String testMatrixParam(@MatrixParam("key") String[] key) {
- String val = "";
- for (String _val : key) {
- val += _val + "::";
- }
- return val;
- }
-
- @GET
- @Path("/header")
- public String testHeaderParam(@HeaderParam("Referer") String referer) {
- return referer;
- }
-
- @POST
- @Path("/RESTEASY-731/false")
- public String testRESTEasy731False(@FormParam("false") boolean bool) {
- return ("RESTEASY-731-" + String.valueOf(bool));
- }
-
- @POST
- @Path("/RESTEASY-731/zero")
- public String testRESTEasy731Zero(@FormParam("zero") int zero) {
- return ("RESTEASY-731-" + String.valueOf(zero));
- }
-}
+package org.jboss.resteasy.jsapi.testing;
+
+import javax.ws.rs.*;
+
+/**
+ * @author Weinan Li
+ * @created_at 08 24 2012
+ */
+@Path("/smoke")
+public class SmokeTestResource {
+ @Path("{id}")
+ @GET
+ @Produces("text/plain")
+ public String testPathParam(@PathParam("id") String id) {
+ return id;
+ }
+
+ @POST
+ public String testFormParam(@FormParam("key") String[] values) {
+ String val = "";
+ for (String _val : values) {
+ val += _val + "::";
+ }
+ return val;
+ }
+
+ @Path("/post2")
+ @POST
+ public String testFormParam2(@FormParam("key") String val) {
+ return val;
+ }
+
+ @GET
+ public String testQueryParam(@QueryParam("key") String[] values) {
+ String val = "";
+ for (String _val : values) {
+ val += _val + "::";
+ }
+ return val;
+ }
+
+ @Path("/cookie")
+ @GET
+ public String testCookieParam(@CookieParam("username") String key) {
+ return key;
+ }
+
+ @GET
+ @Path("/matrix")
+ public String testMatrixParam(@MatrixParam("key") String[] key) {
+ String val = "";
+ for (String _val : key) {
+ val += _val + "::";
+ }
+ return val;
+ }
+
+ @GET
+ @Path("/header")
+ public String testHeaderParam(@HeaderParam("Referer") String referer) {
+ return referer;
+ }
+
+ @POST
+ @Path("/RESTEASY-731/false")
+ public String testRESTEasy731False(@FormParam("false") boolean bool) {
+ return ("RESTEASY-731-" + String.valueOf(bool));
+ }
+
+ @POST
+ @Path("/RESTEASY-731/zero")
+ public String testRESTEasy731Zero(@FormParam("zero") int zero) {
+ return ("RESTEASY-731-" + String.valueOf(zero));
+ }
+}
View
6 ...esteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/TestApplication.java
@@ -1,5 +1,8 @@
package org.jboss.resteasy.jsapi.testing;
+import org.jboss.resteasy.jsapi.testing.AddImpl;
+import org.jboss.resteasy.jsapi.testing.MinusImpl;
+
import java.util.HashSet;
import java.util.Set;
@@ -12,6 +15,8 @@
public TestApplication() {
singletons.add(new SmokeTestResource());
singletons.add(new CachedResource());
+ singletons.add(new AddImpl());
+ singletons.add(new MinusImpl());
}
@Override
@@ -24,5 +29,4 @@ public TestApplication() {
public Set<Object> getSingletons() {
return singletons;
}
-
}
View
27 jaxrs/resteasy-jsapi-testing/src/main/webapp/resteasy789.jsp
@@ -0,0 +1,27 @@
+<html>
+<body>
+<h2>RESTEASY-789 - JSAPIServlet does not generate inherited methods correctly</h2>
+
+<form>
+
+ <input type='button' onclick='testAdd();' value='Test Add'/>
+ <input type='button' onclick='testMinus();' value='Test Minus'/>
+</form>
+
+<div id="add_result"></div>
+<div id="minus_result"></div>
+
+<script src="/resteasy-jsapi-testing/rest-js" type="text/javascript"></script>
+<script type="text/javascript">
+ function testAdd() {
+ document.getElementById('add_result').innerHTML =
+ Add.operate({operand1:1, operand2:1});
+ }
+
+ function testMinus() {
+ document.getElementById('minus_result').innerHTML =
+ Minus.operate({operand1:1, operand2:1});
+ }
+</script>
+</body>
+</html>
View
7 jaxrs/resteasy-jsapi-testing/src/test/java/SmokingTest.java
@@ -63,6 +63,13 @@ public void smokeTest() throws Exception {
selenium.click("css=input[type=\"button\"]");
assertTrue(selenium.isTextPresent("304"));
+ // RESTEASY-789
+ selenium.open("/resteasy-jsapi-testing/resteasy789.jsp");
+ selenium.click("//input[@value='Test Add']");
+ selenium.click("//input[@value='Test Minus']");
+ assertTrue(selenium.isTextPresent("2"));
+ assertTrue(selenium.isTextPresent("0"));
+
}
@Test
View
12 jaxrs/resteasy-jsapi/src/main/java/org/jboss/resteasy/jsapi/MethodMetaData.java
@@ -6,15 +6,7 @@
import org.jboss.resteasy.logging.Logger;
import org.jboss.resteasy.util.FindAnnotation;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.CookieParam;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.HeaderParam;
-import javax.ws.rs.MatrixParam;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
+import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
@@ -46,7 +38,7 @@ public MethodMetaData(ServiceRegistry serviceRegistry, ResourceMethod resource)
this.registry = serviceRegistry;
this.resource = resource;
this.method = resource.getMethod();
- this.klass = method.getDeclaringClass();
+ this.klass = resource.getResourceClass();
Path methodPath = method.getAnnotation(Path.class);
Path klassPath = klass.getAnnotation(Path.class);
Produces produces = method.getAnnotation(Produces.class);
Please sign in to comment.
Something went wrong with that request. Please try again.