Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
2 parents 42d3105 + 6c1f9bd commit 07f9a4944fca8361d865928fb6cca56de890b6c0 @patriot1burke patriot1burke committed Nov 5, 2012
Showing with 311 additions and 126 deletions.
  1. +1 −2 jaxrs/distribution/assembly.xml
  2. +3 −8 jaxrs/distribution/pom.xml
  3. +3 −3 jaxrs/docbook/reference/en/en-US/modules/Guice.xml
  4. +9 −0 ...s/jackson/src/main/java/org/jboss/resteasy/plugins/providers/jackson/ResteasyJacksonProvider.java
  5. +107 −12 jaxrs/providers/jackson/src/test/java/org/jboss/resteasy/test/providers/jackson/JacksonTest.java
  6. +3 −3 jaxrs/resteasy-guice/pom.xml
  7. +12 −0 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/Add.java
  8. +13 −0 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/AddImpl.java
  9. +11 −0 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/Minus.java
  10. +13 −0 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/MinusImpl.java
  11. +18 −0 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/Operation.java
  12. +75 −84 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/SmokeTestResource.java
  13. +5 −1 jaxrs/resteasy-jsapi-testing/src/main/java/org/jboss/resteasy/jsapi/testing/TestApplication.java
  14. +0 −1 jaxrs/resteasy-jsapi-testing/src/main/webapp/index.jsp
  15. +27 −0 jaxrs/resteasy-jsapi-testing/src/main/webapp/resteasy789.jsp
  16. +7 −0 jaxrs/resteasy-jsapi-testing/src/test/java/SmokingTest.java
  17. +2 −2 jaxrs/resteasy-jsapi/src/main/java/org/jboss/resteasy/jsapi/JSAPIServlet.java
  18. +2 −10 jaxrs/resteasy-jsapi/src/main/java/org/jboss/resteasy/jsapi/MethodMetaData.java
