Author: jliu
Date: Wed Jan 9 23:36:42 2008
New Revision: 610703
URL: http://svn.apache.org/viewvc?rev=610703&view=rev
Log:
Revised the algorithm used to determine JSR-311 output content types.
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_book123json.txt
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cd.txt
(with props)
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java
incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
(original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/Message.java
Wed Jan 9 23:36:42 2008
@@ -50,7 +50,8 @@
String MTOM_ENABLED = "mtom-enabled";
String SCHEMA_VALIDATION_ENABLED = "schema-validation-enabled";
String FAULT_STACKTRACE_ENABLED = "faultStackTraceEnabled";
- String CONTENT_TYPE = "Content-Type";
+ String CONTENT_TYPE = "Content-Type";
+ String ACCEPT_CONTENT_TYPE = "Accept";
String BASE_PATH = Message.class.getName() + ".BASE_PATH";
String ENCODING = Message.class.getName() + ".ENCODING";
String FIXED_PARAMETER_ORDER = Message.class.getName() +
"FIXED_PARAMETER_ORDER";
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
Wed Jan 9 23:36:42 2008
@@ -79,9 +79,18 @@
Message msg = exchange.getInMessage();
String subResourcePath =
(String)msg.get(JAXRSInInterceptor.RELATIVE_PATH);
String httpMethod = (String)msg.get(Message.HTTP_REQUEST_METHOD);
+ String contentType = (String)msg.get(Message.CONTENT_TYPE);
+ if (contentType == null) {
+ contentType = "*/*";
+ }
+ String acceptContentType =
(String)msg.get(Message.ACCEPT_CONTENT_TYPE);
+ if (acceptContentType == null) {
+ acceptContentType = "*/*";
+ }
ClassResourceInfo subCri =
JAXRSUtils.findSubResourceClass(classResourceInfo, result.getClass());
- OperationResourceInfo subOri = JAXRSUtils.findTargetMethod(subCri,
subResourcePath,
-
httpMethod, values);
+ OperationResourceInfo subOri = JAXRSUtils.findTargetMethod(subCri,
subResourcePath,
+
httpMethod, values,
+
contentType, acceptContentType);
exchange.put(OperationResourceInfo.class, subOri);
msg.put(JAXRSInInterceptor.RELATIVE_PATH, subResourcePath);
// work out request parameters for the sub-resouce class. Here we
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
Wed Jan 9 23:36:42 2008
@@ -25,13 +25,18 @@
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.Map;
import javax.activation.MimeType;
import javax.activation.MimeTypeParseException;
+import javax.ws.rs.ConsumeMime;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.MatrixParam;
+import javax.ws.rs.ProduceMime;
import javax.ws.rs.QueryParam;
import javax.ws.rs.UriParam;
import javax.ws.rs.core.HttpContext;
@@ -63,12 +68,15 @@
public static OperationResourceInfo
findTargetResourceClass(List<ClassResourceInfo> resources,
String path,
String httpMethod,
- Map<String,
String> values) {
+ Map<String,
String> values,
+ String
contentTypes,
+ String
acceptContentTypes) {
for (ClassResourceInfo resource : resources) {
URITemplate uriTemplate = resource.getURITemplate();
if (uriTemplate.match(path, values)) {
String subResourcePath =
values.get(URITemplate.RIGHT_HAND_VALUE);
- OperationResourceInfo ori = findTargetMethod(resource,
subResourcePath, httpMethod, values);
+ OperationResourceInfo ori = findTargetMethod(resource,
subResourcePath, httpMethod, values,
+ contentTypes,
acceptContentTypes);
if (ori != null) {
return ori;
}
@@ -78,18 +86,77 @@
}
public static OperationResourceInfo findTargetMethod(ClassResourceInfo
resource, String path,
- String httpMethod,
Map<String, String> values) {
+ String httpMethod,
Map<String, String> values,
+ String contentTypes,
String acceptContentTypes) {
+ List<OperationResourceInfo> candidateList = new
ArrayList<OperationResourceInfo>();
+
for (OperationResourceInfo ori :
resource.getMethodDispatcher().getOperationResourceInfos()) {
URITemplate uriTemplate = ori.getURITemplate();
- if (uriTemplate != null && uriTemplate.match(path, values)) {
- if (ori.isSubResourceLocator()) {
- return ori;
- } else if (ori.getHttpMethod() != null &&
ori.getHttpMethod().equalsIgnoreCase(httpMethod)) {
- return ori;
+ if ((uriTemplate != null && uriTemplate.match(path, values))
+ && (ori.isSubResourceLocator() || (ori.getHttpMethod() != null
&& ori.getHttpMethod()
+ .equalsIgnoreCase(httpMethod)))
+ && matchMimeTypes(contentTypes, acceptContentTypes,
ori.getMethod())) {
+ candidateList.add(ori);
+ }
+ }
+
+ if (!candidateList.isEmpty()) {
+ /*
+ * Sort M using the media type of input data as the primary key and
+ * the media type of output data as the secondary key.
+ */
+ Collections.sort(candidateList, new
OperationResourceInfoComparator());
+ return candidateList.get(0);
+ } else {
+ return null;
+ }
+ }
+
+ private static class OperationResourceInfoComparator implements
Comparator<OperationResourceInfo> {
+ public int compare(OperationResourceInfo e1, OperationResourceInfo e2)
{
+ ConsumeMime c1 = e1.getMethod().getAnnotation(ConsumeMime.class);
+ String[] mimeType1 = {"*/*"};
+ if (c1 != null) {
+ mimeType1 = c1.value();
+ }
+
+ ConsumeMime c2 = e2.getMethod().getAnnotation(ConsumeMime.class);
+ String[] mimeType2 = {"*/*"};
+ if (c2 != null) {
+ mimeType2 = c2.value();
+ }
+
+ int resultOfComparingConsumeMime = compareString(mimeType1[0],
mimeType2[0]);
+ if (resultOfComparingConsumeMime == 0) {
+ //use the media type of output data as the secondary key.
+ ProduceMime p1 =
e1.getMethod().getAnnotation(ProduceMime.class);
+ String[] mimeTypeP1 = {"*/*"};
+ if (p1 != null) {
+ mimeTypeP1 = p1.value();
}
+
+ ProduceMime p2 =
e2.getMethod().getAnnotation(ProduceMime.class);
+ String[] mimeTypeP2 = {"*/*"};
+ if (p2 != null) {
+ mimeTypeP2 = p2.value();
+ }
+
+ return compareString(mimeTypeP1[0], mimeTypeP2[0]);
+ } else {
+ return resultOfComparingConsumeMime;
+ }
+
+ }
+
+ private int compareString(String str1, String str2) {
+ if (!str1.startsWith("*/") && str2.startsWith("*/")) {
+ return -1;
+ } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
+ return 1;
}
+
+ return str1.compareTo(str2);
}
- return null;
}
//Message contains following information: PATH, HTTP_REQUEST_METHOD,
CONTENT_TYPE, InputStream.
@@ -103,13 +170,12 @@
for (int i = 0; i < parameterTypes.length; i++) {
Object param = processParameter(parameterTypes[i],
genericParameterTypes[i],
parameterAnnotations[i], values,
message);
-
params.add(param);
}
return params;
}
-
+
private static Object processParameter(Class<?> parameterClass, Type
parameterType,
Annotation[] parameterAnnotations,
Map<String, String> values,
Message message) {
@@ -181,5 +247,108 @@
result = PrimitiveUtils.read((String)result, parameter);
}
return result;
+ }
+
+ public static boolean matchMimeTypes(String contentTypes, String
acceptContentTypes, Method m) {
+ if (contentTypes != null) {
+ try {
+ MimeType mt = new MimeType(contentTypes);
+ contentTypes = mt.getBaseType();
+ } catch (MimeTypeParseException e) {
+ // ignore
+ }
+ }
+ if (acceptContentTypes != null) {
+ try {
+ MimeType mt = new MimeType(acceptContentTypes);
+ acceptContentTypes = mt.getBaseType();
+ } catch (MimeTypeParseException e) {
+ // ignore
+ }
+ }
+
+ String[] consumeMimeTypes = {"*/*"};
+ ConsumeMime c = m.getAnnotation(ConsumeMime.class);
+ if (c != null) {
+ consumeMimeTypes = c.value();
+ }
+
+ String[] produceMimeTypes = {"*/*"};
+ ProduceMime p = m.getAnnotation(ProduceMime.class);
+ if (p != null) {
+ produceMimeTypes = p.value();
+ }
+
+ if (intersectMimeTypes(consumeMimeTypes, contentTypes).length != 0
+ && intersectMimeTypes(produceMimeTypes, acceptContentTypes).length
!= 0) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * intersect two mime types
+ *
+ * @param mimeTypesA
+ * @param mimeTypesB
+ * @return return a list of intersected mime types
+ */
+ public static String[] intersectMimeTypes(String[] mimeTypesA, String[]
mimeTypesB) {
+ List<String> supportedMimeTypeList = new ArrayList<String>();
+
+ for (String mimeTypeB : mimeTypesB) {
+ String[] tmpList = intersectMimeTypes(mimeTypesA, mimeTypeB);
+ supportedMimeTypeList.addAll(Arrays.asList(tmpList));
+ }
+
+ String[] list = new String[supportedMimeTypeList.size()];
+ list = supportedMimeTypeList.toArray(list);
+ return list;
+ }
+
+ /**
+ * intersect two mime types
+ *
+ * @param mimeTypesA
+ * @param mimeTypeB
+ * @return return a list of intersected mime types
+ */
+ public static String[] intersectMimeTypes(String[] mimeTypesA, String
mimeTypeB) {
+ List<String> intersectedMimeTypes = new ArrayList<String>();
+
+ for (String mimeTypeA : mimeTypesA) {
+ if (isSubSetOfMimeTypes(mimeTypeB, mimeTypeA)) {
+ intersectedMimeTypes.add(mimeTypeB);
+ } else if (isSubSetOfMimeTypes(mimeTypeA, mimeTypeB)) {
+ intersectedMimeTypes.add(mimeTypeA);
+ }
+ }
+
+ String[] list = new String[intersectedMimeTypes.size()];
+ list = intersectedMimeTypes.toArray(list);
+ return list;
+ }
+
+ /**
+ * compare two mime types
+ *
+ * @param mimeTypeA
+ * @param mimeTypeB
+ * @return return ture is mimeTypeB is a subset of mimeTypeA or if
mimeTypeB
+ * is equal to mimeTypeA. Return false otherwise.
+ */
+ public static boolean isSubSetOfMimeTypes(String mimeTypeA, String
mimeTypeB) {
+ if (mimeTypeB.equalsIgnoreCase(mimeTypeA)) {
+ return true;
+ } else if (mimeTypeB.startsWith("*/")) {
+ return true;
+ } else if (mimeTypeB.endsWith("/*")
+ && !mimeTypeA.startsWith("*/")
+ && mimeTypeB.substring(0, mimeTypeB.indexOf("/"))
+ .equalsIgnoreCase(mimeTypeA.substring(0,
mimeTypeB.indexOf("/")))) {
+ return true;
+ }
+
+ return false;
}
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Wed Jan 9 23:36:42 2008
@@ -22,7 +22,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.jaxrs.JAXRSServiceImpl;
import org.apache.cxf.jaxrs.JAXRSUtils;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@@ -37,7 +39,7 @@
public static final String RELATIVE_PATH = "relative.path";
- //private static final Logger LOG =
Logger.getLogger(RESTDispatchInterceptor.class.getName());
+ private static final Logger LOG =
LogUtils.getL7dLogger(JAXRSInInterceptor.class);
//private static final ResourceBundle BUNDLE =
BundleUtils.getBundle(RESTDispatchInterceptor.class);
public JAXRSInInterceptor() {
@@ -48,6 +50,15 @@
String path = (String)message.get(Message.PATH_INFO);
String address = (String)message.get(Message.BASE_PATH);
String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
+ String contentType = (String)message.get(Message.CONTENT_TYPE);
+ if (contentType == null) {
+ contentType = "*/*";
+ }
+ String acceptContentType =
(String)message.get(Message.ACCEPT_CONTENT_TYPE);
+ if (acceptContentType == null) {
+ acceptContentType = "*/*";
+ }
+ message.getExchange().put(Message.ACCEPT_CONTENT_TYPE,
acceptContentType);
if (address.startsWith("http")) {
int idx = address.indexOf('/', 7);
@@ -68,20 +79,30 @@
path = path + "/";
}
message.put(RELATIVE_PATH, path);
+
+ LOG.info("Request path is: " + path);
+ LOG.info("Request HTTP method is: " + httpMethod);
+ LOG.info("Request contentType is: " + contentType);
+ LOG.info("Accept contentType is: " + acceptContentType);
+
//1. Matching target resource classes and method
Service service = message.getExchange().get(Service.class);
List<ClassResourceInfo> resources =
((JAXRSServiceImpl)service).getClassResourceInfos();
Map<String, String> values = new HashMap<String, String>();
- OperationResourceInfo ori =
JAXRSUtils.findTargetResourceClass(resources, path, httpMethod, values);
+ OperationResourceInfo ori =
JAXRSUtils.findTargetResourceClass(resources, path, httpMethod, values,
+
contentType, acceptContentType);
if (ori == null) {
+ LOG.severe("No operation found");
//throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OP",
BUNDLE, method, path));
}
+ LOG.info("Found operation: " + ori.getMethod().getName());
+
message.getExchange().put(OperationResourceInfo.class, ori);
message.put(RELATIVE_PATH, values.get(URITemplate.RIGHT_HAND_VALUE));
-
+
//2. Process parameters
List<Object> params = JAXRSUtils
.processParameters(ori.getMethod(), values, message);
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Wed Jan 9 23:36:42 2008
@@ -21,12 +21,18 @@
import java.io.IOException;
import java.io.OutputStream;
+import java.util.logging.Logger;
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+import javax.ws.rs.ProduceMime;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.EntityProvider;
import javax.ws.rs.ext.ProviderFactory;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
+import org.apache.cxf.jaxrs.JAXRSUtils;
import org.apache.cxf.jaxrs.model.OperationResourceInfo;
import org.apache.cxf.jaxrs.provider.ProviderFactoryImpl;
import org.apache.cxf.message.Exchange;
@@ -35,6 +41,7 @@
import org.apache.cxf.phase.Phase;
public class JAXRSOutInterceptor extends AbstractOutDatabindingInterceptor {
+ private static final Logger LOG =
LogUtils.getL7dLogger(JAXRSInInterceptor.class);
public JAXRSOutInterceptor() {
super(Phase.MARSHAL);
@@ -71,28 +78,25 @@
}
Class targetType = responseObj.getClass();
-/* if (responseObj.getClass().isArray()) {
- targetType = responseObj.getClass().getComponentType();
- } else if (responseObj instanceof List &&
((List)responseObj).get(0) != null) {
- //NOTE: if its a List, the provider should try to determine if
it can support
- //every object inside the List instead of the first one only.
- targetType = ((List)responseObj).get(0).getClass();
-
- }*/
-
- //TODO: decide the output media type based on resource
method/resource class/provider
- String[] methodMimeTypes =
exchange.get(OperationResourceInfo.class).getProduceMimeTypes();
+ String[] availableContentTypes =
computeAvailableContentTypes(message);
+ StringBuffer typesTmp = new StringBuffer();
+ for (String type : availableContentTypes) {
+ typesTmp.append(type + ",");
+ }
+ LOG.info("Available content types for response is: " + typesTmp);
+
EntityProvider provider =
((ProviderFactoryImpl)ProviderFactory.getInstance())
- .createEntityProvider(targetType, methodMimeTypes, false);
+ .createEntityProvider(targetType, availableContentTypes,
false);
+ LOG.info("Response EntityProvider is: " +
provider.getClass().getName());
try {
- if (!"*/*".equals(methodMimeTypes[0])) {
- message.put(Message.CONTENT_TYPE, methodMimeTypes[0]);
- }
+ String outputContentType =
computeFinalContentTypes(availableContentTypes, provider);
+ LOG.info("Response content type is: " + outputContentType);
+
+ message.put(Message.CONTENT_TYPE,
computeFinalContentTypes(availableContentTypes, provider));
provider.writeTo(responseObj, null, null, out);
-
} catch (IOException e) {
e.printStackTrace();
}
@@ -100,5 +104,34 @@
}
}
+
+ private String[] computeAvailableContentTypes(Message message) {
+ Exchange exchange = message.getExchange();
+
+ String[] methodMimeTypes =
exchange.get(OperationResourceInfo.class).getProduceMimeTypes();
+ String acceptContentType =
(String)exchange.get(Message.ACCEPT_CONTENT_TYPE);
+ if (acceptContentType != null) {
+ try {
+ MimeType mt = new MimeType(acceptContentType);
+ acceptContentType = mt.getBaseType();
+ } catch (MimeTypeParseException e) {
+ // ignore
+ }
+ }
+
+ return JAXRSUtils.intersectMimeTypes(methodMimeTypes,
acceptContentType);
+ }
+
+ private String computeFinalContentTypes(String[] requestContentTypes,
EntityProvider provider) {
+ String[] providerMimeTypes = {"*/*"};
+
+ ProduceMime c = provider.getClass().getAnnotation(ProduceMime.class);
+ if (c != null) {
+ providerMimeTypes = c.value();
+ }
+
+ String[] list = JAXRSUtils.intersectMimeTypes(requestContentTypes,
providerMimeTypes);
+ return list[0];
+ }
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Wed Jan 9 23:36:42 2008
@@ -101,7 +101,7 @@
}
public boolean match(String uri, Map<String, String>
templateVariableToValue) {
- templateVariableToValue.clear();
+ //templateVariableToValue.clear();
if (uri == null) {
return (templateRegexPattern == null) ? true : false;
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
Wed Jan 9 23:36:42 2008
@@ -31,6 +31,8 @@
import javax.ws.rs.ext.HeaderProvider;
import javax.ws.rs.ext.ProviderFactory;
+import org.apache.cxf.jaxrs.JAXRSUtils;
+
//NOTE: ProviderFactory should provide a method that can pass in media types
@@ -44,7 +46,16 @@
entityProviders.add(new JSONProvider());
entityProviders.add(new StringProvider());
entityProviders.add(new DOMSourceProvider());
+
+ for (EntityProvider ep : entityProviders) {
+ System.out.println("---" + ep.getClass().getName());
+ }
sort();
+
+ for (EntityProvider ep : entityProviders) {
+ System.out.println("---" + ep.getClass().getName());
+ }
+
}
public <T> T createInstance(Class<T> type) {
@@ -70,6 +81,8 @@
boolean isConsumeMime) {
for (EntityProvider<T> ep : entityProviders) {
+ System.out.println("-2222--" + ep.getClass().getName());
+
String[] supportedMimeTypes = {"*/*"};
if (isConsumeMime) {
ConsumeMime c = ep.getClass().getAnnotation(ConsumeMime.class);
@@ -83,7 +96,10 @@
}
}
- if (matchMimeTypes(supportedMimeTypes, requestedMimeTypes) &&
ep.supports(type)) {
+ String[] availableMimeTypes =
JAXRSUtils.intersectMimeTypes(requestedMimeTypes,
+
supportedMimeTypes);
+
+ if (availableMimeTypes.length != 0 && ep.supports(type)) {
return ep;
}
}
@@ -115,34 +131,7 @@
public List<EntityProvider> getEntityProviders() {
return entityProviders;
}
-
- private boolean matchMimeTypes(String[] supportedMimeTypes, String[]
requestedMimeTypes) {
- //TODO:
- for (String supportedMimeType : supportedMimeTypes) {
- for (String requestedMimeType : requestedMimeTypes) {
- if (isMimeTypeSupported(requestedMimeType, supportedMimeType))
{
- return true;
- }
- }
- }
-
- return false;
- }
-
- private boolean isMimeTypeSupported(String requestedMimeType, String
supportedMimeType) {
- // REVISIT: better algorithm
- if (supportedMimeType.equals(requestedMimeType)) {
- return true;
- } else if (supportedMimeType.startsWith("*/")) {
- return true;
- } else if (supportedMimeType.regionMatches(0, requestedMimeType, 0,
supportedMimeType.indexOf("/"))
- && supportedMimeType.endsWith("/*")) {
- return true;
- }
-
- return false;
- }
-
+
/*
* sorts the available providers according to the media types they declare
* support for. Sorting of media types follows the general rule: x/y < * x
< *,
@@ -174,8 +163,13 @@
}
private int compareString(String str1, String str2) {
- //TODO:
- return str2.compareTo(str1);
+ if (!str1.startsWith("*/") && str2.startsWith("*/")) {
+ return -1;
+ } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
+ return 1;
+ }
+
+ return str1.compareTo(str2);
}
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
Wed Jan 9 23:36:42 2008
@@ -53,9 +53,13 @@
assertTrue(template.match("/bookstore/books/123", values));
assertFalse(rootCri.hasSubResources());
MethodDispatcher md = rootCri.getMethodDispatcher();
- assertEquals(4, md.getOperationResourceInfos().size());
+ assertEquals(5, md.getOperationResourceInfos().size());
for (OperationResourceInfo ori : md.getOperationResourceInfos()) {
if ("getBook".equals(ori.getMethod().getName())) {
+ assertEquals("GET", ori.getHttpMethod());
+ assertNotNull(ori.getURITemplate());
+ assertFalse(ori.isSubResourceLocator());
+ } else if ("getBookJSON".equals(ori.getMethod().getName())) {
assertEquals("GET", ori.getHttpMethod());
assertNotNull(ori.getURITemplate());
assertFalse(ori.isSubResourceLocator());
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java
Wed Jan 9 23:36:42 2008
@@ -43,26 +43,53 @@
List<ClassResourceInfo> resources =
((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
Map<String, String> values = new HashMap<String, String>();
+ String contentTypes = "*/*";
+ String acceptContentTypes = "*/*";
+ //If acceptContentTypes does not specify a specific Mime type, the
+ //method is declared with a most specific ProduceMime type is selected.
OperationResourceInfo ori =
JAXRSUtils.findTargetResourceClass(resources, "/bookstore/books/123/",
- "GET",
values);
+ "GET",
values, contentTypes,
+
acceptContentTypes);
+ assertNotNull(ori);
+ assertEquals("getBookJSON", ori.getMethod().getName());
+
+ //test
+ acceptContentTypes = "application/json";
+ ori = JAXRSUtils.findTargetResourceClass(resources,
"/bookstore/books/123/",
+ "GET",
values, contentTypes,
+
acceptContentTypes);
+ assertNotNull(ori);
+ assertEquals("getBookJSON", ori.getMethod().getName());
+
+ //test
+ acceptContentTypes = "application/xml";
+ ori = JAXRSUtils.findTargetResourceClass(resources,
"/bookstore/books/123/",
+ "GET",
values, contentTypes,
+
acceptContentTypes);
assertNotNull(ori);
assertEquals("getBook", ori.getMethod().getName());
+ //test find POST
ori = JAXRSUtils.findTargetResourceClass(resources, "/bookstore/books",
- "POST",
values);
+ "POST",
values, contentTypes,
+
acceptContentTypes);
assertNotNull(ori);
assertEquals("addBook", ori.getMethod().getName());
+ //test find PUT
ori = JAXRSUtils.findTargetResourceClass(resources, "/bookstore/books",
- "PUT",
values);
- assertNotNull(ori);
+ "PUT",
values, contentTypes,
+
acceptContentTypes);
assertEquals("updateBook", ori.getMethod().getName());
+ //test find DELETE
ori = JAXRSUtils.findTargetResourceClass(resources,
"/bookstore/books/123",
-
"DELETE", values);
+
"DELETE", values, contentTypes,
+
acceptContentTypes);
assertNotNull(ori);
- assertEquals("deleteBook", ori.getMethod().getName());
+ assertEquals("deleteBook", ori.getMethod().getName());
+
}
@Test
@@ -74,27 +101,128 @@
List<ClassResourceInfo> resources =
((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
Map<String, String> values = new HashMap<String, String>();
+ String contentTypes = "*/*";
+ String acceptContentTypes = "*/*";
OperationResourceInfo ori =
JAXRSUtils.findTargetResourceClass(resources,
"/bookstore/books/123/chapter/1",
- "GET",
values);
+ "GET",
values, contentTypes,
+
acceptContentTypes);
assertNotNull(ori);
assertEquals("getBook", ori.getMethod().getName());
ori = JAXRSUtils.findTargetResourceClass(resources, "/bookstore/books",
- "POST",
values);
+ "POST",
values, contentTypes,
+
acceptContentTypes);
assertNotNull(ori);
assertEquals("addBook", ori.getMethod().getName());
ori = JAXRSUtils.findTargetResourceClass(resources, "/bookstore/books",
- "PUT",
values);
+ "PUT",
values, contentTypes,
+
acceptContentTypes);
assertNotNull(ori);
assertEquals("updateBook", ori.getMethod().getName());
ori = JAXRSUtils.findTargetResourceClass(resources,
"/bookstore/books/123",
-
"DELETE", values);
+
"DELETE", values, contentTypes,
+
acceptContentTypes);
assertNotNull(ori);
assertEquals("deleteBook", ori.getMethod().getName());
}
+ @Test
+ public void testIntersectMimeTypes() throws Exception {
+ //test basic
+ String[] methodMimeTypes = new String[]{"application/mytype",
"application/xml", "application/json"};
+ String acceptContentType = "application/json";
+ String[] candidateList =
JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);
+
+ assertEquals(1, candidateList.length);
+ assertTrue(candidateList[0].equals("application/json"));
+
+ //test basic
+ methodMimeTypes = new String[]{"application/mytype",
"application/json", "application/xml"};
+ acceptContentType = "application/json";
+ candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes,
acceptContentType);
+
+ assertEquals(1, candidateList.length);
+ assertTrue(candidateList[0].equals("application/json"));
+
+ //test accept wild card */*
+ methodMimeTypes = new String[]{"application/mytype",
"application/json", "application/xml"};
+ acceptContentType = "*/*";
+ candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes,
acceptContentType);
+
+ assertEquals(3, candidateList.length);
+
+ //test accept wild card application/*
+ methodMimeTypes = new String[]{"text/html", "text/xml",
"application/xml"};
+ acceptContentType = "text/*";
+ candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes,
acceptContentType);
+
+ assertEquals(2, candidateList.length);
+ for (String type : candidateList) {
+ assertTrue("text/html".equals(type) || "text/xml".equals(type));
+ }
+
+ //test produce wild card */*
+ methodMimeTypes = new String[]{"*/*"};
+ acceptContentType = "application/json";
+ candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes,
acceptContentType);
+
+ assertEquals(1, candidateList.length);
+ assertTrue("application/json".equals(candidateList[0]));
+
+ //test produce wild card application/*
+ methodMimeTypes = new String[]{"application/*"};
+ acceptContentType = "application/json";
+ candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes,
acceptContentType);
+
+ assertEquals(1, candidateList.length);
+ assertTrue("application/json".equals(candidateList[0]));
+
+ //test produce wild card */*, accept wild card */*
+ methodMimeTypes = new String[]{"*/*"};
+ acceptContentType = "*/*";
+ candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes,
acceptContentType);
+
+ assertEquals(1, candidateList.length);
+ assertTrue("*/*".equals(candidateList[0]));
+ }
+
+ @Test
+ public void testIntersectMimeTypesTwoArray() throws Exception {
+ //test basic
+ String[] acceptedMimeTypes = new String[] {"application/mytype",
"application/xml",
+ "application/json"};
+ String[] providerMimeTypes = new String[] {"*/*"};
+
+ String[] candidateList =
JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, providerMimeTypes);
+
+ assertEquals(3, candidateList.length);
+ for (String type : candidateList) {
+ assertTrue("application/mytype".equals(type) ||
"application/xml".equals(type)
+ || "application/json".equals(type));
+ }
+
+ //test basic
+ acceptedMimeTypes = new String[] {"*/*"};
+ providerMimeTypes = new String[] {"application/mytype",
"application/xml", "application/json"};
+
+ candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes,
providerMimeTypes);
+
+ assertEquals(3, candidateList.length);
+ for (String type : candidateList) {
+ assertTrue("application/mytype".equals(type) ||
"application/xml".equals(type)
+ || "application/json".equals(type));
+ }
+
+ //test empty
+ acceptedMimeTypes = new String[] {"application/mytype",
"application/xml"};
+ providerMimeTypes = new String[] {"application/json"};
+
+ candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes,
providerMimeTypes);
+
+ assertEquals(0, candidateList.length);
+ }
}
Modified:
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java
Wed Jan 9 23:36:42 2008
@@ -21,6 +21,7 @@
package org.apache.cxf.jaxrs.resources;
import javax.ws.rs.HttpMethod;
+import javax.ws.rs.ProduceMime;
import javax.ws.rs.UriParam;
import javax.ws.rs.UriTemplate;
import javax.ws.rs.core.Response;
@@ -33,9 +34,17 @@
@HttpMethod("GET")
@UriTemplate("/books/{bookId}/")
+ @ProduceMime("application/xml")
public Book getBook(@UriParam("bookId") String id) {
return null;
}
+
+ @HttpMethod("GET")
+ @UriTemplate("/books/{bookId}/")
+ @ProduceMime("application/json")
+ public Book getBookJSON(@UriParam("bookId") String id) {
+ return null;
+ }
@HttpMethod("POST")
@UriTemplate("/books")
Modified:
incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++
incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Wed Jan 9 23:36:42 2008
@@ -271,6 +271,7 @@
inMessage.put(Message.ENCODING, normalizedEncoding);
inMessage.put(Message.QUERY_STRING, req.getQueryString());
inMessage.put(Message.CONTENT_TYPE, req.getContentType());
+ inMessage.put(Message.ACCEPT_CONTENT_TYPE,
req.getHeader("Accept"));
if (!StringUtils.isEmpty(endpointInfo.getAddress())) {
inMessage.put(Message.BASE_PATH, new
URL(endpointInfo.getAddress()).getPath());
}
Modified:
incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
(original)
+++
incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Wed Jan 9 23:36:42 2008
@@ -592,7 +592,8 @@
EasyMock.expect(request.getContextPath()).andReturn("/bar");
EasyMock.expect(request.getPathInfo()).andReturn("/foo");
EasyMock.expect(request.getCharacterEncoding()).andReturn("UTF-8");
- EasyMock.expect(request.getQueryString()).andReturn(query);
+ EasyMock.expect(request.getQueryString()).andReturn(query);
+ EasyMock.expect(request.getHeader("Accept")).andReturn("*/*");
EasyMock.expect(request.getContentType()).andReturn("text/xml
charset=utf8");
HttpFields httpFields = new HttpFields();
@@ -686,7 +687,7 @@
request.getCharacterEncoding();
EasyMock.expectLastCall().andReturn("UTF-8");
request.getQueryString();
- EasyMock.expectLastCall().andReturn("wsdl");
+ EasyMock.expectLastCall().andReturn("wsdl");
response.setContentType("text/xml");
EasyMock.expectLastCall();
response.getOutputStream();
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Wed Jan 9 23:36:42 2008
@@ -77,7 +77,7 @@
@HttpMethod("GET")
@UriTemplate("/booknames/{bookId}/")
- @ProduceMime("text/plain")
+ @ProduceMime("text/*")
public String getBookName(@UriParam("bookId") int id) throws
BookNotFoundFault {
System.out.println("----invoking getBookName with id: " + id);
Book book = books.get(new Long(id));
@@ -92,6 +92,7 @@
@HttpMethod("POST")
@UriTemplate("/books")
+ @ProduceMime("text/xml")
public Response addBook(Book book) {
System.out.println("----invoking addBook, book name is: " +
book.getName());
book.setId(++bookId);
@@ -160,11 +161,17 @@
@HttpMethod("GET")
@UriTemplate("/cd/{CDId}/")
+ @ProduceMime("application/xml")
+ public CD getCD(@UriParam("CDId") String id) {
+ System.out.println("----invoking getCD with cdId: " + id);
+ CD cd = cds.get(Long.parseLong(id));
+
+ return cd;
+ }
+
+ @HttpMethod("GET")
+ @UriTemplate("/cd/{CDId}/")
@ProduceMime("application/json")
- // FIXME: getCDJSON and getCDs dont have to use different URLs, but it
looks
- // like we are having problem
- // to match "/cds/" and "/cds/123" correctly using ".*?" as suggested by
- // spec. The former one's pattern is "/cds/(/)?" the later one is
"/cds/(.*?)(/)?
public CD getCDJSON(@UriParam("CDId") String id) {
System.out.println("----invoking getCDJSON with cdId: " + id);
CD cd = cds.get(Long.parseLong(id));
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Wed Jan 9 23:36:42 2008
@@ -292,14 +292,47 @@
public void testGetCDJSON() throws Exception {
String endpointAddress =
"http://localhost:9080/bookstore/cd/123";
- URL url = new URL(endpointAddress);
- InputStream in = url.openStream();
- assertNotNull(in);
- InputStream expected = getClass()
- .getResourceAsStream("resources/expected_get_cdjson.txt");
+ GetMethod get = new GetMethod(endpointAddress);
+ get.addRequestHeader("Accept" , "application/json");
- assertEquals(getStringFromInputStream(expected),
getStringFromInputStream(in));
+ HttpClient httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(get);
+ assertEquals(200, result);
+
+ InputStream expected =
getClass().getResourceAsStream("resources/expected_get_cdjson.txt");
+
+ assertEquals(getStringFromInputStream(expected),
get.getResponseBodyAsString());
+ } finally {
+ // Release current connection to the connection pool once you are
done
+ get.releaseConnection();
+ }
+ }
+
+
+ @Test
+ public void testGetCDXML() throws Exception {
+ String endpointAddress =
+ "http://localhost:9080/bookstore/cd/123";
+
+ GetMethod get = new GetMethod(endpointAddress);
+ get.addRequestHeader("Accept" , "application/xml");
+
+ HttpClient httpclient = new HttpClient();
+
+ try {
+ int result = httpclient.executeMethod(get);
+ assertEquals(200, result);
+
+ InputStream expected =
getClass().getResourceAsStream("resources/expected_get_cd.txt");
+
+ assertEquals(getStringFromInputStream(expected),
get.getResponseBodyAsString());
+ } finally {
+ // Release current connection to the connection pool once you are
done
+ get.releaseConnection();
+ }
}
private String getStringFromInputStream(InputStream in) throws Exception {
Modified:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java?rev=610703&r1=610702&r2=610703&view=diff
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
(original)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedOutsideBookTest.java
Wed Jan 9 23:36:42 2008
@@ -66,7 +66,7 @@
httpUrlConnection.setDoOutput(true);
httpUrlConnection.setDoInput(true);
httpUrlConnection.setRequestMethod("POST");
- httpUrlConnection.setRequestProperty("Accept", "text/html");
+ httpUrlConnection.setRequestProperty("Accept", "text/xml");
httpUrlConnection.setRequestProperty("Content-type", "text/html");
httpUrlConnection.setRequestProperty("Connection", "close");
//httpurlconnection.setRequestProperty("Content-Length",
String.valueOf(is.available()));
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_book123json.txt
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_book123json.txt?rev=610703&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_book123json.txt
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_book123json.txt
Wed Jan 9 23:36:42 2008
@@ -0,0 +1 @@
+{"Book":{"id":"123","name":"CXF in Action"}}
\ No newline at end of file
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_book123json.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_book123json.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cd.txt
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cd.txt?rev=610703&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cd.txt
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cd.txt
Wed Jan 9 23:36:42 2008
@@ -0,0 +1 @@
+<CD><id>123</id><name>BOHEMIAN RHAPSODY</name></CD>
\ No newline at end of file
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cd.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_get_cd.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain