Author: richard.opalka(a)jboss.com
Date: 2010-11-09 04:48:24 -0500 (Tue, 09 Nov 2010)
New Revision: 13245
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/JBWS3084TestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceIface.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/jbws3084/WEB-INF/wsdl/SaajService.wsdl
Log:
[JBWS-3084] refactoring - moving common part of the test to framework, CXF specific part
remains in CXF code base
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/JBWS3084TestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/JBWS3084TestCase.java 2010-11-09
09:33:00 UTC (rev 13244)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/JBWS3084TestCase.java 2010-11-09
09:48:24 UTC (rev 13245)
@@ -51,16 +51,6 @@
return new JBossWSCXFTestSetup(JBWS3084TestCase.class,
"saaj-soap-connection.war");
}
- public void testSoapConnectionPostWithoutChunkedEncoding() throws Exception
- {
- doTestSoapConnection(true);
- }
-
- public void testSoapConnectionPostWithChunkedEncoding() throws Exception
- {
- doTestSoapConnection(false);
- }
-
public void testSoapConnectionGet() throws Exception
{
final String serviceURL = "http://" + getServerHost() +
":8080/saaj-soap-connection/greetMe";
@@ -77,62 +67,4 @@
assertEquals(1, response.countAttachments());
}
-
- private void doTestSoapConnection(boolean disableChunking) throws Exception
- {
- SOAPFactory soapFac = SOAPFactory.newInstance();
- MessageFactory msgFac = MessageFactory.newInstance();
- SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();
- SOAPMessage msg = msgFac.createMessage();
-
- if (disableChunking)
- {
- // this is the custom header checked by ServiceImpl
- msg.getMimeHeaders().addHeader("Transfer-Encoding-Disabled",
"true");
- // this is a hint to SOAPConnection that the chunked encoding is not needed
- msg.getMimeHeaders().addHeader("Transfer-Encoding",
"disabled");
- }
-
- QName sayHi = new
QName("http://www.jboss.org/jbossws/saaj",
"sayHello");
- msg.getSOAPBody().addChildElement(soapFac.createElement(sayHi));
- AttachmentPart ap1 = msg.createAttachmentPart();
-
- char[] content = new char[16 * 1024];
- Arrays.fill(content, 'A');
-
- ap1.setContent(new String(content), "text/plain");
- msg.addAttachmentPart(ap1);
-
- AttachmentPart ap2 = msg.createAttachmentPart();
- ap2.setContent("Attachment content - Part 2", "text/plain");
- msg.addAttachmentPart(ap2);
- msg.saveChanges();
-
- SOAPConnection con = conFac.createConnection();
-
- final String serviceURL = "http://" + getServerHost() +
":8080/saaj-soap-connection";
-
- URL endpoint = new URL(serviceURL);
- SOAPMessage response = con.call(msg, endpoint);
- QName sayHiResp = new
QName("http://www.jboss.org/jbossws/saaj",
"sayHelloResponse");
-
- Iterator<?> sayHiRespIterator =
response.getSOAPBody().getChildElements(sayHiResp);
- SOAPElement soapElement = (SOAPElement) sayHiRespIterator.next();
- assertNotNull(soapElement);
-
- assertEquals(2, response.countAttachments());
-
- String[] values =
response.getMimeHeaders().getHeader("Transfer-Encoding-Disabled");
- if (disableChunking)
- {
- // this means that the ServiceImpl executed the code branch verifying
- // that chunking was disabled
- assertNotNull(values);
- assertTrue(values.length == 1);
- }
- else
- {
- assertNull(values);
- }
- }
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceIface.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceIface.java 2010-11-09
09:33:00 UTC (rev 13244)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceIface.java 2010-11-09
09:48:24 UTC (rev 13245)
@@ -28,8 +28,5 @@
public interface ServiceIface
{
@WebMethod
- String sayHello();
-
- @WebMethod
String greetMe();
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceImpl.java 2010-11-09
09:33:00 UTC (rev 13244)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/saaj/jbws3084/ServiceImpl.java 2010-11-09
09:48:24 UTC (rev 13245)
@@ -44,71 +44,6 @@
private WebServiceContext context;
@SuppressWarnings("unchecked")
- public String sayHello()
- {
- Map<String, List<String>> reqHeaders = (Map<String,
List<String>>) context.getMessageContext().get(
- MessageContext.HTTP_REQUEST_HEADERS);
-
- boolean chunkedEncodingDisabled =
reqHeaders.get("transfer-encoding-disabled") != null;
-
- List<String> transferEncHeader =
reqHeaders.get("transfer-encoding");
-
- if (!chunkedEncodingDisabled)
- {
- if (transferEncHeader == null || transferEncHeader.size() != 1)
- {
- throw new RuntimeException("Transfer-Encoding is missing");
- }
- if (!"chunked".equals(transferEncHeader.get(0)))
- {
- throw new RuntimeException("Wrong Transfer-Encoding value");
- }
- }
- else
- {
- if (transferEncHeader != null)
- {
- throw new RuntimeException("Unexpected Transfer-Encoding header");
- }
- Map<String, List<String>> respHeaders = (Map<String,
List<String>>) context.getMessageContext().get(
- MessageContext.HTTP_RESPONSE_HEADERS);
- if (respHeaders == null)
- {
- respHeaders = new HashMap<String, List<String>>();
- context.getMessageContext().put(MessageContext.HTTP_RESPONSE_HEADERS,
respHeaders);
- }
- respHeaders.put("Transfer-Encoding-Disabled",
Arrays.asList("true"));
- }
-
- Map<String, DataHandler> dataHandlers = (Map<String, DataHandler>)
context.getMessageContext().get(
- MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
-
- Map<String, DataHandler> outDataHandlers = (Map<String, DataHandler>)
context.getMessageContext().get(
- MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
-
- int index = 0;
- try
- {
- for (Map.Entry<String, DataHandler> entry : dataHandlers.entrySet())
- {
- InputStream is = entry.getValue().getInputStream();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- IOUtils.copyStream(baos, is);
- String name = Integer.toString(index++);
- DataHandler handler = new DataHandler(new InputStreamDataSource(
- new ByteArrayInputStream(baos.toByteArray()), "text/plain",
name));
- outDataHandlers.put(name, handler);
- }
- }
- catch (Exception ex)
- {
- throw new RuntimeException(ex);
- }
-
- return "Hello World!";
- }
-
- @SuppressWarnings("unchecked")
public String greetMe()
{
try
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/jbws3084/WEB-INF/wsdl/SaajService.wsdl
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/jbws3084/WEB-INF/wsdl/SaajService.wsdl 2010-11-09
09:33:00 UTC (rev 13244)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/saaj/jbws3084/WEB-INF/wsdl/SaajService.wsdl 2010-11-09
09:48:24 UTC (rev 13245)
@@ -1,76 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="SaajService"
targetNamespace="http://www.jboss.org/jbossws/saaj"
xmlns:tns="http://www.jboss.org/jbossws/saaj"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
-<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.jboss.org/jbossws/saaj"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://www.jboss.org/jbossws/saaj">
-<xsd:element name="sayHello" type="tns:sayHello"/>
-<xsd:complexType name="sayHello">
-<xsd:sequence/>
-</xsd:complexType>
-<xsd:element name="sayHelloResponse"
type="tns:sayHelloResponse"/>
-<xsd:complexType name="sayHelloResponse">
-<xsd:sequence>
-<xsd:element minOccurs="0" name="return"
type="xsd:string"/>
-</xsd:sequence>
-</xsd:complexType>
-<xsd:element name="greetMe" type="tns:greetMe"/>
-<xsd:complexType name="greetMe">
-<xsd:sequence/>
-</xsd:complexType>
-<xsd:element name="greetMeResponse"
type="tns:greetMeResponse"/>
-<xsd:complexType name="greetMeResponse">
-<xsd:sequence>
-<xsd:element minOccurs="0" name="return"
type="xsd:string"/>
-</xsd:sequence>
-</xsd:complexType>
-
-</xsd:schema>
+ <wsdl:types>
+ <xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.jboss.org/jbossws/saaj"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://www.jboss.org/jbossws/saaj">
+ <xsd:element name="greetMe" type="tns:greetMe"/>
+ <xsd:complexType name="greetMe">
+ <xsd:sequence/>
+ </xsd:complexType>
+ <xsd:element name="greetMeResponse"
type="tns:greetMeResponse"/>
+ <xsd:complexType name="greetMeResponse">
+ <xsd:sequence>
+ <xsd:element minOccurs="0" name="return"
type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:schema>
</wsdl:types>
- <wsdl:message name="sayHelloResponse">
- <wsdl:part name="parameters"
element="tns:sayHelloResponse">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="sayHello">
- <wsdl:part name="parameters" element="tns:sayHello">
- </wsdl:part>
- </wsdl:message>
<wsdl:message name="greetMeResponse">
- <wsdl:part name="parameters"
element="tns:greetMeResponse">
- </wsdl:part>
+ <wsdl:part name="parameters"
element="tns:greetMeResponse"/>
</wsdl:message>
+
<wsdl:message name="greetMe">
- <wsdl:part name="parameters" element="tns:greetMe">
- </wsdl:part>
+ <wsdl:part name="parameters" element="tns:greetMe"/>
</wsdl:message>
<wsdl:portType name="ServiceIface">
- <wsdl:operation name="sayHello">
- <wsdl:input name="sayHello" message="tns:sayHello">
- </wsdl:input>
- <wsdl:output name="sayHelloResponse"
message="tns:sayHelloResponse">
- </wsdl:output>
- </wsdl:operation>
-
<wsdl:operation name="greetMe">
- <wsdl:input name="greetMe" message="tns:greetMe">
- </wsdl:input>
- <wsdl:output name="greetMeResponse"
message="tns:greetMeResponse">
- </wsdl:output>
+ <wsdl:input name="greetMe" message="tns:greetMe"/>
+ <wsdl:output name="greetMeResponse"
message="tns:greetMeResponse"/>
</wsdl:operation>
-
</wsdl:portType>
+
<wsdl:binding name="SaajServiceSoapBinding"
type="tns:ServiceIface">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/wsdl/http/"/>
- <wsdl:operation name="sayHello">
- <soap:operation soapAction="" style="document"/>
- <wsdl:input name="sayHello">
- <soap:body use="literal"/>
- </wsdl:input>
- <wsdl:output name="sayHelloResponse">
- <soap:body use="literal"/>
- </wsdl:output>
- </wsdl:operation>
<wsdl:operation name="greetMe">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="greetMe">
@@ -81,9 +43,11 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
+
<wsdl:service name="SaajService">
<wsdl:port name="SaajServicePort"
binding="tns:SaajServiceSoapBinding">
<soap:address location="http://localhost:8080/SaajService"/>
</wsdl:port>
</wsdl:service>
+
</wsdl:definitions>