You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by as...@apache.org on 2010/08/18 18:00:32 UTC
svn commit: r986758 - in /cxf/trunk/rt: ./ frontend/jaxws/
frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/
frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/
frontend/jaxws/src/test/jaxws22/ frontend/jaxws/src/test/jaxws...
Author: asoldano
Date: Wed Aug 18 16:00:31 2010
New Revision: 986758
URL: http://svn.apache.org/viewvc?rev=986758&view=rev
Log:
[CXF-2845] Moving jaxws 2.2 http spi transport to frontend-jaxws module to simplify build
Added:
cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/
cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/
cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImpl.java
cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java
cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletResponseAdapter.java
cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java
cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactory.java
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImplTest.java
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestinationTest.java
cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactoryTest.java
Modified:
cxf/trunk/rt/frontend/jaxws/pom.xml
cxf/trunk/rt/pom.xml
Modified: cxf/trunk/rt/frontend/jaxws/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/pom.xml?rev=986758&r1=986757&r2=986758&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/pom.xml (original)
+++ cxf/trunk/rt/frontend/jaxws/pom.xml Wed Aug 18 16:00:31 2010
@@ -63,6 +63,10 @@
<artifactId>asm</artifactId>
</dependency>
<dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
<version>${project.version}</version>
@@ -90,6 +94,11 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-local</artifactId>
<version>${project.version}</version>
<optional>true</optional>
@@ -184,11 +193,6 @@
<id>jaxws22</id>
<dependencies>
<dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-transports-http-jaxws-spi</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jaxws_2.2_spec</artifactId>
</dependency>
@@ -214,6 +218,18 @@
</sources>
</configuration>
</execution>
+ <execution>
+ <id>add-jaxws22-test-source</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/src/test/jaxws22</source>
+ </sources>
+ </configuration>
+ </execution>
</executions>
</plugin>
<plugin>
@@ -325,6 +341,18 @@
</sources>
</configuration>
</execution>
+ <execution>
+ <id>add-jaxws22-test-source</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${basedir}/src/test/jaxws22</source>
+ </sources>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
Added: cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImpl.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImpl.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImpl.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,68 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import java.io.IOException;
+
+import javax.xml.ws.spi.http.HttpExchange;
+import javax.xml.ws.spi.http.HttpHandler;
+
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.wsdl.http.AddressType;
+
+/**
+ * A javax.xml.ws.spi.http.HttpHandler implementation that uses
+ * a JAXWSHttpSpiDestination instance for message processing
+ */
+public class HttpHandlerImpl extends HttpHandler {
+
+ private JAXWSHttpSpiDestination destination;
+
+ public HttpHandlerImpl(JAXWSHttpSpiDestination destination) {
+ this.destination = destination;
+ }
+
+ @Override
+ public void handle(HttpExchange exchange) throws IOException {
+ try {
+ //Update address in EndpointInfo; this can only happen here,
+ //as the contextPath is provided in the HttpExchange only
+ EndpointInfo ei = destination.getEndpointInfo();
+ if (ei != null) {
+ String ad = ei.getAddress();
+ String path = exchange.getHttpContext().getPath();
+ if (ad != null && ad.equals(path)) {
+ synchronized (ei) {
+ String contextPath = exchange.getContextPath();
+ ei.setAddress(contextPath + path);
+ if (ei.getExtensor(AddressType.class) != null) {
+ ei.getExtensor(AddressType.class).setLocation(contextPath + path);
+ }
+ }
+ }
+ }
+ //service request
+ destination.doService(new HttpServletRequestAdapter(exchange),
+ new HttpServletResponseAdapter(exchange));
+ } finally {
+ exchange.close();
+ }
+ }
+
+}
Added: cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletRequestAdapter.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,407 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.DispatcherType;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.Part;
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpExchange;
+
+import org.apache.commons.lang.NotImplementedException;
+
+/**
+ * This class provides a HttpServletRequest instance using information
+ * coming from the HttpExchange and HttpContext instances provided
+ * by the underlying container.
+ * Note: many methods' implementation still TODO.
+ *
+ */
+class HttpServletRequestAdapter implements HttpServletRequest {
+
+ private HttpExchange exchange;
+ private HttpContext context;
+ private String characterEncoding;
+ private ServletInputStreamAdapter servletInputStreamAdapter;
+ private BufferedReader reader;
+
+ public HttpServletRequestAdapter(HttpExchange exchange) {
+ this.exchange = exchange;
+ this.context = exchange.getHttpContext();
+ }
+
+ public AsyncContext getAsyncContext() {
+ throw new NotImplementedException();
+ }
+
+ public Object getAttribute(String name) {
+ return exchange.getAttribute(name);
+ }
+
+ public Enumeration<String> getAttributeNames() {
+ return Collections.enumeration(exchange.getAttributeNames());
+ }
+
+ public String getCharacterEncoding() {
+ return characterEncoding;
+ }
+
+ public int getContentLength() {
+ return 0;
+ }
+
+ public String getContentType() {
+ return this.getHeader("Content-Type");
+ }
+
+ public DispatcherType getDispatcherType() {
+ throw new NotImplementedException();
+ }
+
+ public ServletInputStream getInputStream() throws IOException {
+ if (servletInputStreamAdapter == null) {
+ servletInputStreamAdapter = new ServletInputStreamAdapter(exchange.getRequestBody());
+ }
+ return servletInputStreamAdapter;
+ }
+
+ public String getLocalAddr() {
+ InetSocketAddress isa = exchange.getLocalAddress();
+ if (isa != null) {
+ InetAddress ia = isa.getAddress();
+ if (ia != null) {
+ return ia.getHostAddress();
+ }
+ }
+ return null;
+ }
+
+ public Locale getLocale() {
+ return null;
+ }
+
+ public Enumeration<Locale> getLocales() {
+ throw new NotImplementedException();
+ }
+
+ public String getLocalName() {
+ InetSocketAddress isa = exchange.getLocalAddress();
+ if (isa != null) {
+ InetAddress ia = isa.getAddress();
+ if (ia != null) {
+ return ia.getHostName();
+ }
+ }
+ return null;
+ }
+
+ public int getLocalPort() {
+ InetSocketAddress isa = exchange.getLocalAddress();
+ return isa != null ? isa.getPort() : 0;
+ }
+
+ public String getParameter(String name) {
+ throw new NotImplementedException();
+ }
+
+ public Map<String, String[]> getParameterMap() {
+ throw new NotImplementedException();
+ }
+
+ public Enumeration<String> getParameterNames() {
+ throw new NotImplementedException();
+ }
+
+ public String[] getParameterValues(String name) {
+ throw new NotImplementedException();
+ }
+
+ public String getProtocol() {
+ return exchange.getProtocol();
+ }
+
+ public BufferedReader getReader() throws IOException {
+ if (reader == null) {
+ Reader isr = characterEncoding == null
+ ? new InputStreamReader(exchange.getRequestBody())
+ : new InputStreamReader(exchange.getRequestBody(), characterEncoding);
+ reader = new BufferedReader(isr);
+ }
+ return reader;
+ }
+
+ @Deprecated
+ public String getRealPath(String path) {
+ throw new NotImplementedException();
+ }
+
+ public String getRemoteAddr() {
+ InetSocketAddress isa = exchange.getRemoteAddress();
+ if (isa != null) {
+ InetAddress ia = isa.getAddress();
+ if (ia != null) {
+ return ia.getHostAddress();
+ }
+ }
+ return null;
+ }
+
+ public String getRemoteHost() {
+ InetSocketAddress isa = exchange.getRemoteAddress();
+ if (isa != null) {
+ InetAddress ia = isa.getAddress();
+ if (ia != null) {
+ return ia.getHostName();
+ }
+ }
+ return null;
+ }
+
+ public int getRemotePort() {
+ InetSocketAddress isa = exchange.getRemoteAddress();
+ return isa != null ? isa.getPort() : 0;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path) {
+ throw new NotImplementedException();
+ }
+
+ public String getScheme() {
+ return exchange.getScheme();
+ }
+
+ public String getServerName() {
+ return null;
+ }
+
+ public int getServerPort() {
+ return 0;
+ }
+
+ public ServletContext getServletContext() {
+ return null;
+ }
+
+ public boolean isAsyncStarted() {
+ throw new NotImplementedException();
+ }
+
+ public boolean isAsyncSupported() {
+ throw new NotImplementedException();
+ }
+
+ public boolean isSecure() {
+ throw new NotImplementedException();
+ }
+
+ public void removeAttribute(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setAttribute(String name, Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
+ this.characterEncoding = env;
+ }
+
+ public AsyncContext startAsync() {
+ throw new NotImplementedException();
+ }
+
+ public AsyncContext startAsync(ServletRequest request, ServletResponse response) {
+ throw new NotImplementedException();
+ }
+
+ public boolean authenticate(HttpServletResponse response) throws IOException, ServletException {
+ throw new NotImplementedException();
+ }
+
+ public String getAuthType() {
+ return null;
+ }
+
+ public String getContextPath() {
+ return exchange.getContextPath();
+ }
+
+ public Cookie[] getCookies() {
+ return null;
+ }
+
+ public long getDateHeader(String name) {
+ String s = this.getHeader(name);
+ return s != null ? Long.valueOf(s) : 0;
+ }
+
+ public String getHeader(String name) {
+ return exchange.getRequestHeader(name);
+ }
+
+ public Enumeration<String> getHeaderNames() {
+ return Collections.enumeration(exchange.getRequestHeaders().keySet());
+ }
+
+ public Enumeration<String> getHeaders(String name) {
+ List<String> list = exchange.getRequestHeaders().get(name);
+ return list != null ? Collections.enumeration(list) : null;
+ }
+
+ public int getIntHeader(String name) {
+ String s = this.getHeader(name);
+ return s != null ? Integer.valueOf(s) : 0;
+ }
+
+ public String getMethod() {
+ return exchange.getRequestMethod();
+ }
+
+ public Part getPart(String name) throws IOException, ServletException {
+ throw new NotImplementedException();
+ }
+
+ public Collection<Part> getParts() throws IOException, ServletException {
+ throw new NotImplementedException();
+ }
+
+ public String getPathInfo() {
+ return exchange.getPathInfo();
+ }
+
+ public String getPathTranslated() {
+ return null;
+ }
+
+ public String getQueryString() {
+ return exchange.getQueryString();
+ }
+
+ public String getRemoteUser() {
+ return null;
+ }
+
+ public String getRequestedSessionId() {
+ return null;
+ }
+
+ public String getRequestURI() {
+ return exchange.getRequestURI();
+ }
+
+ public StringBuffer getRequestURL() {
+ StringBuffer sb = new StringBuffer();
+ sb.append(exchange.getScheme());
+ sb.append("://");
+ InetSocketAddress la = exchange.getLocalAddress();
+ sb.append(la.getHostName());
+ if (la.getPort() > 0) {
+ sb.append(":");
+ sb.append(la.getPort());
+ }
+ sb.append(exchange.getContextPath());
+ sb.append(context.getPath());
+ return sb;
+ }
+
+ public String getServletPath() {
+ return null;
+ }
+
+ public HttpSession getSession() {
+ return null;
+ }
+
+ public HttpSession getSession(boolean create) {
+ return null;
+ }
+
+ public Principal getUserPrincipal() {
+ return exchange.getUserPrincipal();
+ }
+
+ public boolean isRequestedSessionIdFromCookie() {
+ throw new NotImplementedException();
+ }
+
+ @Deprecated
+ public boolean isRequestedSessionIdFromUrl() {
+ throw new NotImplementedException();
+ }
+
+ public boolean isRequestedSessionIdFromURL() {
+ throw new NotImplementedException();
+ }
+
+ public boolean isRequestedSessionIdValid() {
+ return false;
+ }
+
+ public boolean isUserInRole(String role) {
+ return exchange.isUserInRole(role);
+ }
+
+ public void login(String username, String password) throws ServletException {
+ throw new NotImplementedException();
+ }
+
+ public void logout() throws ServletException {
+ throw new NotImplementedException();
+ }
+
+ private class ServletInputStreamAdapter extends ServletInputStream {
+
+ private InputStream delegate;
+
+ public ServletInputStreamAdapter(InputStream delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public int read() throws IOException {
+ return delegate.read();
+ }
+ }
+}
Added: cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletResponseAdapter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletResponseAdapter.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletResponseAdapter.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpServletResponseAdapter.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,244 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.ws.spi.http.HttpExchange;
+
+import org.apache.commons.lang.NotImplementedException;
+
+/**
+ * This class provides a HttpServletResponse instance using information
+ * coming from the HttpExchange instance provided
+ * by the underlying container.
+ * Note: many methods' implementation still TODO.
+ *
+ */
+class HttpServletResponseAdapter implements HttpServletResponse {
+
+ private HttpExchange exchange;
+ private String characterEncoding;
+ private Locale locale;
+ private boolean committed;
+ private ServletOutputStreamAdapter servletOutputStream;
+ private PrintWriter writer;
+ private int status;
+
+ public HttpServletResponseAdapter(HttpExchange exchange) {
+ this.exchange = exchange;
+ }
+
+ public void flushBuffer() throws IOException {
+ exchange.getResponseBody().flush();
+ committed = true;
+ }
+
+ public int getBufferSize() {
+ throw new NotImplementedException();
+ }
+
+ public String getCharacterEncoding() {
+ return characterEncoding;
+ }
+
+ public String getContentType() {
+ return this.getHeader("Content-Type");
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException {
+ if (servletOutputStream == null) {
+ servletOutputStream = new ServletOutputStreamAdapter(exchange.getResponseBody());
+ }
+ return servletOutputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException {
+ if (writer == null) {
+ if (characterEncoding != null) {
+ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(exchange.getResponseBody(),
+ characterEncoding)));
+ } else {
+ writer = new PrintWriter(exchange.getResponseBody());
+ }
+ }
+ return writer;
+ }
+
+ public boolean isCommitted() {
+ return committed;
+ }
+
+ public void reset() {
+ throw new NotImplementedException();
+ }
+
+ public void resetBuffer() {
+ throw new NotImplementedException();
+ }
+
+ public void setBufferSize(int size) {
+ throw new NotImplementedException();
+ }
+
+ public void setCharacterEncoding(String charset) {
+ this.characterEncoding = charset;
+ }
+
+ public void setContentLength(int len) {
+ throw new NotImplementedException();
+ }
+
+ public void setContentType(String type) {
+ if (!committed) {
+ exchange.getResponseHeaders().put("Content-Type", Collections.singletonList(type));
+ }
+ }
+
+ public void setLocale(Locale loc) {
+ this.locale = loc;
+ }
+
+ public void addCookie(Cookie cookie) {
+ throw new NotImplementedException();
+ }
+
+ public void addDateHeader(String name, long date) {
+ this.addHeader(name, String.valueOf(date));
+ }
+
+ public void addHeader(String name, String value) {
+ exchange.addResponseHeader(name, value);
+ }
+
+ public void addIntHeader(String name, int value) {
+ this.addHeader(name, String.valueOf(value));
+ }
+
+ public boolean containsHeader(String name) {
+ return exchange.getResponseHeaders().containsKey(name);
+ }
+
+ public String encodeURL(String url) {
+ throw new NotImplementedException();
+ }
+
+ public String encodeRedirectURL(String url) {
+ throw new NotImplementedException();
+ }
+
+ @Deprecated
+ public String encodeUrl(String url) {
+ throw new NotImplementedException();
+ }
+
+ @Deprecated
+ public String encodeRedirectUrl(String url) {
+ throw new NotImplementedException();
+ }
+
+ public String getHeader(String name) {
+ List<String> headers = exchange.getResponseHeaders().get(name);
+ return (headers != null && !headers.isEmpty()) ? headers.get(0) : null;
+ }
+
+ public Collection<String> getHeaderNames() {
+ return exchange.getResponseHeaders().keySet();
+ }
+
+ public Collection<String> getHeaders(String headerName) {
+ return exchange.getResponseHeaders().get(headerName);
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void sendError(int sc) throws IOException {
+ this.setStatus(sc);
+ this.committed = true;
+ }
+
+ public void sendError(int sc, String msg) throws IOException {
+ this.sendError(sc);
+ }
+
+ public void sendRedirect(String location) throws IOException {
+ throw new NotImplementedException();
+ }
+
+ public void setDateHeader(String name, long date) {
+ this.setHeader(name, String.valueOf(date));
+ }
+
+ public void setHeader(String name, String value) {
+ List<String> list = new LinkedList<String>();
+ list.add(value);
+ exchange.getResponseHeaders().put(name, list);
+ }
+
+ public void setIntHeader(String name, int value) {
+ this.setHeader(name, String.valueOf(value));
+ }
+
+ public void setStatus(int sc) {
+ this.status = sc;
+ this.exchange.setStatus(sc);
+ }
+
+ @Deprecated
+ public void setStatus(int sc, String sm) {
+ this.setStatus(sc);
+ }
+
+ private class ServletOutputStreamAdapter extends ServletOutputStream {
+
+ private OutputStream delegate;
+
+ public ServletOutputStreamAdapter(OutputStream delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ delegate.write(b);
+ }
+
+ @Override
+ public void flush() throws IOException {
+ delegate.flush();
+ }
+ }
+}
Added: cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,172 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.continuations.SuspendedInvocationException;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.HTTPSession;
+import org.apache.cxf.transports.http.QueryHandler;
+import org.apache.cxf.transports.http.QueryHandlerRegistry;
+import org.apache.cxf.transports.http.StemMatchingQueryHandler;
+
+public class JAXWSHttpSpiDestination extends AbstractHTTPDestination {
+
+ static final Logger LOG = LogUtils.getL7dLogger(JAXWSHttpSpiDestination.class);
+
+ private static final long serialVersionUID = 1L;
+
+ public JAXWSHttpSpiDestination(Bus b, EndpointInfo ei)
+ throws IOException {
+ super(b, ei, false);
+ }
+
+ @Override
+ protected Logger getLogger() {
+ return LOG;
+ }
+
+ /**
+ * This is called by handlers for servicing requests
+ *
+ * @param context
+ * @param req
+ * @param resp
+ * @throws IOException
+ */
+ protected void doService(HttpServletRequest req, HttpServletResponse resp)
+ throws IOException {
+
+ QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
+
+ if (null != req.getQueryString() && queryHandlerRegistry != null) {
+ String reqAddr = req.getRequestURL().toString();
+ String requestURL = reqAddr + "?" + req.getQueryString();
+ String pathInfo = req.getPathInfo();
+ for (QueryHandler qh : queryHandlerRegistry.getHandlers()) {
+ boolean recognized =
+ qh instanceof StemMatchingQueryHandler
+ ? ((StemMatchingQueryHandler)qh).isRecognizedQuery(requestURL,
+ pathInfo,
+ endpointInfo,
+ contextMatchOnExact())
+ : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
+ if (recognized) {
+ //replace the endpointInfo address with request url only for get wsdl
+ String errorMsg = null;
+ CachedOutputStream out = new CachedOutputStream();
+ try {
+ synchronized (endpointInfo) {
+ String oldAddress = endpointInfo.getAddress();
+ endpointInfo.setAddress(reqAddr);
+ resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
+ try {
+ qh.writeResponse(requestURL, pathInfo, endpointInfo, out);
+ } catch (Exception ex) {
+ LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+ errorMsg = ex.getMessage();
+ }
+ endpointInfo.setAddress(oldAddress);
+ }
+ if (errorMsg != null) {
+ resp.sendError(500, errorMsg);
+ } else {
+ out.writeCacheTo(resp.getOutputStream());
+ resp.getOutputStream().flush();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ } finally {
+ out.close();
+ }
+ return;
+ }
+ }
+ }
+
+ try {
+ BusFactory.setThreadDefaultBus(bus);
+ serviceRequest(req, resp);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ BusFactory.setThreadDefaultBus(null);
+ }
+ }
+
+ protected void serviceRequest(final HttpServletRequest req, final HttpServletResponse resp)
+ throws IOException {
+
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Service http request on thread: " + Thread.currentThread());
+ }
+ Message inMessage = new MessageImpl();
+ setupMessage(inMessage, null, req, resp);
+
+ ((MessageImpl)inMessage).setDestination(this);
+
+ ExchangeImpl exchange = new ExchangeImpl();
+ exchange.setInMessage(inMessage);
+ exchange.setSession(new HTTPSession(req));
+
+ try {
+ incomingObserver.onMessage(inMessage);
+ resp.flushBuffer();
+ } catch (SuspendedInvocationException ex) {
+ if (ex.getRuntimeException() != null) {
+ throw ex.getRuntimeException();
+ }
+ // else nothing to do
+ } catch (Fault ex) {
+ Throwable cause = ex.getCause();
+ if (cause instanceof RuntimeException) {
+ throw (RuntimeException)cause;
+ } else {
+ throw ex;
+ }
+ } catch (RuntimeException ex) {
+ throw ex;
+ } finally {
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Finished servicing http request on thread: " + Thread.currentThread());
+ }
+ }
+ }
+
+ protected String getBasePath(String contextPath) throws IOException {
+ return contextPath + getAddress().getAddress().getValue();
+ }
+
+}
Added: cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactory.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactory.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactory.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,52 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import java.io.IOException;
+
+import javax.xml.ws.spi.http.HttpContext;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
+
+public class JAXWSHttpSpiTransportFactory extends AbstractHTTPTransportFactory implements DestinationFactory {
+
+ private HttpContext context;
+ private JAXWSHttpSpiDestination destination;
+
+ public JAXWSHttpSpiTransportFactory(Bus bus, HttpContext context) {
+ super();
+ this.context = context;
+ this.bus = bus; //directly set the bus to prevent this factory from being registered
+ }
+
+ public Destination getDestination(EndpointInfo endpointInfo) throws IOException {
+ if (destination == null) {
+ destination = new JAXWSHttpSpiDestination(getBus(), endpointInfo);
+ // set handler into the provided HttpContext, our Destination hook into the server container
+ HttpHandlerImpl handler = new HttpHandlerImpl(destination);
+ context.setHandler(handler);
+ }
+ return destination;
+ }
+
+}
Added: cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImplTest.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImplTest.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/HttpHandlerImplTest.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,67 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.ws.spi.http.HttpExchange;
+import javax.xml.ws.spi.http.HttpHandler;
+
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class HttpHandlerImplTest extends Assert {
+
+ private IMocksControl control;
+ private HttpHandler handler;
+ private JAXWSHttpSpiDestination destination;
+ private HttpExchange exchange;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ destination = control.createMock(JAXWSHttpSpiDestination.class);
+ handler = new HttpHandlerImpl(destination);
+ exchange = control.createMock(HttpExchange.class);
+ }
+
+ @After
+ public void tearDown() {
+ exchange = null;
+ handler = null;
+ destination = null;
+ control = null;
+ }
+
+ @Test
+ public void testHttpHandlerImpl() throws Exception {
+ exchange.close();
+ destination.doService(EasyMock.isA(HttpServletRequest.class),
+ EasyMock.isA(HttpServletResponse.class));
+ control.replay();
+
+ handler.handle(exchange);
+ control.verify();
+ }
+
+}
Added: cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestinationTest.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestinationTest.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestinationTest.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,167 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpExchange;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.transport.http.WSDLQueryHandler;
+import org.apache.cxf.transports.http.QueryHandler;
+import org.apache.cxf.transports.http.QueryHandlerRegistry;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.easymock.classextension.EasyMock.eq;
+import static org.easymock.classextension.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.isA;
+
+public class JAXWSHttpSpiDestinationTest extends Assert {
+
+ private static final String ADDRESS = "http://localhost:80/foo/bar";
+ private static final String CONTEXT_PATH = "/foo";
+ private static final String PATH = "/bar";
+ private IMocksControl control;
+ private Bus bus;
+ private HttpContext context;
+ private MessageObserver observer;
+ private EndpointInfo endpoint;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ bus = control.createMock(Bus.class);
+ observer = control.createMock(MessageObserver.class);
+ context = control.createMock(HttpContext.class);
+ endpoint = new EndpointInfo();
+ endpoint.setAddress(ADDRESS);
+ }
+
+ @After
+ public void tearDown() {
+ context = null;
+ bus = null;
+ observer = null;
+ }
+
+ @Test
+ public void testCtor() throws Exception {
+ JAXWSHttpSpiDestination destination =
+ new JAXWSHttpSpiDestination(bus, endpoint);
+
+ assertNull(destination.getMessageObserver());
+ assertNotNull(destination.getAddress());
+ assertNotNull(destination.getAddress().getAddress());
+ assertEquals(ADDRESS,
+ destination.getAddress().getAddress().getValue());
+ }
+
+ @Test
+ public void testMessage() throws Exception {
+ expect(bus.getExtension(QueryHandlerRegistry.class)).andReturn(null);
+ HttpExchange exchange = setUpExchange();
+ control.replay();
+
+ JAXWSHttpSpiDestination destination =
+ new JAXWSHttpSpiDestination(bus, endpoint);
+ destination.setMessageObserver(observer);
+
+ destination.doService(new HttpServletRequestAdapter(exchange),
+ new HttpServletResponseAdapter(exchange));
+
+ control.verify();
+ }
+
+ @Test
+ public void testWSDLQuery() throws Exception {
+ WSDLQueryHandler wqh = control.createMock(WSDLQueryHandler.class);
+ String pathInfo = null;
+ String addr = ADDRESS + "?wsdl";
+ expect(wqh.isRecognizedQuery(addr, pathInfo, endpoint, false)).andReturn(true);
+ wqh.writeResponse(eq(addr), eq(pathInfo), eq(endpoint), isA(OutputStream.class));
+ EasyMock.expectLastCall();
+ QueryHandlerRegistry qhr = control.createMock(QueryHandlerRegistry.class);
+ expect(qhr.getHandlers()).andReturn(Collections.singletonList((QueryHandler)wqh));
+ expect(bus.getExtension(QueryHandlerRegistry.class)).andReturn(qhr);
+ HttpExchange exchange = setUpExchangeForWSDLQuery(pathInfo);
+ control.replay();
+
+ JAXWSHttpSpiDestination destination =
+ new JAXWSHttpSpiDestination(bus, endpoint);
+ destination.setMessageObserver(observer);
+
+ destination.doService(new HttpServletRequestAdapter(exchange),
+ new HttpServletResponseAdapter(exchange));
+
+ control.verify();
+ }
+
+ private HttpExchange setUpExchange() throws Exception {
+ HttpExchange exchange = control.createMock(HttpExchange.class);
+ expect(exchange.getHttpContext()).andReturn(context).anyTimes();
+ expect(exchange.getQueryString()).andReturn(null);
+ expect(exchange.getPathInfo()).andReturn(null);
+ expect(exchange.getContextPath()).andReturn(CONTEXT_PATH);
+ Map<String, List<String>> reqHeaders = new HashMap<String, List<String>>();
+ reqHeaders.put("Content-Type", Collections.singletonList("text/xml"));
+ expect(exchange.getRequestHeaders()).andReturn(reqHeaders).anyTimes();
+ OutputStream responseBody = control.createMock(OutputStream.class);
+ responseBody.flush();
+ EasyMock.expectLastCall();
+ expect(exchange.getResponseBody()).andReturn(responseBody).anyTimes();
+ observer.onMessage(isA(Message.class));
+ EasyMock.expectLastCall();
+
+ return exchange;
+ }
+
+ private HttpExchange setUpExchangeForWSDLQuery(String pathInfo) throws Exception {
+ HttpExchange exchange = control.createMock(HttpExchange.class);
+ expect(exchange.getHttpContext()).andReturn(context).anyTimes();
+ expect(exchange.getQueryString()).andReturn("wsdl").anyTimes();
+ expect(exchange.getPathInfo()).andReturn(pathInfo);
+ expect(context.getPath()).andReturn(PATH);
+ expect(exchange.getContextPath()).andReturn(CONTEXT_PATH);
+ expect(exchange.getScheme()).andReturn("http");
+ expect(exchange.getLocalAddress()).andReturn(new InetSocketAddress("localhost", 80));
+ Map<String, List<String>> resHeaders = new HashMap<String, List<String>>();
+ expect(exchange.getResponseHeaders()).andReturn(resHeaders).anyTimes();
+ OutputStream responseBody = control.createMock(OutputStream.class);
+ responseBody.flush();
+ EasyMock.expectLastCall();
+ expect(exchange.getResponseBody()).andReturn(responseBody).anyTimes();
+
+ return exchange;
+ }
+
+}
Added: cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactoryTest.java?rev=986758&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactoryTest.java (added)
+++ cxf/trunk/rt/frontend/jaxws/src/test/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiTransportFactoryTest.java Wed Aug 18 16:00:31 2010
@@ -0,0 +1,82 @@
+/**
+ * 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.transport.http_jaxws_spi;
+
+import javax.xml.ws.spi.http.HttpContext;
+import javax.xml.ws.spi.http.HttpHandler;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JAXWSHttpSpiTransportFactoryTest extends Assert {
+
+ private IMocksControl control;
+ private HttpContext context;
+ private JAXWSHttpSpiTransportFactory factory;
+ private Bus bus;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ context = control.createMock(HttpContext.class);
+ bus = control.createMock(Bus.class);
+ factory = new JAXWSHttpSpiTransportFactory(bus, context);
+ }
+
+ @After
+ public void tearDown() {
+ factory = null;
+ context = null;
+ bus = null;
+ }
+
+ @Test
+ public void testGetDestination1() throws Exception {
+ getDestination("/bar");
+ }
+
+ @Test
+ public void testGetDestination2() throws Exception {
+ getDestination("http://localhost:8080/foo/bar");
+ }
+
+ public void getDestination(String endpointAddress) throws Exception {
+ context.setHandler(EasyMock.isA(HttpHandler.class));
+ control.replay();
+
+ EndpointInfo endpoint = new EndpointInfo();
+ endpoint.setAddress(endpointAddress);
+
+ Destination destination = factory.getDestination(endpoint);
+ assertNotNull(destination);
+ assertNotNull(destination.getAddress());
+ assertNotNull(destination.getAddress().getAddress());
+ assertEquals(endpointAddress, destination.getAddress().getAddress().getValue());
+ assertEquals(endpointAddress, endpoint.getAddress());
+ control.verify();
+ }
+
+}
Modified: cxf/trunk/rt/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/pom.xml?rev=986758&r1=986757&r2=986758&view=diff
==============================================================================
--- cxf/trunk/rt/pom.xml (original)
+++ cxf/trunk/rt/pom.xml Wed Aug 18 16:00:31 2010
@@ -58,13 +58,4 @@
<module>javascript</module>
</modules>
- <profiles>
- <profile>
- <id>jaxws22</id>
- <modules>
- <module>transports/http-jaxws-spi</module>
- </modules>
- </profile>
- </profiles>
-
</project>