You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by wj...@apache.org on 2009/04/03 17:46:18 UTC

svn commit: r761712 [2/3] - in /tuscany/branches/sca-java-1.x/modules: ./ binding-erlang-runtime/ binding-erlang-runtime/src/ binding-erlang-runtime/src/main/ binding-erlang-runtime/src/main/java/ binding-erlang-runtime/src/main/java/org/ binding-erlan...

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/FloatTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/FloatTypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/FloatTypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/FloatTypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.erlang.impl.types;
+
+import com.ericsson.otp.erlang.OtpErlangDouble;
+import com.ericsson.otp.erlang.OtpErlangObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class FloatTypeHelper implements TypeHelper {
+
+	public OtpErlangObject toErlang(Object object) {
+		return new OtpErlangDouble((Float) object);
+	}
+
+	public Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		return (float) ((OtpErlangDouble) object).doubleValue();
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/IntTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/IntTypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/IntTypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/IntTypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.erlang.impl.types;
+
+import com.ericsson.otp.erlang.OtpErlangInt;
+import com.ericsson.otp.erlang.OtpErlangLong;
+import com.ericsson.otp.erlang.OtpErlangObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IntTypeHelper implements TypeHelper {
+
+	public OtpErlangObject toErlang(Object object) {
+		return new OtpErlangInt((Integer) object);
+	}
+
+	public Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		return (int) ((OtpErlangLong) object).longValue();
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ListTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ListTypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ListTypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ListTypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,64 @@
+/*
+ * 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.erlang.impl.types;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.ericsson.otp.erlang.OtpErlangList;
+import com.ericsson.otp.erlang.OtpErlangObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ListTypeHelper implements TypeHelper {
+
+	public OtpErlangObject toErlang(Object object) {
+		int i = 0;
+		List<OtpErlangObject> elements = new ArrayList<OtpErlangObject>();
+		while (true) {
+			try {
+				Object arrElement = Array.get(object, i);
+				Object[] args = new Object[] { arrElement };
+				elements.add(TypeHelpersProxy.toErlang(args));
+				i++;
+			} catch (ArrayIndexOutOfBoundsException e) {
+				// expected
+				break;
+			}
+		}
+		return new OtpErlangList(elements.toArray(new OtpErlangObject[elements
+				.size()]));
+	}
+
+	public Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		OtpErlangList erlangList = (OtpErlangList) object;
+		Object result = Array.newInstance(forClass.getComponentType(),
+				erlangList.arity());
+		for (int i = 0; i < erlangList.arity(); i++) {
+			Array.set(result, i, TypeHelpersProxy.toJava(erlangList
+					.elementAt(i), forClass.getComponentType()));
+		}
+		return result;
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/LongTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/LongTypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/LongTypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/LongTypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.erlang.impl.types;
+
+import com.ericsson.otp.erlang.OtpErlangLong;
+import com.ericsson.otp.erlang.OtpErlangObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class LongTypeHelper implements TypeHelper {
+
+	public OtpErlangObject toErlang(Object object) {
+		return new OtpErlangLong((Long) object);
+	}
+
+	public Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		return ((OtpErlangLong) object).longValue();
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ShortTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ShortTypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ShortTypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/ShortTypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.erlang.impl.types;
+
+import com.ericsson.otp.erlang.OtpErlangLong;
+import com.ericsson.otp.erlang.OtpErlangObject;
+import com.ericsson.otp.erlang.OtpErlangShort;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ShortTypeHelper implements TypeHelper {
+
+	public OtpErlangObject toErlang(Object object) {
+		return new OtpErlangShort((Short) object);
+	}
+
+	public Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		return (short) ((OtpErlangLong) object).longValue();
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/StringTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/StringTypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/StringTypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/StringTypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.erlang.impl.types;
+
+import com.ericsson.otp.erlang.OtpErlangObject;
+import com.ericsson.otp.erlang.OtpErlangString;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StringTypeHelper implements TypeHelper {
+
+	public OtpErlangObject toErlang(Object object) {
+		return new OtpErlangString((String) object);
+	}
+
+	public Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		return ((OtpErlangString) object).stringValue();
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TupleTypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TupleTypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TupleTypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TupleTypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,71 @@
+/*
+ * 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.erlang.impl.types;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.ericsson.otp.erlang.OtpErlangObject;
+import com.ericsson.otp.erlang.OtpErlangTuple;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TupleTypeHelper implements TypeHelper {
+
+	public OtpErlangObject toErlang(Object object) {
+		Class<?> forClass = object.getClass();
+		List<OtpErlangObject> tupleMembers = new ArrayList<OtpErlangObject>();
+		Field[] fields = forClass.getFields();
+		for (int i = 0; i < fields.length; i++) {
+			Object[] args = null;
+			try {
+				args = new Object[] { fields[i].get(object) };
+			} catch (IllegalArgumentException e) {
+				// no problem should occur here
+			} catch (IllegalAccessException e) {
+				// and here
+			}
+			OtpErlangObject member = TypeHelpersProxy.toErlang(args);
+			tupleMembers.add(member);
+		}
+		OtpErlangObject result = new OtpErlangTuple(tupleMembers
+				.toArray(new OtpErlangObject[tupleMembers.size()]));
+		return result;
+	}
+
+	public Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		Object result = null;
+		OtpErlangTuple tuple = (OtpErlangTuple) object;
+		Field[] fields = forClass.getFields();
+		result = forClass.newInstance();
+		for (int i = 0; i < tuple.arity(); i++) {
+			OtpErlangObject tupleMember = tuple.elementAt(i);
+			Object javaMember = TypeHelpersProxy.toJava(tupleMember, fields[i]
+					.getType());
+			fields[i].setAccessible(true);
+			fields[i].set(result, javaMember);
+		}
+		return result;
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelper.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelper.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelper.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelper.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,33 @@
+/*
+ * 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.erlang.impl.types;
+
+import com.ericsson.otp.erlang.OtpErlangObject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TypeHelper {
+
+	Object toJava(OtpErlangObject object, Class<?> forClass) throws Exception;
+
+	OtpErlangObject toErlang(Object object);
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelpersProxy.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelpersProxy.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelpersProxy.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/java/org/apache/tuscany/sca/binding/erlang/impl/types/TypeHelpersProxy.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,218 @@
+/*
+ * 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.erlang.impl.types;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.binding.erlang.impl.TypeMismatchException;
+
+import com.ericsson.otp.erlang.OtpErlangList;
+import com.ericsson.otp.erlang.OtpErlangObject;
+import com.ericsson.otp.erlang.OtpErlangTuple;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class TypeHelpersProxy {
+
+	private static Map<Class<?>, TypeHelper> primitiveTypes = null;
+
+	static {
+		// initiate type helpers
+		primitiveTypes = new HashMap<Class<?>, TypeHelper>();
+		primitiveTypes.put(boolean.class, new BooleanTypeHelper());
+		primitiveTypes.put(short.class, new ShortTypeHelper());
+		primitiveTypes.put(byte.class, new ByteTypeHelper());
+		primitiveTypes.put(char.class, new CharTypeHelper());
+		primitiveTypes.put(int.class, new IntTypeHelper());
+		primitiveTypes.put(long.class, new LongTypeHelper());
+		primitiveTypes.put(float.class, new FloatTypeHelper());
+		primitiveTypes.put(double.class, new DoubleTypeHelper());
+		primitiveTypes.put(String.class, new StringTypeHelper());
+		primitiveTypes.put(Boolean.class, primitiveTypes.get(boolean.class));
+		primitiveTypes.put(Character.class, primitiveTypes.get(char.class));
+		primitiveTypes.put(Short.class, primitiveTypes.get(char.class));
+		primitiveTypes.put(Byte.class, primitiveTypes.get(byte.class));
+		primitiveTypes.put(Short.class, primitiveTypes.get(short.class));
+		primitiveTypes.put(Integer.class, primitiveTypes.get(int.class));
+		primitiveTypes.put(Long.class, primitiveTypes.get(long.class));
+		primitiveTypes.put(Float.class, primitiveTypes.get(float.class));
+		primitiveTypes.put(Double.class, primitiveTypes.get(double.class));
+		primitiveTypes.put(byte[].class, new BinaryTypeHelper());
+	}
+
+	private static TypeHelper getTypeHelper(Class<?> forClass) {
+		TypeHelper typeHelper = primitiveTypes.get(forClass);
+		if (typeHelper == null && forClass.isArray()) {
+			typeHelper = new ListTypeHelper();
+		}
+		if (typeHelper == null) {
+			typeHelper = new TupleTypeHelper();
+		}
+		return typeHelper;
+	}
+
+	/**
+	 * Converts Java objects arrays to Erlang: 1. single object (if array arity
+	 * == 1) or 2. tuple (if array arity > 1)
+	 * 
+	 * @param objects
+	 * @return
+	 */
+	public static OtpErlangObject toErlang(Object[] objects) {
+		OtpErlangObject result = null;
+		if (objects != null) {
+			TypeHelper helper = null;
+			switch (objects.length) {
+			case 0:
+				result = new OtpErlangList();
+				break;
+			case 1:
+				helper = getTypeHelper(objects[0].getClass());
+				result = helper.toErlang(objects[0]);
+				break;
+			default:
+				OtpErlangObject[] erlObjects = new OtpErlangObject[objects.length];
+				for (int i = 0; i < objects.length; i++) {
+					helper = getTypeHelper(objects[i].getClass());
+					erlObjects[i] = helper.toErlang(objects[i]);
+				}
+				result = new OtpErlangTuple(erlObjects);
+				break;
+			}
+		}
+		return result;
+	}
+
+	/**
+	 * Creates Erlang list basing on unknown Java arrays
+	 * 
+	 * @param array
+	 * @return
+	 */
+	public static OtpErlangList toErlangAsList(Object array) {
+		OtpErlangList result = null;
+		if (array != null) {
+			List<OtpErlangObject> attrsList = new ArrayList<OtpErlangObject>();
+			int i = 0;
+			while (true) {
+				try {
+					TypeHelper helper = getTypeHelper(Array.get(array, i)
+							.getClass());
+					attrsList.add(helper.toErlang(Array.get(array, i)));
+					i++;
+				} catch (ArrayIndexOutOfBoundsException e) {
+					break;
+				}
+			}
+			result = new OtpErlangList(attrsList
+					.toArray(new OtpErlangObject[attrsList.size()]));
+		} else {
+			result = new OtpErlangList();
+		}
+		return result;
+	}
+
+	/**
+	 * Converts single Erlang object to Java
+	 * 
+	 * @param object
+	 * @param forClass
+	 * @return
+	 * @throws Exception
+	 */
+	public static Object toJava(OtpErlangObject object, Class<?> forClass)
+			throws Exception {
+		try {
+			TypeHelper helper = getTypeHelper(forClass);
+			return helper.toJava(object, forClass);
+		} catch (ClassCastException e) {
+			throw new TypeMismatchException(forClass, object.getClass());
+		}
+	}
+
+	/**
+	 * Creates array of Java objects from Erlang list
+	 * 
+	 * @param objects
+	 * @param forClass
+	 * @return
+	 * @throws Exception
+	 */
+	public static Object[] toJavaFromList(OtpErlangList objects,
+			Class<?>[] forClass) throws Exception {
+		Object[] result = new Object[objects.arity()];
+		try {
+			for (int i = 0; i < objects.arity(); i++) {
+				TypeHelper helper = getTypeHelper(forClass[i]);
+				result[i] = helper.toJava(objects.elementAt(i), forClass[i]);
+			}
+		} catch (Exception e) {
+			// type mismatch as mismatch of parameters count or parameters type
+			if (e.getClass().equals(ClassCastException.class)
+					|| e.getClass()
+							.equals(ArrayIndexOutOfBoundsException.class))
+				throw new TypeMismatchException();
+		}
+		return result;
+	}
+
+	/**
+	 * Converts incoming Erlang message to operation arguments
+	 * 
+	 * @param objects
+	 * @param forClass
+	 * @return
+	 * @throws Exception
+	 */
+	public static Object[] toJavaAsArgs(OtpErlangObject objects,
+			Class<?>[] forClass) throws Exception {
+		OtpErlangObject[] args = null;
+		// normalize input
+		if (objects.getClass().equals(OtpErlangTuple.class)) {
+			args = new OtpErlangObject[((OtpErlangTuple) objects).arity()];
+			for (int i = 0; i < ((OtpErlangTuple) objects).arity(); i++) {
+				args[i] = ((OtpErlangTuple) objects).elementAt(i);
+			}
+		} else {
+			args = new OtpErlangObject[1];
+			args[0] = objects;
+		}
+		Object[] result = new Object[args.length];
+		try {
+			for (int i = 0; i < args.length; i++) {
+				TypeHelper helper = getTypeHelper(forClass[i]);
+				result[i] = helper.toJava(args[i], forClass[i]);
+			}
+		} catch (Exception e) {
+			// type mismatch as mismatch of parameters count or parameters type
+			if (e.getClass().equals(ClassCastException.class)
+					|| e.getClass()
+							.equals(ArrayIndexOutOfBoundsException.class))
+				throw new TypeMismatchException();
+		}
+		return result;
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory Fri Apr  3 15:46:15 2009
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.erlang.impl.ErlangBindingProviderFactory;model=org.apache.tuscany.sca.binding.erlang.ErlangBinding

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxInterface.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxInterface.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxInterface.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxInterface.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,55 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MboxInterface {
+
+	String sendArgs(String arg) throws Exception;
+
+	boolean sendArgs(boolean arg) throws Exception;
+
+	float sendArgs(float arg) throws Exception;
+
+	double sendArgs(double arg) throws Exception;
+
+	long sendArgs(long arg) throws Exception;
+
+	int sendArgs(int arg) throws Exception;
+
+	char sendArgs(char arg) throws Exception;
+
+	short sendArgs(short arg) throws Exception;
+
+	byte sendArgs(byte arg) throws Exception;
+
+	void sendArgs(int arg1, String arg2) throws Exception;
+
+	StructuredTuple sendArgs(StructuredTuple arg) throws Exception;
+
+	String[] sendArgs(String[] arg) throws Exception;
+
+	String[][] sendArgs(String[][] arg);
+	
+	byte[] sendArgs(byte[] arg);
+	
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/MboxListener.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,65 @@
+/*
+ * 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.erlang.testing;
+
+import org.apache.tuscany.sca.binding.erlang.impl.types.TypeHelpersProxy;
+
+import com.ericsson.otp.erlang.OtpMbox;
+import com.ericsson.otp.erlang.OtpMsg;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MboxListener implements Runnable {
+
+	private OtpMbox mbox;
+	private OtpMsg msg;
+	private Object response;
+	private long duration;
+
+	public MboxListener(OtpMbox mbox, Object response) {
+		this(mbox, response, 0);
+	}
+	
+	public MboxListener(OtpMbox mbox, Object response, long duration) {
+		this.mbox = mbox;
+		this.response = response;
+		this.duration = duration;
+	}
+
+	public void run() {
+		try {
+			msg = mbox.receiveMsg();
+			Thread.sleep(duration);
+			if (response != null) {
+				Object[] args = new Object[1];
+				args[0] = response;
+				mbox.send(msg.getSenderPid(), TypeHelpersProxy.toErlang(args));
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public OtpMsg getMsg() {
+		return msg;
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ModuleInterface.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ModuleInterface.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ModuleInterface.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ModuleInterface.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.binding.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ModuleInterface {
+
+	String start(String arg1, String arg2) throws Exception;
+
+	String start() throws Exception;
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceServiceTestCase.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,816 @@
+/*
+ * 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.erlang.testing;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.binding.erlang.impl.TypeMismatchException;
+import org.apache.tuscany.sca.binding.erlang.impl.exceptions.ErlangException;
+import org.apache.tuscany.sca.binding.erlang.testing.dynaignore.IgnorableRunner;
+import org.apache.tuscany.sca.binding.erlang.testing.dynaignore.IgnoreTest;
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.ericsson.otp.erlang.OtpAuthException;
+import com.ericsson.otp.erlang.OtpConnection;
+import com.ericsson.otp.erlang.OtpErlangAtom;
+import com.ericsson.otp.erlang.OtpErlangBinary;
+import com.ericsson.otp.erlang.OtpErlangBoolean;
+import com.ericsson.otp.erlang.OtpErlangDouble;
+import com.ericsson.otp.erlang.OtpErlangInt;
+import com.ericsson.otp.erlang.OtpErlangList;
+import com.ericsson.otp.erlang.OtpErlangLong;
+import com.ericsson.otp.erlang.OtpErlangObject;
+import com.ericsson.otp.erlang.OtpErlangString;
+import com.ericsson.otp.erlang.OtpErlangTuple;
+import com.ericsson.otp.erlang.OtpMbox;
+import com.ericsson.otp.erlang.OtpNode;
+import com.ericsson.otp.erlang.OtpPeer;
+import com.ericsson.otp.erlang.OtpSelf;
+
+/**
+ * Test is annotated with test runner, which will ignore tests if epmd is not
+ * available
+ * 
+ * @version $Rev$ $Date$
+ */
+@RunWith(IgnorableRunner.class)
+public class ReferenceServiceTestCase {
+
+	private static final String EPMD_COMMAND = "epmd";
+
+	private static MboxInterface mboxReference;
+	private static MboxInterface timeoutMboxReference;
+	private static ServiceInterface moduleReference;
+	private static ServiceInterface cookieModuleReference;
+	private static ServiceInterface invalidCookieModuleReference;
+	private static ServiceInterface timeoutModuleReference;
+	private static OtpNode serNode;
+	private static OtpMbox serMbox;
+	private static OtpNode refNode;
+	private static OtpMbox refMbox;
+	private static Process epmdProcess;
+
+	@BeforeClass
+	public static void init() throws IOException {
+		try {
+			epmdProcess = Runtime.getRuntime().exec(EPMD_COMMAND);
+			SCADomain domain = SCADomain
+					.newInstance("ErlangReference.composite");
+			SCADomain.newInstance("ErlangService.composite");
+			ReferenceTestComponentImpl component = domain.getService(
+					ReferenceTestComponentImpl.class, "ReferenceTest");
+
+			mboxReference = component.getMboxReference();
+			timeoutMboxReference = component.getTimeoutMboxReference();
+			moduleReference = component.getModuleReference();
+			cookieModuleReference = component.getCookieModuleReference();
+			invalidCookieModuleReference = component
+					.getInvalidCookieModuleReference();
+			timeoutModuleReference = component.getTimeoutModuleReference();
+
+			serNode = new OtpNode("MboxServer");
+			serMbox = serNode.createMbox("sendArgs");
+			refNode = new OtpNode("MboxClient");
+			refMbox = refNode.createMbox("connector_to_SCA_mbox");
+		} catch (IOException e) {
+			System.out.println("Problem executing " + EPMD_COMMAND + ": "
+					+ e.getLocalizedMessage() + ". Tests will be IGNORED.");
+		}
+	}
+
+	@AfterClass
+	public static void clean() {
+		if (epmdProcess != null) {
+			epmdProcess.destroy();
+		}
+	}
+
+	@Before
+	public void before() {
+		if (epmdProcess == null) {
+			throw new IgnoreTest();
+		}
+	}
+
+	/**
+	 * Tests passing strings
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testStrings() throws Exception {
+		String strArg = "Test message";
+		String strResult = "OK";
+		MboxListener mboxListener = new MboxListener(serMbox, strResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		String testResult = mboxReference.sendArgs(strArg);
+		assertEquals(strArg, ((OtpErlangString) mboxListener.getMsg().getMsg())
+				.stringValue());
+		assertEquals(strResult, testResult);
+	}
+
+	/**
+	 * Tests passing booleans
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testBooleans() throws Exception {
+		boolean booleanArg = true;
+		boolean booleanResult = false;
+		MboxListener mboxListener = new MboxListener(serMbox, booleanResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		boolean testResult = mboxReference.sendArgs(booleanArg);
+		assertEquals(booleanArg, ((OtpErlangAtom) mboxListener.getMsg()
+				.getMsg()).booleanValue());
+		assertEquals(booleanResult, testResult);
+	}
+
+	/**
+	 * Tests passing floats
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testFloats() throws Exception {
+		float floatArg = 1.0f;
+		float floatResult = 2.0f;
+		MboxListener mboxListener = new MboxListener(serMbox, floatResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		float testResult = mboxReference.sendArgs(floatArg);
+		assertEquals(floatArg, ((OtpErlangDouble) mboxListener.getMsg()
+				.getMsg()).doubleValue(), 0);
+		assertEquals(floatResult, testResult, 0);
+	}
+
+	/**
+	 * Tests passing doubles
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testDoubles() throws Exception {
+		double doubleArg = 1.0f;
+		double doubleResult = 2.0f;
+		MboxListener mboxListener = new MboxListener(serMbox, doubleResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		double testResult = mboxReference.sendArgs(doubleArg);
+		assertEquals(doubleArg, ((OtpErlangDouble) mboxListener.getMsg()
+				.getMsg()).doubleValue(), 0);
+		assertEquals(doubleResult, testResult, 0);
+	}
+
+	/**
+	 * Tests passing long values
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testLongs() throws Exception {
+		long longArg = 1;
+		long longResult = 2;
+		MboxListener mboxListener = new MboxListener(serMbox, longResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		long testResult = mboxReference.sendArgs(longArg);
+		assertEquals(longArg, ((OtpErlangLong) mboxListener.getMsg().getMsg())
+				.longValue(), 0);
+		assertEquals(longResult, testResult, 0);
+	}
+
+	/**
+	 * Tests passing integers
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testInts() throws Exception {
+		int intArg = 1;
+		int intResult = 2;
+		MboxListener mboxListener = new MboxListener(serMbox, intResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		int testResult = mboxReference.sendArgs(intArg);
+		assertEquals(intArg, ((OtpErlangLong) mboxListener.getMsg().getMsg())
+				.intValue(), 0);
+		assertEquals(intResult, testResult, 0);
+	}
+
+	/**
+	 * Tests passing chars
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testChars() throws Exception {
+		char charArg = 1;
+		char charResult = 2;
+		MboxListener mboxListener = new MboxListener(serMbox, charResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		char testResult = mboxReference.sendArgs(charArg);
+		assertEquals(charArg, ((OtpErlangLong) mboxListener.getMsg().getMsg())
+				.charValue(), 0);
+		assertEquals(charResult, testResult, 0);
+	}
+
+	/**
+	 * Tests passing shorts
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testShorts() throws Exception {
+		short shortArg = 1;
+		short shortResult = 2;
+		MboxListener mboxListener = new MboxListener(serMbox, shortResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		short testResult = mboxReference.sendArgs(shortArg);
+		assertEquals(shortArg, ((OtpErlangLong) mboxListener.getMsg().getMsg())
+				.shortValue(), 0);
+		assertEquals(shortResult, testResult, 0);
+	}
+
+	/**
+	 * Tests passing bytes
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testBytes() throws Exception {
+		byte byteArg = 1;
+		byte byteResult = 2;
+		MboxListener mboxListener = new MboxListener(serMbox, byteResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		byte testResult = mboxReference.sendArgs(byteArg);
+		assertEquals(byteArg, ((OtpErlangLong) mboxListener.getMsg().getMsg())
+				.byteValue(), 0);
+		assertEquals(byteResult, testResult, 0);
+	}
+
+	/**
+	 * Tests passing multiple arguments
+	 * 
+	 * @throws Exception
+	 */
+	// TODO: this test fails sometime
+	@Test(timeout = 1000)
+	public void testMultipleArguments() throws Exception {
+		MboxListener mboxListener = new MboxListener(serMbox, true);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		String testString = "TupleString";
+		int testInt = 10;
+		mboxReference.sendArgs(testInt, testString);
+		assertEquals(testInt, ((OtpErlangLong) ((OtpErlangTuple) mboxListener
+				.getMsg().getMsg()).elementAt(0)).longValue());
+		assertEquals(testString,
+				((OtpErlangString) ((OtpErlangTuple) mboxListener.getMsg()
+						.getMsg()).elementAt(1)).stringValue());
+	}
+
+	/**
+	 * Tests passing tuples
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testTuples() throws Exception {
+		StructuredTuple tupleResult = new StructuredTuple();
+		tupleResult.arg1.arg1 = 1;
+		tupleResult.arg1.arg2 = "Tuple inside tuple";
+		tupleResult.arg2 = "Tuple!";
+		tupleResult.arg3 = true;
+		MboxListener mboxListener = new MboxListener(serMbox, tupleResult);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		StructuredTuple testArg = new StructuredTuple();
+		testArg.arg2 = "Arg2a";
+		testArg.arg3 = true;
+		testArg.arg1.arg1 = 10;
+		testArg.arg1.arg2 = "Arg2b";
+		StructuredTuple testResult = mboxReference.sendArgs(testArg);
+		assertEquals(tupleResult, testResult);
+		OtpErlangTuple received = (OtpErlangTuple) mboxListener.getMsg()
+				.getMsg();
+		assertEquals(testArg.arg1.arg1,
+				((OtpErlangLong) ((OtpErlangTuple) received.elementAt(0))
+						.elementAt(0)).longValue());
+		assertEquals(testArg.arg1.arg2,
+				((OtpErlangString) ((OtpErlangTuple) received.elementAt(0))
+						.elementAt(1)).stringValue());
+		assertEquals(testArg.arg2, ((OtpErlangString) received.elementAt(1))
+				.stringValue());
+		assertEquals(testArg.arg3, ((OtpErlangAtom) received.elementAt(2))
+				.booleanValue());
+	}
+
+	/**
+	 * Test passing Erlang binaries
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testBinaries() throws Exception {
+		byte[] testArg = { 0, 1 };
+		MboxListener mboxListener = new MboxListener(serMbox, testArg);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		byte[] testResult = mboxReference.sendArgs(testArg);
+		assertEquals(testArg.length, testResult.length);
+		for (int i = 0; i < testArg.length; i++) {
+			assertEquals(testArg[i], testResult[i]);
+		}
+		OtpErlangBinary received = (OtpErlangBinary) mboxListener.getMsg()
+				.getMsg();
+		assertEquals(testArg.length, received.size());
+		for (int i = 0; i < testArg.length; i++) {
+			assertEquals(testArg[i], received.binaryValue()[i]);
+		}
+	}
+
+	/**
+	 * Tests passing lists
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testLists() throws Exception {
+		String[] testArg = new String[] { "One", "Two", "Three" };
+		MboxListener mboxListener = new MboxListener(serMbox, testArg);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		String[] testResult = mboxReference.sendArgs(testArg);
+		assertEquals(testArg.length, testResult.length);
+		for (int i = 0; i < testArg.length; i++) {
+			assertEquals(testArg[i], testResult[i]);
+		}
+		OtpErlangList received = (OtpErlangList) mboxListener.getMsg().getMsg();
+		assertEquals(testArg.length, received.arity());
+		for (int i = 0; i < testArg.length; i++) {
+			assertEquals(testArg[i], ((OtpErlangString) received.elementAt(i))
+					.stringValue());
+		}
+	}
+
+	/**
+	 * Tests passing multidimensional lists
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testMultiDimLists() throws Exception {
+		String[][] testArg = new String[][] { { "One", "Two" },
+				{ "Three", "Four", "Five" }, { "Six" } };
+		MboxListener mboxListener = new MboxListener(serMbox, testArg);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		String[][] testResult = mboxReference.sendArgs(testArg);
+		assertEquals(testArg.length, testResult.length);
+		for (int i = 0; i < testArg.length; i++) {
+			for (int j = 0; j < testArg[i].length; j++) {
+				assertEquals(testArg[i][j], testResult[i][j]);
+			}
+		}
+		OtpErlangList received = (OtpErlangList) mboxListener.getMsg().getMsg();
+		assertEquals(testArg.length, received.arity());
+		for (int i = 0; i < testArg.length; i++) {
+			for (int j = 0; j < testArg[i].length; j++) {
+				assertEquals(testArg[i][j],
+						(((OtpErlangString) ((OtpErlangList) received
+								.elementAt(i)).elementAt(j)).stringValue()));
+			}
+		}
+	}
+
+	/**
+	 * Tests mismatched interface
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void typeMismatch() throws Exception {
+		try {
+			StructuredTuple arg = new StructuredTuple();
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			String[] arg = new String[] { "test" };
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			long arg = 1;
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			int arg = 1;
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			short arg = 1;
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			char arg = 1;
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			byte arg = 1;
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			double arg = 1;
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			float arg = 1;
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			String arg = "1";
+			MboxListener mboxListener = new MboxListener(serMbox, true);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+
+		try {
+			boolean arg = true;
+			MboxListener mboxListener = new MboxListener(serMbox, 1);
+			Thread mboxThread = new Thread(mboxListener);
+			mboxThread.start();
+			mboxReference.sendArgs(arg);
+		} catch (Exception e) {
+			assertEquals(TypeMismatchException.class, e.getClass());
+			System.out.println(e.getMessage());
+		}
+	}
+
+	/**
+	 * Basic RPC test, without arguments
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 10000000)
+	public void testRPC() throws Exception {
+		String[] result = moduleReference.sayHellos();
+		assertEquals(2, result.length);
+		assertEquals("1", result[0]);
+		assertEquals("2", result[1]);
+	}
+
+	/**
+	 * Tests RPC with arguments
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testRPCWithArgs() throws Exception {
+		String arg1 = "One";
+		String arg2 = "Two";
+		String testResult = moduleReference.sayHello(arg1, arg2);
+		assertEquals("Hello " + arg1 + " " + arg2, testResult);
+	}
+
+	/**
+	 * Tests RPC with structured arguments
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testRPCWithComplexArgs() throws Exception {
+		StructuredTuple arg = new StructuredTuple();
+		arg.arg1.arg2 = "Not empty";
+		arg.arg2 = "Not empty";
+		StructuredTuple testResult = moduleReference.passComplexArgs(arg,
+				new String[] { "some", "array" });
+		assertEquals(arg, testResult);
+	}
+
+	/**
+	 * Tests RPC with no result
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testRPCWithVoidResult() throws Exception {
+		moduleReference.doNothing();
+	}
+
+	/**
+	 * Tests handling requests pointing to unknown functions
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testUnknownFunction() throws Exception {
+
+		// following functions differs by parameters
+
+		try {
+			moduleReference.sayHello();
+		} catch (Exception e) {
+			assertEquals(ErlangException.class, e.getClass());
+		}
+
+		try {
+			moduleReference.sayHello("1");
+		} catch (Exception e) {
+			assertEquals(ErlangException.class, e.getClass());
+		}
+
+		try {
+			moduleReference.sayHello(1, 2);
+		} catch (Exception e) {
+			assertEquals(ErlangException.class, e.getClass());
+		}
+
+		// for following ones name not exists
+
+		moduleReference.notExist();
+
+		try {
+			moduleReference.notExistWithException();
+		} catch (Exception e) {
+			assertEquals(ErlangException.class, e.getClass());
+		}
+	}
+	
+	/**
+	 * Tests mbox with retrieving and answering with basic arguments
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testMbox() throws Exception {
+		OtpErlangObject[] args = new OtpErlangObject[2];
+		args[0] = new OtpErlangString("world");
+		args[1] = new OtpErlangString("!");
+		OtpErlangTuple tuple = new OtpErlangTuple(args);
+		refMbox.send("sayHello", "RPCServerMbox", tuple);
+		OtpErlangString result = (OtpErlangString) refMbox.receiveMsg()
+				.getMsg();
+		assertEquals("Hello world !", result.stringValue());
+	}
+
+	/**
+	 * Tests service mbox receiving complex message
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 2000)
+	public void testMboxWithComplexArgs() throws Exception {
+		int arg1 = 1;
+		String arg2 = "arg2";
+		String arg3 = "arg3";
+		boolean arg4 = true;
+
+		OtpErlangObject[] smallTupleContent = new OtpErlangObject[2];
+		smallTupleContent[0] = new OtpErlangInt(arg1);
+		smallTupleContent[1] = new OtpErlangString(arg2);
+		OtpErlangTuple smallTuple = new OtpErlangTuple(smallTupleContent);
+		OtpErlangObject[] structuredTupleContent = new OtpErlangObject[3];
+		structuredTupleContent[0] = smallTuple;
+		structuredTupleContent[1] = new OtpErlangString(arg3);
+		structuredTupleContent[2] = new OtpErlangBoolean(arg4);
+		OtpErlangTuple structuredTuple = new OtpErlangTuple(
+				structuredTupleContent);
+		OtpErlangObject[] secondArg = new OtpErlangObject[2];
+		secondArg[0] = new OtpErlangString("in");
+		secondArg[1] = new OtpErlangString("array");
+		OtpErlangList list = new OtpErlangList(secondArg);
+		OtpErlangObject[] argsContent = new OtpErlangObject[2];
+		argsContent[0] = structuredTuple;
+		argsContent[1] = list;
+		OtpErlangTuple args = new OtpErlangTuple(argsContent);
+		refMbox.send("passComplexArgs", "RPCServerMbox", args);
+		OtpErlangObject result = refMbox.receiveMsg().getMsg();
+		assertEquals(arg1,
+				((OtpErlangLong) ((OtpErlangTuple) ((OtpErlangTuple) result)
+						.elementAt(0)).elementAt(0)).intValue());
+		assertEquals(arg2,
+				((OtpErlangString) ((OtpErlangTuple) ((OtpErlangTuple) result)
+						.elementAt(0)).elementAt(1)).stringValue());
+		assertEquals(arg3, ((OtpErlangString) ((OtpErlangTuple) result)
+				.elementAt(1)).stringValue());
+		assertEquals(arg4, ((OtpErlangAtom) ((OtpErlangTuple) result)
+				.elementAt(2)).booleanValue());
+	}
+
+	/**
+	 * Tests timeout feature for reference binding messaging
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 4000)
+	public void testMboxReferenceTimeouts() throws Exception {
+		long timeBiggerThanTimeout = 1000;
+		String stringResult = "result";
+
+		// doing test for response time bigger than declared timeout (500)
+		MboxListener mboxListener = new MboxListener(serMbox, stringResult,
+				timeBiggerThanTimeout);
+		Thread mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		try {
+			// timeout exception expected
+			timeoutMboxReference.sendArgs("");
+			fail("Exception expected");
+		} catch (Exception e) {
+			assertEquals(ErlangException.class, e.getClass());
+			assertEquals(e.getCause().getClass(), InterruptedException.class);
+		}
+
+		// doing test for response time smaller than declared timeout (500)
+		mboxListener = new MboxListener(serMbox, stringResult, 0);
+		mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		// expecting no timeout exception
+		String testResult = timeoutMboxReference.sendArgs("");
+		assertEquals(stringResult, testResult);
+
+		// doing test for response time which will cause timeout. This time
+		// there is no declared exception in users operation so we expect no
+		// exception and null result
+		mboxListener = new MboxListener(serMbox, new byte[1],
+				timeBiggerThanTimeout);
+		mboxThread = new Thread(mboxListener);
+		mboxThread.start();
+		// expecting no timeout exception
+		byte[] result = timeoutMboxReference.sendArgs(new byte[1]);
+		assertEquals(null, result);
+	}
+
+	/**
+	 * Tests timeout feature for reference binding RPC
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 4000)
+	public void testRpcReferenceTimeouts() throws Exception {
+
+		// doing test for response time which will cause timeout. Method does
+		// not
+		// declare exception so only null value will be returned
+		String result1 = timeoutModuleReference.sayHello("hello", "world");
+		assertEquals(null, result1);
+
+		// doing test for response time which will cause timeout. Method declare
+		// exception, so expecting one
+		try {
+			timeoutModuleReference.sayHellos();
+			fail("Exception expected");
+		} catch (Exception e) {
+			assertEquals(ErlangException.class, e.getClass());
+		}
+
+		// doing test for response time shorter than timeout
+		timeoutModuleReference.doNothing();
+	}
+
+	/**
+	 * Tests timeout feature for service side bindings
+	 * @throws Exception
+	 */
+	@Test(timeout = 4000)
+	public void testServiceTimeouts() throws Exception {
+		OtpSelf self = new OtpSelf("tmp_connector_"
+				+ System.currentTimeMillis());
+		OtpPeer peer = new OtpPeer("RPCServerTimeout");
+		OtpConnection connection = self.connect(peer);
+		// delay message sending after connecting
+		Thread.sleep(1000);
+		// service binding timeout set to 500 so after that time it will give up
+		// and close connection
+		try {
+			connection.send("rex", new OtpErlangString("test"));
+			fail("Exception expected");
+		} catch (Exception e) {
+			assertEquals(IOException.class, e.getClass());
+		}
+
+		connection = self.connect(peer);
+		// sending message immediately and encountering no connection close
+		connection.send("rex", new OtpErlangString("test"));
+
+	}
+
+	/**
+	 * Tests cookie feature for both reference and service bindings RPC
+	 * 
+	 * @throws Exception
+	 */
+	@Test(timeout = 1000)
+	public void testReferenceCookies() throws Exception {
+		// testing wrong cookie
+		try {
+			invalidCookieModuleReference.sayHellos();
+			fail("Exception expected");
+		} catch (Exception e) {
+			assertEquals(ErlangException.class, e.getClass());
+			assertEquals(OtpAuthException.class, e.getCause().getClass());
+		}
+
+		// testing correct cookie
+		cookieModuleReference.sayHellos();
+
+	}
+	
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponent.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponent.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponent.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponent.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,27 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ReferenceTestComponent {
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ReferenceTestComponentImpl.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,110 @@
+/*
+ * 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.erlang.testing;
+
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReferenceTestComponentImpl implements ReferenceTestComponent {
+
+	private MboxInterface mboxReference;
+	private MboxInterface timeoutMboxReference;
+	private MboxInterface cookieMboxReference;
+	private ServiceInterface moduleReference;
+	private ServiceInterface cookieModuleReference;
+	private ServiceInterface invalidCookieModuleReference;
+	private ServiceInterface timeoutModuleReference;
+	private ServiceInterface clonedModuleReference;
+
+	@Reference
+	public void setMboxReference(MboxInterface mboxReference) {
+		this.mboxReference = mboxReference;
+	}
+	
+	@Reference
+	public void setTimeoutMboxReference(MboxInterface timeoutMboxReference) {
+		this.timeoutMboxReference = timeoutMboxReference;
+	}
+	
+	@Reference
+	public void setCookieMboxReference(MboxInterface cookieMboxReference) {
+		this.cookieMboxReference = cookieMboxReference;
+	}
+
+	@Reference
+	public void setModuleReference(ServiceInterface timeoutModuleReference) {
+		this.moduleReference = timeoutModuleReference;
+	}
+	
+	@Reference
+	public void setCookieModuleReference(ServiceInterface cookieModuleReference) {
+		this.cookieModuleReference = cookieModuleReference;
+	}
+	
+	@Reference
+	public void setInvalidCookieModuleReference(ServiceInterface invalidCookieModuleReference) {
+		this.invalidCookieModuleReference = invalidCookieModuleReference;
+	}
+	
+	@Reference
+	public void setTimeoutModuleReference(ServiceInterface timeoutModuleReference) {
+		this.timeoutModuleReference = timeoutModuleReference;
+	}
+
+	@Reference
+	public void setClonedModuleReference(ServiceInterface clonedModuleReference) {
+		this.clonedModuleReference = clonedModuleReference;
+	}
+
+	public MboxInterface getMboxReference() {
+		return mboxReference;
+	}
+
+	public MboxInterface getTimeoutMboxReference() {
+		return timeoutMboxReference;
+	}
+	
+	public MboxInterface getCookieMboxReference() {
+		return cookieMboxReference;
+	}
+	
+	public ServiceInterface getModuleReference() {
+		return moduleReference;
+	}
+
+	public ServiceInterface getCookieModuleReference() {
+		return cookieModuleReference;
+	}
+
+	public ServiceInterface getInvalidCookieModuleReference() {
+		return invalidCookieModuleReference;
+	}
+	
+	public ServiceInterface getTimeoutModuleReference() {
+		return timeoutModuleReference;
+	}
+
+	public ServiceInterface getClonedModuleReference() {
+		return clonedModuleReference;
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceInterface.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceInterface.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceInterface.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceInterface.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,45 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ServiceInterface {
+
+	void doNothing();
+
+	String sayHello(String arg1, String arg2);
+
+	String[] sayHellos() throws Exception;
+
+	StructuredTuple passComplexArgs(StructuredTuple arg1, String[] arg2);
+
+	String sayHello() throws Exception;
+
+	String sayHello(String arg) throws Exception;
+
+	String sayHello(int arg1, int arg2);
+
+	void notExistWithException() throws Exception;
+
+	void notExist();
+	
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponent.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponent.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponent.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponent.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ServiceTestComponent {
+
+	String sayHello(String arg1, String arg2);
+
+	String[] sayHellos() throws Exception;
+
+	StructuredTuple passComplexArgs(StructuredTuple arg1, String[] arg2);
+
+	void doNothing();
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImpl.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImpl.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImpl.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,44 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceTestComponentImpl implements ServiceTestComponent {
+
+	public String sayHello(String arg1, String arg2) {
+		return "Hello " + arg1 + " " + arg2;
+	}
+
+	public String[] sayHellos() {
+		String[] result = new String[] { "1", "2" };
+		return result;
+	}
+
+	public StructuredTuple passComplexArgs(StructuredTuple arg1, String[] arg2) {
+		return arg1;
+	}
+
+	public void doNothing() {
+		// doing nothing
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplClone.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,44 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceTestComponentImplClone implements ServiceTestComponent {
+
+	public String sayHello(String arg1, String arg2) {
+		return "Bye " + arg1 + " " + arg2;
+	}
+
+	public String[] sayHellos() {
+		String[] result = new String[] { "-1", "-2" };
+		return result;
+	}
+
+	public StructuredTuple passComplexArgs(StructuredTuple arg1, String[] arg2) {
+		return arg1;
+	}
+
+	public void doNothing() {
+
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplTimeout.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplTimeout.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplTimeout.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ServiceTestComponentImplTimeout.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,61 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServiceTestComponentImplTimeout implements ServiceTestComponent {
+
+	private long duration = 1000;
+	
+	public String sayHello(String arg1, String arg2) {
+		try {
+			Thread.sleep(duration);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		return "Bye " + arg1 + " " + arg2;
+	}
+
+	public String[] sayHellos() {
+		try {
+			Thread.sleep(duration);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		String[] result = new String[] { "-1", "-2" };
+		return result;
+	}
+
+	public StructuredTuple passComplexArgs(StructuredTuple arg1, String[] arg2) {
+		try {
+			Thread.sleep(duration);
+		} catch (InterruptedException e) {
+			e.printStackTrace();
+		}
+		return arg1;
+	}
+
+	public void doNothing() {
+
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/SmallTuple.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/SmallTuple.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/SmallTuple.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/SmallTuple.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SmallTuple {
+
+	public int arg1;
+	public String arg2 = "";
+
+	public boolean equals(Object o) {
+		SmallTuple comp = (SmallTuple) o;
+		return arg1 == comp.arg1 && arg2.equals(arg2);
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/StructuredTuple.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/StructuredTuple.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/StructuredTuple.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/StructuredTuple.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.erlang.testing;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StructuredTuple {
+
+	public SmallTuple arg1 = new SmallTuple();
+	public String arg2 = "";
+	public boolean arg3;
+
+	public boolean equals(Object o) {
+		StructuredTuple comp = (StructuredTuple) o;
+		return arg2.equals(comp.arg2) && arg3 == comp.arg3
+				&& arg1.equals(comp.arg1);
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnorableRunner.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnorableRunner.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnorableRunner.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnorableRunner.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,139 @@
+/*
+ * 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.erlang.testing.dynaignore;
+
+import org.junit.runner.Description;
+import org.junit.runner.Result;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runner.notification.StoppedByUserException;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.InitializationError;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IgnorableRunner extends Runner {
+
+	private static final class Notifier extends RunNotifier {
+		private final RunNotifier notifier;
+
+		public Notifier(final RunNotifier notifier) {
+			this.notifier = notifier;
+		}
+
+		public void addFirstListener(final RunListener listener) {
+			notifier.addFirstListener(listener);
+		}
+
+		public void addListener(final RunListener listener) {
+			notifier.addListener(listener);
+		}
+
+		@Override
+		public boolean equals(final Object obj) {
+			return notifier.equals(obj);
+		}
+
+		@Override
+		public void fireTestFailure(final Failure failure) {
+			if (failure.getException().getClass() == IgnoreTest.class) {
+				notifier.fireTestIgnored(failure.getDescription());
+			} else {
+				notifier.fireTestFailure(failure);
+			}
+		}
+
+		@Override
+		public void fireTestFinished(final Description description) {
+			notifier.fireTestFinished(description);
+		}
+
+		@Override
+		public void fireTestIgnored(final Description description) {
+			notifier.fireTestIgnored(description);
+		}
+
+		@Override
+		public void fireTestRunFinished(final Result result) {
+			notifier.fireTestRunFinished(result);
+		}
+
+		@Override
+		public void fireTestRunStarted(final Description description) {
+			notifier.fireTestRunStarted(description);
+		}
+
+		@Override
+		public void fireTestStarted(final Description description)
+				throws StoppedByUserException {
+			notifier.fireTestStarted(description);
+		}
+
+		@Override
+		public int hashCode() {
+			return notifier.hashCode();
+		}
+
+		@Override
+		public void pleaseStop() {
+			notifier.pleaseStop();
+		}
+
+		@Override
+		public void removeListener(final RunListener listener) {
+			notifier.removeListener(listener);
+		}
+
+		public void testAborted(final Description description,
+				final Throwable cause) {
+			((Notifier) notifier).testAborted(description, cause);
+		}
+
+		@Override
+		public String toString() {
+			return notifier.toString();
+		}
+
+	}
+
+	Runner runner = null;
+
+	public IgnorableRunner(Class<?> testClass) {
+		try {
+			runner = new BlockJUnit4ClassRunner(testClass);
+		} catch (InitializationError e) {
+			e.printStackTrace();
+		}
+	}
+
+	@Override
+	public Description getDescription() {
+		return runner.getDescription();
+	}
+
+	@Override
+	public void run(RunNotifier notifier) {
+		runner.run(new Notifier(notifier));
+	}
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnoreTest.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnoreTest.java?rev=761712&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnoreTest.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-erlang-runtime/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/dynaignore/IgnoreTest.java Fri Apr  3 15:46:15 2009
@@ -0,0 +1,29 @@
+/*
+ * 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.erlang.testing.dynaignore;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public final class IgnoreTest extends Error {
+
+	private static final long serialVersionUID = 1L;
+
+}