You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by mm...@apache.org on 2006/11/02 08:04:13 UTC
svn commit: r470251 - in /incubator/cxf/trunk:
codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/
rt/core/src/main/java/org/apache/cxf/interceptor/
rt/core/src/test/java/org/apache/cxf/transport/
rt/frontend/jaxws/src/test/java/org/apach...
Author: mmao
Date: Wed Nov 1 23:04:12 2006
New Revision: 470251
URL: http://svn.apache.org/viewvc?view=rev&rev=470251
Log:
Http GET update
* Decode the query string
Eclipse-plugin update
* re-organize the code
Modified:
incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/HttpUriMapperTest.java
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
Modified: incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java?view=diff&rev=470251&r1=470250&r2=470251
==============================================================================
--- incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java (original)
+++ incubator/cxf/trunk/codegen-plugin/src/main/java/org/apache/cxf/maven_plugin/eclipse/EclipsePluginMojo.java Wed Nov 1 23:04:12 2006
@@ -49,8 +49,7 @@
public class EclipsePluginMojo extends AbstractMojo {
private static final String LIB_PATH = "lib";
private static final String PLUGIN_XML = "plugin.xml";
- private static final String ECLIPSE_PLUGIN_TEMPLATE =
- "/org/apache/cxf/maven_plugin/eclipse/3.0/plugin.xml.vm";
+ private static final String ECLIPSE_PLUGIN_TEMPLATE = "/org/apache/cxf/maven_plugin/eclipse/3.0/plugin.xml.vm";
/**
* @parameter expression="${project}"
* @required
@@ -75,7 +74,7 @@
* @parameter
*/
String[] excludes;
-
+
/**
* @parameter
*/
@@ -89,7 +88,7 @@
baseDir = new File(targetDirectory, project.getGroupId() + "_" + project.getVersion());
libPath = new File(baseDir, LIB_PATH);
zipFile = new File(targetDirectory, project.getGroupId() + "_" + project.getVersion() + ".zip");
-
+
if (baseDir.exists()) {
FileUtils.removeDir(baseDir);
}
@@ -119,21 +118,19 @@
}
return false;
}
-
+
private void copyLicense() throws IOException {
- File licFile = new File(license);
+ File licFile = new File(license);
if (licFile != null && licFile.exists()) {
org.apache.tools.ant.util.FileUtils fileUtils = org.apache.tools.ant.util.FileUtils
- .newFileUtils();
+ .newFileUtils();
fileUtils.copyFile(licFile, new File(baseDir, "LICENSE"));
}
}
- public void execute() throws MojoExecutionException, MojoFailureException {
- init();
-
- if (dependencies != null && !dependencies.isEmpty()) {
- List jars = new ArrayList();
+ private List copyJars() throws Exception {
+ List jars = new ArrayList();
+ if (dependencies != null && !dependencies.isEmpty()) {
org.apache.tools.ant.util.FileUtils fileUtils = org.apache.tools.ant.util.FileUtils
.newFileUtils();
for (Iterator it = dependencies.iterator(); it.hasNext();) {
@@ -154,22 +151,25 @@
e.printStackTrace();
throw new MojoExecutionException(e.getMessage(), e);
}
-
jars.add(newJar);
- }
-
- try {
- generatePluginXML(jars, new File(baseDir, PLUGIN_XML));
- copyLicense();
- } catch (Exception e) {
- e.printStackTrace();
- throw new MojoExecutionException(e.getMessage(), e);
- }
-
- zip();
-
- cleanUp();
+ }
}
+ return jars;
+ }
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ init();
+
+ try {
+ generatePluginXML(copyJars(), new File(baseDir, PLUGIN_XML));
+ copyLicense();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+
+ zip();
+ cleanUp();
}
private void cleanUp() {
@@ -183,7 +183,7 @@
private String getVelocityLogFile(String log) {
return new File(targetDirectory, log).toString();
}
-
+
private String getVersion() {
return StringUtils.formatVersionNumber(project.getVersion());
}
@@ -203,11 +203,13 @@
private void generatePluginXML(List jars, File targetFile) throws Exception {
initVelocity();
- String templateName = ECLIPSE_PLUGIN_TEMPLATE;
-
Template tmpl = null;
- tmpl = Velocity.getTemplate(templateName);
+ tmpl = Velocity.getTemplate(ECLIPSE_PLUGIN_TEMPLATE);
+
+ if (tmpl == null) {
+ throw new RuntimeException("Can not load template file: " + ECLIPSE_PLUGIN_TEMPLATE);
+ }
VelocityContext ctx = new VelocityContext();
ctx.put("ECLIPSE_VERSION", "3.0");
@@ -220,9 +222,6 @@
outputs = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(targetFile)), "UTF-8");
VelocityWriter writer = new VelocityWriter(outputs);
- if (tmpl == null) {
- throw new RuntimeException("Can not load template file: " + templateName);
- }
tmpl.merge(ctx, writer);
writer.close();
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java?view=diff&rev=470251&r1=470250&r2=470251
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java Wed Nov 1 23:04:12 2006
@@ -19,8 +19,10 @@
package org.apache.cxf.interceptor;
+import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
+import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
@@ -146,11 +148,21 @@
}
return parameters;
}
+
+ private String uriDecode(String query) {
+ try {
+ query = URLDecoder.decode(query, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ LOG.warning(query + " can not be decoded: " + e.getMessage());
+ }
+ return query;
+ }
protected Map<String, String> getQueries(Message message) {
Map<String, String> queries = new LinkedHashMap<String, String>();
String query = (String)message.get(Message.QUERY_STRING);
if (!StringUtils.isEmpty(query)) {
+ query = uriDecode(query);
List<String> parts = Arrays.asList(query.split("&"));
for (String part : parts) {
String[] keyValue = part.split("=");
@@ -166,7 +178,7 @@
if (i + 1 > parts.size()) {
queries.put(parts.get(i), null);
} else {
- queries.put(parts.get(i), parts.get(i + 1));
+ queries.put(parts.get(i), uriDecode(parts.get(i + 1)));
}
}
return queries;
Modified: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/HttpUriMapperTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/HttpUriMapperTest.java?view=diff&rev=470251&r1=470250&r2=470251
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/HttpUriMapperTest.java (original)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/transport/HttpUriMapperTest.java Wed Nov 1 23:04:12 2006
@@ -28,12 +28,10 @@
public void testGetContext() throws Exception {
URL url = new URL("http://localhost:8080/SoapContext/SoapPort");
String path = url.getPath();
- System.err.println(path);
assertEquals("/SoapContext", HttpUriMapper.getContextName(path));
url = new URL("http://localhost:8080/SoapContext/SoapPort/");
path = url.getPath();
- System.err.println(path);
assertEquals("/SoapContext/SoapPort", HttpUriMapper.getContextName(path));
}
Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java?view=diff&rev=470251&r1=470250&r2=470251
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/URIMappingInterceptorRPCTest.java Wed Nov 1 23:04:12 2006
@@ -94,7 +94,7 @@
}
public void testGetGreetMeFromPath() throws Exception {
- message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe/me/king");
+ message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe/me/king+author");
URIMappingInterceptor interceptor = new URIMappingInterceptor();
interceptor.handleMessage(message);
@@ -105,7 +105,7 @@
assertNotNull(parameters);
assertEquals(1, ((List)parameters).size());
String value = (String) ((List)parameters).get(0);
- assertEquals("king", value);
+ assertEquals("king author", value);
}
public void testGetSayHiFromQuery() throws Exception {
@@ -122,5 +122,21 @@
assertEquals(1, ((List)parameters).size());
String value = (String) ((List)parameters).get(0);
assertEquals("king", value);
+ }
+
+ public void testGetSayHiFromQueryEncoded() throws Exception {
+ message.put(Message.PATH_INFO, "/SOAPServiceRPCLit/SoapPort/greetMe");
+ message.put(Message.QUERY_STRING, "?me=king+author");
+
+ URIMappingInterceptor interceptor = new URIMappingInterceptor();
+ interceptor.handleMessage(message);
+
+ assertNull(message.getContent(Exception.class));
+
+ Object parameters = message.getContent(List.class);
+ assertNotNull(parameters);
+ assertEquals(1, ((List)parameters).size());
+ String value = (String) ((List)parameters).get(0);
+ assertEquals("king author", value);
}
}
Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?view=diff&rev=470251&r1=470250&r2=470251
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java Wed Nov 1 23:04:12 2006
@@ -23,6 +23,7 @@
import java.lang.reflect.UndeclaredThrowableException;
import java.net.HttpURLConnection;
import java.net.URL;
+import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
@@ -476,7 +477,7 @@
public void testGetSayHi() throws Exception {
HttpURLConnection httpConnection =
- getHttpConnection("http://localhost:9000/SoapContext/SoapPort/sayHi");
+ getHttpConnection("http://localhost:9000/SoapContext/SoapPort/sayHi");
httpConnection.connect();
httpConnection.connect();
@@ -531,6 +532,36 @@
XPathConstants.STRING);
assertEquals("Hello cxf", response);
}
+
+ public void testGetGreetMeFromQuery() throws Exception {
+ String url =
+ URLEncoder.encode("http://localhost:9000/SoapContext/SoapPort/greetMe?me=cxf (was CeltixFire)",
+ "UTF-8");
+ HttpURLConnection httpConnection = getHttpConnection(url);
+ httpConnection.connect();
+
+ assertEquals(200, httpConnection.getResponseCode());
+
+ assertEquals("text/xml", httpConnection.getContentType());
+ assertEquals("OK", httpConnection.getResponseMessage());
+
+ InputStream in = httpConnection.getInputStream();
+ assertNotNull(in);
+
+ Document doc = XMLUtils.parse(in);
+ assertNotNull(doc);
+
+ Map<String, String> ns = new HashMap<String, String>();
+ ns.put("soap", Soap11.SOAP_NAMESPACE);
+ ns.put("ns2", "http://apache.org/hello_world_soap_http/types");
+ XPathUtils xu = new XPathUtils(ns);
+ Node body = (Node) xu.getValue("/soap:Envelope/soap:Body", doc, XPathConstants.NODE);
+ assertNotNull(body);
+ String response = (String) xu.getValue("//ns2:greetMeResponse/ns2:responseType/text()",
+ body,
+ XPathConstants.STRING);
+ assertEquals("Hello cxf", response);
+ }
public static void main(String[] args) {
junit.textui.TestRunner.run(ClientServerTest.class);