summaryrefslogtreecommitdiffstats
path: root/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java')
-rw-r--r--sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java32
1 files changed, 25 insertions, 7 deletions
diff --git a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java
index 41f6d95f3c..f30b5c9853 100644
--- a/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java
+++ b/sandbox/sebastien/java/embed/samples/implementation-extension/src/test/java/sample/impl/EmbedTestCase.java
@@ -25,8 +25,10 @@ import static sample.impl.EmbedUtil.component;
import static sample.impl.EmbedUtil.composite;
import static sample.impl.EmbedUtil.contrib;
import static sample.impl.EmbedUtil.deploy;
+import static sample.impl.EmbedUtil.extensionPoints;
import static sample.impl.EmbedUtil.implementation;
import static sample.impl.EmbedUtil.node;
+import static sample.impl.EmbedUtil.providerFactories;
import static sample.impl.EmbedUtil.reference;
import static sample.impl.EmbedUtil.service;
import static sample.impl.EmbedUtil.wsdli;
@@ -36,6 +38,9 @@ import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.contribution.Contribution;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -50,7 +55,8 @@ import sample.WelloTest;
/**
* Test how to assemble a contribution, a SCDL composite and run it on an embedded
- * Tuscany runtime node.
+ * Tuscany runtime node. Also shows how pass in a ProviderFactory instead of having
+ * it loaded and constructed by the runtime node.
*
* @version $Rev$ $Date$
*/
@@ -60,12 +66,12 @@ public class EmbedTestCase {
@BeforeClass
public static void setUp() throws Exception {
- // Load the test WSDL definitions (could also construct
- // the WSDL and XSD models in code but that'd be quite
- // painful, so just load them from XML for now)
+ // Load the test WSDL definitions (could also construct the WSDL
+ // and XSD models in code but that'd be quite painful, so just
+ // load them from XML for now)
final Contribution contrib = contrib("test", here());
- WSDLInterface Hello_wsdl = wsdli("Hello.wsdl", "http://sample", "Hello", contrib);
- WSDLInterface Upper_wsdl = wsdli("Upper.wsdl", "http://sample", "Upper", contrib);
+ WSDLInterface Hello_wsdl = wsdli("Hello.wsdl", "http://sample/hello", "Hello", contrib);
+ WSDLInterface Upper_wsdl = wsdli("Upper.wsdl", "http://sample/upper", "Upper", contrib);
// Assemble a test composite model (see EmbedUtil
// for the little DSL used here, much more concise
@@ -91,12 +97,24 @@ public class EmbedTestCase {
reference("upper", "upper-test")),
component("upper-test",
implementation(UpperTest.class,
- service(Upper.class))));
+ service(Upper.class))));
+
+ // Register a test instance of our sample implementation ProviderFactory
+ providerFactories().addProviderFactory(testProviderFactory());
// Run with it
node = node(deploy(contrib, comp));
node.start();
}
+
+ static ProviderFactory<SampleImplementation> testProviderFactory() {
+ // This shows how to get called when a provider is created
+ return new SampleProviderFactory(extensionPoints()) {
+ public ImplementationProvider createImplementationProvider(RuntimeComponent comp, SampleImplementation impl) {
+ out.println("Creating a provider for component " + comp.getName());
+ return super.createImplementationProvider(comp, impl);
+ }};
+ }
@AfterClass
public static void tearDown() throws Exception {