From f18abd2aa0e272086f0e74f564285e449af79f16 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 27 Jul 2009 15:03:22 +0000 Subject: Add a second test source directory as we can't use src/main/java as it needs a compile dependency on the classes in the test folder git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@798181 13f79535-47bb-0310-9956-ffa450edef68 --- java/sca/otest/current/tests/pom.xml | 22 +++++ .../main/java/tuscany/TuscanyRuntimeBridge.java | 106 --------------------- .../main/ttest/tuscany/TuscanyRuntimeBridge.java | 106 +++++++++++++++++++++ 3 files changed, 128 insertions(+), 106 deletions(-) delete mode 100644 java/sca/otest/current/tests/src/main/java/tuscany/TuscanyRuntimeBridge.java create mode 100644 java/sca/otest/current/tests/src/main/ttest/tuscany/TuscanyRuntimeBridge.java diff --git a/java/sca/otest/current/tests/pom.xml b/java/sca/otest/current/tests/pom.xml index c9059512fc..cfa311844f 100644 --- a/java/sca/otest/current/tests/pom.xml +++ b/java/sca/otest/current/tests/pom.xml @@ -70,5 +70,27 @@ ${artifactId} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.3 + + + add-test-source + generate-sources + + add-test-source + + + + src/main/ttest + src/main/tests + + + + + + diff --git a/java/sca/otest/current/tests/src/main/java/tuscany/TuscanyRuntimeBridge.java b/java/sca/otest/current/tests/src/main/java/tuscany/TuscanyRuntimeBridge.java deleted file mode 100644 index 1b5b76e4b6..0000000000 --- a/java/sca/otest/current/tests/src/main/java/tuscany/TuscanyRuntimeBridge.java +++ /dev/null @@ -1,106 +0,0 @@ -package tuscany; - -import org.apache.tuscany.sca.node.Contribution; -import org.apache.tuscany.sca.node.ContributionLocationHelper; -import org.apache.tuscany.sca.node.Node; -import org.apache.tuscany.sca.node.NodeFactory; - -import client.RuntimeBridge; -import client.TestConfiguration; - -/** - * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x) - * @author Kelvin Goodson - * - */ -public class TuscanyRuntimeBridge implements RuntimeBridge { - - static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION"; - - protected NodeFactory launcher; - protected Node node; - TestConfiguration testConfiguration = null; - - public TuscanyRuntimeBridge() { - - } - - public TestConfiguration getTestConfiguration() { - return testConfiguration; - } - - public void setTestConfiguration(TestConfiguration testConfiguration) { - this.testConfiguration = testConfiguration; - } - - public boolean startContribution(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 ); - for( int i = 0; i < contributions.length ; i++ ) { - contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]); - } // end for - - node = launcher.createNode(testConfiguration.getComposite(), 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) throws Exception { - String[] locations; - locations = testConfiguration.getContributionNames(); - - if( locations != null && contributionLocation != null ) { - - for( int i=0; i < locations.length; i++ ) { - String aLocation = contributionLocation.replaceAll("%1", locations[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(); - node.destroy(); - } // end if - if (launcher != null) { - launcher.destroy(); - } // end if - } // end method stopContribution - - public String getContributionLocation(Class testClass) { - return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass()); - } // end method getContributionLocation - -} // end class TuscanyRuntimeBridge diff --git a/java/sca/otest/current/tests/src/main/ttest/tuscany/TuscanyRuntimeBridge.java b/java/sca/otest/current/tests/src/main/ttest/tuscany/TuscanyRuntimeBridge.java new file mode 100644 index 0000000000..1b5b76e4b6 --- /dev/null +++ b/java/sca/otest/current/tests/src/main/ttest/tuscany/TuscanyRuntimeBridge.java @@ -0,0 +1,106 @@ +package tuscany; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +import client.RuntimeBridge; +import client.TestConfiguration; + +/** + * An implementation of the Runtime Bridge for the Apache Tuscany SCA runtime (version 2.x) + * @author Kelvin Goodson + * + */ +public class TuscanyRuntimeBridge implements RuntimeBridge { + + static final String CONTRIBUTION_LOCATION_PROPKEY = "OASIS_TESTENV_CONTRIBUTION_LOCATION"; + + protected NodeFactory launcher; + protected Node node; + TestConfiguration testConfiguration = null; + + public TuscanyRuntimeBridge() { + + } + + public TestConfiguration getTestConfiguration() { + return testConfiguration; + } + + public void setTestConfiguration(TestConfiguration testConfiguration) { + this.testConfiguration = testConfiguration; + } + + public boolean startContribution(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 ); + for( int i = 0; i < contributions.length ; i++ ) { + contributions[i] = new Contribution(contributionNames[i], contributionURIs[i]); + } // end for + + node = launcher.createNode(testConfiguration.getComposite(), 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) throws Exception { + String[] locations; + locations = testConfiguration.getContributionNames(); + + if( locations != null && contributionLocation != null ) { + + for( int i=0; i < locations.length; i++ ) { + String aLocation = contributionLocation.replaceAll("%1", locations[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(); + node.destroy(); + } // end if + if (launcher != null) { + launcher.destroy(); + } // end if + } // end method stopContribution + + public String getContributionLocation(Class testClass) { + return ContributionLocationHelper.getContributionLocation(testConfiguration.getTestClass()); + } // end method getContributionLocation + +} // end class TuscanyRuntimeBridge -- cgit v1.2.3