From ece4fd35da7b7fc76264776f81705e6b5b52d3e0 Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:11:48 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835140 13f79535-47bb-0310-9956-ffa450edef68 --- .../account/services/account/AccountReport.java | 32 ++ .../account/services/account/AccountService.java | 25 ++ .../services/account/AccountServiceImpl.java | 53 +++ .../account/services/account/AccountSummary.java | 46 +++ .../services/accountdata/AccountDataService.java | 26 ++ .../accountdata/AccountDataServiceImpl.java | 48 +++ .../services/accountdata/CheckingAccount.java | 39 +++ .../services/accountdata/SavingsAccount.java | 39 +++ .../account/services/accountdata/StockAccount.java | 48 +++ .../services/stockquote/StockQuoteService.java | 24 ++ .../builder/ExternalWebServiceBuilderTestCase.java | 379 +++++++++++++++++++++ .../binding/axis2/handler/HelloWorldService.java | 26 ++ .../handler/HelloWorldServiceComponentImpl.java | 44 +++ .../binding/axis2/util/SDODataBindingTestCase.java | 123 +++++++ 14 files changed, 952 insertions(+) create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountReport.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountSummary.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/StockAccount.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilderTestCase.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldService.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldServiceComponentImpl.java create mode 100644 sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/SDODataBindingTestCase.java (limited to 'sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany') diff --git a/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountReport.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountReport.java new file mode 100644 index 0000000000..0600e14f8d --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.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/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountService.java new file mode 100644 index 0000000000..b605d19f09 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.assembly.tests.bigbank.account.services.account; + +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface AccountService { + + AccountReport getAccountReport(String customerID); +} diff --git a/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java new file mode 100644 index 0000000000..cd3fcfe1f5 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountServiceImpl.java @@ -0,0 +1,53 @@ +/** + * + * 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.binding.axis2.assembly.tests.bigbank.account.services.account; + + +import org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.accountdata.AccountDataService; +import org.apache.tuscany.binding.axis2.assembly.tests.bigbank.account.services.stockquote.StockQuoteService; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +public class AccountServiceImpl implements AccountService { + + @Property + private String currency = "USD"; + @Reference + private AccountDataService accountDataService; + @Reference + private StockQuoteService stockQuoteService; + + public AccountServiceImpl() { + } + + public AccountReport getAccountReport(String customerID) { + return null; + } + + + //methods to access the fields + protected StockQuoteService getStockQuoteService() { + return stockQuoteService; + } + protected AccountDataService getAccountDataService() { + return accountDataService; + } + protected String getCurrency() { + return currency; + } + +} diff --git a/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountSummary.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/account/AccountSummary.java new file mode 100644 index 0000000000..9000e4ba19 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.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/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataService.java new file mode 100644 index 0000000000..d2dc72e868 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.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/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..d945ee1f34 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.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/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/CheckingAccount.java new file mode 100644 index 0000000000..6b75194b98 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.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/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/SavingsAccount.java new file mode 100644 index 0000000000..a37b504829 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.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/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/StockAccount.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/accountdata/StockAccount.java new file mode 100644 index 0000000000..2a5ac5f4a3 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.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/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/assembly/tests/bigbank/account/services/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..021b19d14d --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/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.binding.axis2.assembly.tests.bigbank.account.services.stockquote; + +public interface StockQuoteService { + + float getQuote(String symbol); +} + + \ No newline at end of file diff --git a/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilderTestCase.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilderTestCase.java new file mode 100644 index 0000000000..d040b87b86 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/builder/ExternalWebServiceBuilderTestCase.java @@ -0,0 +1,379 @@ +/** + * 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.binding.axis2.builder; + +import java.net.URL; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.tuscany.binding.axis2.assembly.WebServiceBinding; +import org.apache.tuscany.binding.axis2.externalservice.Axis2OperationInvoker; +import org.apache.tuscany.binding.axis2.externalservice.Axis2ServiceInvoker; +import org.apache.tuscany.binding.axis2.util.WebServicePortMetaData; +import org.apache.tuscany.common.resource.ResourceLoader; +import org.apache.tuscany.common.resource.impl.ResourceLoaderImpl; +import org.apache.tuscany.core.extension.ExternalServiceContextFactory; +import org.apache.tuscany.model.assembly.AssemblyContext; +import org.apache.tuscany.model.assembly.AssemblyInitializationException; +import org.apache.tuscany.model.assembly.AssemblyVisitor; +import org.apache.tuscany.model.assembly.Binding; +import org.apache.tuscany.model.assembly.Composite; +import org.apache.tuscany.model.assembly.ConfiguredService; +import org.apache.tuscany.model.assembly.ExternalService; +import org.apache.tuscany.model.assembly.OverrideOption; +import org.apache.tuscany.model.assembly.Part; +import org.apache.tuscany.model.assembly.Scope; +import org.apache.tuscany.model.assembly.Service; +import org.apache.tuscany.model.assembly.ServiceContract; + +import commonj.sdo.helper.TypeHelper; + +public class ExternalWebServiceBuilderTestCase extends TestCase { + + private Definition definition; + + private static final QName SERVICE_NAME = new QName("http://helloworldaxis.samples.tuscany.apache.org", "HelloWorldServiceImplService"); + + private static final String PORTNAME = "helloworld"; + + private static final QName GET_GREETINGS_QN = new QName(SERVICE_NAME.getNamespaceURI(), "getGreetings"); + + public void testCreateOperationInvokers() { + ExternalWebServiceBuilder builder = new ExternalWebServiceBuilder(); + + Port port = definition.getService(SERVICE_NAME).getPort(PORTNAME); + WebServicePortMetaData wspmd = new WebServicePortMetaData(definition, port, null, false); + + Map invokers = builder.createOperationInvokers(Foo.class, null, getClass().getClassLoader(),wspmd); + assertNotNull(invokers); + assertEquals(1, invokers.size()); + + Axis2OperationInvoker opInvoker = invokers.get(GET_GREETINGS_QN.getLocalPart()); + assertNotNull(opInvoker); + assertEquals(GET_GREETINGS_QN, opInvoker.getWSDLOperationName()); + } + + public void testCreateExternalServiceContextFactory() { + ExternalWebServiceBuilder builder = new ExternalWebServiceBuilder(); + ExternalService es = createMockExternalService(); + ExternalServiceContextFactory cf = builder.createExternalServiceContextFactory(es); + assertNotNull(cf); + Axis2ServiceInvoker si = (Axis2ServiceInvoker) cf.createContext().getHandler(); + assertNotNull(si); + } + + protected void setUp() throws Exception { + super.setUp(); + WSDLReader reader = WSDLFactory.newInstance().newWSDLReader(); + reader.setFeature("javax.wsdl.verbose", false); + URL url = getClass().getResource("helloworld.wsdl"); + this.definition = reader.readWSDL(url.toString()); + } + + interface Foo { + public void getGreetings(); + }; + + private ExternalService createMockExternalService() { + ExternalService es = new ExternalService() { + + public List getBindings() { + return Arrays.asList(new Binding[] { createMockBinding() }); + } + + public OverrideOption getOverrideOption() { + + return null; + } + + public void setOverrideOption(OverrideOption value) { + + } + + public ConfiguredService getConfiguredService() { + return new ConfiguredService() { + + public String getName() { + + return null; + } + + public void setName(String name) { + + } + + public Service getPort() { + return new Service() { + + public ServiceContract getServiceContract() { + return new ServiceContract() { + + public Class getInterface() { + return Foo.class; + } + + public void setInterface(Class value) { + + } + + public Class getCallbackInterface() { + + return null; + } + + public void setCallbackInterface(Class value) { + + } + + public Scope getScope() { + + return null; + } + + public void setScope(Scope scope) { + + } + + public List getExtensibilityElements() { + + return null; + } + + public List getExtensibilityAttributes() { + + return null; + } + + public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException { + + } + + public void freeze() { + + } + + public boolean accept(AssemblyVisitor visitor) { + + return false; + } + }; + } + + public void setServiceContract(ServiceContract contract) { + + } + + public String getName() { + + return null; + } + + public void setName(String name) { + + } + + public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException { + + } + + public void freeze() { + + } + + public boolean accept(AssemblyVisitor visitor) { + + return false; + } + }; + } + + public void setPort(Service port) { + + } + + public Part getPart() { + + return null; + } + + public void setPart(Part part) { + + } + + public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException { + + } + + public void freeze() { + + } + + public boolean accept(AssemblyVisitor visitor) { + + return false; + } + + public void setProxyFactory(Object proxyFactory) { + + } + + public Object getProxyFactory() { + + return null; + } + }; + } + + public void setConfiguredService(ConfiguredService configuredService) { + + } + + public String getName() { + + return "myService"; + } + + public void setName(String value) { + + } + + public Composite getComposite() { + + return null; + } + + public void setComposite(Composite composite) { + + } + + public List getExtensibilityElements() { + + return null; + } + + public List getExtensibilityAttributes() { + + return null; + } + + public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException { + + } + + public void freeze() { + + } + + public boolean accept(AssemblyVisitor visitor) { + + return false; + } + + public void setContextFactory(Object contextFactory) { + + } + + public Object getContextFactory() { + + return null; + } + }; + return es; + } + + private Binding createMockBinding() { + WebServiceBinding b = new WebServiceBinding() { + + public void setPortURI(String portURI) { + + } + + public Port getWSDLPort() { + return definition.getService(SERVICE_NAME).getPort(PORTNAME); + } + + public Definition getWSDLDefinition() { + return definition; + } + + public void setWSDLPort(Port value) { + + } + + public void setWSDLDefinition(Definition definition) { + + } + + public TypeHelper getTypeHelper() { + + return null; + } + + public void setTypeHelper(TypeHelper typeHelper) { + + } + + public ResourceLoader getResourceLoader() { + return new ResourceLoaderImpl(Thread.currentThread().getContextClassLoader()); + } + + public void setResourceLoader(ResourceLoader resourceLoader) { + + } + + public String getURI() { + + return null; + } + + public void setURI(String value) { + + } + + public void initialize(AssemblyContext modelContext) throws AssemblyInitializationException { + + } + + public void freeze() { + + } + + public boolean accept(AssemblyVisitor visitor) { + + return false; + } + + public void setWebAppName(String webAppName) { + } + + public String getWebAppName() { + return null; + } + + }; + return b; + } + +} diff --git a/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldService.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldService.java new file mode 100644 index 0000000000..6d046d84c4 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldService.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.binding.axis2.handler; + +/** + * This is the business interface of the HelloWorld service component. + */ +public interface HelloWorldService { + + String getGreetings(String name); + +} diff --git a/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldServiceComponentImpl.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldServiceComponentImpl.java new file mode 100644 index 0000000000..972b94e5a7 --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/handler/HelloWorldServiceComponentImpl.java @@ -0,0 +1,44 @@ +/** + * + * 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.binding.axis2.handler; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service component. + */ +@Service(HelloWorldService.class) +//FIXME workaround for JIRA TUSCANY-41 +@Scope("MODULE") +public class HelloWorldServiceComponentImpl implements HelloWorldService { + + @Reference + // Injected by the SCA container. + private HelloWorldService hellowWorldService; + + /** + * @see org.apache.tuscany.samples.helloworldwsclient.HelloWorldService#getGreetings(java.lang.String) + */ + public String getGreetings(final String name) { + assert null != hellowWorldService : "helloWorldService was not set by the SCA runtime!"; + + return hellowWorldService.getGreetings(name); + } + +} diff --git a/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/SDODataBindingTestCase.java b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/SDODataBindingTestCase.java new file mode 100644 index 0000000000..621f12068c --- /dev/null +++ b/sca-java-1.x/branches/java-post-M1/sca/bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/util/SDODataBindingTestCase.java @@ -0,0 +1,123 @@ +/** + * + * 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.binding.axis2.util; + +import java.net.URL; + +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.axiom.om.OMElement; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + +public class SDODataBindingTestCase extends TestCase { + public static final QName DOCLITWRAPPED_QN = new QName("http://www.example.org/creditscore/doclitwrapped/", "getCreditScore"); + + public static final QName DOCLIT_QN = new QName("http://www.example.org/creditscore/doclit/", "getCreditScoreRequest"); + + public static final QName GREETING_QN = new QName("http://helloworldaxis.samples.tuscany.apache.org", "getGreetings"); + + private TypeHelper typeHelper; + + private SDODataBinding docLitWrappedDB; + + private SDODataBinding docLitDB; + + private SDODataBinding greetingDB; + + public void testToOMElement() { + String s = "petra"; + + OMElement omElement = greetingDB.toOMElement(new Object[] { s }); + assertNotNull(omElement); + + Object[] os = greetingDB.fromOMElement(omElement); + assertNotNull(os); + assertEquals(1, os.length); + assertEquals(s, os[0]); + } + + public void testDocLit() { + DataFactory dataFactory = SDOUtil.createDataFactory(typeHelper); + DataObject dataObject = dataFactory.create("http://www.example.org/creditscore/doclit/", "Customer"); + dataObject.setString(0, "111-22-3333"); + dataObject.setString(1, "John"); + dataObject.setString(2, "Smith"); + + OMElement omElement = docLitDB.toOMElement(new Object[] { dataObject }); + assertNotNull(omElement); + + Object[] os = docLitDB.fromOMElement(omElement); + assertNotNull(os); + assertEquals(os.length, 1); + assertTrue(os[0] instanceof DataObject); + + dataObject = (DataObject) os[0]; + assertEquals(dataObject.getString(0), "111-22-3333"); + assertEquals(dataObject.getString(1), "John"); + assertEquals(dataObject.getString(2), "Smith"); + } + + public void testDocLitWrapped() { + Object[] args = new Object[] { "111-22-3333", "John", "Smith" }; + + OMElement omElement = docLitWrappedDB.toOMElement(args); + assertNotNull(omElement); + + Object[] os = docLitWrappedDB.fromOMElement(omElement); + assertNotNull(os); + assertEquals(os.length, 3); + + assertEquals(os[0], "111-22-3333"); + assertEquals(os[1], "John"); + assertEquals(os[2], "Smith"); + } + + protected void setUp() throws Exception { + super.setUp(); + DataObjectUtil.initRuntime(); + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); + + typeHelper = SDOUtil.createTypeHelper(); + XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper); + URL url = getClass().getResource("helloworld.wsdl"); + xsdHelper.define(url.openStream(), null); + url = getClass().getResource("CreditScoreDocLitWrapped.wsdl"); + xsdHelper.define(url.openStream(), null); + url = getClass().getResource("CreditScoreDocLit.wsdl"); + xsdHelper.define(url.openStream(), null); + + this.greetingDB = new SDODataBinding(getClass().getClassLoader(),typeHelper, GREETING_QN, true); + this.docLitWrappedDB = new SDODataBinding(getClass().getClassLoader(),typeHelper, DOCLITWRAPPED_QN, true); + + this.docLitDB = new SDODataBinding(getClass().getClassLoader(),typeHelper, DOCLIT_QN, false); + + } finally { + Thread.currentThread().setContextClassLoader(cl); + } + } + +} -- cgit v1.2.3