From 71b9f42ceb8dcf0c5a510a3a5909211d75bdb145 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 22 Jul 2008 16:01:38 +0000 Subject: 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 --- java/sca/itest/corba/pom.xml | 14 +++- .../sca/test/corba/ScenarioFourTestCase.java | 96 ++++++++++++++++++++++ .../tuscany/sca/test/corba/types/ScenarioFour.java | 32 ++++++++ .../test/corba/types/ScenarioFourComponent.java | 40 +++++++++ .../sca/test/corba/types/ScenarioFourImpl.java | 31 +++++++ .../sca/test/corba/types/ScenarioFourStruct.java | 39 +++++++++ .../src/test/resources/ScenarioFour.composite | 43 ++++++++++ 7 files changed, 294 insertions(+), 1 deletion(-) create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/ScenarioFourTestCase.java create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFour.java create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourComponent.java create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourImpl.java create mode 100644 java/sca/itest/corba/src/test/java/org/apache/tuscany/sca/test/corba/types/ScenarioFourStruct.java create mode 100644 java/sca/itest/corba/src/test/resources/ScenarioFour.composite (limited to 'java/sca/itest/corba') 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 @@ -51,6 +51,18 @@ 1.4-SNAPSHOT runtime + + org.apache.tuscany.sca + tuscany-binding-sca + 1.4-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-binding-sca-corba + 1.4-SNAPSHOT + runtime + junit junit @@ -58,4 +70,4 @@ compile - \ No newline at end of file + 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 @@ + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3