summaryrefslogtreecommitdiffstats
path: root/java/sca/itest
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-14 13:47:22 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-14 13:47:22 +0000
commit5c6c6b427b6a2b0fbb89831576d9e8cd89e545bc (patch)
tree51a03427dde04cf19894cf83829cd5f19ae7753a /java/sca/itest
parent14cd6f4d9b362d7fc5a591959c9eaf8c08985230 (diff)
TUSCANY-2455: apply patch from Ramkumar Ramalingam for a test for Exception not thrown on duplicate component names within a composite
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685895 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/itest')
-rw-r--r--java/sca/itest/validation/src/test/java/calculator/warning/DuplicateComponentNameTestCase.java47
-rw-r--r--java/sca/itest/validation/src/test/java/domain/CustomCompositeBuilder.java15
2 files changed, 32 insertions, 30 deletions
diff --git a/java/sca/itest/validation/src/test/java/calculator/warning/DuplicateComponentNameTestCase.java b/java/sca/itest/validation/src/test/java/calculator/warning/DuplicateComponentNameTestCase.java
index ff1bd6cb09..4d70df1102 100644
--- a/java/sca/itest/validation/src/test/java/calculator/warning/DuplicateComponentNameTestCase.java
+++ b/java/sca/itest/validation/src/test/java/calculator/warning/DuplicateComponentNameTestCase.java
@@ -18,57 +18,44 @@
*/
package calculator.warning;
-import java.io.File;
-
import junit.framework.TestCase;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.logging.impl.DefaultLoggingMonitorImpl;
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCAContribution;
-import org.apache.tuscany.sca.node.SCANode2;
-import org.apache.tuscany.sca.node.SCANode2Factory;
-import org.apache.tuscany.sca.node.impl.NodeImpl;
+
+import domain.CustomCompositeBuilder;
/**
* This shows how to test the Calculator service component.
*/
public class DuplicateComponentNameTestCase extends TestCase {
- private CalculatorService calculatorService;
- private SCANode2 node;
-
+ private CustomCompositeBuilder customDomain;
+
@Override
- protected void setUp() throws Exception {
- SCANode2Factory nodeFactory = SCANode2Factory.newInstance();
- node = nodeFactory.createSCANode(new File("src/main/resources/DuplicateComponentName/Calculator.composite").toURL().toString(),
- new SCAContribution("TestContribution",
- new File("src/main/resources/DuplicateComponentName").toURL().toString()));
- /*
- node = SCANode2Factory.createSCANodeWithComposite("DuplicateComponentName/Calculator.composite");
- */
- node.start();
- calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent");
+ protected void setUp() throws Exception
+ {
+ customDomain = CustomCompositeBuilder.getInstance();
+ try {
+ customDomain.loadContribution("src/main/resources/DuplicateComponentName/Calculator.composite",
+ "TestContribution", "src/main/resources/DuplicateComponentName/");
+ customDomain.buildContribution();
+ } catch (Exception ex){
+ //throw ex;
+ }
}
@Override
protected void tearDown() throws Exception {
- node.stop();
+ //nothing to do
}
- public void testCalculator() throws Exception {
- ExtensionPointRegistry registry = ((NodeImpl)node).getExtensionPointRegistry();
- UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
- MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
- Monitor monitor = monitorFactory.createMonitor();
+ public void testCalculator() {
+ Monitor monitor = customDomain.getMonitorInstance();
Problem problem = ((DefaultLoggingMonitorImpl)monitor).getLastLoggedProblem();
assertNotNull(problem);
assertEquals("DuplicateComponentName", problem.getMessageId());
-
}
}
diff --git a/java/sca/itest/validation/src/test/java/domain/CustomCompositeBuilder.java b/java/sca/itest/validation/src/test/java/domain/CustomCompositeBuilder.java
index 9ad5407ed6..8665bfd535 100644
--- a/java/sca/itest/validation/src/test/java/domain/CustomCompositeBuilder.java
+++ b/java/sca/itest/validation/src/test/java/domain/CustomCompositeBuilder.java
@@ -27,10 +27,12 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.xml.namespace.QName;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl;
@@ -189,6 +191,19 @@ public class CustomCompositeBuilder {
return monitor;
}
+ public void buildContribution() throws Exception {
+ // Create a composite model for the domain
+ Composite domainComposite = assemblyFactory.createComposite();
+ domainComposite.setName(new QName("http://customdomain", "domain"));
+
+ // Add all deployables to it, normally the domain administrator would select
+ // the deployables to include
+ domainComposite.getIncludes().addAll(workspace.getDeployables());
+
+ // Build the domain composite and wire the components included in it
+ domainCompositeBuilder.build(domainComposite);
+ }
+
public void readContribution(String compositeURL, String sourceURI, String sourceURL) throws Exception {
init();