summaryrefslogtreecommitdiffstats
path: root/sandbox/sebastien/java/vhost/modules/extensibility/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/sebastien/java/vhost/modules/extensibility/src/test')
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java87
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java58
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java118
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java101
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java79
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java31
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java103
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java42
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java30
-rw-r--r--sandbox/sebastien/java/vhost/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface19
10 files changed, 668 insertions, 0 deletions
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
new file mode 100644
index 0000000000..6865ba0d9d
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
@@ -0,0 +1,87 @@
+/*
+ * 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.extensibility;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test Case for ClasspathServiceDiscover
+ */
+public class ContextClassLoaderServiceDiscovererTestCase {
+ private static ContextClassLoaderServiceDiscoverer discover;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ discover = new ContextClassLoaderServiceDiscoverer();
+ }
+
+ @Test
+ public void testDiscovery() {
+ Collection<ServiceDeclaration> discriptors =
+ discover.getServiceDeclarations("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint");
+ Assert.assertEquals(1, discriptors.size());
+ discriptors =
+ discover.getServiceDeclarations("notthere");
+ Assert.assertEquals(0, discriptors.size());
+ }
+
+ @Test
+ public void testDiscoverResources() throws IOException {
+ Collection<ServiceDeclaration> descriptors = discover.getServiceDeclarations("/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface");
+ Assert.assertEquals(3, descriptors.size());
+ }
+
+ @Test
+ public void testDiscoveryFirst() throws IOException {
+ ServiceDeclaration descriptor =
+ discover.getServiceDeclaration("org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint");
+ Assert.assertNotNull(descriptor);
+ descriptor = discover.getServiceDeclaration("notthere");
+ Assert.assertNull(descriptor);
+ }
+
+ @Test
+ public void testXPathFactory() {
+ Collection<ServiceDeclaration> discriptors = discover.getServiceDeclarations("javax.xml.xpath.XPathFactory");
+ if (!discriptors.isEmpty()) {
+ ServiceDeclaration d = discriptors.iterator().next();
+ Assert.assertNotNull(d.getClassName());
+ Assert.assertTrue(d.getAttributes().containsKey("class"));
+ }
+ }
+
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java
new file mode 100644
index 0000000000..9758cba3b4
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java
@@ -0,0 +1,58 @@
+/*
+ * 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.extensibility;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DefaultExtensionPointRegistryTestCase {
+ private ExtensionPointRegistry registry;
+
+ @Before
+ public void setUp() throws Exception {
+ registry = new DefaultExtensionPointRegistry();
+ }
+
+ @Test
+ public void testRegistry() {
+ MyExtensionPoint service = new MyExtensionPointImpl();
+ registry.addExtensionPoint(service);
+ assertSame(service, registry.getExtensionPoint(MyExtensionPoint.class));
+ registry.removeExtensionPoint(service);
+ assertNull(registry.getExtensionPoint(MyExtensionPoint.class));
+ }
+
+ public static interface MyExtensionPoint {
+ void doSomething();
+ }
+
+ private static class MyExtensionPointImpl implements MyExtensionPoint {
+
+ public void doSomething() {
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
new file mode 100644
index 0000000000..0a5f4d6442
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
@@ -0,0 +1,118 @@
+/*
+ * 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.extensibility;
+
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.DefaultUtilityExtensionPoint;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class DefaultUtilityExtensionPointTestCase {
+ private static UtilityExtensionPoint ep;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ ep = new DefaultUtilityExtensionPoint(new DefaultExtensionPointRegistry());
+ ep.start();
+ }
+
+ @Test
+ public void testGet() {
+ MyUtilityImpl my = new MyUtilityImpl();
+ ep.addUtility(my);
+ Assert.assertTrue(my.started);
+ Utility1 u1 = ep.getUtility(Utility1.class);
+ Assert.assertSame(my, u1);
+ Utility2 u2 = ep.getUtility(Utility2.class);
+ Assert.assertSame(my, u2);
+ ep.removeUtility(my);
+ Assert.assertFalse(my.started);
+ u1 = ep.getUtility(Utility1.class);
+ Assert.assertNull(u1);
+
+ ep.addUtility("1", my);
+ u1= ep.getUtility(Utility1.class);
+ Assert.assertNull(u1);
+ u1= ep.getUtility(Utility1.class, "1");
+ Assert.assertNotNull(u1);
+ ep.removeUtility(my);
+ u1= ep.getUtility(Utility1.class, "1");
+ Assert.assertNull(u1);
+
+ u1 = ep.getUtility(MyUtilityImpl.class);
+ Assert.assertNotNull(u1);
+ u2 = ep.getUtility(Utility2.class);
+ Assert.assertSame(u1, u2);
+ ep.removeUtility(u1);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ ep.stop();
+ }
+
+ public static interface Utility1 extends Serializable {
+ void op1();
+ }
+
+ public static interface Utility2 extends Serializable {
+ void op2();
+ }
+
+ public static class MyUtilityImpl implements Utility1, Utility2, LifeCycleListener {
+ public boolean started;
+
+ public void start() {
+ System.out.println("start");
+ started = true;
+ }
+
+ public void stop() {
+ System.out.println("stop");
+ started = false;
+ }
+
+ public void op1() {
+ System.out.println("op1");
+ }
+
+ public void op2() {
+ System.out.println("op2");
+ }
+
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java
new file mode 100644
index 0000000000..e13a47cc1b
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java
@@ -0,0 +1,101 @@
+/*
+ * 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.extensibility;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.tuscany.sca.extensibility.test.TestInterface;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ServiceDiscoveryTestCase {
+ private static final String NAME = "org.apache.tuscany.sca.extensibility.test.TestInterface";
+
+ @Test
+ public void testRanking() throws Exception {
+ ServiceDeclaration sd = ServiceDiscovery.getInstance().getServiceDeclaration(NAME);
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd.getClassName());
+
+ Collection<ServiceDeclaration> sds = ServiceDiscovery.getInstance().getServiceDeclarations(NAME);
+ Assert.assertEquals(3, sds.size());
+
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(NAME, true);
+ Assert.assertEquals(3, sds.size());
+ Iterator<ServiceDeclaration> it = sds.iterator();
+ ServiceDeclaration sd1 = it.next();
+ ServiceDeclaration sd2 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd1.getClassName());
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.TestImpl", sd2.getClassName());
+ }
+
+ @Test
+ public void testServiceType() throws Exception {
+ ServiceDeclaration sd = ServiceDiscovery.getInstance().getServiceDeclaration(TestInterface.class);
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd.getClassName());
+
+ Collection<ServiceDeclaration> sds = ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class);
+ Assert.assertEquals(2, sds.size());
+
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, true);
+ Assert.assertEquals(2, sds.size());
+ Iterator<ServiceDeclaration> it = sds.iterator();
+ ServiceDeclaration sd1 = it.next();
+ ServiceDeclaration sd2 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd1.getClassName());
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.TestImpl", sd2.getClassName());
+ }
+
+ @Test
+ /**
+ * Test if the external attributes override the one in the META-INF/services/<SPI>
+ */
+ public void testAttributes() throws Exception {
+ ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance(new ContextClassLoaderServiceDiscoverer());
+ serviceDiscovery.setAttribute(TestInterface.class.getName(), "attr", "value");
+ serviceDiscovery.setAttribute(TestInterface.class.getName(), "attr1", "value1");
+ for (ServiceDeclaration sd : serviceDiscovery.getServiceDeclarations(TestInterface.class)) {
+ Assert.assertEquals("value1", sd.getAttributes().get("attr1"));
+ Assert.assertEquals("value", sd.getAttributes().get("attr"));
+ }
+ }
+
+ @Test
+ public void testFilter() throws Exception {
+ Collection<ServiceDeclaration> sds =
+ ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, "(attr=abc)");
+
+ Assert.assertEquals(1, sds.size());
+
+ Iterator<ServiceDeclaration> it = sds.iterator();
+ ServiceDeclaration sd1 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.Test2Impl", sd1.getClassName());
+
+ sds = ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, "(attr=1*)");
+ Assert.assertEquals(1, sds.size());
+ it = sds.iterator();
+ sd1 = it.next();
+ Assert.assertEquals("org.apache.tuscany.sca.extensibility.test.TestImpl", sd1.getClassName());
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java
new file mode 100644
index 0000000000..7920fdf4f4
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java
@@ -0,0 +1,79 @@
+/*
+ * 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.extensibility;
+
+import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.extensibility.test.Test2Impl;
+import org.apache.tuscany.sca.extensibility.test.TestImpl;
+import org.apache.tuscany.sca.extensibility.test.TestInterface;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ServiceHelperTestCase {
+ @Test
+ public void testNewInstance() throws Exception {
+ Test2Impl implA = ServiceHelper.newInstance(Test2Impl.class);
+ Assert.assertNull(implA.getRegistry());
+
+ TestImpl impl1 = ServiceHelper.newInstance(TestImpl.class);
+ Assert.assertNotNull(impl1);
+ }
+
+ @Test
+ public void testNewInstance2() throws Exception {
+ Collection<ServiceDeclaration> sds =
+ ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, true);
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Iterator<ServiceDeclaration> iterator = sds.iterator();
+ Test2Impl implA = ServiceHelper.newInstance(registry, iterator.next());
+ Assert.assertSame(registry, implA.getRegistry());
+
+ TestImpl impl1 = ServiceHelper.newInstance(registry, iterator.next());
+ Assert.assertNotNull(impl1);
+ }
+
+ @Test
+ public void testNewLazyInstance() throws Exception {
+ Collection<ServiceDeclaration> sds =
+ ServiceDiscovery.getInstance().getServiceDeclarations(TestInterface.class, true);
+ ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
+ Iterator<ServiceDeclaration> iterator = sds.iterator();
+ TestInterface ti = ServiceHelper.newLazyInstance(registry, iterator.next(), TestInterface.class);
+ Assert.assertTrue(Proxy.isProxyClass(ti.getClass()));
+ Assert.assertTrue(ti instanceof LifeCycleListener);
+ Assert.assertTrue(ti.toString().startsWith("Proxy"));
+ Assert.assertEquals(System.identityHashCode(ti), ti.hashCode());
+ ServiceHelper.start(ti);
+ ServiceHelper.stop(ti);
+ QName name = ti.getArtifactType();
+ Assert.assertEquals(new QName("http://sample", "Test2"), name);
+ String str = ti.test("ABC");
+ Assert.assertEquals("Test 2: ABC", str);
+ ServiceHelper.stop(ti);
+ }
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java
new file mode 100644
index 0000000000..f1ed50c5f2
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java
@@ -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.
+ */
+
+package org.apache.tuscany.sca.extensibility.test;
+
+/**
+ *
+ */
+public class DummyImpl {
+
+ public void test(String str) {
+ System.out.println("Test: " + str);
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java
new file mode 100644
index 0000000000..6a1ba4d7ba
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java
@@ -0,0 +1,103 @@
+/*
+ * 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.extensibility.test;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+
+/**
+ *
+ */
+public class Test2Impl implements TestInterface, LifeCycleListener {
+ private ExtensionPointRegistry registry;
+ public int state = 0;
+
+ public Test2Impl(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public Test2Impl() {
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.extensibility.test.TestInterface#test(java.lang.String)
+ */
+ public String test(String str) {
+ System.out.println("Test 2: " + str);
+ return "Test 2: " + str;
+ }
+
+ public ExtensionPointRegistry getRegistry() {
+ return registry;
+ }
+
+ public void start() {
+ state = 1;
+ }
+
+ public void stop() {
+ state = -1;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((registry == null) ? 0 : registry.hashCode());
+ result = prime * result + state;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Test2Impl other = (Test2Impl)obj;
+ if (registry == null) {
+ if (other.registry != null)
+ return false;
+ } else if (!registry.equals(other.registry))
+ return false;
+ if (state != other.state)
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Test2Impl [state=" + state + "]";
+ }
+
+ public QName getArtifactType() {
+ // TODO Auto-generated method stub
+ return new QName("http://sample", "Test2");
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java
new file mode 100644
index 0000000000..4def8a5227
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java
@@ -0,0 +1,42 @@
+/*
+ * 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.extensibility.test;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public class TestImpl implements TestInterface {
+
+ /* (non-Javadoc)
+ * @see org.apache.tuscany.sca.extensibility.test.TestInterface#test(java.lang.String)
+ */
+ public String test(String str) {
+ System.out.println("Test: " + str);
+ return "Test: " + str;
+ }
+
+ public QName getArtifactType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java
new file mode 100644
index 0000000000..2f0c34df7d
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java
@@ -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.
+ */
+
+package org.apache.tuscany.sca.extensibility.test;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ */
+public interface TestInterface {
+ String test(String str);
+ QName getArtifactType();
+}
diff --git a/sandbox/sebastien/java/vhost/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface
new file mode 100644
index 0000000000..12991071e5
--- /dev/null
+++ b/sandbox/sebastien/java/vhost/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface
@@ -0,0 +1,19 @@
+# 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.
+org.apache.tuscany.sca.extensibility.test.TestImpl;ranking=10;attr=123
+org.apache.tuscany.sca.extensibility.test.Test2Impl;ranking=20,attr=abc,qname=http://sample#Test2,model=org.apache.tuscany.sca.extensibility.test.TestInterface
+org.apache.tuscany.sca.extensibility.test.DummyImpl \ No newline at end of file