You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by ro...@apache.org on 2010/03/02 23:48:46 UTC

svn commit: r918236 - in /incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal: ./ jaxb/polymorphic/ pojo/ pojo/polymorphic/

Author: rott
Date: Tue Mar  2 22:48:45 2010
New Revision: 918236

URL: http://svn.apache.org/viewvc?rev=918236&view=rev
Log:
Jackson polymorphic tests and provider priority test

Added:
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJSON4JBattleTest.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/IProperties.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyJAXBObject.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyProperties.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/ObjectFactory.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Animal.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Cat.java
    incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Dog.java

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJSON4JBattleTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJSON4JBattleTest.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJSON4JBattleTest.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/JacksonJSON4JBattleTest.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.wink.providers.json.JSONUtils;
+import org.apache.wink.providers.json.JsonProvider;
+import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
+import org.apache.wink.test.mock.MockRequestConstructor;
+import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.json.JSONObject;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class JacksonJSON4JBattleTest extends MockServletInvocationTest {
+
+    @Override
+    protected Class<?>[] getClasses() {
+        return new Class<?>[] {JSON4JResource.class};
+    }
+
+    @Override
+    protected Object[] getSingletons() {
+        // this test checks to make sure we can override system providers (JsonProvider) to establish a new priority
+        // last one listed takes priority
+        // (note: this test relies on consistent behavior in MockServletInvocationTest.getSingletons() -- if this
+        //  method re-orders the data return from here, test results may change)
+        return new Object[] {new JacksonJaxbJsonProvider(), new JsonProvider()};
+    }
+
+    @Path("/json4j")
+    public static class JSON4JResource {
+
+        @POST
+        @Consumes("application/json")
+        @Produces("application/json")
+        @Path("object")
+        public JSONObject echoObject(JSONObject object) {
+            return object;
+        }
+    }
+    
+    private static final String JSON =
+        "{\"entry\": {\n" + "  \"id\": \"entry:id\",\n"
+            + "  \"title\": {\n"
+            + "    \"content\": \"entry title\",\n"
+            + "    \"type\": \"text\"\n"
+            + "  }\n"
+            + "}}";
+    
+    public void testPost() throws Exception {
+        MockHttpServletRequest request =
+            MockRequestConstructor.constructMockRequest("POST",
+                                                        "/json4j/object",
+                                                        MediaType.APPLICATION_JSON,
+                                                        MediaType.APPLICATION_JSON,
+                                                        JSON.getBytes());
+        MockHttpServletResponse response = invoke(request);
+        assertEquals(200, response.getStatus());
+        assertTrue(JSONUtils.equals(JSONUtils.objectForString(JSON),
+                JSONUtils.objectForString(response.getContentAsString())));
+    }
+    
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/PolymorphicTest.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.wink.providers.jackson.internal.jaxb.polymorphic.MyJAXBObject;
+import org.apache.wink.providers.jackson.internal.jaxb.polymorphic.MyProperties;
+import org.apache.wink.providers.jackson.internal.pojo.polymorphic.Animal;
+import org.apache.wink.providers.jackson.internal.pojo.polymorphic.Dog;
+import org.apache.wink.providers.json.JSONUtils;
+import org.apache.wink.server.internal.servlet.MockServletInvocationTest;
+import org.apache.wink.test.mock.MockRequestConstructor;
+import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
+import org.json.JSONObject;
+import org.junit.Test;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class PolymorphicTest extends MockServletInvocationTest {
+
+    JacksonJsonProvider jacksonProvider;
+    
+    @Override
+    protected Class<?>[] getClasses() {
+        return new Class<?>[] {MyJAXBObjectResource.class, AnimalResource.class};
+    }
+
+    @Override
+    protected Object[] getSingletons() {
+        ObjectMapper mapper = new ObjectMapper();
+        JaxbAnnotationIntrospector jaxbIntrospector = new JaxbAnnotationIntrospector();
+        mapper.getSerializationConfig().setAnnotationIntrospector(jaxbIntrospector);
+        mapper.getDeserializationConfig().setAnnotationIntrospector(jaxbIntrospector);
+        jacksonProvider = new JacksonJsonProvider();
+        jacksonProvider.setMapper(mapper);
+        return new Object[]{jacksonProvider};
+    }
+
+    @Path("/test/myproperties")
+    public static class MyJAXBObjectResource {
+
+        @GET
+        public MyJAXBObject getMyJAXBObject() throws IOException {
+            MyJAXBObject p = new MyJAXBObject();
+            MyProperties myProps = new MyProperties();
+            myProps.addProperty("I rock?", "Yes, yes I do.");
+            p.setConfiguration(myProps);
+            return p;
+        }
+
+    }
+    
+    @Path("/test/animal")
+    public static class AnimalResource {
+
+        @GET
+        @Produces("application/json")
+        public Animal getDog() throws IOException {
+            Animal animal = new Dog();
+            return animal;
+        }
+
+    }
+    
+    @Test
+    public void testGetMyProperties() throws Exception {
+        MockHttpServletRequest request =
+            MockRequestConstructor.constructMockRequest("GET", "/test/myproperties", "application/json");
+        MockHttpServletResponse response = invoke(request);
+        assertEquals(200, response.getStatus());
+
+        String expectedResponseString = "{\"config\":{\"properties\":{\"I rock?\":\"Yes, yes I do.\"}}}";
+                
+        assertTrue(JSONUtils.equals(new JSONObject(expectedResponseString),
+                                    new JSONObject(response.getContentAsString())));
+        assertTrue(JSONUtils.equals(JSONUtils.objectForString(expectedResponseString), JSONUtils
+                .objectForString(response.getContentAsString())));
+        
+        // call the provider as though the wink-client was in use on the client side
+        InputStream is = new ByteArrayInputStream(response.getContentAsByteArray());
+        MyJAXBObject myJAXBObject = (MyJAXBObject)jacksonProvider.readFrom(Object.class, MyJAXBObject.class, null, MediaType.APPLICATION_JSON_TYPE, null, is);
+
+        // make sure the Jackson deserializer is using the 'type' property on the XmlElement annotation in MyJAXBObject
+        // confirm Jackson deserialized to expected object type -- support for this was added in Jackson 1.4
+        assertTrue(myJAXBObject.getConfiguration() instanceof MyProperties);
+    }
+    
+    @Test
+    public void testGetMyPropertiesJaxbProvider() throws Exception {
+        MockHttpServletRequest request =
+            MockRequestConstructor.constructMockRequest("GET", "/test/myproperties", "application/json");
+        MockHttpServletResponse response = invoke(request);
+        assertEquals(200, response.getStatus());
+
+        String expectedResponseString = "{\"config\":{\"properties\":{\"I rock?\":\"Yes, yes I do.\"}}}";
+                
+        assertTrue(JSONUtils.equals(new JSONObject(expectedResponseString),
+                                    new JSONObject(response.getContentAsString())));
+        assertTrue(JSONUtils.equals(JSONUtils.objectForString(expectedResponseString), JSONUtils
+                .objectForString(response.getContentAsString())));
+        
+        // call the provider as though the wink-client was in use on the client side
+        InputStream is = new ByteArrayInputStream(response.getContentAsByteArray());
+        // use JacksonJaxbJsonProvider with default configuration instead of the old JacksonJsonProvider
+        JacksonJaxbJsonProvider jacksonJAXBProvider = new JacksonJaxbJsonProvider();
+        MyJAXBObject myJAXBObject = (MyJAXBObject)jacksonJAXBProvider.readFrom(Object.class, MyJAXBObject.class, null, MediaType.APPLICATION_JSON_TYPE, null, is);
+
+        // make sure the Jackson deserializer is using the 'type' property on the XmlElement annotation in MyJAXBObject
+        // confirm Jackson deserialized to expected object type -- support for this was added in Jackson 1.4
+        assertTrue(myJAXBObject.getConfiguration() instanceof MyProperties);
+    }
+    
+    @Test
+    public void testGetAnimal() throws Exception {
+        
+        MockHttpServletRequest request =
+            MockRequestConstructor.constructMockRequest("GET", "/test/animal", "application/json");
+        MockHttpServletResponse response = invoke(request);
+        assertEquals(200, response.getStatus());
+        
+        // make sure @JsonIgnore is honored
+        String expectedResponseString = "{\"type\":\"dog\"}";
+        assertTrue(JSONUtils.equals(new JSONObject(expectedResponseString),
+                new JSONObject(response.getContentAsString())));
+        
+        // call the provider as though the wink-client was in use on the client side
+        InputStream is = new ByteArrayInputStream(response.getContentAsByteArray());
+        JacksonJsonProvider jacksonProvider = new JacksonJsonProvider();
+        Animal animal = (Animal)jacksonProvider.readFrom(Object.class, Animal.class, null, MediaType.APPLICATION_JSON_TYPE, null, is);
+        
+        // make sure pseudo polymorphism support works.  See Animal class with @JsonCreator and @JsonProperty annotations
+        assertEquals(Dog.class, animal.getClass());
+
+    }
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/IProperties.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/IProperties.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/IProperties.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/IProperties.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal.jaxb.polymorphic;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public interface IProperties <K,V> {
+
+    public void addProperty(K key, V value);
+    public V getProperty(K key);
+    
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyJAXBObject.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyJAXBObject.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyJAXBObject.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyJAXBObject.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal.jaxb.polymorphic;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "MyJAXBObject", namespace = "http://org.apache.wink.providers.jackson.internal.jaxb.polymorphic/")
+public class MyJAXBObject {
+
+    // make sure Jackson reads the 'type' property
+	@XmlElement (type=MyProperties.class)
+	private IProperties<String, String> config = new MyProperties();
+	
+	public IProperties<String, String> getConfiguration() {
+		return this.config;
+	}
+
+	public void setConfiguration(IProperties<String, String> config) {
+		this.config = config;
+	}
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyProperties.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyProperties.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyProperties.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/MyProperties.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal.jaxb.polymorphic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "MyProperties", namespace = "http://org.apache.wink.providers.jackson.internal.jaxb.polymorphic/")
+public class MyProperties implements IProperties<String, String> {
+
+	private Map<String, String> properties = new HashMap<String, String>();
+	
+	public void addProperty(String key, String value) {
+		properties.put(key, value);
+	}
+
+	public String getProperty(String key) {
+		return properties.get(key);
+	}
+	
+
+	
+
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/ObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/ObjectFactory.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/ObjectFactory.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/jaxb/polymorphic/ObjectFactory.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal.jaxb.polymorphic;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.namespace.QName;
+
+public class ObjectFactory {
+
+    private final static QName _MyProperties_QNAME = new QName("http://org.apache.wink.providers.jackson.internal.jaxb.polymorphic/", "myProperties");
+    private final static QName _MyJAXBObject_QNAME = new QName("http://org.apache.wink.providers.jackson.internal.jaxb.polymorphic/", "myJAXBObject");
+	
+    public MyProperties createMyProperties() {
+        return new MyProperties();
+    }
+    
+    @XmlElementDecl(namespace = "http://org.apache.wink.providers.jackson.internal.jaxb.polymorphic/", name = "myProperties")
+    public JAXBElement<MyProperties> createMyProperties(MyProperties value) {
+        return new JAXBElement<MyProperties>(_MyProperties_QNAME, MyProperties.class, null, value);
+    }
+    
+    public MyJAXBObject createMyJAXBObject() {
+    	return new MyJAXBObject();
+    }
+    
+    @XmlElementDecl(namespace = "http://org.apache.wink.providers.jackson.internal.jaxb.polymorphic/", name = "myJAXBObject")
+    public JAXBElement<MyJAXBObject> createMyJAXBObject(MyJAXBObject value) {
+    	return new JAXBElement<MyJAXBObject>(_MyJAXBObject_QNAME, MyJAXBObject.class, null, value);
+    }
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Animal.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Animal.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Animal.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Animal.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal.pojo.polymorphic;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+public class Animal {
+
+    private String type;
+
+    @JsonIgnore
+    private String ignored;
+    
+    // type must have some data so Jackson client can properly unmarshal to correct object
+    protected Animal(String _type) {
+        this.setType(_type);
+    }
+    
+    /**
+     * Creator method that can instantiate instances of
+     * appropriate polymorphic type
+     * 
+     * It's pretty ugly to require a supertype to have knowledge
+     * of its subtypes, but that's the story of polymorphism in Jackson
+     * as of 1.4.0 release.  See:
+     * http://archive.codehaus.org/lists/org.codehaus.jackson.user/msg/5f7770581001061754sa3b9a6an67b111c39da8151c@mail.gmail.com
+     */
+    @JsonCreator
+    public static Animal create(@JsonProperty("type") String type)
+    {
+        if ("dog".equals(type)) {
+            return new Dog();
+        }
+        if ("cat".equals(type)) {
+            return new Cat();
+        }
+        throw new IllegalArgumentException("No such animal type ('"+type+"')");
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    @JsonIgnore
+    public String getIgnored() {
+        return ignored;
+    }
+
+    @JsonIgnore
+    public void setIgnored(String ignored) {
+        this.ignored = ignored;
+    }
+    
+    
+    
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Cat.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Cat.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Cat.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Cat.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal.pojo.polymorphic;
+
+
+public class Cat extends Animal {
+
+    public Cat() {
+        this("cat");
+    }
+    
+    private Cat(String type) {
+        super(type);
+    }
+
+}

Added: incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Dog.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Dog.java?rev=918236&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Dog.java (added)
+++ incubator/wink/trunk/wink-providers/wink-jackson-provider/src/test/java/org/apache/wink/providers/jackson/internal/pojo/polymorphic/Dog.java Tue Mar  2 22:48:45 2010
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.wink.providers.jackson.internal.pojo.polymorphic;
+
+
+public class Dog extends Animal {
+
+    public Dog() {
+        this("dog");
+    }
+    
+    private Dog(String type) {
+        super(type);
+    }
+
+
+}