View
3 jaxrs/distribution/assembly.xml 100644 → 100755
@@ -162,6 +162,7 @@
<useTransitiveFiltering>true</useTransitiveFiltering>
<includes>
<include>org.jboss.resteasy:resteasy-jaxrs</include>
+ <include>org.jboss.resteasy:resteasy-client</include>
<include>org.jboss.resteasy:resteasy-jaxb-provider</include>
<include>org.jboss.resteasy:resteasy-jettison-provider</include>
<include>org.jboss.resteasy:resteasy-fastinfoset-provider</include>
@@ -171,9 +172,7 @@
<include>org.jboss.resteasy:resteasy-yaml-provider</include>
<include>org.jboss.resteasy:resteasy-spring</include>
<include>org.jboss.resteasy:resteasy-guice</include>
- <include>org.jboss.resteasy:async-http-jbossweb</include>
<include>org.jboss.resteasy:async-http-servlet-3.0</include>
- <include>org.jboss.resteasy:async-http-tomcat6</include>
<include>org.jboss.resteasy:resteasy-cache-core</include>
<include>org.jboss.resteasy:resteasy-oauth</include>
<include>org.jboss.resteasy:resteasy-cdi</include>
View
11 jaxrs/distribution/pom.xml 100644 → 100755
@@ -22,15 +22,15 @@
<artifactId>resteasy-jaxrs</artifactId>
<version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.jboss.resteasy</groupId>
- <artifactId>jaxrs-api</artifactId>
+ <artifactId>resteasy-client</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>org.jboss.resteasy</groupId>
- <artifactId>async-http-jbossweb</artifactId>
+ <artifactId>jaxrs-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
@@ -40,11 +40,6 @@
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
- <artifactId>async-http-tomcat6</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>${project.version}</version>
</dependency>
@@ -1,6 +1,6 @@
<chapter id="Guice1">
- <title>Guice 2.0 Integration</title>
- <para>RESTEasy has some simple integration with Guice 2.0. RESTEasy will scan the binding types for a Guice Module
+ <title>Guice 3.0 Integration</title>
+ <para>RESTEasy has some simple integration with Guice 3.0. RESTEasy will scan the binding types for a Guice Module
for @Path and @Provider annotations. It will register these bindings with RESTEasy. The guice-hello
project that comes in the RESTEasy examples/ directory gives a nice example of this.</para>
<programlisting>
@@ -109,4 +109,4 @@ public class HelloModule implements Module
]]>
</programlisting>
</section>
-</chapter>
+</chapter>
@@ -1,5 +1,6 @@
package org.jboss.resteasy.plugins.providers.jackson;
+import org.codehaus.jackson.jaxrs.Annotations;
import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
import org.jboss.resteasy.annotations.providers.NoJackson;
import org.jboss.resteasy.util.FindAnnotation;
@@ -22,6 +23,14 @@
@Produces({"application/*+json", "text/json"})
public class ResteasyJacksonProvider extends JacksonJsonProvider
{
+
+ public ResteasyJacksonProvider() {
+ super();
+ Annotations[] ANNOTATIONS = {Annotations.JACKSON, Annotations.JAXB};
+ _mapperConfig.setAnnotationsToUse(ANNOTATIONS);
+ }
+
+
@Override
public boolean isReadable(Class<?> aClass, Type type, Annotation[] annotations, MediaType mediaType)
{
@@ -1,26 +1,23 @@
package org.jboss.resteasy.test.providers.jackson;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.jboss.resteasy.annotations.providers.NoJackson;
import org.jboss.resteasy.annotations.providers.jaxb.json.BadgerFish;
import org.jboss.resteasy.client.ClientRequest;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.client.ProxyFactory;
import org.jboss.resteasy.test.BaseResourceTest;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlRootElement;
+import javax.ws.rs.*;
+import javax.xml.bind.annotation.*;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import static org.jboss.resteasy.test.TestPortProvider.generateBaseUrl;
import static org.jboss.resteasy.test.TestPortProvider.generateURL;
@@ -193,6 +190,7 @@ public static void setUp() throws Exception
{
dispatcher.getRegistry().addPerRequestResource(JacksonService.class);
dispatcher.getRegistry().addPerRequestResource(XmlService.class);
+ dispatcher.getRegistry().addPerRequestResource(JAXBService.class);
}
@Test
@@ -259,7 +257,104 @@ public void testJackson() throws Exception
}
- @Test
+
+ @XmlRootElement
+ public static class XmlResourceWithJAXB {
+ String attr1;
+ String attr2;
+
+ @XmlElement(name = "attr_1")
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ @XmlElement
+ public String getAttr2() {
+ return attr2;
+ }
+
+ public void setAttr2(String attr2) {
+ this.attr2 = attr2;
+ }
+ }
+
+
+ public static class XmlResourceWithJacksonAnnotation {
+ String attr1;
+ String attr2;
+
+ @JsonProperty("attr_1")
+ public String getAttr1() {
+ return attr1;
+ }
+
+ public void setAttr1(String attr1) {
+ this.attr1 = attr1;
+ }
+
+ @XmlElement
+ public String getAttr2() {
+ return attr2;
+ }
+
+ public void setAttr2(String attr2) {
+ this.attr2 = attr2;
+ }
+ }
+
+ @Path("/jaxb")
+ public static class JAXBService
+ {
+
+ @GET
+ @Produces("application/json")
+ public XmlResourceWithJAXB getJAXBResource() {
+ XmlResourceWithJAXB resourceWithJAXB = new XmlResourceWithJAXB();
+ resourceWithJAXB.setAttr1("XXX");
+ resourceWithJAXB.setAttr2("YYY");
+ return resourceWithJAXB;
+ }
+
+
+ @GET
+ @Path(("/json"))
+ @Produces("application/json")
+ public XmlResourceWithJacksonAnnotation getJacksonAnnotatedResource() {
+ XmlResourceWithJacksonAnnotation resource = new XmlResourceWithJacksonAnnotation();
+ resource.setAttr1("XXX");
+ resource.setAttr2("YYY");
+ return resource;
+ }
+
+ }
+
+ @Test
+ public void testJacksonJAXB() throws Exception {
+ {
+ DefaultHttpClient client = new DefaultHttpClient();
+ HttpGet get = new HttpGet(generateBaseUrl() + "/jaxb");
+ HttpResponse response = client.execute(get);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+ Assert.assertTrue(reader.readLine().contains("attr_1"));
+ }
+
+ {
+ DefaultHttpClient client = new DefaultHttpClient();
+ HttpGet get = new HttpGet(generateBaseUrl() + "/jaxb/json");
+ HttpResponse response = client.execute(get);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+ Assert.assertTrue(reader.readLine().contains("attr_1"));
+
+ }
+
+ }
+
+
+ @Test
public void testJacksonProxy() throws Exception
{
JacksonProxy proxy = ProxyFactory.create(JacksonProxy.class, generateBaseUrl());
@@ -14,9 +14,9 @@
<dependencies>
<dependency>
- <groupId>com.google.code.guice</groupId>
+ <groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
- <version>2.0</version>
+ <version>3.0</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
@@ -48,4 +48,4 @@
</dependency>
-->
</dependencies>
-</project>
+</project>
@@ -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 {
+
+}
@@ -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;
+ }
+}
@@ -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{
+}
@@ -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;
+ }
+}
@@ -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);
+}
Oops, something went wrong.

0 comments on commit 07f9a49

Please sign in to comment.