Author: ningjiang
Date: Thu Oct 4 22:49:08 2007
New Revision: 582082
URL: http://svn.apache.org/viewvc?rev=582082&view=rev
Log:
CXF-1086 got the http-jetty systest worked and also fixed the jaxws unitest
failures which were caused by my last commit
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/Dummy.java
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/DummyInterface.java
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
(with props)
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml
(with props)
Modified:
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
Modified:
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=582082&r1=582081&r2=582082&view=diff
==============================================================================
---
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
(original)
+++
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
Thu Oct 4 22:49:08 2007
@@ -237,10 +237,14 @@
private void invokeSetter(Method method, Object resource) {
try {
- method.setAccessible(true);
- Method targetMethod = getTarget().getClass().
+ method.setAccessible(true);
+ if
(method.getDeclaringClass().isAssignableFrom(getTarget().getClass())) {
+ method.invoke(getTarget(), resource);
+ } else { // deal with the proxy setter method
+ Method targetMethod = getTarget().getClass().
getMethod(method.getName(), new Class[]{resource.getClass()});
- targetMethod.invoke(getTarget(), resource);
+ targetMethod.invoke(getTarget(), resource);
+ }
} catch (IllegalAccessException e) {
LOG.log(Level.SEVERE, "INJECTION_SETTER_NOT_VISIBLE", method);
} catch (InvocationTargetException e) {
@@ -248,7 +252,7 @@
} catch (SecurityException e) {
LogUtils.log(LOG, Level.SEVERE,
"INJECTION_SETTER_RAISED_EXCEPTION", e, method);
} catch (NoSuchMethodException e) {
- LOG.log(Level.SEVERE, "INJECTION_SETTER_METHOD_NOT_FOUND", method);
+ LOG.log(Level.SEVERE, "INJECTION_SETTER_METHOD_NOT_FOUND", new
Object[] {method.getName()});
}
}
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/Dummy.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/Dummy.java?rev=582082&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/Dummy.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/Dummy.java
Thu Oct 4 22:49:08 2007
@@ -0,0 +1,32 @@
+/**
+ * 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.cxf.systest.http_jetty;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
[EMAIL PROTECTED]
+public class Dummy implements DummyInterface {
+ @WebMethod
+ public String echo(String what) {
+ return what;
+ }
+
+}
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/Dummy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/Dummy.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/DummyInterface.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/DummyInterface.java?rev=582082&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/DummyInterface.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/DummyInterface.java
Thu Oct 4 22:49:08 2007
@@ -0,0 +1,29 @@
+/**
+ * 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.cxf.systest.http_jetty;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
[EMAIL PROTECTED]
+public interface DummyInterface {
+ @WebMethod
+ String echo(String what);
+
+}
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/DummyInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/DummyInterface.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java?rev=582082&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
Thu Oct 4 22:49:08 2007
@@ -0,0 +1,148 @@
+/**
+ * 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.cxf.systest.http_jetty;
+
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Properties;
+
+
+import org.apache.cxf.helpers.IOUtils;
+
+import org.apache.cxf.io.CachedOutputStream;
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+
+
+/**
+ * This class tests starting up and shutting down the embedded server when
there
+ * is extra jetty configuration.
+ */
+public class EngineLifecycleTest extends Assert {
+ private GenericApplicationContext applicationContext;
+
+ private void readBeans(Resource beanResource) {
+ XmlBeanDefinitionReader reader = new
XmlBeanDefinitionReader(applicationContext);
+ reader.loadBeanDefinitions(beanResource);
+ }
+
+ public void setUpBus() throws Exception {
+ applicationContext = new GenericApplicationContext();
+ readBeans(new ClassPathResource("META-INF/cxf/cxf.xml"));
+ readBeans(new
ClassPathResource("META-INF/cxf/cxf-extension-soap.xml"));
+ readBeans(new
ClassPathResource("META-INF/cxf/cxf-extension-http.xml"));
+ readBeans(new
ClassPathResource("META-INF/cxf/cxf-extension-http-jetty.xml"));
+ readBeans(new ClassPathResource("jetty-engine.xml", getClass()));
+
+
+ // bring in some property values from a Properties file
+ PropertyPlaceholderConfigurer cfg = new
PropertyPlaceholderConfigurer();
+ Properties properties = new Properties();
+ properties.setProperty("staticResourceURL", getStaticResourceURL());
+ cfg.setProperties(properties);
+ // now actually do the replacement
+ cfg.postProcessBeanFactory(applicationContext.getBeanFactory());
+ applicationContext.refresh();
+ }
+
+ public void launchService() throws Exception {
+ applicationContext = new GenericApplicationContext();
+ readBeans(new ClassPathResource("server-lifecycle-beans.xml",
getClass()));
+ applicationContext.refresh();
+ }
+
+ private void invokeService() {
+ DummyInterface client = (DummyInterface)
applicationContext.getBean("dummy-client");
+ assertEquals("We should get out put from this client", "hello world",
client.echo("hello world"));
+ }
+
+ private HttpURLConnection getHttpConnection(String target) throws
Exception {
+ URL url = new URL(target);
+
+ URLConnection connection = url.openConnection();
+
+ assertTrue(connection instanceof HttpURLConnection);
+ return (HttpURLConnection)connection;
+ }
+
+ private void getTestHtml() throws Exception {
+ HttpURLConnection httpConnection =
+ getHttpConnection("http://localhost:8808/test.html");
+ httpConnection.connect();
+ InputStream in = httpConnection.getInputStream();
+ assertNotNull(in);
+ CachedOutputStream response = new CachedOutputStream();
+ IOUtils.copy(in, response);
+ in.close();
+ response.close();
+
+ FileInputStream htmlFile =
+ new
FileInputStream("target/test-classes/org/apache/cxf/systest/http_jetty/test.html");
+ CachedOutputStream html = new CachedOutputStream();
+ IOUtils.copy(htmlFile, html);
+ htmlFile.close();
+ html.close();
+
+ assertEquals("Can't get the right test html",
html.getOut().toString(), response.getOut().toString());
+
+
+
+ }
+
+ public String getStaticResourceURL() throws IOException {
+ File staticFile = new
File("target/test-classes/org/apache/cxf/systest/http_jetty/");
+ staticFile = staticFile.getAbsoluteFile();
+ URL furl = staticFile.toURL();
+ return furl.toString();
+ }
+
+ public void shutdownService() throws Exception {
+ applicationContext.destroy();
+ applicationContext.close();
+ }
+
+ @Test
+ public void testServerUpDownUp() throws Exception {
+ setUpBus();
+ launchService();
+ shutdownService();
+ try {
+ launchService();
+ invokeService();
+ getTestHtml();
+ } catch (java.net.BindException be) {
+ fail("bind exception");
+ }
+ shutdownService();
+ }
+
+}
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/EngineLifecycleTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml?rev=582082&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
Thu Oct 4 22:49:08 2007
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+ xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
+ xsi:schemaLocation="
+ http://cxf.apache.org/configuration/security
+ http://cxf.apache.org/schemas/configuration/security.xsd
+ http://cxf.apache.org/transports/http/configuration
+ http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://cxf.apache.org/transports/http-jetty/configuration
+ http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+ http://www.springframework.org/schema/beans
+
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+ <httpj:engine-factory bus="cxf">
+ <httpj:engine port="8808">
+ <httpj:handlers>
+ <bean class="org.mortbay.jetty.handler.ResourceHandler">
+ <property name="baseResource">
+ <bean class="org.mortbay.resource.FileResource">
+ <constructor-arg value="${staticResourceURL}" />
+ </bean>
+ </property>
+ </bean>
+ </httpj:handlers>
+ </httpj:engine>
+ </httpj:engine-factory>
+
+ </beans>
\ No newline at end of file
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/jetty-engine.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml?rev=582082&view=auto
==============================================================================
---
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml
(added)
+++
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml
Thu Oct 4 22:49:08 2007
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
+ http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+ ">
+
+ <bean id="aegisBean"
class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope='prototype'>
+ <property name='configuration'>
+ <bean class='org.apache.cxf.aegis.type.Configuration'>
+ <property name='defaultMinOccurs' value='1' />
+ <property name='defaultNillable' value='false' />
+ </bean>
+ </property>
+ </bean>
+
+ <!-- define a service factory that supports both JAX-WS annotations and also
Aegis files. -->
+ <bean id='jaxws-and-aegis-service-factory'
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
+ scope='prototype'>
+ <property name="dataBinding" ref="aegisBean" />
+ </bean>
+
+ <jaxws:endpoint id="dummy-service-endpoint"
implementor="org.apache.cxf.systest.http_jetty.Dummy"
address="http://localhost:8808/Dummy">
+ <jaxws:serviceFactory>
+ <ref bean='jaxws-and-aegis-service-factory' />
+ </jaxws:serviceFactory>
+ </jaxws:endpoint>
+
+ <bean id="dummy-client"
class="org.apache.cxf.systest.http_jetty.DummyInterface"
factory-bean="clientFactory" factory-method="create" />
+
+ <bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
+ <property name="serviceClass"
value="org.apache.cxf.systest.http_jetty.DummyInterface" />
+ <property name="address" value="http://localhost:8808/Dummy" />
+ </bean>
+
+</beans>
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/http_jetty/server-lifecycle-beans.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml