summaryrefslogtreecommitdiffstats
path: root/java/sca/itest/corba
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-22 16:01:38 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-22 16:01:38 +0000
commit71b9f42ceb8dcf0c5a510a3a5909211d75bdb145 (patch)
tree6c64d16d8f438a89501f05a6faa27ea63206fa6c /java/sca/itest/corba
parent273d7efc7b7c1e35609fee005fb9ef97c4f3e53f (diff)
Apply the patch from Wojtek for TUSCANY-2469. Thanks.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@678786 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/itest/corba')
-rw-r--r--java/sca/itest/corba/pom.xml14
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java96
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java32
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java40
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java31
-rw-r--r--java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java39
-rw-r--r--java/sca/itest/corba/src/test/resources/ScenarioFour.composite43
7 files changed, 294 insertions, 1 deletions
diff --git a/java/sca/itest/corba/pom.xml b/java/sca/itest/corba/pom.xml
index 910c5ca7cc..b1d45f7c32 100644
--- a/java/sca/itest/corba/pom.xml
+++ b/java/sca/itest/corba/pom.xml
@@ -52,10 +52,22 @@
<scope>runtime</scope>
</dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-corba</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
-</project> \ No newline at end of file
+</project>
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java
new file mode 100644
index 0000000000..f47792c5f2
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import junit.framework.Assert;
+
+import org.apache.tuscany.sca.host.corba.naming.TransientNameServer;
+import org.apache.tuscany.sca.host.corba.naming.TransientNameService;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFour;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFourComponent;
+import org.apache.tuscany.sca.test.corba.types.ScenarioFourStruct;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests SCA default binding over CORBA binding
+ */
+public class ScenarioFourTestCase {
+
+ // note that those values are also used in resources/*.composite file
+ private static int ORB_INITIAL_PORT = 5060;
+ private static SCADomain domain;
+ private static TransientNameServer server;
+
+ /**
+ * Sets up name service, creates and registers traditional CORBA service,
+ * obtains SCADomain
+ */
+ @BeforeClass
+ public static void setUp() {
+ try {
+ try {
+ server =
+ new TransientNameServer("localhost", ORB_INITIAL_PORT, TransientNameService.DEFAULT_SERVICE_NAME);
+ Thread t = server.start();
+ if (t == null) {
+ Assert.fail("The naming server cannot be started");
+ }
+ } catch (Throwable e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ // obtain domain
+ domain = SCADomain.newInstance("ScenarioFour.composite");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Kills previously spawned name service.
+ */
+ @AfterClass
+ public static void tearDown() {
+ server.stop();
+ }
+
+ @Test
+ public void test_generalTest() {
+ try {
+ ScenarioFourComponent soc = domain.getService(ScenarioFourComponent.class, "ScenarioFour");
+ ScenarioFour so = soc.getScenarioFour();
+ ScenarioFourStruct input = new ScenarioFourStruct();
+ input.field1 = "Test";
+ input.field2 = 1;
+ input.field3 = new double[1];
+ ScenarioFourStruct output = so.setStruct(input);
+ assertTrue(input.equals(output));
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail(e.getMessage());
+ }
+ }
+
+}
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java
new file mode 100644
index 0000000000..d1492f85e5
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Operations for ScenarioFour
+ */
+@Remotable
+public interface ScenarioFour {
+
+ ScenarioFourStruct setStruct(ScenarioFourStruct struct);
+
+}
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java
new file mode 100644
index 0000000000..f29c050043
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * Component for obtaining ScenarioFour reference
+ */
+public class ScenarioFourComponent {
+
+ private ScenarioFour scenarioFour;
+
+ @Reference
+ public void setScenarioFour(ScenarioFour scenarioFour) {
+ this.scenarioFour = scenarioFour;
+ }
+
+ public ScenarioFour getScenarioFour() {
+ return scenarioFour;
+ }
+
+}
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java
new file mode 100644
index 0000000000..c047fafca4
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+/**
+ * Implementation of ScenarioFour service
+ */
+public class ScenarioFourImpl implements ScenarioFour {
+
+ public ScenarioFourStruct setStruct(ScenarioFourStruct struct) {
+ return struct;
+ }
+
+}
diff --git a/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java
new file mode 100644
index 0000000000..c142fecb79
--- /dev/null
+++ b/java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.test.corba.types;
+
+/**
+ * Type for ScenarioFour test
+ */
+public class ScenarioFourStruct {
+
+ public String field1;
+ public int field2;
+ public double[] field3;
+
+ public boolean equals(ScenarioFourStruct arg) {
+ return (field1 != null && arg.field1 != null
+ && field1.equals(arg.field1)
+ && field2 == arg.field2
+ && field3 != null
+ && arg.field3 != null && field3.length == arg.field3.length);
+ }
+
+}
diff --git a/java/sca/itest/corba/src/test/resources/ScenarioFour.composite b/java/sca/itest/corba/src/test/resources/ScenarioFour.composite
new file mode 100644
index 0000000000..c13bf7fd79
--- /dev/null
+++ b/java/sca/itest/corba/src/test/resources/ScenarioFour.composite
@@ -0,0 +1,43 @@
+<!--
+ * 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.
+-->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Corba">
+
+ <!-- note that some binding configuration (like port or host name) is also used in JUnit test class -->
+
+ <component name="ScenarioFourService">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFourImpl" />
+ </component>
+ <service name="ScenarioFour" promote="ScenarioFourService">
+ <interface.java interface="org.apache.tuscany.sca.test.corba.types.ScenarioFour"/>
+ <binding.sca uri="corbaname::localhost:5060#ScenarioFour"/>
+ </service>
+
+ <component name="ScenarioFour">
+ <implementation.java class="org.apache.tuscany.sca.test.corba.types.ScenarioFourComponent" />
+ <reference name="scenarioFour">
+ <binding.sca uri="corbaname::localhost:5060#ScenarioFour"/>
+ </reference>
+ </component>
+
+</composite>