Allow user app server config; tests deployed WAR
diff --git a/dbws/config.properties b/dbws/config.properties
index 3aface3..de1068d 100644
--- a/dbws/config.properties
+++ b/dbws/config.properties
@@ -1,4 +1,5 @@
eclipselink.version=2.4.2-SNAPSHOT
eclipselink.home=
server.name=
-external.txn.controller.name=
\ No newline at end of file
+external.txn.controller.name=
+
diff --git a/dbws/dbws.simple/README.md b/dbws/dbws.simple/README.md
index bddfba0..45af487 100644
--- a/dbws/dbws.simple/README.md
+++ b/dbws/dbws.simple/README.md
@@ -1,7 +1,7 @@
EclipseLink DBWS: Simple Example
================================
-This simple example illustrates how EclipseLink DBWS can be used to generate a JAX-WS web service based on a very simple database schema.This example is based on:
+This simple example illustrates how EclipseLink DBWS can be used to generate a JAX-WS web service based on a very simple database schema. This example is based on:
http://wiki.eclipse.org/EclipseLink/Examples/DBWS/DBWSBasicTable
@@ -10,8 +10,25 @@
Running the Example
-------------------
-1. Download the example - Clone the examples GIT repo
-2. Configure the database information
-3. Run the tests: mvn test
+1. Download the example - Clone the examples GIT repo
+2. Configure database and application server information for use by the DBWS builder (dbws-builder.xml)
+3. Configure application server information for use by the DBWS runtime (../config.properties)
+ The following two properties must be set according to the target application server:
+ - server.name
+ - external.txn.controller.name
+ Valid values for each are:
+ - WebLogic
+ - org.eclipse.persistence.platform.server.wls.WebLogic_10_Platform
+ - org.eclipse.persistence.transaction.wls.WebLogicTransactionController
+ - GlassFish
+ - org.eclipse.persistence.platform.server.sunas.SunAS9ServerPlatform
+ - org.eclipse.persistence.transaction.sunas.SunAS9TransactionController
+ - JBoss
+ - org.eclipse.persistence.platform.server.jboss.JBossPlatform
+ - org.eclipse.persistence.transaction.jboss.JBossTransactionController
+ - WebSphere
+ - org.eclipse.persistence.platform.server.was.WebSphere_7_Platform
+ - org.eclipse.persistence.transaction.was.WebSphereTransactionController
4. Run the Packaging: mvn package
-5. Deploy WAR file to compatible target server
\ No newline at end of file
+5. Deploy WAR file to compatible target server
+6. Run the Integration Tests: mvn integration-test
diff --git a/dbws/dbws.simple/dbws-builder.xml b/dbws/dbws.simple/dbws-builder.xml
index e156f9a..b401cd9 100644
--- a/dbws/dbws.simple/dbws-builder.xml
+++ b/dbws/dbws.simple/dbws-builder.xml
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<dbws-builder version="1.2">
<properties>
- <property name="projectName">simpletable</property>
+ <property name="projectName">emp</property>
<property name="logLevel">all</property>
<property name="username">user</property>
<property name="password">password</property>
<property name="url">jdbc:mysql://localhost:3306/test</property>
<property name="driver">com.mysql.jdbc.Driver</property>
<property name="platformClassname">org.eclipse.persistence.platform.database.MySQLPlatform</property>
- <property name="dataSource">jdbc/DBWStestDS</property>
- <property name="wsdlLocationURI">http://localhost:8080/dbws.simple/simpletable?wsdl</property>
+ <property name="dataSource">jdbc/TestDS</property>
+ <property name="wsdlLocationURI">http://localhost:8080/dbws.simple/emp?wsdl</property>
</properties>
- <table schemaPattern="%" tableNamePattern="SIMPLETABLE" catalogPattern="%" />
+ <table schemaPattern="%" tableNamePattern="EMP" catalogPattern="%" />
</dbws-builder>
\ No newline at end of file
diff --git a/dbws/dbws.simple/pom.xml b/dbws/dbws.simple/pom.xml
index 1a7e7d0..ac3cd7d 100644
--- a/dbws/dbws.simple/pom.xml
+++ b/dbws/dbws.simple/pom.xml
@@ -103,28 +103,21 @@
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.servlet</artifactId>
<version>2.4.0</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.eclipse.persistence</groupId>
- <artifactId>dbws.builder</artifactId>
- <version>${eclipselink.version}</version>
- <scope>test</scope>
- </dependency>
-
+
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.wsdl</artifactId>
<version>1.6.2</version>
- <scope>provided</scope>
+ <scope>test</scope>
</dependency>
-
- <dependency>
+
+ <dependency>
<groupId>org.eclipse.persistence</groupId>
- <artifactId>javax.servlet</artifactId>
- <version>2.4.0</version>
- <scope>provided</scope>
+ <artifactId>dbws.builder</artifactId>
+ <version>${eclipselink.version}</version>
+ <scope>test</scope>
</dependency>
<dependency>
@@ -196,6 +189,43 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.7.2</version>
+ <executions>
+ <execution>
+ <id>emp-test</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <forkMode>once</forkMode>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <includes>
+ <include>**/EmpServiceTestSuite.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ <version>2.14.1</version>
+ <executions>
+ <execution>
+ <id>generate-emp-test-report</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
diff --git a/dbws/dbws.simple/src/test/java/dbws/EmpServiceTestSuite.java b/dbws/dbws.simple/src/test/java/dbws/EmpServiceTestSuite.java
new file mode 100644
index 0000000..8761012
--- /dev/null
+++ b/dbws/dbws.simple/src/test/java/dbws/EmpServiceTestSuite.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
+ * which accompanies this distribution.
+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
+ * and the Eclipse Distribution License is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php.
+ *
+ * Contributors:
+ * David McCann - May 10, 2013 - Initial implementation
+ ******************************************************************************/
+package dbws;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.eclipse.persistence.platform.xml.XMLComparer;
+import org.eclipse.persistence.platform.xml.XMLParser;
+import org.eclipse.persistence.platform.xml.XMLPlatform;
+import org.eclipse.persistence.platform.xml.XMLPlatformFactory;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests building a web service from table info.
+ *
+ */
+public class EmpServiceTestSuite {
+ static XMLComparer comparer = new XMLComparer();
+ static XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
+ static XMLParser xmlParser = xmlPlatform.newXMLParser();
+
+ static final String SOAP_FINDALL_REQUEST =
+ "<env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
+ "<env:Body>" +
+ "<findAll_empType xmlns=\"urn:empService\" xmlns:urn=\"urn:emp\"/>" +
+ "</env:Body>" +
+ "</env:Envelope>";
+ static final String SOAP_FINDALL_RESPONSE =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" +
+ "<srvc:findAll_empTypeResponse xmlns=\"urn:emp\" xmlns:srvc=\"urn:empService\">" +
+ "<srvc:result>" +
+ "<empType>" +
+ "<empno>7369</empno>" +
+ "<ename>SMITH</ename>" +
+ "<job>CLERK</job>" +
+ "<mgr>7902</mgr>" +
+ "<hiredate>1980-12-17</hiredate>" +
+ "<sal>800.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>20</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7499</empno>" +
+ "<ename>ALLEN</ename>" +
+ "<job>SALESMAN</job>" +
+ "<mgr>7698</mgr>" +
+ "<hiredate>1981-02-20</hiredate>" +
+ "<sal>1600.00</sal>" +
+ "<comm>300.00</comm>" +
+ "<deptno>30</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7521</empno>" +
+ "<ename>WARD</ename>" +
+ "<job>SALESMAN</job>" +
+ "<mgr>7698</mgr>" +
+ "<hiredate>1981-02-22</hiredate>" +
+ "<sal>1250.00</sal>" +
+ "<comm>500.00</comm>" +
+ "<deptno>30</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7566</empno>" +
+ "<ename>JONES</ename>" +
+ "<job>MANAGER</job>" +
+ "<mgr>7839</mgr>" +
+ "<hiredate>1981-04-02</hiredate>" +
+ "<sal>2975.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>20</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7654</empno>" +
+ "<ename>MARTIN</ename>" +
+ "<job>SALESMAN</job>" +
+ "<mgr>7698</mgr>" +
+ "<hiredate>1981-09-28</hiredate>" +
+ "<sal>1250.00</sal>" +
+ "<comm>1400.00</comm>" +
+ "<deptno>30</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7698</empno>" +
+ "<ename>BLAKE</ename>" +
+ "<job>MANAGER</job>" +
+ "<mgr>7839</mgr>" +
+ "<hiredate>1981-05-01</hiredate>" +
+ "<sal>2850.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>30</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7782</empno>" +
+ "<ename>CLARK</ename>" +
+ "<job>MANAGER</job>" +
+ "<mgr>7839</mgr>" +
+ "<hiredate>1981-06-09</hiredate>" +
+ "<sal>2450.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>10</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7788</empno>" +
+ "<ename>SCOTT</ename>" +
+ "<job>ANALYST</job>" +
+ "<mgr>7566</mgr>" +
+ "<hiredate>1981-06-09</hiredate>" +
+ "<sal>3000.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>20</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7839</empno>" +
+ "<ename>KING</ename>" +
+ "<job>PRESIDENT</job>" +
+ "<mgr xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<hiredate>1981-11-17</hiredate>" +
+ "<sal>5000.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>10</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7844</empno>" +
+ "<ename>TURNER</ename>" +
+ "<job>SALESMAN</job>" +
+ "<mgr>7698</mgr>" +
+ "<hiredate>1981-09-08</hiredate>" +
+ "<sal>1500.00</sal>" +
+ "<comm>0.00</comm>" +
+ "<deptno>30</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7876</empno>" +
+ "<ename>ADAMS</ename>" +
+ "<job>CLERK</job>" +
+ "<mgr>7788</mgr>" +
+ "<hiredate>1987-05-23</hiredate>" +
+ "<sal>1100.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>20</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7900</empno>" +
+ "<ename>JAMES</ename>" +
+ "<job>CLERK</job>" +
+ "<mgr>7698</mgr>" +
+ "<hiredate>1981-12-03</hiredate>" +
+ "<sal>950.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>30</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7902</empno>" +
+ "<ename>FORD</ename>" +
+ "<job>ANALYST</job>" +
+ "<mgr>7566</mgr>" +
+ "<hiredate>1981-12-03</hiredate>" +
+ "<sal>3000.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>20</deptno>" +
+ "</empType>" +
+ "<empType>" +
+ "<empno>7934</empno>" +
+ "<ename>MILLER</ename>" +
+ "<job>CLERK</job>" +
+ "<mgr>7782</mgr>" +
+ "<hiredate>1982-01-23</hiredate>" +
+ "<sal>1300.00</sal>" +
+ "<comm xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\"/>" +
+ "<deptno>10</deptno>" +
+ "</empType>" +
+ "</srvc:result>" +
+ "</srvc:findAll_empTypeResponse>";
+
+ @Test
+ public void testService() {
+ try {
+ QName qname = new QName("urn:empService", "empServicePort");
+ Service service = Service.create(new QName("urn:emp", "empService"));
+ service.addPort(qname, SOAPBinding.SOAP11HTTP_BINDING, "http://" + "localhost" + ":" + "8080" + "/dbws.simple/emp");
+ //service.addPort(qname, SOAPBinding.SOAP11HTTP_BINDING, "http://" + host + ":" + port + "/dbws.simple/simpletable");
+ Dispatch<SOAPMessage> sourceDispatch = service.createDispatch(qname, SOAPMessage.class, Service.Mode.MESSAGE);
+
+ SOAPMessage request = createSOAPMessage(SOAP_FINDALL_REQUEST);
+ SOAPMessage response = sourceDispatch.invoke(request);
+ assertNotNull("findAll_empType failed: response is null.", response);
+ SOAPBody responseBody = response.getSOAPPart().getEnvelope().getBody();
+ Document resultDoc = responseBody.extractContentAsDocument();
+ Document controlDoc = xmlParser.parse(new StringReader(SOAP_FINDALL_RESPONSE));
+
+ NodeList elts = resultDoc.getDocumentElement().getElementsByTagNameNS("urn:empService", "result");
+ assertTrue("The wrong number of elements were returned.", ((elts != null && elts.getLength() > 0) && elts.getLength() == 1));
+ Node testNode = elts.item(0);
+ assertTrue("Didn't find [<srvc:result>] element", testNode.getLocalName().equalsIgnoreCase("result"));
+ elts = controlDoc.getDocumentElement().getElementsByTagNameNS("urn:empService", "result");
+ Node ctrlNode = elts.item(0);
+ assertTrue("findAll_empType document comparison failed. Expected:\n" + documentToString(ctrlNode) + "\nbut was:\n" + documentToString(testNode), comparer.isNodeEqual(ctrlNode, testNode));
+ } catch (Exception x) {
+ fail("Service test failed: " + x.getMessage());
+ }
+ }
+
+
+ /**
+ * Create a SOAP message based on a given String.
+ */
+ public static SOAPMessage createSOAPMessage(String message) {
+ SOAPMessage soapMessage;
+ try {
+ MessageFactory factory = MessageFactory.newInstance();
+ soapMessage = factory.createMessage();
+ soapMessage.getSOAPPart().setContent((Source)new StreamSource(new StringReader(message)));
+ soapMessage.saveChanges();
+ } catch (Exception e) {
+ e.printStackTrace();
+ soapMessage = null;
+ }
+ return soapMessage;
+ }
+
+ /**
+ * Returns the given org.w3c.dom.Document as a String.
+ *
+ */
+ public static String documentToString(Node doc) {
+ DOMSource domSource = new DOMSource(doc);
+ StringWriter stringWriter = new StringWriter();
+ StreamResult result = new StreamResult(stringWriter);
+ try {
+ Transformer transformer = TransformerFactory.newInstance().newTransformer();
+ transformer.setOutputProperty("indent", "yes");
+ transformer.transform(domSource, result);
+ return stringWriter.toString();
+ } catch (Exception e) {
+ // e.printStackTrace();
+ return "<empty/>";
+ }
+ }
+}
\ No newline at end of file