summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container')
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java75
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java76
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java32
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java25
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java46
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java26
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java39
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java48
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java24
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java28
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl98
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java51
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java86
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java74
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java78
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java91
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java27
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java50
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java156
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java115
-rw-r--r--sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java184
24 files changed, 1540 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java
new file mode 100644
index 0000000000..c751b0a2ef
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/impl/JavaScriptImplementationTestCase.java
@@ -0,0 +1,75 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.impl;
+
+import junit.framework.TestCase;
+
+/**
+ * FIXME commented out until SCDL loading works
+ *
+ * @version $Rev: 368822 $ $Date: 2006-01-13 18:54:38 +0000 (Fri, 13 Jan 2006) $
+ */
+public class JavaScriptImplementationTestCase extends TestCase {
+
+ private JavaScriptImplementationImpl impl = (JavaScriptImplementationImpl) new JavaScriptAssemblyFactoryImpl()
+ .createJavaScriptImplementation();
+
+ public void testDummy(){} // remove when tests added back
+
+// public void testNoImplementationClass() {
+// impl.setScriptFile("no.such.script.js");
+// try {
+// impl.initialize(new AssemblyModelContextImpl(null, null));
+// impl.getComponentType();
+// fail("Expected IllegalArgumentException");
+// } catch (IllegalArgumentException e) {
+// // ok
+// }
+// }
+
+// public void testHelloWorldWithSidefile() {
+// impl.setScriptFile("org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js");
+// impl.initialize(new AssemblyModelContextImpl(new AssemblyLoaderImpl(), ResourceLoaderFactory.getResourceLoader(Thread
+// .currentThread().getContextClassLoader())));
+// ComponentType type = impl.getComponentType();
+// Assert.assertNotNull(type);
+// List<Property> props = type.getProperties();
+// Assert.assertEquals(1, props.size());
+// Assert.assertTrue(props.get(0).getName().equals("text"));
+//
+// Assert.assertTrue(type.getReferences().isEmpty());
+//
+// List<Service> services = type.getServices();
+// Assert.assertEquals(1, services.size());
+// Assert.assertTrue(services.get(0).getName().equals("HelloWorldService"));
+// }
+
+ // static {
+ // // bootstrap this somehow
+ // AssemblyPackage.eINSTANCE.getClass();
+ // }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(JavaScriptImplementationTestCase.class.getClassLoader());
+ }
+
+ protected void tearDown() throws Exception {
+ Thread.currentThread().setContextClassLoader(null);
+ super.tearDown();
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java
new file mode 100644
index 0000000000..8edb27a473
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/mock/HelloWorldService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.mock;
+
+/**
+ * @version $Rev: 368822 $ $Date: 2006-01-13 18:54:38 +0000 (Fri, 13 Jan 2006) $
+ */
+public interface HelloWorldService {
+ String hello(String name);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java
new file mode 100644
index 0000000000..91ce8a73eb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/JavaScriptAssemblyLoaderTestCase.java
@@ -0,0 +1,76 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+
+/**
+ */
+public class JavaScriptAssemblyLoaderTestCase extends TestCase {
+
+ private AssemblyModelContext modelContext;
+
+ /**
+ *
+ */
+ public JavaScriptAssemblyLoaderTestCase() {
+ super();
+ }
+
+ public void testLoader() {
+/*
+
+ AssemblyLoader loader = modelContext.getAssemblyLoader();
+ Module module = loader.getModule(getClass().getResource("sca.module").toString());
+ module.initialize(modelContext);
+
+ Assert.assertTrue(module.getName().equals("tuscany.container.js.assembly.tests.bigbank.account"));
+
+ Component component = module.getComponent("AccountServiceComponent");
+ Assert.assertTrue(component != null);
+
+ EntryPoint entryPoint = module.getEntryPoint("AccountService");
+ Assert.assertTrue(entryPoint != null);
+
+ Object value = component.getConfiguredProperty("currency").getValue();
+ Assert.assertTrue(value.equals("EURO"));
+
+ ConfiguredService configuredService = component.getConfiguredReference("accountDataService").getConfiguredServices().get(0);
+ Assert.assertTrue(configuredService.getPart().getName().equals("AccountDataServiceComponent"));
+
+ InterfaceType interfaceType = configuredService.getService().getInterfaceContract().getInterfaceType();
+ OperationType operationType = interfaceType.getOperationType("getCheckingAccount");
+ Type type = operationType.getInputType();
+ Property arg = (Property) type.getProperties().get(0);
+ Assert.assertTrue(arg.getType().getInstanceClass() == String.class);
+*/
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ modelContext = new AssemblyModelContextImpl(null,null);
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java
new file mode 100644
index 0000000000..90c47d400c
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountReport.java
@@ -0,0 +1,32 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.account;
+
+import java.util.List;
+
+/**
+ * @model
+ */
+
+public interface AccountReport {
+
+ /**
+ * @model type="services.account.AccountSummary"
+ */
+
+ List getAccountSummaries();
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java
new file mode 100644
index 0000000000..ff555e178f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountService.java
@@ -0,0 +1,25 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.account;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface AccountService {
+
+ public AccountReport getAccountReport(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java
new file mode 100644
index 0000000000..ad3b4ad737
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/account/AccountSummary.java
@@ -0,0 +1,46 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.account;
+
+/**
+ * @model
+ */
+
+public interface AccountSummary {
+
+ /**
+ * @model
+ */
+ String getAccountNumber();
+
+ void setAccountNumber(String accountNumber);
+
+ /**
+ * @model
+ */
+ String getAccountType();
+
+ void setAccountType(String accountType);
+
+ /**
+ * @model
+ */
+ float getBalance();
+
+ void setBalance(float balance);
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
new file mode 100644
index 0000000000..42d8994392
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.accountdata;
+
+public interface AccountDataService {
+
+ CheckingAccount getCheckingAccount(String customerID);
+
+ SavingsAccount getSavingsAccount(String customerID);
+
+ StockAccount getStockAccount(String customerID);
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
new file mode 100644
index 0000000000..24b91020f7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.accountdata;
+
+public class AccountDataServiceImpl implements AccountDataService {
+
+ public CheckingAccount getCheckingAccount(String customerID) {
+
+ CheckingAccount checkingAccount = new CheckingAccount();
+ checkingAccount.setAccountNumber(customerID + "_" + "CHA12345");
+ checkingAccount.setBalance(1500.0f);
+
+ return checkingAccount;
+ }
+
+ public SavingsAccount getSavingsAccount(String customerID) {
+
+ SavingsAccount savingsAccount = new SavingsAccount();
+ savingsAccount.setAccountNumber(customerID + "_" + "SAA12345");
+ savingsAccount.setBalance(1500.0f);
+
+ return savingsAccount;
+ }
+
+ public StockAccount getStockAccount(String customerID) {
+
+ StockAccount stockAccount = new StockAccount();
+ stockAccount.setAccountNumber(customerID + "_" + "STA12345");
+ stockAccount.setSymbol("IBM");
+ stockAccount.setQuantity(100);
+
+ return stockAccount;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
new file mode 100644
index 0000000000..43b755e0fb
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.accountdata;
+
+public class CheckingAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
new file mode 100644
index 0000000000..3f8cb65ad7
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.accountdata;
+
+public class SavingsAccount {
+
+ private String accountNumber;
+ private float balance;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public float getBalance() {
+ return balance;
+ }
+
+ public void setBalance(float balance) {
+ this.balance = balance;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
new file mode 100644
index 0000000000..ae6cdd6ff6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/accountdata/StockAccount.java
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.accountdata;
+
+public class StockAccount {
+
+ private String accountNumber;
+ private String symbol;
+ private int quantity;
+
+ public String getAccountNumber() {
+ return accountNumber;
+ }
+
+ public void setAccountNumber(String accountNumber) {
+ this.accountNumber = accountNumber;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..8720bcdaf6
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java
@@ -0,0 +1,24 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.stockquote;
+
+public interface StockQuoteService {
+
+ public float getQuote(String symbol);
+}
+
+ \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
new file mode 100644
index 0000000000..9765b67c2f
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteServiceImpl.java
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.assembly.tests.bigbank.account.services.stockquote;
+
+/* Dummy'd up StockQuoteService, override webservice for now */
+
+public class StockQuoteServiceImpl implements StockQuoteService {
+
+ public float getQuote(String symbol) {
+ // Just hardcode for now
+ return 83.00f;
+ }
+
+} \ No newline at end of file
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
new file mode 100644
index 0000000000..01df4ef054
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/assembly/tests/bigbank/account/services/stockquote/StockQuoteWebService.wsdl
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2005 The Apache Software Foundation or its licensors, as applicable.
+
+ Licensed 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.
+ -->
+<wsdl:definitions targetNamespace="http://webservice.stockquote" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.stockquote" xmlns:intf="http://webservice.stockquote" xmlns:tns1="http://stockquote" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="">
+ <!--WSDL created by Apache Axis version: 1.2.1
+Built on Jun 14, 2005 (09:15:57 EDT)-->
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="GetQuoteRequest">
+ <sequence>
+ <element name="symbol" nillable="true" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ <complexType name="GetQuoteResponse">
+ <sequence>
+ <element name="price" type="xsd:float"/>
+ </sequence>
+ </complexType>
+ </schema>
+ <schema elementFormDefault="qualified" targetNamespace="http://webservice.stockquote" xmlns="http://www.w3.org/2001/XMLSchema">
+ <import namespace="http://stockquote"/>
+ <element name="request" type="tns1:GetQuoteRequest"/>
+ <element name="getQuoteReturn" type="tns1:GetQuoteResponse"/>
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="getQuoteResponse">
+
+ <wsdl:part element="impl:getQuoteReturn" name="getQuoteReturn"/>
+
+ </wsdl:message>
+
+ <wsdl:message name="getQuoteRequest">
+
+ <wsdl:part element="impl:request" name="request"/>
+
+ </wsdl:message>
+
+ <wsdl:portType name="StockQuoteWebService">
+
+ <wsdl:operation name="getQuote" parameterOrder="request">
+
+ <wsdl:input message="impl:getQuoteRequest" name="getQuoteRequest"/>
+
+ <wsdl:output message="impl:getQuoteResponse" name="getQuoteResponse"/>
+
+ </wsdl:operation>
+
+ </wsdl:portType>
+
+ <wsdl:binding name="StockQuoteWebServiceSoapBinding" type="impl:StockQuoteWebService">
+
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+ <wsdl:operation name="getQuote">
+
+ <wsdlsoap:operation soapAction=""/>
+
+ <wsdl:input name="getQuoteRequest">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:input>
+
+ <wsdl:output name="getQuoteResponse">
+
+ <wsdlsoap:body use="literal"/>
+
+ </wsdl:output>
+
+ </wsdl:operation>
+
+ </wsdl:binding>
+
+ <wsdl:service name="StockQuoteWebServiceService">
+
+ <wsdl:port binding="impl:StockQuoteWebServiceSoapBinding" name="StockQuoteWebService">
+
+ <wsdlsoap:address location="http://localhost:8123/StockQuoteWebService/services/StockQuoteWebService"/>
+
+ </wsdl:port>
+
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java
new file mode 100644
index 0000000000..d21c17636a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/JSComponentContextBuilderTestCase.java
@@ -0,0 +1,51 @@
+package org.apache.tuscany.container.js.builder;
+
+import java.util.Collection;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.js.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.js.config.JavaScriptComponentRuntimeConfiguration;
+import org.apache.tuscany.container.js.mock.MockAssemblyFactory;
+import org.apache.tuscany.core.builder.RuntimeConfiguration;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.InstanceContext;
+import org.apache.tuscany.core.context.QualifiedName;
+import org.apache.tuscany.core.context.impl.EventContextImpl;
+import org.apache.tuscany.core.context.scope.ModuleScopeContext;
+import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+public class JSComponentContextBuilderTestCase extends TestCase {
+
+ public void testBasicInvocation() throws Exception {
+ JavaScriptComponentContextBuilder jsBuilder = new JavaScriptComponentContextBuilder();
+ jsBuilder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+ JavaScriptTargetWireBuilder jsWireBuilder = new JavaScriptTargetWireBuilder();
+ SimpleComponent component = MockAssemblyFactory.createComponent("foo",
+ "org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js", HelloWorldService.class, Scope.MODULE);
+ component.initialize(new AssemblyModelContextImpl(new AssemblyFactoryImpl(), new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader())));
+ jsBuilder.build(component, null);
+ ModuleScopeContext context = new ModuleScopeContext(new EventContextImpl());
+ RuntimeConfiguration<InstanceContext> config = (RuntimeConfiguration) component.getComponentImplementation()
+ .getRuntimeConfiguration();
+ context.registerConfiguration(config);
+ context.start();
+ context.onEvent(EventContext.MODULE_START, null);
+ for (ProxyFactory proxyFactory : (Collection<ProxyFactory>) config.getTargetProxyFactories().values()) {
+ jsWireBuilder.completeTargetChain(proxyFactory, JavaScriptComponentRuntimeConfiguration.class, context);
+ proxyFactory.initialize();
+ }
+ InstanceContext ctx = config.createInstanceContext();
+ HelloWorldService hello = (HelloWorldService) ctx.getInstance(new QualifiedName("foo/HelloWorldService"));
+ Assert.assertNotNull(hello);
+ Assert.assertEquals("Hello foo", hello.hello("foo"));
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java
new file mode 100644
index 0000000000..5f5e8d769a
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockHandlerBuilder.java
@@ -0,0 +1,86 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+/**
+ * Adds a handler to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockHandlerBuilder implements RuntimeConfigurationBuilder {
+
+ private MessageHandler handler;
+
+ private boolean source;
+
+ private boolean request;
+
+ /**
+ * Creates the builder.
+ *
+ * @param handler the handler to add to the source or target proxy configuration
+ * @param source true if the handler should be added on the source side; false if the handler should be added to the
+ * target side
+ * @param request true if the handler is a request handler; false if the handler is a response handler
+ */
+ public MockHandlerBuilder(MessageHandler handler, boolean source, boolean request) {
+ this.handler = handler;
+ this.source = source;
+ this.request = request;
+ }
+
+ public void build(AssemblyModelObject modelObject, Context context) throws BuilderException {
+ if (source) {
+ if (!(modelObject instanceof ConfiguredReference)) {
+ return;
+ } else {
+ ConfiguredReference cref = (ConfiguredReference) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cref.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+ } else {
+ if (!(modelObject instanceof ConfiguredService)) {
+ return;
+ } else {
+ ConfiguredService cservice = (ConfiguredService) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cservice.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ if (request) {
+ config.addRequestHandler(handler);
+ } else {
+ config.addResponseHandler(handler);
+ }
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java
new file mode 100644
index 0000000000..0ed27101dd
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/builder/MockInterceptorBuilder.java
@@ -0,0 +1,74 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.builder;
+
+import org.apache.tuscany.core.builder.BuilderException;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.context.Context;
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.spi.ProxyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelObject;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+
+/**
+ * Adds an interceptor to a source or target proxy configuration
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockInterceptorBuilder implements RuntimeConfigurationBuilder {
+
+ private Interceptor interceptor;
+
+ private boolean source;
+
+ /**
+ * Creates the builder
+ *
+ * @param interceptor the interceptor ot add
+ * @param source true if the interceptor should be added to the source side; false if the interceptor should be
+ * added to the target side
+ */
+ public MockInterceptorBuilder(Interceptor interceptor, boolean source) {
+ this.interceptor = interceptor;
+ this.source = source;
+ }
+
+ public void build(AssemblyModelObject modelObject, Context context) throws BuilderException {
+ if (source) {
+ if (!(modelObject instanceof ConfiguredReference)) {
+ return;
+ } else {
+ ConfiguredReference cref = (ConfiguredReference) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cref.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ config.addSourceInterceptor(interceptor);
+ }
+ }
+ } else {
+ if (!(modelObject instanceof ConfiguredService)) {
+ return;
+ } else {
+ ConfiguredService cservice = (ConfiguredService) modelObject;
+ ProxyFactory pFactory = (ProxyFactory) cservice.getProxyFactory();
+ for (InvocationConfiguration config : pFactory.getProxyConfiguration().getInvocationConfigurations().values()) {
+ config.addTargetInterceptor(interceptor);
+ }
+ }
+
+ }
+ }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java
new file mode 100644
index 0000000000..4f9ba1ab49
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/config/ModuleComponentConfigurationLoaderTestCase.java
@@ -0,0 +1,78 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.config;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.js.assembly.impl.JavaScriptImplementationImpl;
+import org.apache.tuscany.container.js.loader.JavaScriptSCDLModelLoader;
+import org.apache.tuscany.core.config.ConfigurationException;
+import org.apache.tuscany.core.config.ModuleComponentConfigurationLoader;
+import org.apache.tuscany.core.config.impl.ModuleComponentConfigurationLoaderImpl;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ComponentImplementation;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.ModuleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.assembly.loader.AssemblyModelLoader;
+import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+
+/**
+ * @version $Rev: 368822 $ $Date: 2006-01-13 18:54:38 +0000 (Fri, 13 Jan 2006) $
+ */
+public class ModuleComponentConfigurationLoaderTestCase extends TestCase {
+ private ModuleComponentConfigurationLoader loader;
+
+ public void testFoo() throws ConfigurationException {
+ URL xml = ModuleComponentConfigurationLoaderTestCase.class.getResource("ModuleComponentLoaderTest1.module");
+ ModuleComponent moduleComponent = loader.loadModuleComponent("test", "test", xml.toString());
+ Assert.assertEquals("test", moduleComponent.getName());
+ Module module = moduleComponent.getModuleImplementation();
+ Assert.assertEquals("ModuleComponentLoaderTest1", module.getName());
+ List<Component> components = module.getComponents();
+ Assert.assertEquals(1, components.size());
+ Component component = components.get(0);
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ component = module.getComponent("HelloWorldServiceComponent");
+ Assert.assertEquals("HelloWorldServiceComponent", component.getName());
+
+ ComponentImplementation implementation = component.getComponentImplementation();
+ Assert.assertTrue(implementation instanceof JavaScriptImplementationImpl);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ List<SCDLModelLoader> scdlLoaders=new ArrayList<SCDLModelLoader>();
+ JavaScriptSCDLModelLoader jsLoader=new JavaScriptSCDLModelLoader();
+ scdlLoaders.add(jsLoader);
+ AssemblyModelLoader modelLoader=new SCDLAssemblyModelLoaderImpl(scdlLoaders);
+ AssemblyModelContext modelContext=new AssemblyModelContextImpl(
+ new AssemblyFactoryImpl(), modelLoader,new ResourceLoaderImpl(this.getClass().getClassLoader()));
+ loader = new ModuleComponentConfigurationLoaderImpl(modelContext);
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java
new file mode 100644
index 0000000000..cd29f59327
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/integration/JSComponentContextTestCase.java
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.integration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.container.js.assembly.mock.HelloWorldService;
+import org.apache.tuscany.container.js.builder.JavaScriptComponentContextBuilder;
+import org.apache.tuscany.container.js.builder.JavaScriptTargetWireBuilder;
+import org.apache.tuscany.container.js.builder.MockInterceptorBuilder;
+import org.apache.tuscany.container.js.invocation.mock.MockSyncInterceptor;
+import org.apache.tuscany.container.js.mock.MockAssemblyFactory;
+import org.apache.tuscany.container.js.mock.MockModuleFactory;
+import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
+import org.apache.tuscany.core.builder.impl.DefaultWireBuilder;
+import org.apache.tuscany.core.builder.impl.HierarchicalBuilder;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.context.EventContext;
+import org.apache.tuscany.core.context.impl.AggregateContextImpl;
+import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
+import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
+import org.apache.tuscany.core.runtime.RuntimeContext;
+import org.apache.tuscany.core.runtime.RuntimeContextImpl;
+import org.apache.tuscany.core.system.builder.SystemComponentContextBuilder;
+import org.apache.tuscany.core.system.builder.SystemEntryPointBuilder;
+import org.apache.tuscany.core.system.builder.SystemExternalServiceBuilder;
+import org.apache.tuscany.model.assembly.Scope;
+
+/**
+ * Integration tests for JavaScript components and aggregate contexts
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSComponentContextTestCase extends TestCase {
+
+ public void testBasicInvocation() throws Exception {
+ MessageFactory msgFactory = new MessageFactoryImpl();
+
+ List<RuntimeConfigurationBuilder> builders = new ArrayList();
+ builders.add((new SystemComponentContextBuilder()));
+ builders.add(new SystemEntryPointBuilder());
+ builders.add(new SystemExternalServiceBuilder());
+
+ JavaScriptComponentContextBuilder javaBuilder = new JavaScriptComponentContextBuilder();
+ javaBuilder.setMessageFactory(msgFactory);
+ javaBuilder.setProxyFactoryFactory(new JDKProxyFactoryFactory());
+
+ MockSyncInterceptor mockInterceptor = new MockSyncInterceptor();
+ MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, true);
+ HierarchicalBuilder refBuilder = new HierarchicalBuilder();
+ refBuilder.addBuilder(interceptorBuilder);
+ javaBuilder.setReferenceBuilder(refBuilder);
+ builders.add(javaBuilder);
+
+ DefaultWireBuilder defaultWireBuilder = new DefaultWireBuilder();
+
+ RuntimeContext runtime = new RuntimeContextImpl(null, null, builders, defaultWireBuilder);
+ runtime.addBuilder(new JavaScriptTargetWireBuilder());
+ runtime.start();
+ runtime.getRootContext().registerModelObject(
+ MockAssemblyFactory.createSystemComponent("test.module", AggregateContextImpl.class.getName(),
+ Scope.AGGREGATE));
+ AggregateContext child = (AggregateContext) runtime.getRootContext().getContext("test.module");
+ child.registerModelObject(MockModuleFactory.createModule());
+ child.fireEvent(EventContext.MODULE_START, null);
+ HelloWorldService source = (HelloWorldService) child.locateInstance("source/HelloWorldService");
+ Assert.assertNotNull(source);
+ Assert.assertEquals("Hello foo",source.hello("foo"));
+ //Assert.assertEquals(1, mockInterceptor.getCount());
+ child.fireEvent(EventContext.MODULE_STOP, null);
+ runtime.stop();
+ }
+
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java
new file mode 100644
index 0000000000..7064ec5d65
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockHandler.java
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+package org.apache.tuscany.container.js.invocation.mock;
+
+import org.apache.tuscany.core.invocation.MessageHandler;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * A test handler
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockHandler implements MessageHandler {
+
+ private int count =0;
+
+ public boolean processMessage(Message message) {
+ //System.out.println("Invoking handler");
+ count++;
+ return true;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java
new file mode 100644
index 0000000000..caab4b3756
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/invocation/mock/MockSyncInterceptor.java
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.invocation.mock;
+
+import org.apache.tuscany.core.invocation.Interceptor;
+import org.apache.tuscany.core.message.Message;
+
+/**
+ * A test interceptor
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockSyncInterceptor implements Interceptor {
+
+ private int count;
+
+ private Interceptor next;
+
+ public MockSyncInterceptor() {
+ }
+
+ public Message invoke(Message msg) {
+ ++count;
+ //System.out.println("Invoking interceptor");
+ return next.invoke(msg);
+ }
+
+ public int getCount() {
+ return count;
+ }
+
+ public void setNext(Interceptor next) {
+ this.next=next;
+ }
+}
+
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java
new file mode 100644
index 0000000000..5cb80b29aa
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockAssemblyFactory.java
@@ -0,0 +1,156 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.mock;
+
+import org.apache.tuscany.container.js.assembly.JavaScriptAssemblyFactory;
+import org.apache.tuscany.container.js.assembly.JavaScriptImplementation;
+import org.apache.tuscany.container.js.assembly.impl.JavaScriptAssemblyFactoryImpl;
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+import org.apache.tuscany.core.context.AggregateContext;
+import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
+import org.apache.tuscany.core.system.assembly.SystemImplementation;
+import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.SimpleComponent;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Generates test components and module assemblies
+ *
+ * @version $Rev: 377775 $ $Date: 2006-02-14 09:18:31 -0800 (Tue, 14 Feb 2006) $
+ */
+public class MockAssemblyFactory {
+
+ private static JavaScriptAssemblyFactory factory = new JavaScriptAssemblyFactoryImpl();
+
+ private static SystemAssemblyFactory systemFactory = new SystemAssemblyFactoryImpl();
+
+ public static SimpleComponent createComponent(String name, String scriptFile, Class type, Scope scope) {
+ SimpleComponent sc = factory.createSimpleComponent();
+ JavaScriptImplementation impl = factory.createJavaScriptImplementation();
+ impl.setComponentType(factory.createComponentType());
+ impl.setScriptFile(scriptFile);
+ sc.setComponentImplementation(impl);
+ Service s = factory.createService();
+ String serviceName = type.getName().substring(type.getName().lastIndexOf('.')+1);
+ s.setName(serviceName);
+ JavaServiceContract contract = factory.createJavaServiceContract();
+ s.setServiceContract(contract);
+ contract.setScope(scope);
+ contract.setInterface(type);
+ impl.getComponentType().getServices().add(s);
+ ConfiguredService cService = factory.createConfiguredService();
+ cService.setService(s);
+ cService.initialize(new AssemblyModelContextImpl(null,null));
+ sc.getConfiguredServices().add(cService);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ public static Component createSystemComponent(String name, String type, Scope scope) throws NoSuchMethodException,
+ ClassNotFoundException {
+ Class claz = JavaIntrospectionHelper.loadClass(type);
+ Component sc = null;
+ if (AggregateContext.class.isAssignableFrom(claz)) {
+ sc = systemFactory.createModuleComponent();
+ } else {
+ sc = systemFactory.createSimpleComponent();
+ }
+ SystemImplementation impl = systemFactory.createSystemImplementation();
+ impl.setImplementationClass(claz);
+ sc.setComponentImplementation(impl);
+ Service s = systemFactory.createService();
+ JavaServiceContract ji = systemFactory.createJavaServiceContract();
+ s.setServiceContract(ji);
+ ji.setScope(scope);
+ impl.setComponentType(systemFactory.createComponentType());
+ impl.getComponentType().getServices().add(s);
+ sc.setName(name);
+ sc.setComponentImplementation(impl);
+ return sc;
+ }
+
+ // public static SimpleComponent createComponent(String name, String scriptFile, String serviceName, ScopeEnum
+ // scope)
+ // throws NoSuchMethodException, ClassNotFoundException {
+ // SimpleComponent sc = new PojoSimpleComponent();
+ // PojoJavaScriptImplementation impl = new PojoJavaScriptImplementation();
+ // impl.setScriptFile(scriptFile);
+ // impl.initialize(new AssemblyModelContextImpl());
+ //
+ // sc.setComponentImplementation(impl);
+ // Service s = new PojoService();
+ // s.setName(serviceName.substring(serviceName.lastIndexOf('.') + 1));
+ // PojoJavaInterface ji = new PojoJavaInterface();
+ // ji.setInterface(serviceName);
+ // Class claz = JavaIntrospectionHelper.loadClass(serviceName);
+ // PojoInterfaceType iType = new PojoInterfaceType();
+ // iType.setInstanceClass(claz);
+ // for (Method m : claz.getMethods()) {
+ // // assume no method overloading
+ // PojoOperationType type = new PojoOperationType();
+ // type.setName(m.getName());
+ // for (Class inputType : m.getParameterTypes()) {
+ // type.setOutputType(new SDOType(null,null,inputType,Collections.EMPTY_LIST));
+ // }
+ // iType.addOperationType(type);
+ // }
+ // ji.setInterfaceType(iType);
+ //
+ //
+ // s.setInterfaceContract(ji);
+ // ji.setScope(scope);
+ // impl.getServices().add(s);
+ // sc.setName(name);
+ // sc.setComponentImplementation(impl);
+ // PojoConfiguredService cService = new PojoConfiguredService();
+ // cService.setService(s);
+ // sc.getConfiguredServices().add(cService);
+ // return sc;
+ // }
+ //
+ // public static Component createSystemComponent(String name, String type, ScopeEnum scope) throws
+ // NoSuchMethodException,
+ // ClassNotFoundException {
+ //
+ // Class claz = JavaIntrospectionHelper.loadClass(type);
+ // PojoComponent sc = null;
+ // if (AggregateContext.class.isAssignableFrom(claz)) {
+ // sc = new PojoAggregateComponent();
+ // } else {
+ // sc = new PojoSimpleComponent();
+ // }
+ // SystemImplementation impl = new PojoSystemImplementation();
+ // impl.setClass(type);
+ // sc.setComponentImplementation(impl);
+ // Service s = new PojoService();
+ // JavaInterface ji = new PojoJavaInterface();
+ // s.setInterfaceContract(ji);
+ // ji.setScope(scope);
+ // impl.getServices().add(s);
+ // sc.setName(name);
+ // sc.setComponentImplementation(impl);
+ // return sc;
+ // }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java
new file mode 100644
index 0000000000..fe66104000
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/mock/MockModuleFactory.java
@@ -0,0 +1,115 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.container.js.mock;
+
+import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl;
+import org.apache.tuscany.container.js.assembly.mock.HelloWorldService;
+import org.apache.tuscany.model.assembly.AssemblyFactory;
+import org.apache.tuscany.model.assembly.AssemblyModelContext;
+import org.apache.tuscany.model.assembly.Component;
+import org.apache.tuscany.model.assembly.ConfiguredReference;
+import org.apache.tuscany.model.assembly.ConfiguredService;
+import org.apache.tuscany.model.assembly.Module;
+import org.apache.tuscany.model.assembly.Reference;
+import org.apache.tuscany.model.assembly.Scope;
+import org.apache.tuscany.model.assembly.Service;
+import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.model.assembly.impl.AssemblyModelContextImpl;
+import org.apache.tuscany.model.scdl.loader.impl.SCDLAssemblyModelLoaderImpl;
+import org.apache.tuscany.model.types.java.JavaServiceContract;
+
+/**
+ * Generates mock modules
+ *
+ * @version $Rev$ $Date$
+ */
+public class MockModuleFactory {
+
+ private static AssemblyFactory factory = new AssemblyFactoryImpl();
+
+ private static AssemblyModelContext assemblyContext = new AssemblyModelContextImpl(new AssemblyFactoryImpl(),
+ new SCDLAssemblyModelLoaderImpl(null), new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader()));
+
+ private MockModuleFactory() {
+ }
+
+ public static Module createModule() throws Exception {
+ Component sourceComponent = MockAssemblyFactory.createComponent("source",
+ "org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js", HelloWorldService.class, Scope.MODULE);
+ Component targetComponent = MockAssemblyFactory.createComponent("target",
+ "org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js", HelloWorldService.class, Scope.MODULE);
+
+ Service targetService = factory.createService();
+ JavaServiceContract targetContract = factory.createJavaServiceContract();
+ targetContract.setInterface(HelloWorldService.class);
+ targetService.setServiceContract(targetContract);
+ targetService.setName("GenericComponent");
+ ConfiguredService cTargetService = factory.createConfiguredService();
+ cTargetService.setService(targetService);
+ cTargetService.initialize(assemblyContext);
+ targetComponent.getConfiguredServices().add(cTargetService);
+ targetComponent.initialize(assemblyContext);
+
+ Reference ref = factory.createReference();
+ ConfiguredReference cref = factory.createConfiguredReference();
+ ref.setName("setGenericComponent");
+ JavaServiceContract inter = factory.createJavaServiceContract();
+ inter.setInterface(HelloWorldService.class);
+ ref.setServiceContract(inter);
+ cref.setReference(ref);
+ cref.getTargetConfiguredServices().add(cTargetService);
+ cref.initialize(assemblyContext);
+ sourceComponent.getConfiguredReferences().add(cref);
+ sourceComponent.initialize(assemblyContext);
+
+ Module module = factory.createModule();
+ module.setName("test.module");
+ module.getComponents().add(sourceComponent);
+ module.getComponents().add(targetComponent);
+ module.initialize(assemblyContext);
+ return module;
+ }
+
+ // public static Module createModule() throws Exception {
+ // Component sourceComponent =
+ // MockAssemblyFactory.createComponent("source","org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js",HelloWorldService.class.getCanonicalName(),ScopeEnum.MODULE_LITERAL);
+ // Component targetComponent =
+ // MockAssemblyFactory.createComponent("target","org/apache/tuscany/container/js/assembly/mock/HelloWorldImpl.js",HelloWorldService.class.getCanonicalName(),ScopeEnum.MODULE_LITERAL);
+ // PojoReference ref = new PojoReference();
+ // PojoConfiguredReference cref = new PojoConfiguredReference();
+ // ref.setName("helloWorld");
+ // PojoInterface inter = new PojoJavaInterface();
+ // PojoInterfaceType type = new PojoInterfaceType();
+ // type.setInstanceClass(HelloWorldService.class);
+ // PojoOperationType oType = new PojoOperationType();
+ // oType.setName("hello");
+ // SDOType inputType = new SDOType("String","",String.class,null);
+ // oType.setInputType(inputType);
+ // type.addOperationType(oType);
+ // inter.setInterfaceType(type);
+ // ref.setInterfaceContract(inter);
+ // cref.setReference(ref);
+ // cref.setPart(targetComponent);
+ // PojoPort port = new PojoPort();
+ // port.setName("HelloWorldService");
+ // cref.setPort(port);
+ // sourceComponent.getConfiguredReferences().add(cref);
+ // PojoModule module = new PojoModule();
+ // module.setName("test.module");
+ // module.addComponent(sourceComponent);
+ // module.addComponent(targetComponent);
+ // return module;
+ // }
+
+}
diff --git a/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java
new file mode 100644
index 0000000000..9269c1cf7e
--- /dev/null
+++ b/sca-java-1.x/tags/java-stable-20060304/sca/container.js/src/test/java/org/apache/tuscany/container/js/rhino/RhinoInvokerTestCase.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.container.js.rhino;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.mozilla.javascript.EcmaError;
+
+/**
+ * Tests for the RhinoInvoker
+ */
+public class RhinoInvokerTestCase extends TestCase {
+
+ private static final String scriptName = "RhinoInvokerTestCase.js";
+ private String script;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.script = readResource(scriptName);
+ }
+
+ public void testSimpleInvocation() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Object x = ri.invoke("echo", "petra", null);
+ assertEquals("petra", x);
+ }
+
+ public void testCopy() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Object x = ri.invoke("echo", "petra", null);
+ assertEquals("petra", x);
+
+ ri = ri.copy();
+ x = ri.invoke("echo", "sue", null);
+ assertEquals("sue", x);
+
+ }
+
+ public void testContexts1() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("a", "petra");
+ Object x = ri.invoke("getA", null, contexts);
+ assertEquals("petra", x);
+ }
+
+ /**
+ * Tests context not accessable across invocations
+ */
+ public void testContexts2() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("a", "petra");
+ Object x = ri.invoke("getA", null, contexts);
+ assertEquals("petra", x);
+
+ try {
+ x = ri.invoke("getA", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+ }
+
+ /**
+ * Tests shared scope is accessable across invocations
+ */
+ public void testScopes1() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setGlobalVarY", "petra", null);
+
+ Object x = ri.invoke("getGlobalVarY", null, null);
+ assertEquals("petra", x);
+ }
+
+ /**
+ * Tests local vars are NOT accessable across invocations
+ */
+ public void testScopes2() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setLocalVarY", "petra", null);
+
+ try {
+ ri.invoke("getGlobalVarY", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+ }
+
+ /**
+ * Tests shared scope is accessable when using contexts (ie an invocation scope)
+ */
+ public void testScopes3() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setGlobalVarY", "petra", null);
+
+ Map<String, Object> contexts = new HashMap<String, Object>();
+ contexts.put("a", "sue");
+ Object x = ri.invoke("getGlobalVarY", null, contexts);
+ assertEquals("petra", x);
+
+ x = ri.invoke("getA", null, contexts);
+ assertEquals("sue", x);
+
+ }
+
+ /**
+ * Tests a copy only retains the script scope not the shared scope
+ */
+ public void testScopes4() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ ri.invoke("setGlobalVarY", "petra", null);
+
+ ri = ri.copy();
+ try {
+ ri.invoke("getGlobalVarY", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+ try {
+ ri.invoke("getA", null, null);
+ assertTrue("expected ReferenceError", false);
+ } catch (EcmaError e) {
+ assertEquals("ReferenceError", e.getName());
+ }
+
+ }
+
+ public void testGetInt() {
+ RhinoScript ri = new RhinoScript(scriptName, script);
+ Object x = ri.invoke("getInt", null, Integer.TYPE, null);
+ assertEquals(Integer.class, x.getClass());
+ }
+
+ /**
+ * Read a resource into a String
+ */
+ private String readResource(String name) {
+ try {
+ URL url = getClass().getResource(name);
+ if (url == null) {
+ throw new RuntimeException("resource not found: " + name);
+ }
+ InputStream inputStream = url.openStream();
+
+ StringBuffer resource = new StringBuffer();
+ int n = 0;
+
+ while ((n = inputStream.read()) != -1) {
+ resource.append((char) n);
+ }
+
+ inputStream.close();
+
+ String s = resource.toString();
+ return s;
+
+ } catch (IOException e) {
+ throw new RuntimeException("IOException reading resource " + name, e);
+ }
+ }
+
+} \ No newline at end of file