You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wink.apache.org by bl...@apache.org on 2009/09/23 01:10:46 UTC
svn commit: r817893 - in
/incubator/wink/trunk/wink-providers/wink-jettison-provider/src:
main/java/org/apache/wink/providers/jettison/ main/resources/
main/resources/META-INF/
test/java/org/apache/wink/providers/jettison/internal/ test/resources/
test...
Author: bluk
Date: Tue Sep 22 23:10:46 2009
New Revision: 817893
URL: http://svn.apache.org/viewvc?rev=817893&view=rev
Log:
wink-jettison-provider use BadgerFish by default
See [WINK-142]
Added:
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/resources/
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/resources/META-INF/
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/resources/META-INF/wink-application
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/META-INF/
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/META-INF/wink.properties (with props)
Modified:
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBElementProvider.java
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBProvider.java
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBBadgerFishTest.java
incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBMappedTest.java
Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBElementProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBElementProvider.java?rev=817893&r1=817892&r2=817893&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBElementProvider.java (original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBElementProvider.java Tue Sep 22 23:10:46 2009
@@ -59,10 +59,9 @@
import org.slf4j.LoggerFactory;
/**
- * A Jettison JAXBElement provider. By default, use the MappedNamespace
- * convention. Namespace mapping needs to be set if namespaces are used. In
- * Application sub-class, use {@link Application#getSingletons()} to add to
- * application.
+ * A Jettison JAXBElement provider. By default, use the BadgerFishConvention.
+ * Namespace mapping needs to be set if namespaces are used. In Application
+ * sub-class, use {@link Application#getSingletons()} to add to application.
*/
@Provider
@Consumes(MediaType.APPLICATION_JSON)
@@ -78,8 +77,12 @@
final private Configuration outputConfiguration;
+ private boolean isReadable;
+
+ private boolean isWritable;
+
public JettisonJAXBElementProvider() {
- this(false, null, null);
+ this(true, null, null);
}
public JettisonJAXBElementProvider(boolean isBadgerFishConventionUsed,
@@ -96,13 +99,24 @@
} else {
this.outputConfiguration = new Configuration(new HashMap<String, String>());
}
+ // see http://jira.codehaus.org/browse/JETTISON-74 . reading disabled for now
+ isReadable = false;
+ isWritable = true;
+ }
+
+ public void setUseAsReader(boolean isReadable) {
+ this.isReadable = isReadable;
+ }
+
+ public void setUseAsWriter(boolean isWritable) {
+ this.isWritable = isWritable;
}
public boolean isReadable(Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType) {
- return isJAXBElement(type, genericType);
+ return isReadable && isJAXBElement(type, genericType);
}
public JAXBElement<?> readFrom(Class<JAXBElement<?>> type,
@@ -152,7 +166,7 @@
Type genericType,
Annotation[] annotations,
MediaType mediaType) {
- return isJAXBElement(type, genericType);
+ return isWritable && isJAXBElement(type, genericType);
}
public void writeTo(JAXBElement<?> t,
Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBProvider.java?rev=817893&r1=817892&r2=817893&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBProvider.java (original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/java/org/apache/wink/providers/jettison/JettisonJAXBProvider.java Tue Sep 22 23:10:46 2009
@@ -75,8 +75,12 @@
final private Configuration outputConfiguration;
+ private boolean isReadable;
+
+ private boolean isWritable;
+
public JettisonJAXBProvider() {
- this(false, null, null);
+ this(true, null, null);
}
public JettisonJAXBProvider(boolean isBadgerFishConventionUsed,
@@ -93,13 +97,25 @@
} else {
this.outputConfiguration = new Configuration(new HashMap<String, String>());
}
+
+ // see http://jira.codehaus.org/browse/JETTISON-74 . reading disabled for now
+ isReadable = false;
+ isWritable = true;
+ }
+
+ public void setUseAsReader(boolean isReadable) {
+ this.isReadable = isReadable;
+ }
+
+ public void setUseAsWriter(boolean isWritable) {
+ this.isWritable = isWritable;
}
public boolean isReadable(Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType) {
- return isJAXBObject(type, genericType);
+ return isReadable && isJAXBObject(type, genericType);
}
public Object readFrom(Class<Object> type,
@@ -155,7 +171,7 @@
Type genericType,
Annotation[] annotations,
MediaType mediaType) {
- return isJAXBObject(type, genericType);
+ return isWritable && isJAXBObject(type, genericType);
}
public void writeTo(Object t,
Added: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/resources/META-INF/wink-application
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/resources/META-INF/wink-application?rev=817893&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/resources/META-INF/wink-application (added)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/main/resources/META-INF/wink-application Tue Sep 22 23:10:46 2009
@@ -0,0 +1,21 @@
+##
+## 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.
+##
+
+org.apache.wink.providers.jettison.JettisonJAXBProvider
+org.apache.wink.providers.jettison.JettisonJAXBElementProvider
Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBBadgerFishTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBBadgerFishTest.java?rev=817893&r1=817892&r2=817893&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBBadgerFishTest.java (original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBBadgerFishTest.java Tue Sep 22 23:10:46 2009
@@ -59,14 +59,21 @@
@Override
protected Object[] getSingletons() {
-
JettisonJAXBProvider jaxbProvider = new JettisonJAXBProvider(true, null, null);
+ jaxbProvider.setUseAsReader(true);
JettisonJAXBElementProvider jaxbElementProvider =
new JettisonJAXBElementProvider(true, null, null);
+ jaxbElementProvider.setUseAsReader(true);
+
return new Object[] {jaxbProvider, jaxbElementProvider};
}
+ @Override
+ public String getPropertiesFile() {
+ return "META-INF/wink.properties";
+ }
+
@Path("/test/person")
public static class PersonResource {
@@ -169,9 +176,10 @@
.getBytes());
MockHttpServletResponse response = invoke(request);
assertEquals(200, response.getStatus());
- assertTrue(JSONUtils.equals(new JSONObject(
- " {\"person\":{\"desc\":{\"$\":\"My desc\"},\"name\":{\"$\":\"My Name\"}}} "),
- new JSONObject(response.getContentAsString())));
+ assertTrue(JSONUtils
+ .equals(new JSONObject(
+ " {\"person\":{\"desc\":{\"$\":\"My desc\"},\"name\":{\"$\":\"My Name\"}}} "),
+ new JSONObject(response.getContentAsString())));
}
public void testGetAtomEntry() throws Exception {
@@ -207,8 +215,9 @@
MockHttpServletResponse response = invoke(request);
assertEquals(200, response.getStatus());
- assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON_POST), JSONUtils
- .objectForString(response.getContentAsString())));
+ assertTrue(response.getContentAsString(), JSONUtils.equals(JSONUtils
+ .objectForString(ENTRY_JSON_POST), JSONUtils.objectForString(response
+ .getContentAsString())));
}
public void testPostAtomEntryElement() throws Exception {
@@ -220,8 +229,11 @@
request.setContent(ENTRY_JSON_POST.getBytes());
MockHttpServletResponse response = invoke(request);
assertEquals(200, response.getStatus());
- assertTrue(JSONUtils.equals(JSONUtils.objectForString(ENTRY_JSON_POST), JSONUtils
- .objectForString(response.getContentAsString())));
+ System.out.println(response.getContentAsString());
+ System.out.println(ENTRY_JSON_POST);
+ assertTrue(response.getContentAsString(), JSONUtils.equals(JSONUtils
+ .objectForString(ENTRY_JSON_POST), JSONUtils.objectForString(response
+ .getContentAsString())));
}
private static final String ENTRY_STR =
Modified: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBMappedTest.java
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBMappedTest.java?rev=817893&r1=817892&r2=817893&view=diff
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBMappedTest.java (original)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/java/org/apache/wink/providers/jettison/internal/JettisonJAXBMappedTest.java Tue Sep 22 23:10:46 2009
@@ -79,13 +79,19 @@
JettisonJAXBProvider jaxbProvider =
new JettisonJAXBProvider(false, new Configuration(namespaceMap),
new Configuration(outputNamespaceMap));
-
+ jaxbProvider.setUseAsReader(true);
JettisonJAXBElementProvider jaxbElementProvider =
new JettisonJAXBElementProvider(false, new Configuration(namespaceMap),
new Configuration(outputNamespaceMap));
+ jaxbElementProvider.setUseAsReader(true);
return new Object[] {jaxbProvider, jaxbElementProvider};
}
+ @Override
+ public String getPropertiesFile() {
+ return "META-INF/wink.properties";
+ }
+
@Path("/test/person")
public static class PersonResource {
Added: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/META-INF/wink.properties
URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/META-INF/wink.properties?rev=817893&view=auto
==============================================================================
--- incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/META-INF/wink.properties (added)
+++ incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/META-INF/wink.properties Tue Sep 22 23:10:46 2009
@@ -0,0 +1,20 @@
+##
+## 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.
+##
+
+wink.loadApplications=false
Propchange: incubator/wink/trunk/wink-providers/wink-jettison-provider/src/test/resources/META-INF/wink.properties
------------------------------------------------------------------------------
svn:eol-style = native