From b5c0d648cf147d3709eb78d98011f38e07aee723 Mon Sep 17 00:00:00 2001 From: lresende Date: Fri, 13 Nov 2009 01:25:44 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835694 13f79535-47bb-0310-9956-ffa450edef68 --- .../corba/testing/service/mocks/TestDataType.java | 88 ++++++++ .../corba/testing/service/mocks/TestInterface.java | 148 +++++++++++++ .../service/mocks/TestInterfaceContract.java | 58 +++++ .../corba/testing/service/mocks/TestOperation.java | 195 +++++++++++++++++ .../service/mocks/TestRuntimeComponentService.java | 239 +++++++++++++++++++++ .../testing/service/mocks/TestRuntimeWire.java | 107 +++++++++ 6 files changed, 835 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java create mode 100644 sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java (limited to 'sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service') diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java new file mode 100644 index 0000000000..7ebc3fce85 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestDataType.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.service.mocks; + +import java.lang.reflect.Type; + +import org.apache.tuscany.sca.interfacedef.DataType; + +/** + * Mock DataType implementation. Only few methods needs to be implemented. + */ +public class TestDataType implements DataType { + + public Class typeClass; + public L logical; + + public TestDataType(Class typeClass) { + this.typeClass = typeClass; + } + + public TestDataType(Class typeClass, L logical) { + this.typeClass = typeClass; + this.logical = logical; + } + + public String getDataBinding() { + return null; + } + + public Type getGenericType() { + return null; + } + + public L getLogical() { + return logical; + } + + public T getMetaData(Class arg0) { + return null; + } + + public Class getPhysical() { + return typeClass; + } + + public void setDataBinding(String arg0) { + + } + + public void setGenericType(Type arg0) { + + } + + public void setLogical(L arg0) { + + } + + public void setMetaData(Class arg0, T arg1) { + + } + + public void setPhysical(Class arg0) { + + } + + @Override + public Object clone() { + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java new file mode 100644 index 0000000000..296fa0a454 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.service.mocks; + +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Mock TestInterface implementation. Only few methods needs to be implemented. + */ +public class TestInterface implements JavaInterface { + + private List operations; + private Class javaClass; + + public TestInterface(List opearations, Class javaClass) { + this.operations = opearations; + this.javaClass = javaClass; + } + + public List getOperations() { + return operations; + } + + public boolean isConversational() { + return false; + } + + public boolean isDynamic() { + return false; + } + + public boolean isRemotable() { + return false; + } + + public void resetDataBinding(String dataBinding) { + + } + + public void resetInterfaceInputTypes(Interface newInterface) { + + } + + public void resetInterfaceOutputTypes(Interface newInterface) { + + } + + public void setConversational(boolean conversational) { + + } + + public void setDefaultDataBinding(String dataBinding) { + + } + + public void setRemotable(boolean remotable) { + + } + + public List getApplicablePolicySets() { + return null; + } + + public List getPolicySets() { + return null; + } + + public List getRequiredIntents() { + return null; + } + + public IntentAttachPointType getType() { + return null; + } + + public void setType(IntentAttachPointType type) { + + } + + @Override + public Object clone() { + return null; + } + + public Class getCallbackClass() { + return null; + } + + public Class getJavaClass() { + return javaClass; + } + + public String getName() { + return null; + } + + public QName getQName() { + return null; + } + + public void setCallbackClass(Class arg0) { + } + + public void setJavaClass(Class javaClass) { + this.javaClass = javaClass; + } + + public void setName(String arg0) { + } + + public void setQName(QName arg0) { + + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean arg0) { + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java new file mode 100644 index 0000000000..d691705955 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterfaceContract.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.service.mocks; + +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; + +/** + * Mock InterfaceContract implementation. Only few methods needs to be + * implemented. + */ +public class TestInterfaceContract implements InterfaceContract { + + private Interface iface; + + public Interface getCallbackInterface() { + return null; + } + + public Interface getInterface() { + return iface; + } + + public InterfaceContract makeUnidirectional(boolean isCallback) { + return null; + } + + public void setCallbackInterface(Interface callbackInterface) { + + } + + public void setInterface(Interface callInterface) { + this.iface = callInterface; + } + + @Override + public Object clone() { + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java new file mode 100644 index 0000000000..07a9119afb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java @@ -0,0 +1,195 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.service.mocks; + +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.interfacedef.ConversationSequence; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.Interface; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.interfacedef.ParameterMode; +import org.apache.tuscany.sca.interfacedef.util.WrapperInfo; +import org.apache.tuscany.sca.interfacedef.util.XMLType; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Mock Operation implementation. Only few methods needs to be implemented. + */ +public class TestOperation implements Operation { + + private DataType> inputType; + private DataType outputType; + private String name; + + public ConversationSequence getConversationSequence() { + return null; + } + + public String getDataBinding() { + return null; + } + + public Map>> getFaultBeans() { + return null; + } + + public List getFaultTypes() { + return null; + } + + public DataType> getInputType() { + return inputType; + } + + public Interface getInterface() { + return null; + } + + public String getName() { + return name; + } + + public DataType getOutputType() { + return outputType; + } + + public WrapperInfo getInputWrapper() { + return null; + } + + public WrapperInfo getOutputWrapper() { + return null; + } + + public boolean isDynamic() { + return false; + } + + public boolean isNonBlocking() { + return false; + } + + public boolean isUnresolved() { + return false; + } + + public boolean isInputWrapperStyle() { + return false; + } + + public boolean isOutputWrapperStyle() { + return false; + } + + public void setConversationSequence(ConversationSequence sequence) { + + } + + public void setDataBinding(String dataBinding) { + + } + + public void setDynamic(boolean b) { + + } + + public void setFaultBeans(Map>> faultBeans) { + + } + + public void setFaultTypes(List faultTypes) { + + } + + public void setInputType(DataType> inputType) { + this.inputType = inputType; + } + + public void setInterface(Interface interfaze) { + + } + + public void setName(String name) { + this.name = name; + } + + public void setNonBlocking(boolean nonBlocking) { + + } + + public void setOutputType(DataType outputType) { + this.outputType = outputType; + } + + public void setUnresolved(boolean unresolved) { + + } + + public void setInputWrapper(WrapperInfo wrapperInfo) { + + } + + public void setOutputWrapper(WrapperInfo wrapperInfo) { + + } + + public void setInputWrapperStyle(boolean wrapperStyle) { + + } + + public void setOutputWrapperStyle(boolean wrapperStyle) { + + } + + public List getApplicablePolicySets() { + return null; + } + + public List getPolicySets() { + return null; + } + + @Override + public Object clone() { + return null; + } + + public List getRequiredIntents() { + return null; + } + + public IntentAttachPointType getType() { + return null; + } + + public void setType(IntentAttachPointType type) { + } + + public List getParameterModes() { + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java new file mode 100644 index 0000000000..a99b829e9c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeComponentService.java @@ -0,0 +1,239 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.service.mocks; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Callback; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ConfiguredOperation; +import org.apache.tuscany.sca.assembly.Extension; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.interfacedef.DataType; +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.provider.PolicyProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * Mock RuntimeComponentService implementation. Only few methods needs to be + * implemented. + */ +public class TestRuntimeComponentService implements RuntimeComponentService { + + private InterfaceContract interfaceContract; + private RuntimeWire runtimeWire; + + public TestRuntimeComponentService(Object invocationTarget) { + runtimeWire = new TestRuntimeWire(invocationTarget); + List operations = new ArrayList(); + Method[] methods = invocationTarget.getClass().getMethods(); + for (int i = 0; i < methods.length; i++) { + int mod = methods[i].getModifiers(); + if (methods[i].getDeclaringClass().equals(invocationTarget.getClass()) && Modifier.isPublic(mod) + && !methods[i].getName().startsWith("_")) { + Operation operation = new TestOperation(); + DataType returnType = new TestDataType(methods[i].getReturnType()); + operation.setOutputType(returnType); + Class[] argTypes = methods[i].getParameterTypes(); + List argDataTypes = new ArrayList(); + for (int j = 0; j < argTypes.length; j++) { + argDataTypes.add(new TestDataType(argTypes[j])); + } + TestDataType> inputDataType = new TestDataType>(null, argDataTypes); + operation.setInputType(inputDataType); + operations.add(operation); + operation.setName(methods[i].getName()); + } + } + TestInterface iface = new TestInterface(operations, invocationTarget.getClass()); + interfaceContract = new TestInterfaceContract(); + interfaceContract.setInterface(iface); + } + + public void addPolicyProvider(Binding binding, PolicyProvider policyProvider) { + + } + + public ServiceBindingProvider getBindingProvider(Binding binding) { + return null; + } + + public List getCallbackWires() { + return null; + } + + public InvocationChain getInvocationChain(Binding binding, Operation operation) { + return null; + } + + public InvocationChain getInvocationChain(Binding binding, InterfaceContract interfaceContract, Operation operation) { + return null; + } + + public Invoker getInvoker(Binding binding, Operation operation) { + return null; + } + + public Invoker getInvoker(Binding binding, InterfaceContract interfaceContract, Operation operation) { + return null; + } + + public List getPolicyProviders(Binding binding) { + return null; + } + + public RuntimeWire getRuntimeWire(Binding binding) { + return runtimeWire; + } + + public RuntimeWire getRuntimeWire(Binding binding, InterfaceContract interfaceContract) { + return null; + } + + public List getRuntimeWires() { + return null; + } + + public void setBindingProvider(Binding binding, ServiceBindingProvider bindingProvider) { + + } + + public ComponentReference getCallbackReference() { + return null; + } + + public Service getService() { + return null; + } + + public void setCallbackReference(ComponentReference callbackReference) { + + } + + public void setService(Service service) { + + } + + public InterfaceContract getInterfaceContract() { + return interfaceContract; + } + + public InterfaceContract getInterfaceContract(Binding binding) { + return getInterfaceContract(); + } + + public String getName() { + return null; + } + + public boolean isCallback() { + return false; + } + + public void setInterfaceContract(InterfaceContract interfaceContract) { + this.interfaceContract = interfaceContract; + } + + public void setIsCallback(boolean isCallback) { + + } + + public void setName(String name) { + + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + + } + + public List getExtensions() { + return null; + } + + public List getAttributeExtensions() { + return null; + } + + public List getRequiredIntents() { + return null; + } + + public IntentAttachPointType getType() { + return null; + } + + public void setType(IntentAttachPointType type) { + + } + + public List getConfiguredOperations() { + return null; + } + + public B getBinding(Class bindingClass) { + return null; + } + + public List getBindings() { + return null; + } + + public Callback getCallback() { + return null; + } + + public B getCallbackBinding(Class bindingClass) { + return null; + } + + public void setCallback(Callback callback) { + + } + + public List getApplicablePolicySets() { + return null; + } + + public List getPolicySets() { + return null; + } + + @Override + public Object clone() { + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java new file mode 100644 index 0000000000..5b7caf1010 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-1.5.2/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestRuntimeWire.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.corba.testing.service.mocks; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.EndpointReference; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +/** + * Mock RuntimeWire implementation. Only few methods needs to be implemented. + */ +public class TestRuntimeWire implements RuntimeWire { + private Object invocationTarget; + + public TestRuntimeWire(Object invocationTarget) { + this.invocationTarget = invocationTarget; + } + + public InvocationChain getInvocationChain(Operation arg0) { + return null; + } + + public List getInvocationChains() { + return null; + } + + public EndpointReference getSource() { + return null; + } + + public EndpointReference getTarget() { + return null; + } + + public Object invoke(Operation operation, Object[] args) throws InvocationTargetException { + Class[] types = new Class[args.length]; + for (int i = 0; i < args.length; i++) { + types[i] = args[i].getClass(); + } + Object result = null; + try { + Method[] methods = invocationTarget.getClass().getMethods(); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().equals(operation.getName())) { + result = methods[i].invoke(invocationTarget, args); + break; + } + } + } catch (InvocationTargetException e) { + throw e; + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + return result; + } + + public Object invoke(Operation operation, Message arg1) throws InvocationTargetException { + + return null; + } + + public Object invoke(Message arg1) throws InvocationTargetException { + + return null; + } + + public void rebuild() { + + } + + public void setTarget(EndpointReference arg0) { + + } + + @Override + public Object clone() { + return null; + } + + public InvocationChain getBindingInvocationChain() { + return null; + } +} -- cgit v1.2.3