summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:13:23 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 23:13:23 +0000
commit6d0e93c68d3aeaeb4bb6d96ac0460eec40ef786e (patch)
treea956ed510e14a5509b8ef49fae42cfd439629825 /sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache
parent3ac2d800d840f03618fc364090d786effde84b1f (diff)
Moving 1.x branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835143 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache')
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java38
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java67
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java65
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java124
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java55
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java114
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java74
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java86
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java60
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java71
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java93
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java177
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java176
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java33
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java59
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java56
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java80
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java126
-rw-r--r--sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java384
24 files changed, 2259 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java
new file mode 100644
index 0000000000..72739d56c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/AssertionTestCase.java
@@ -0,0 +1,38 @@
+/*
+ * 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.spi;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AssertionTestCase extends TestCase {
+ /**
+ * test case that confirms that JRE assertions are enabled
+ */
+ public void testAssertionsAreEnabled() {
+ try {
+ assert false;
+ fail("assertions are not enabled");
+ } catch (AssertionError e) {
+ // ok
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java
new file mode 100644
index 0000000000..1f5faa5f9e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/QualifiedNameTestCase.java
@@ -0,0 +1,67 @@
+/*
+ * 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.spi;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests parsing of naming patters
+ *
+ * @version $Rev$ $Date$
+ */
+public class QualifiedNameTestCase extends TestCase {
+
+ public void testSimpleName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo");
+ assertEquals("Foo", name.getPartName());
+ assertEquals(null, name.getPortName());
+ }
+
+ public void testCompoundName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar");
+ assertEquals("Foo", name.getPartName());
+ assertEquals("Bar", name.getPortName());
+ }
+
+ public void testCompoundMultiName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar/Baz");
+ assertEquals("Foo", name.getPartName());
+ assertEquals("Bar/Baz", name.getPortName());
+ }
+
+ public void testInvalidName() throws Exception {
+ try {
+ new QualifiedName("/Foo/Bar");
+ fail("Invalid name exception not thrown");
+ } catch (InvalidNameException e) {
+ //expected
+ }
+ }
+
+ public void testQualifiedName() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar");
+ assertEquals("Foo/Bar", name.getQualifiedName());
+ }
+
+ public void testToString() throws Exception {
+ QualifiedName name = new QualifiedName("Foo/Bar");
+ assertEquals("Foo/Bar", name.toString());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java
new file mode 100644
index 0000000000..6d431a5dcf
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyExceptionTestCase.java
@@ -0,0 +1,65 @@
+/*
+ * 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.spi;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyExceptionTestCase extends TestCase {
+
+ public void testIdentifier() throws Exception {
+ TuscanyException e = new TestException();
+ e.setIdentifier("foo");
+ assertEquals("foo", e.getIdentifier());
+ }
+
+ public void testAddContext() throws Exception {
+ TuscanyException e = new TestException();
+ e.addContextName("foo");
+ e.addContextName("bar");
+ assertEquals("foo", e.returnContextNames().get(0));
+ assertEquals("bar", e.returnContextNames().get(1));
+ }
+
+ public void testEmptyContext() throws Exception {
+ TuscanyException e = new TestException();
+ assertEquals(0, e.returnContextNames().size());
+ }
+
+ public void testGetMessage() throws Exception {
+ TuscanyException e = new TestException();
+ e.getMessage();
+ }
+
+ public void testFullMessage() throws Exception {
+ TuscanyException e = new TestException();
+ e.setIdentifier("foo");
+ e.addContextName("foo");
+ e.getMessage();
+ }
+
+
+ private class TestException extends TuscanyException {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java
new file mode 100644
index 0000000000..3a04391cfd
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/TuscanyRuntimeExceptionTestCase.java
@@ -0,0 +1,65 @@
+/*
+ * 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.spi;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.api.TuscanyRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TuscanyRuntimeExceptionTestCase extends TestCase {
+
+ public void testIdentifier() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.setIdentifier("foo");
+ assertEquals("foo", e.getIdentifier());
+ }
+
+ public void testAddContext() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.addContextName("foo");
+ e.addContextName("bar");
+ assertEquals("foo", e.returnContextNames().get(0));
+ assertEquals("bar", e.returnContextNames().get(1));
+ }
+
+ public void testEmptyContext() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ assertEquals(0, e.returnContextNames().size());
+ }
+
+ public void testEmptyGetMessage() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.getMessage();
+ }
+
+ public void testFullMessage() throws Exception {
+ TuscanyRuntimeException e = new TestException();
+ e.setIdentifier("foo");
+ e.addContextName("foo");
+ e.getMessage();
+ }
+
+
+ private class TestException extends TuscanyRuntimeException {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
new file mode 100644
index 0000000000..affd52df42
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/annotation/ConstructorAnnotationTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.spi.annotation;
+
+import java.util.Arrays;
+
+import org.osoa.sca.annotations.Constructor;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConstructorAnnotationTest extends TestCase {
+ public void testSingleName() throws NoSuchMethodException {
+ Constructor ann = Foo1.class.getConstructor(String.class).getAnnotation(Constructor.class);
+ assertNotNull(ann);
+ String[] names = ann.value();
+ assertTrue(Arrays.equals(new String[]{"prop"}, names));
+ }
+
+ public void testMultipleNames() throws NoSuchMethodException {
+ Constructor ann = Foo1.class.getConstructor(String.class, String.class).getAnnotation(Constructor.class);
+ assertNotNull(ann);
+ String[] names = ann.value();
+ assertTrue(Arrays.equals(new String[]{"prop", "ref"}, names));
+ }
+
+ public static class Foo1 {
+ @Constructor({"prop", "ref"})
+ public Foo1(String prop, String ref) {
+ }
+
+ @Constructor("prop")
+ public Foo1(String prop) {
+ }
+ }
+
+ public static class Foo2 {
+ public Foo2(@Autowire String prop,
+ @Autowire String ref) {
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
new file mode 100644
index 0000000000..a5e035026b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/component/AbstractSCAObjectTestCase.java
@@ -0,0 +1,124 @@
+/*
+ * 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.spi.component;
+
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.event.EventFilter;
+import org.apache.tuscany.spi.event.RuntimeEventListener;
+import org.apache.tuscany.spi.event.TrueFilter;
+import org.apache.tuscany.spi.model.Scope;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractSCAObjectTestCase extends TestCase {
+
+ public void testFireListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ listener.onEvent(EasyMock.same(event));
+ EasyMock.expectLastCall();
+ EasyMock.replay(listener);
+ object.addListener(listener);
+ object.publish(event);
+ }
+
+ public void testRemoveListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ EasyMock.replay(listener);
+ object.addListener(listener);
+ object.removeListener(listener);
+ object.publish(event);
+ }
+
+ public void testFalseFilterListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ EasyMock.replay(listener);
+ object.addListener(new FalseFilter(), listener);
+ object.publish(event);
+ }
+
+ public void testTrueFilterListener() {
+ SCAObject object = new TestSCAObject("foo", null);
+ Event event = new TestEvent();
+ RuntimeEventListener listener = EasyMock.createMock(RuntimeEventListener.class);
+ listener.onEvent(EasyMock.same(event));
+ EasyMock.expectLastCall();
+ EasyMock.replay(listener);
+ object.addListener(new TrueFilter(), listener);
+ object.publish(event);
+ }
+
+ public void testToString() {
+ SCAObject object = new TestSCAObject("foo", null);
+ assertNotNull(object.toString());
+ }
+
+ public void testGetName() {
+ SCAObject object = new TestSCAObject("foo", null);
+ assertEquals("foo", object.getName());
+ }
+
+
+ public void testToPrepare() {
+ SCAObject object = new TestSCAObject("foo", null);
+ object.prepare();
+ }
+
+
+ private class TestSCAObject extends AbstractSCAObject {
+ public TestSCAObject(String name, CompositeComponent parent) {
+ super(name, parent);
+ }
+
+ public Scope getScope() {
+ return null;
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return null;
+ }
+ }
+
+ private class TestEvent implements Event {
+ public Object getSource() {
+ return null;
+ }
+ }
+
+ private class FalseFilter implements EventFilter {
+
+ public boolean match(Event event) {
+ return false;
+ }
+ }
+
+
+}
+
+
+
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java
new file mode 100644
index 0000000000..40843dea94
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DOMHelperTestCase.java
@@ -0,0 +1,55 @@
+/*
+ * 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.spi.databinding.extension;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class DOMHelperTestCase extends TestCase {
+ private static final QName FOO_NAME = new QName("http://foo", "foo");
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testDOM() throws Exception {
+ DocumentBuilder builder = DOMHelper.newDocumentBuilder();
+ assertNotNull(builder);
+ Document document = DOMHelper.newDocument();
+ assertNotNull(document);
+ Element element = DOMHelper.createElement(document, FOO_NAME);
+ document.appendChild(element);
+ QName name = DOMHelper.getQName(element);
+ assertEquals(FOO_NAME, name);
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java
new file mode 100644
index 0000000000..b4b5f6a39a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/DataBindingExtensionTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * 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.spi.databinding.extension;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.easymock.EasyMock;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ */
+public class DataBindingExtensionTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testExtension() {
+ DataBinding1 binding1 = new DataBinding1(Node.class);
+ assertEquals(Node.class.getName(), binding1.getName());
+ assertNotNull(binding1.introspect(Element.class));
+ assertNull(binding1.introspect(String.class));
+ assertNull(binding1.getWrapperHandler());
+
+ DataBindingRegistry registry = EasyMock.createMock(DataBindingRegistry.class);
+ registry.register(binding1);
+ EasyMock.expect(registry.getDataBinding(Node.class.getName())).andReturn(binding1);
+ EasyMock.replay(registry);
+
+ binding1.setDataBindingRegistry(registry);
+ binding1.init();
+ assertNotNull(registry.getDataBinding(Node.class.getName()));
+
+ DataBinding1 binding2 = new DataBinding1("dom", Node.class);
+ assertEquals("dom", binding2.getName());
+ }
+
+ private static class DataBinding1 extends DataBindingExtension {
+
+ /**
+ * @param baseType
+ */
+ public DataBinding1(Class<?> baseType) {
+ super(baseType);
+ }
+
+ /**
+ * @param name
+ * @param baseType
+ */
+ public DataBinding1(String name, Class<?> baseType) {
+ super(name, baseType);
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java
new file mode 100644
index 0000000000..c955352812
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/SimpleTypeMapperExtensionTestCase.java
@@ -0,0 +1,114 @@
+/*
+ * 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.spi.databinding.extension;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.NamespaceContext;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.idl.TypeInfo;
+import org.easymock.EasyMock;
+
+/**
+ *
+ */
+public class SimpleTypeMapperExtensionTestCase extends TestCase {
+
+ private static final Map<String, Object> SAMPLE_VALUES = new HashMap<String, Object>();
+
+ static {
+ SAMPLE_VALUES.put("anyURI", "http://www.w3.com");
+ SAMPLE_VALUES.put("boolean", new String[] {"true", "false", "1", "0"});
+ SAMPLE_VALUES.put("byte", new String[] {"-128", "127"});
+ SAMPLE_VALUES.put("date", new String[] {"2004-03-15", "2002-09-24-06:00"});
+ SAMPLE_VALUES.put("dateTime", "2003-12-25T08:30:00");
+ SAMPLE_VALUES.put("decimal", "3.1415292");
+ SAMPLE_VALUES.put("double", new String[] {"3.1415292", "INF", "NaN"});
+ SAMPLE_VALUES.put("duration", new String[] {"P8M3DT7H33M2S", "P5Y2M10DT15H"});
+ SAMPLE_VALUES.put("float", new String[] {"3.1415292", "INF", "NaN"});
+ SAMPLE_VALUES.put("gDay", "---11");
+ SAMPLE_VALUES.put("gMonth", "--02--");
+ SAMPLE_VALUES.put("gMonthDay", "--02-14");
+ SAMPLE_VALUES.put("gYear", "1999");
+ SAMPLE_VALUES.put("gYearMonth", "1972-08");
+ SAMPLE_VALUES.put("ID", "id-102");
+ SAMPLE_VALUES.put("IDREF", "id-102");
+ SAMPLE_VALUES.put("IDREFS", "id-102 id-103 id-100");
+ SAMPLE_VALUES.put("int", "77");
+ SAMPLE_VALUES.put("integer", "77");
+ SAMPLE_VALUES.put("long", "214");
+ SAMPLE_VALUES.put("negativeInteger", "-123");
+ SAMPLE_VALUES.put("nonNegativeInteger", "2");
+ SAMPLE_VALUES.put("nonPositiveInteger", "0");
+ SAMPLE_VALUES.put("positiveInteger", "500");
+ SAMPLE_VALUES.put("short", "476");
+ SAMPLE_VALUES.put("string", "Joeseph");
+ SAMPLE_VALUES.put("time", "13:02:00");
+ SAMPLE_VALUES.put("base64Binary", "TWFu");
+ SAMPLE_VALUES.put("hexBinary", "2CDB5F");
+ SAMPLE_VALUES.put("QName", "f:foo");
+ SAMPLE_VALUES.put("NOTATION", "f:bar");
+ }
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testMap() throws Exception {
+ SimpleTypeMapperExtension extension = new SimpleTypeMapperExtension();
+ TransformationContext context = EasyMock.createMock(TransformationContext.class);
+ Map<Class<?>, Object> metaData = new HashMap<Class<?>, Object>();
+ EasyMock.expect(context.getMetadata()).andReturn(metaData).anyTimes();
+ EasyMock.replay(context);
+
+ NamespaceContext namespaceContext = EasyMock.createMock(NamespaceContext.class);
+ EasyMock.expect(namespaceContext.getNamespaceURI(EasyMock.eq("f"))).andReturn("http://foo")
+ .anyTimes();
+ EasyMock.expect(namespaceContext.getPrefix(EasyMock.eq("http://foo"))).andReturn("f").anyTimes();
+ EasyMock.replay(namespaceContext);
+ context.getMetadata().put(NamespaceContext.class, namespaceContext);
+ for (TypeInfo simpleType : SimpleTypeMapperExtension.XSD_SIMPLE_TYPES.values()) {
+ String name = simpleType.getQName().getLocalPart();
+ Object value = SAMPLE_VALUES.get(name);
+ if (value instanceof String[]) {
+ for (String s : (String[])value) {
+ Object obj = extension.toJavaObject(simpleType, s, context);
+ String str = extension.toXMLLiteral(simpleType, obj, context);
+ assertNotNull(str);
+ // assertTrue("[" + name + "] " + s + " " + str,
+ // str.contains((String) s));
+ }
+ } else if (value instanceof String) {
+ Object obj = extension.toJavaObject(simpleType, (String)value, context);
+ String str = extension.toXMLLiteral(simpleType, obj, context);
+ assertNotNull(str);
+ // assertTrue("[" + name + "] " + value + " " + str,
+ // str.contains((String) value));
+ }
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java
new file mode 100644
index 0000000000..6f5dfc90e2
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/TransformerExtensionTestCase.java
@@ -0,0 +1,74 @@
+/*
+ * 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.spi.databinding.extension;
+
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.TransformerRegistry;
+import org.easymock.EasyMock;
+import org.w3c.dom.Node;
+
+/**
+ * Test case for TransformerExtension
+ */
+public class TransformerExtensionTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testExtension() {
+ MyTransformer transformer = new MyTransformer();
+ assertEquals(Node.class.getName(), transformer.getSourceDataBinding());
+ assertEquals(XMLStreamReader.class.getName(), transformer.getTargetDataBinding());
+ assertEquals(50, transformer.getWeight());
+ TransformerRegistry registry = EasyMock.createMock(TransformerRegistry.class);
+ registry.registerTransformer(EasyMock.isA(Transformer.class));
+ EasyMock
+ .expect(registry.getTransformer(transformer.getSourceDataBinding(), transformer.getTargetDataBinding()))
+ .andReturn(transformer);
+ EasyMock.replay(registry);
+ transformer.setTransformerRegistry(registry);
+ transformer.init();
+ assertSame(transformer, registry.getTransformer(transformer.getSourceDataBinding(), transformer
+ .getTargetDataBinding()));
+ }
+
+ private static class MyTransformer extends TransformerExtension<Node, XMLStreamReader> {
+
+ @Override
+ protected Class getSourceType() {
+ return Node.class;
+ }
+
+ @Override
+ protected Class getTargetType() {
+ return XMLStreamReader.class;
+ }
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java
new file mode 100644
index 0000000000..4693025c11
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/databinding/extension/XSDDataTypeConverterTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * 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.spi.databinding.extension;
+
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class XSDDataTypeConverterTestCase extends TestCase {
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testConvert() throws Exception {
+ XSDDataTypeConverter c = new XSDDataTypeConverter();
+ assertEquals("123", c.parseAnySimpleType(c.printAnySimpleType("123")));
+ assertEquals(true, c.parseBoolean(c.printBoolean(true)));
+ assertEquals(false, c.parseBoolean(c.printBoolean(false)));
+ assertEquals(123.0, c.parseDouble(c.printDouble(123.0)));
+ assertEquals(123.0f, c.parseFloat(c.printFloat(123.0f)));
+ assertEquals(64, c.parseByte(c.printByte((byte)64)));
+ assertEquals(123, c.parseInt(c.printInt(123)));
+ assertEquals(new BigInteger("123456"), c.parseInteger(c.printInteger(new BigInteger("123456"))));
+ assertEquals(123456L, c.parseLong(c.printLong(123456L)));
+ assertEquals((short)123, c.parseShort(c.printShort((short)123)));
+
+ Calendar calendar = new GregorianCalendar();
+ String s = c.printDate(calendar);
+ calendar = (GregorianCalendar)c.parseDate(s);
+ assertEquals(s, c.printDate(calendar));
+
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
new file mode 100644
index 0000000000..2c3d953c73
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/AtomicComponentExtensionTestCase.java
@@ -0,0 +1,86 @@
+/*
+ * 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.spi.extension;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AtomicComponentExtensionTestCase extends TestCase {
+
+ public void testIsEagerInit() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.isEagerInit();
+ }
+
+ public void testPrepare() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.prepare();
+ }
+
+ public void testInit() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.init(null);
+ }
+
+ public void testDestroy() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.destroy(null);
+ }
+
+ public void testInboundWire() throws Exception {
+ TestExtension ext = new TestExtension();
+ ext.getInboundWire(null);
+ }
+
+ private class TestExtension extends AtomicComponentExtension {
+ public TestExtension() {
+ super(null, null, null, null, null, null, 0);
+ }
+
+ public Object getServiceInstance() throws TargetException {
+ return null;
+ }
+
+ public Object createInstance() throws ObjectCreationException {
+ return null;
+ }
+
+ public Object getServiceInstance(String name) throws TargetException {
+ return null;
+ }
+
+ public List<Class<?>> getServiceInterfaces() {
+ return null;
+ }
+
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
+ return null;
+ }
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java
new file mode 100644
index 0000000000..54229633eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ComponentTypeLoaderExtensionTestCase.java
@@ -0,0 +1,60 @@
+/*
+ * 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.spi.extension;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.Implementation;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeLoaderExtensionTestCase extends TestCase {
+
+ public void testRegistrationDeregistration() throws Exception {
+ Extension loader = new Extension();
+ LoaderRegistry registry = createMock(LoaderRegistry.class);
+ registry.registerLoader(eq(Implementation.class), eq(loader));
+ registry.unregisterLoader(eq(Implementation.class));
+ EasyMock.replay(registry);
+ loader.setLoaderRegistry(registry);
+ loader.start();
+ loader.stop();
+ }
+
+
+ private class Extension extends ComponentTypeLoaderExtension<Implementation> {
+
+ protected Class<Implementation> getImplementationClass() {
+ return Implementation.class;
+ }
+
+ public void load(CompositeComponent parent, Implementation implementation,
+ DeploymentContext deploymentContext) throws LoaderException {
+
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java
new file mode 100644
index 0000000000..d05aad05ae
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/LoaderExtensionTestCase.java
@@ -0,0 +1,71 @@
+/*
+ * 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.spi.extension;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ModelObject;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LoaderExtensionTestCase extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testRegistrationDeregistration() throws Exception {
+ LoaderRegistry registry = EasyMock.createMock(LoaderRegistry.class);
+ registry.registerLoader(isA(QName.class), isA(Extension.class));
+ expectLastCall();
+ registry.unregisterLoader(isA(QName.class), isA(Extension.class));
+ expectLastCall();
+ EasyMock.replay(registry);
+ Extension loader = new Extension(registry);
+ loader.start();
+ loader.stop();
+ }
+
+
+ private static class Extension extends LoaderExtension {
+
+ public Extension(LoaderRegistry registry) {
+ super(registry);
+ }
+
+ public QName getXMLType() {
+ return new QName("");
+ }
+
+ public ModelObject load(CompositeComponent parent,
+ XMLStreamReader reader,
+ DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+ throw new AssertionError();
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
new file mode 100644
index 0000000000..81693a088d
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ReferenceTestCase.java
@@ -0,0 +1,93 @@
+/*
+ * 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.spi.extension;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.QualifiedName;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.wire.InboundInvocationChain;
+import org.apache.tuscany.spi.wire.InboundWire;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.OutboundWire;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTestCase extends TestCase {
+
+ public void testScope() throws Exception {
+ TestReference ref = new TestReference<Object>(Object.class);
+ assertEquals(Scope.COMPOSITE, ref.getScope());
+ }
+
+ public void testSetGetInterface() throws Exception {
+ TestReference<TestReference> ref = new TestReference<TestReference>(TestReference.class);
+ assertEquals(TestReference.class, ref.getInterface());
+
+ }
+
+ public void testPrepare() throws Exception {
+ InboundInvocationChain chain = createMock(InboundInvocationChain.class);
+ Operation<Type> operation = new Operation<Type>("test", null, null, null, false, null);
+ chain.setTargetInvoker(null);
+ expectLastCall();
+ chain.getOperation();
+ expectLastCall().andReturn(operation);
+ chain.prepare();
+ expectLastCall();
+ InboundWire wire = createMock(InboundWire.class);
+ wire.getInvocationChains();
+ Map<Operation, InvocationChain> chains = new HashMap<Operation, InvocationChain>();
+ chains.put(operation, chain);
+ expectLastCall().andReturn(chains);
+ OutboundWire outboundWire = createMock(OutboundWire.class);
+ outboundWire.getTargetName();
+ expectLastCall().andReturn(new QualifiedName("foo/bar"));
+ replay(chain);
+ replay(wire);
+ replay(outboundWire);
+ TestReference<Object> ref = new TestReference<Object>(Object.class);
+ ref.setInboundWire(wire);
+ ref.setOutboundWire(outboundWire);
+ ref.prepare();
+ }
+
+ private class TestReference<T> extends ReferenceExtension {
+ public TestReference(Class<T> clazz) {
+ super(null, clazz, null, null);
+ }
+
+ public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
+ return null;
+ }
+
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
new file mode 100644
index 0000000000..29a8fc4c6c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/extension/ServiceExtensionTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * 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.spi.extension;
+
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Scope;
+import org.apache.tuscany.spi.wire.InboundWire;
+
+import junit.framework.TestCase;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceExtensionTestCase extends TestCase {
+
+ public void testScope() throws Exception {
+ ServiceExtension service = new ServiceExtension(null, null, null, null);
+ assertEquals(Scope.COMPOSITE, service.getScope());
+ }
+
+ public void testSetGetInterface() throws Exception {
+ InboundWire wire = createMock(InboundWire.class);
+ JavaServiceContract contract = new JavaServiceContract(getClass());
+ expect(wire.getServiceContract()).andReturn(contract);
+ replay(wire);
+ ServiceExtension service = new ServiceExtension(null, null, null, null);
+ service.setInboundWire(wire);
+ service.getInterface();
+ }
+
+
+ public void testPrepare() throws Exception {
+ ServiceExtension service = new ServiceExtension(null, null, null, null);
+ service.prepare();
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java
new file mode 100644
index 0000000000..29994b8cba
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/idl/java/JavaIDLUtilsTestCase.java
@@ -0,0 +1,177 @@
+/*
+ * 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.spi.idl.java;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findOperation;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JavaIDLUtilsTestCase extends TestCase {
+ private Method[] methods;
+ private List<Operation<?>> operations;
+
+ public void testNoParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertEquals("foo", method.getName());
+ assertEquals(0, method.getParameterTypes().length);
+ }
+
+ public void testNoParamsFindOperation() throws Exception {
+ Method method = Foo.class.getMethod("foo");
+ Operation ret = findOperation(method, operations);
+ assertEquals("foo", ret.getName());
+ assertEquals(0, method.getParameterTypes().length);
+ }
+
+ public void testParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertEquals("foo", method.getName());
+ assertEquals(String.class, method.getParameterTypes()[0]);
+ }
+
+ public void testParamsFindOperation() throws Exception {
+ Method method = Foo.class.getMethod("foo", String.class);
+ Operation ret = findOperation(method, operations);
+ assertEquals("foo", ret.getName());
+ assertEquals(String.class, method.getParameterTypes()[0]);
+ }
+
+
+ public void testTooManyParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(String.class, Object.class);
+ DataType<Type> type2 = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ types.add(type2);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertNull(method);
+ }
+
+ public void testDifferentParamsFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(Integer.class, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertNull(method);
+ }
+
+ public void testPrimitiveParamNoFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(Integer.class, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertNull(method);
+ }
+
+ public void testPrimitiveParamFindMethod() {
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<Type> type = new DataType<Type>(Integer.TYPE, Object.class);
+ types.add(type);
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ Operation<Type> operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ Method method = findMethod(operation, methods);
+ assertEquals("foo", method.getName());
+ assertEquals(Integer.TYPE, method.getParameterTypes()[0]);
+ }
+
+ public void testPrimitiveParamFindOperation() throws NoSuchMethodException {
+ Method method = Foo.class.getMethod("foo", Integer.TYPE);
+ Operation<?> operation = findOperation(method, operations);
+ assertEquals(Integer.TYPE, operation.getInputType().getLogical().get(0).getPhysical());
+ }
+
+
+ public void testNotFoundMethod() {
+ Operation<Type> operation = new Operation<Type>("not there", null, null, null, false, null);
+ assertNull(findMethod(operation, methods));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ methods = Foo.class.getMethods();
+
+ Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+ operations = new ArrayList<Operation<?>>();
+ operations.add(operation);
+
+ List<DataType<Type>> types = new ArrayList<DataType<Type>>();
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ DataType<Type> type = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ types = new ArrayList<DataType<Type>>();
+ type = new DataType<Type>(String.class, Object.class);
+ DataType<Type> type2 = new DataType<Type>(String.class, Object.class);
+ types.add(type);
+ types.add(type2);
+ inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ types = new ArrayList<DataType<Type>>();
+ type = new DataType<Type>(Integer.class, Object.class);
+ types.add(type);
+ inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ types = new ArrayList<DataType<Type>>();
+ type = new DataType<Type>(Integer.TYPE, Object.class);
+ types.add(type);
+ inputType = new DataType<List<DataType<Type>>>(Object[].class, types);
+ operation = new Operation<Type>("foo", inputType, null, null, false, null);
+ operations.add(operation);
+
+ }
+
+ private interface Foo {
+ void foo();
+
+ void foo(String foo);
+
+ void foo(int b);
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java
new file mode 100644
index 0000000000..18887880fe
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/implementation/java/AbstractPropertyProcessorTestCase.java
@@ -0,0 +1,176 @@
+/*
+ * 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.spi.implementation.java;
+
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyProcessorTestCase extends TestCase {
+
+ private ImplementationProcessor processor;
+
+
+ public void testVisitMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitMethod(null, method, type, null);
+ JavaMappedProperty<?> prop = type.getProperties().get("test");
+ assertNotNull(prop.getDefaultValueFactory());
+ }
+
+ public void testVisitNoParamsMethod() throws Exception {
+ Method method = Foo.class.getMethod("setNoParamsBar");
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalPropertyException e) {
+ //expected
+ }
+ }
+
+ public void testVisitNonVoidMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBadBar", String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (IllegalPropertyException e) {
+ //expected
+ }
+ }
+
+ public void testDuplicateMethod() throws Exception {
+ Method method = Foo.class.getMethod("setBar", String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitMethod(null, method, type, null);
+ try {
+ processor.visitMethod(null, method, type, null);
+ fail();
+ } catch (DuplicatePropertyException e) {
+ //expected
+ }
+ }
+
+ public void testVisitField() throws Exception {
+ Field field = Foo.class.getDeclaredField("d");
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitField(null, field, type, null);
+ JavaMappedProperty<?> prop = type.getProperties().get("test");
+ assertNotNull(prop.getDefaultValueFactory());
+ }
+
+ public void testVisitConstructor() throws Exception {
+ Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitConstructor(null, ctor, type, null);
+ ConstructorDefinition def = type.getConstructorDefinition();
+ assertEquals("test", def.getInjectionNames().get(0));
+ assertNotNull(type.getProperties().get("test"));
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void setUp() throws Exception {
+ super.setUp();
+ ImplementationProcessorService service = EasyMock.createMock(ImplementationProcessorService.class);
+ service.addName(EasyMock.isA(List.class), EasyMock.eq(0), EasyMock.eq("test"));
+ EasyMock.expectLastCall().andStubAnswer(new IAnswer() {
+ public Object answer() throws Throwable {
+ ((List<Object>) EasyMock.getCurrentArguments()[0]).add("test");
+ return null;
+ }
+ });
+ EasyMock.replay(service);
+ processor = new TestProcessor(service);
+ }
+
+ @Retention(RUNTIME)
+ private @interface Bar {
+
+ }
+
+ private class TestProcessor extends AbstractPropertyProcessor<Bar> {
+
+ public TestProcessor(ImplementationProcessorService service) {
+ super(Bar.class, service);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected <T> void initProperty(JavaMappedProperty<T> property,
+ Bar annotation,
+ CompositeComponent parent,
+ DeploymentContext context) {
+ property.setDefaultValueFactory(EasyMock.createMock(ObjectFactory.class));
+ property.setName("test");
+ }
+
+ protected String getName(Bar annotation) {
+ return "test";
+ }
+ }
+
+
+ private static class Foo {
+
+ @Bar
+ protected String d;
+
+ public Foo(String a, @Bar String b) {
+ }
+
+ public Foo(@Bar String d) {
+ this.d = d;
+ }
+
+ @Bar
+ public void setBar(String d) {
+ this.d = d;
+ }
+
+ @Bar
+ public void setNoParamsBar() {
+ }
+
+ @Bar
+ public String setBadBar(String d) {
+ return null;
+ }
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java
new file mode 100644
index 0000000000..f8c991f7d4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/loader/LoaderExceptionTestCase.java
@@ -0,0 +1,33 @@
+/*
+ * 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.spi.loader;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LoaderExceptionTestCase extends TestCase {
+
+ public void testResourceURI() throws Exception {
+ LoaderException e = new LoaderException();
+ e.setResourceURI("test");
+ assertEquals("test", e.getResourceURI());
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
new file mode 100644
index 0000000000..7facc55a6f
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ScopeTestCase.java
@@ -0,0 +1,59 @@
+/*
+ * 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.spi.model;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ScopeTestCase extends TestCase {
+
+ public void testEquals() throws Exception {
+ Scope module = new Scope("module");
+ assertTrue(module.equals(Scope.MODULE));
+ }
+
+ public void testEqualsNew() throws Exception {
+ Scope foo = new Scope("foo");
+ Scope foo2 = new Scope("FOO");
+ assertTrue(foo.equals(foo2));
+ }
+
+ public void testNotEquals() throws Exception {
+ Scope foo = new Scope("BAR");
+ Scope foo2 = new Scope("FOO");
+ assertFalse(foo.equals(foo2));
+ }
+
+ public void testNotEqualsDifferent() throws Exception {
+ Scope foo = new Scope("FOO");
+ assertFalse(foo.equals(new Bar("FOO")));
+ }
+
+ public class Bar {
+ private String scope;
+
+ public Bar(String scope) {
+ this.scope = scope;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java
new file mode 100644
index 0000000000..0c986dec34
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/model/ServiceContractTestCase.java
@@ -0,0 +1,56 @@
+/*
+ * 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.spi.model;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Type;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceContractTestCase extends TestCase {
+
+ public void testAddOperation() throws Exception {
+ ServiceContract<Type> contract = new TestContract();
+ Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+ Map<String, Operation<Type>> ops = new HashMap<String, Operation<Type>>();
+ ops.put("foo", operation);
+ contract.setOperations(ops);
+ assertEquals(contract, operation.getServiceContract());
+ assertFalse(operation.isCallback());
+ }
+
+ public void testAddCallbackOperation() throws Exception {
+ ServiceContract<Type> contract = new TestContract();
+ Operation<Type> operation = new Operation<Type>("foo", null, null, null, false, null);
+ Map<String, Operation<Type>> ops = new HashMap<String, Operation<Type>>();
+ ops.put("foo", operation);
+ contract.setCallbackOperations(ops);
+ assertEquals(contract, operation.getServiceContract());
+ assertTrue(operation.isCallback());
+ }
+
+
+ private class TestContract extends ServiceContract<Type> {
+
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..ec178af70a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractInboundInvocationHandlerTestCase.java
@@ -0,0 +1,80 @@
+/*
+ * 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.spi.wire;
+
+import java.lang.reflect.Array;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractInboundInvocationHandlerTestCase extends TestCase {
+
+ public void testInvocation() throws Throwable {
+ InvocationHandler handler = new InvocationHandler();
+ Interceptor interceptor = new MockInterceptor();
+ TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.replay(invoker);
+ InboundInvocationChain chain = EasyMock.createMock(InboundInvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor);
+ EasyMock.replay(chain);
+ Object resp = handler.invoke(chain, invoker, new String[]{"foo"});
+ assertEquals("response", resp);
+ }
+
+
+ private class InvocationHandler extends AbstractInboundInvocationHandler {
+
+ protected Object getMessageId() {
+ return new Object();
+ }
+
+ protected Object getCorrelationId() {
+ return new Object();
+ }
+ }
+
+ private class MockInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ assertNotNull(msg.getCorrelationId());
+ assertNotNull(msg.getTargetInvoker());
+ assertNotNull(msg.getMessageId());
+ assertEquals("foo", Array.get(msg.getBody(), 0));
+ msg.setBody("response");
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java
new file mode 100644
index 0000000000..a6104e4af1
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/AbstractOutboundInvocationHandlerTestCase.java
@@ -0,0 +1,126 @@
+/*
+ * 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.spi.wire;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractOutboundInvocationHandlerTestCase extends TestCase {
+
+ public void testInvocation() throws Throwable {
+ InvocationHandler handler = new InvocationHandler();
+ Interceptor interceptor = new MockInterceptor();
+ TargetInvoker invoker = EasyMock.createMock(TargetInvoker.class);
+ EasyMock.replay(invoker);
+ OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor);
+ EasyMock.replay(chain);
+ Object resp = handler.invoke(chain, invoker, new String[]{"foo"});
+ assertEquals("response", resp);
+ }
+
+ public void testShortCircuitInvocation() throws Throwable {
+ InvocationHandler handler = new InvocationHandler();
+ TargetInvoker invoker = new MockInvoker();
+ OutboundInvocationChain chain = EasyMock.createMock(OutboundInvocationChain.class);
+ EasyMock.expect(chain.getHeadInterceptor()).andReturn(null);
+ EasyMock.expect(chain.getTargetInvoker()).andReturn(invoker);
+ EasyMock.replay(chain);
+ Object resp = handler.invoke(chain, invoker, new String[]{"foo"});
+ assertEquals("response", resp);
+ }
+
+
+ private class MockInvoker implements TargetInvoker {
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ assertEquals("foo", Array.get(payload, 0));
+ return "response";
+ }
+
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ fail();
+ return null;
+ }
+
+ public boolean isCacheable() {
+ return false;
+ }
+
+ public void setCacheable(boolean cacheable) {
+
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+
+ private class InvocationHandler extends AbstractOutboundInvocationHandler {
+
+ protected Object getFromAddress() {
+ return new Object();
+ }
+
+ protected Object getMessageId() {
+ return new Object();
+ }
+
+ protected Object getCorrelationId() {
+ return new Object();
+ }
+ }
+
+ private class MockInterceptor implements Interceptor {
+
+ public Message invoke(Message msg) {
+ assertNotNull(msg.getCorrelationId());
+ assertNotNull(msg.getTargetInvoker());
+ assertNotNull(msg.getMessageId());
+ assertNotNull(msg.getFromAddress());
+ assertEquals("foo", Array.get(msg.getBody(), 0));
+ msg.setBody("response");
+ return msg;
+ }
+
+ public void setNext(Interceptor next) {
+
+ }
+
+ public Interceptor getNext() {
+ return null;
+ }
+
+ public boolean isOptimizable() {
+ return false;
+ }
+ }
+
+
+}
diff --git a/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java
new file mode 100644
index 0000000000..9478473894
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-M2/sca/kernel/spi/src/test/java/org/apache/tuscany/spi/wire/ContractCompatibilityTestCase.java
@@ -0,0 +1,384 @@
+/*
+ * 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.spi.wire;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.Reference;
+import org.apache.tuscany.spi.component.Service;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ReferenceDefinition;
+import org.apache.tuscany.spi.model.ReferenceTarget;
+import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.model.ServiceDefinition;
+
+import junit.framework.TestCase;
+
+/**
+ * TODO some tests commented out due to DataType.equals() needing to be strict
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContractCompatibilityTestCase extends TestCase {
+
+ private WireService wireService = new MockWireService();
+
+ public void testNoOperation() throws Exception {
+ ServiceContract source = new MockContract<Type>("FooContract");
+ ServiceContract target = new MockContract<Type>("FooContract");
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testBasic() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ Operation<Type> opSource2 = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opSource2);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testBasicIncompatibleOperationNames() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ Operation<Type> opSource2 = new Operation<Type>("op2", null, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op2", opSource2);
+ target.setOperations(targetOperations);
+ try {
+ wireService.checkCompatibility(source, target, false);
+ fail();
+ } catch (IncompatibleServiceContractException e) {
+ //expected
+ }
+ }
+
+ public void testInputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ List<DataType<Type>> sourceInputTypes = new ArrayList<DataType<Type>>();
+ sourceInputTypes.add(new DataType<Type>(Object.class, Object.class));
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(String.class, sourceInputTypes);
+ Operation<Type> opSource1 = new Operation<Type>("op1", inputType, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ List<DataType<Type>> targetInputTypes = new ArrayList<DataType<Type>>();
+ targetInputTypes.add(new DataType<Type>(Object.class, Object.class));
+ DataType<List<DataType<Type>>> targetInputType =
+ new DataType<List<DataType<Type>>>(String.class, targetInputTypes);
+
+ Operation<Type> opTarget = new Operation<Type>("op1", targetInputType, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+
+ public void testIncompatibleInputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ List<DataType<Type>> sourceInputTypes = new ArrayList<DataType<Type>>();
+ sourceInputTypes.add(new DataType<Type>(Integer.class, Integer.class));
+ DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(String.class, sourceInputTypes);
+ Operation<Type> opSource1 = new Operation<Type>("op1", inputType, null, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ List<DataType<Type>> targetInputTypes = new ArrayList<DataType<Type>>();
+ targetInputTypes.add(new DataType<Type>(String.class, String.class));
+ DataType<List<DataType<Type>>> targetInputType =
+ new DataType<List<DataType<Type>>>(String.class, targetInputTypes);
+
+ Operation<Type> opTarget = new Operation<Type>("op1", targetInputType, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ try {
+ wireService.checkCompatibility(source, target, false);
+ fail();
+ } catch (IncompatibleServiceContractException e) {
+ //expected
+ }
+ }
+
+ /**
+ * Verfies source input types can be super types of the target
+ */
+ public void testSourceSuperTypeInputCompatibility() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// List<DataType<Type>> sourceInputTypes = new ArrayList<DataType<Type>>();
+// sourceInputTypes.add(new DataType<Type>(Object.class, Object.class));
+// DataType<List<DataType<Type>>> inputType = new DataType<List<DataType<Type>>>(String.class, sourceInputTypes);
+// Operation<Type> opSource1 = new Operation<Type>("op1", inputType, null, null, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// List<DataType<Type>> targetInputTypes = new ArrayList<DataType<Type>>();
+// targetInputTypes.add(new DataType<Type>(String.class, String.class));
+// DataType<List<DataType<Type>>> targetInputType =
+// new DataType<List<DataType<Type>>>(String.class, targetInputTypes);
+//
+// Operation<Type> opTarget = new Operation<Type>("op1", targetInputType, null, null, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testOutputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceOutputType = new DataType<Type>(String.class, String.class);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, sourceOutputType, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ DataType<Type> targetOutputType = new DataType<Type>(String.class, String.class);
+ Operation<Type> opTarget = new Operation<Type>("op1", null, targetOutputType, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verfies a return type that is a supertype of of the target is compatible
+ */
+ public void testSupertypeOutputTypes() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// DataType<Type> sourceOutputType = new DataType<Type>(Object.class, Object.class);
+// Operation<Type> opSource1 = new Operation<Type>("op1", null, sourceOutputType, null, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// DataType<Type> targetOutputType = new DataType<Type>(String.class, String.class);
+// Operation<Type> opTarget = new Operation<Type>("op1", null, targetOutputType, null, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testIncompatibleOutputTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceOutputType = new DataType<Type>(String.class, String.class);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, sourceOutputType, null, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ DataType<Type> targetOutputType = new DataType<Type>(Integer.class, Integer.class);
+ Operation<Type> opTarget = new Operation<Type>("op1", null, targetOutputType, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ try {
+ wireService.checkCompatibility(source, target, false);
+ fail();
+ } catch (IncompatibleServiceContractException e) {
+ //expected
+ }
+ }
+
+ public void testFaultTypes() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceFaultType = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ DataType<Type> targetFaultType = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> targetFaultTypes = new ArrayList<DataType<Type>>();
+ targetFaultTypes.add(0, targetFaultType);
+
+ Operation<Type> opTarget = new Operation<Type>("op1", null, null, targetFaultTypes, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ public void testSourceFaultTargetNoFaultCompatibility() throws Exception {
+ ServiceContract<Type> source = new MockContract<Type>("FooContract");
+ DataType<Type> sourceFaultType = new DataType<Type>(String.class, String.class);
+ List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+ sourceFaultTypes.add(0, sourceFaultType);
+ Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+ Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+ sourceOperations.put("op1", opSource1);
+ source.setOperations(sourceOperations);
+
+ ServiceContract<Type> target = new MockContract<Type>("FooContract");
+ Operation<Type> opTarget = new Operation<Type>("op1", null, null, null, false, null);
+ Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+ targetOperations.put("op1", opTarget);
+ target.setOperations(targetOperations);
+ wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verifies a source's fault which is a supertype of the target's fault are compatibile
+ *
+ * @throws Exception
+ */
+ public void testFaultSuperTypes() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// DataType<Type> sourceFaultType = new DataType<Type>(Exception.class, Exception.class);
+// List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+// sourceFaultTypes.add(0, sourceFaultType);
+// Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// DataType<Type> targetFaultType = new DataType<Type>(TuscanyException.class, TuscanyException.class);
+// List<DataType<Type>> targetFaultTypes = new ArrayList<DataType<Type>>();
+// targetFaultTypes.add(0, targetFaultType);
+//
+// Operation<Type> opTarget = new Operation<Type>("op1", null, null, targetFaultTypes, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ /**
+ * Verifies a source's faults which are supertypes and a superset of the target's faults are compatibile
+ */
+ public void testFaultSuperTypesAndSuperset() throws Exception {
+// ServiceContract<Type> source = new MockContract<Type>("FooContract");
+// DataType<Type> sourceFaultType = new DataType<Type>(Exception.class, Exception.class);
+// DataType<Type> sourceFaultType2 = new DataType<Type>(RuntimeException.class, RuntimeException.class);
+// List<DataType<Type>> sourceFaultTypes = new ArrayList<DataType<Type>>();
+// sourceFaultTypes.add(0, sourceFaultType);
+// sourceFaultTypes.add(1, sourceFaultType2);
+// Operation<Type> opSource1 = new Operation<Type>("op1", null, null, sourceFaultTypes, false, null);
+// Map<String, Operation<Type>> sourceOperations = new HashMap<String, Operation<Type>>();
+// sourceOperations.put("op1", opSource1);
+// source.setOperations(sourceOperations);
+//
+// ServiceContract<Type> target = new MockContract<Type>("FooContract");
+// DataType<Type> targetFaultType = new DataType<Type>(TuscanyException.class, TuscanyException.class);
+// List<DataType<Type>> targetFaultTypes = new ArrayList<DataType<Type>>();
+// targetFaultTypes.add(0, targetFaultType);
+//
+// Operation<Type> opTarget = new Operation<Type>("op1", null, null, targetFaultTypes, false, null);
+// Map<String, Operation<Type>> targetOperations = new HashMap<String, Operation<Type>>();
+// targetOperations.put("op1", opTarget);
+// target.setOperations(targetOperations);
+// wireService.checkCompatibility(source, target, false);
+ }
+
+ private class MockContract<T> extends ServiceContract<T> {
+ public MockContract() {
+ }
+
+ public MockContract(Class interfaceClass) {
+ super(interfaceClass);
+ }
+
+ public MockContract(String interfaceName) {
+ super(interfaceName);
+ }
+ }
+
+ private class MockWireService extends WireServiceExtension {
+ public MockWireService() {
+ super(null, null);
+ }
+
+ public Object createProxy(RuntimeWire wire) throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object createCallbackProxy(ServiceContract<?> contract, InboundWire wire) throws ProxyCreationException {
+ throw new UnsupportedOperationException();
+ }
+
+
+ public WireInvocationHandler createHandler(RuntimeWire wire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public WireInvocationHandler createCallbackHandler(InboundWire wire) {
+ throw new UnsupportedOperationException();
+ }
+
+ public OutboundInvocationChain createOutboundChain(Operation<?> operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public InboundInvocationChain createInboundChain(Operation<?> operation) {
+ throw new UnsupportedOperationException();
+ }
+
+ public InboundWire createWire(ServiceDefinition service) {
+ throw new UnsupportedOperationException();
+ }
+
+ public OutboundWire createWire(ReferenceTarget reference, ReferenceDefinition def) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void createWires(Component component, ComponentDefinition<?> definition) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void createWires(Reference reference, ServiceContract<?> contract) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void createWires(Service service, String targetName, ServiceContract<?> contract) {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+}