summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-03 13:45:30 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-03 13:45:30 +0000
commite5b11b62469b3ea4a0e3fcc038ab3f198f5b6a6c (patch)
tree80cfa4dbbd0a10bbd76995024897215543f46bc0
parent9cd7350c10d82df7320849727f41e4802826642f (diff)
Add runner for binding.ws otests
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@950995 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--otest/newlayout/tuscany-ws-test-runner/pom.xml195
-rw-r--r--otest/newlayout/tuscany-ws-test-runner/src/test/resources/oasis-sca-tests.properties30
-rw-r--r--otest/newlayout/tuscany-ws-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties31
-rw-r--r--otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java150
-rw-r--r--otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java217
5 files changed, 623 insertions, 0 deletions
diff --git a/otest/newlayout/tuscany-ws-test-runner/pom.xml b/otest/newlayout/tuscany-ws-test-runner/pom.xml
new file mode 100644
index 0000000000..0147cb00b2
--- /dev/null
+++ b/otest/newlayout/tuscany-ws-test-runner/pom.xml
@@ -0,0 +1,195 @@
+<?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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-otests-sca-ws-tests</artifactId>
+ <name>Apache Tuscany SCA Specification Tests for WS Binding</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-deployment</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-runtime-axis2</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-all</artifactId>
+ <version>5.2.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.ws</groupId>
+ <artifactId>jaxws-rt</artifactId>
+ <version>2.1.7</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ </dependencies>
+
+ <executions>
+
+ <execution>
+ <id>copy-files-from-svn</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant antfile="../build.xml">
+ <property name="from.dir" value="../sca-ws/Test_Client_BWS/src/main/resources"/>
+ <property name="to.dir" value="src/main/resources"/>
+ <target name="copyResourceDir"/>
+ </ant>
+ <ant antfile="../build.xml">
+ <property name="from.dir" value="../sca-ws/Test_Client_BWS/src/main/java"/>
+ <property name="to.dir" value="src/test/java"/>
+ <target name="copySourceDir"/>
+ </ant>
+ <ant antfile="../build.xml">
+ <property name="from.dir" value="../sca-assembly/Test_Client/src/main/java/testClient"/>
+ <property name="to.dir" value="src/test/java/testClient"/>
+ <target name="copySourceDir"/>
+ </ant>
+ <ant antfile="../build.xml">
+ <property name="from.file" value="../sca-assembly/Test_Client/src/main/java/client/BaseJAXWSTestRunner.java"/>
+ <property name="to.file" value="src/test/java/client/BaseJAXWSTestRunner.java"/>
+ <target name="copyFile"/>
+ </ant>
+ <ant antfile="../build.xml">
+ <property name="from.file" value="../sca-assembly/Test_Client/src/main/java/client/RuntimeBridge.java"/>
+ <property name="to.file" value="src/test/java/client/RuntimeBridge.java"/>
+ <target name="copyFile"/>
+ </ant>
+ <ant antfile="../build.xml">
+ <property name="from.file" value="../sca-assembly/Test_Client/src/main/java/client/TestConfiguration.java"/>
+ <property name="to.file" value="src/test/java/client/TestConfiguration.java"/>
+ <target name="copyFile"/>
+ </ant>
+ <ant antfile="../build.xml">
+ <property name="from.file" value="../sca-assembly/Test_Client/src/main/java/client/TuscanyRuntimeBridge.java"/>
+ <property name="to.file" value="src/test/java/client/TuscanyRuntimeBridge.java"/>
+ <target name="copyFile"/>
+ </ant>
+ <ant antfile="../build.xml">
+ <property name="from.file" value="../sca-assembly/Test_Client/src/main/resources/TestClient.wsdl"/>
+ <property name="to.file" value="src/main/resources/TestClient.wsdl"/>
+ <target name="copyFile"/>
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <id>add-test-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-test-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/test/tjava</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/otest/newlayout/tuscany-ws-test-runner/src/test/resources/oasis-sca-tests.properties b/otest/newlayout/tuscany-ws-test-runner/src/test/resources/oasis-sca-tests.properties
new file mode 100644
index 0000000000..1c9c109504
--- /dev/null
+++ b/otest/newlayout/tuscany-ws-test-runner/src/test/resources/oasis-sca-tests.properties
@@ -0,0 +1,30 @@
+# 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.
+
+# OASIS SCA Assembly test properties
+# The implementation type to use for Assembly test suite
+# org.oasis.sca.tests.assembly.lang=BPEL
+org.oasis.sca.tests.assembly.lang=Java
+
+# The class to use as the Runtime Bridge for the SCA runtime under test
+#org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyOSGiRuntimeBridge
+org.oasis.sca.tests.assembly.runtime_bridge=org.apache.tuscany.sca.otest.TuscanyRuntimeBridge
+
+# The location of the contributions for the test suite
+# %1 represents the placement of the name of each contribution into the location URI
+org.oasis.sca.tests.assembly.contribution.location=../sca-jms/%1/target/%1.zip
+
diff --git a/otest/newlayout/tuscany-ws-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties b/otest/newlayout/tuscany-ws-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
new file mode 100644
index 0000000000..3a3f346c7f
--- /dev/null
+++ b/otest/newlayout/tuscany-ws-test-runner/src/test/resources/tuscany-oasis-sca-tests-errors.properties
@@ -0,0 +1,31 @@
+# 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.
+
+BWS_2001=unknown message
+BWS_2002=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2002, Artifact: Test_BWS_2002.composite] - Invalid WebService binding wsdlElement attribute: http://test.sca.oasisopen.org/#wsdl.port(NonExistentPortName)
+BWS_2003=unknown message
+BWS_2005=org.oasisopen.sca.ServiceRuntimeException: [] - Exception while generating WSDL for TEST_BWS_2005Component1/Reference1 exception was: null
+BWS_2007=unknown message
+BWS_2011=unknown message
+BWS_2013=unknown message
+BWS_2015=unknown message
+BWS_2016=unknown message
+BWS_2017=unknown message
+BWS_2018=unknown message
+BWS_2019=org.oasisopen.sca.ServiceRuntimeException: [Contribution: BWS_2019, Artifact: Test_BWS_2019.composite] - XMLSchema validation error occured in: Test_BWS_2019.composite ,line = 36, column = 10, Message = cvc-complex-type.3.2.2: Attribute 'invalidAttribute' is not allowed to appear in element 'binding.ws'.
+BWS_2020=unknown message
+BWS_2022=unknown message \ No newline at end of file
diff --git a/otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java b/otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
new file mode 100644
index 0000000000..42cd7df60c
--- /dev/null
+++ b/otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyOSGiRuntimeBridge.java
@@ -0,0 +1,150 @@
+/*
+ * 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.tuscany.sca.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+import client.RuntimeBridge;
+import client.TestConfiguration;
+
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyOSGiRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeLauncher launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ public TuscanyOSGiRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public boolean startContribution(String compositeName, String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ launcher = NodeLauncher.newInstance();
+
+ Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation,contributionNames);
+ for (int i = 0; i < contributions.length; i++) {
+ contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+ } // end for
+
+ node = launcher.createNode(compositeName, contributions);
+ System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader());
+ // Start the node
+ node.start();
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation, String[] contributionNames) throws Exception {
+ String[] locations = new String[contributionNames.length];
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", contributionNames[i]);
+
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.destroy();
+ } // end if
+ } // end method stopContribution
+
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = ex.getMessage();
+
+ if (expectedMessage == null){
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ }
+
+ if (receivedMessage == null){
+ fail("Null received error message for test " + testName);
+ }
+
+ int messageStart = receivedMessage.indexOf("] - ");
+
+ if (messageStart < 0){
+ fail("Message separator not found for test " + testName);
+ }
+
+ receivedMessage = receivedMessage.substring(messageStart + 4);
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+ }
+
+} // end class TuscanyRuntimeBridge
diff --git a/otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java b/otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
new file mode 100644
index 0000000000..e7a161ae13
--- /dev/null
+++ b/otest/newlayout/tuscany-ws-test-runner/src/test/tjava/org/apache/tuscany/sca/otest/TuscanyRuntimeBridge.java
@@ -0,0 +1,217 @@
+/*
+ * 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.tuscany.sca.otest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+import testClient.TestException_Exception;
+import client.RuntimeBridge;
+
+/**
+ * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x)
+ *
+ */
+public class TuscanyRuntimeBridge implements RuntimeBridge {
+
+ static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION";
+
+ protected NodeFactory launcher;
+ protected Node node;
+ protected Properties expectedErrorMessages;
+
+ public TuscanyRuntimeBridge() {
+ // read test error mapping
+ expectedErrorMessages = new Properties();
+ try {
+ InputStream propertiesStream = this.getClass().getResourceAsStream("/tuscany-oasis-sca-tests-errors.properties");
+ expectedErrorMessages.load(propertiesStream);
+ } catch (IOException e) {
+ System.out.println("Unable to read oasis-sca-tests-errors.properties file");
+ }
+ }
+
+ public boolean startContribution(String compositeName, String contributionLocation, String[] contributionNames) throws Exception {
+ try {
+ // Tuscany specific code which starts the contribution(s) holding the test
+ launcher = NodeFactory.newInstance();
+
+ Contribution[] contributions = new Contribution[contributionNames.length];
+ String[] contributionURIs = getContributionURIs(contributionLocation, contributionNames);
+ for (int i = 0; i < contributions.length; i++) {
+ contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]);
+ } // end for
+
+ node = launcher.createNode(compositeName, contributions);
+ // Start the node
+ node.start();
+
+ // For debugging
+ // print out the composites that have been read in success cases
+ // System.out.println(((NodeImpl)node).dumpDomainComposite());
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ throw e;
+ } // end try
+
+ return true;
+ } // end method startContribution
+
+ /**
+ * Gets the location of the Contributions as URIs
+ * @param contributionLocation - a location pattern URI, which contains one or more "%1"
+ * substrings, which are substituted with the name of the contribution to get the URI of
+ * the contribution
+ * @return the contribution locations as an array of Strings
+ */
+ protected String[] getContributionURIs(String contributionLocation, String[] contributionNames) throws Exception {
+ String[] locations = new String[contributionNames.length];
+
+ if (locations != null && contributionLocation != null) {
+
+ for (int i = 0; i < locations.length; i++) {
+ String aLocation = contributionLocation.replaceAll("%1", contributionNames[i]);
+
+ locations[i] = aLocation;
+ } // end for
+ } else {
+ if (locations == null) {
+ // No contribution specified - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution supplied - error");
+ } else {
+ // No contribution location supplied - throw an Exception
+ throw new Exception("Unable to start SCA runtime - no contribution location supplied - error");
+ } // end if
+ } // end if
+
+ return locations;
+ } // end getContributionURI
+
+ public void stopContribution() {
+ if (node != null) {
+ node.stop();
+ } // end if
+ if (launcher != null) {
+ launcher.destroy();
+ } // end if
+ } // end method stopContribution
+
+ public void checkError(String testName, Throwable ex) throws Throwable {
+
+ String expectedMessage = expectedErrorMessages.getProperty(testName);
+ String receivedMessage = getErrorMessage(ex);//ex.getMessage();
+
+ if (expectedMessage == null){
+ writeMissingMessage(testName, ex);
+ fail("Null expected error message for test " + testName +
+ "Please add message to oasis-sca-tests-errors.properties");
+ } // end if
+
+ if (receivedMessage == null){
+ ex.printStackTrace();
+ fail("Null received error message for test " + testName);
+ } // end if
+
+ if (expectedMessage.startsWith("*")) {
+ // allow using * to ignore a message comparison
+ return;
+ }
+
+ // Deal with the case where the message has variable parts within it
+ // marked with the characters ***. Here we tokenize the expected string
+ // and make sure all the individual parts are present in the results string
+ String expectedMessageParts[] = expectedMessage.split("\\*\\*\\*");
+
+ if (expectedMessageParts.length > 1){
+ int foundParts = 0;
+ for(int i = 0; i < expectedMessageParts.length; i++){
+ if (receivedMessage.indexOf(expectedMessageParts[i]) > -1 ){
+ foundParts++;
+ }
+ }
+
+ if (foundParts == expectedMessageParts.length){
+ return;
+ }
+ }
+
+
+ // Deal with the case where the end of the message is variable (eg contains absolute filenames)
+ // and where the only relevant part is the start of the message - in this case the expected
+ // message only contains the stem section which is unchanging...
+ if( receivedMessage.length() > expectedMessage.length() ) {
+ // Truncate the received message to the length of the expected message
+ receivedMessage = receivedMessage.substring(0, expectedMessage.length() );
+ } // end if
+
+ if (!expectedMessage.equals(receivedMessage)) {
+ writeIncorrectMessage(testName, expectedMessage, receivedMessage);
+ }
+
+ assertEquals( expectedMessage, receivedMessage );
+
+ return;
+
+ }
+
+ protected void writeMissingMessage(String testName, Throwable ex) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestMissingMsgs.txt", true));
+ out.write(testName + "=*");
+ out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected void writeIncorrectMessage(String testName, String expected, String received) {
+ try {
+ BufferedWriter out = new BufferedWriter(new FileWriter("target/OTestIncorrectMsgs.txt", true));
+ out.write(testName); out.newLine();
+ out.write(" " + expected); out.newLine();
+ out.write(" " + received); out.newLine();
+ out.close();
+ } catch (IOException e) {
+ }
+ }
+
+ protected String getErrorMessage(Throwable ex) {
+ String errorMessage = null;
+
+ if (ex instanceof TestException_Exception) {
+ TestException_Exception te = (TestException_Exception) ex;
+ errorMessage = te.getFaultInfo().getMessage();
+ } else {
+ errorMessage = ex.getMessage();
+ }
+
+ return errorMessage;
+ }
+} // end class TuscanyRuntimeBridge