diff options
author | Damjan Jovanovic <damjan@apache.org> | 2018-04-08 12:55:05 +0000 |
---|---|---|
committer | Damjan Jovanovic <damjan@apache.org> | 2018-04-08 12:55:05 +0000 |
commit | a3b76bbcc506e4d4ba5b0d4c9b6b2914caef462f (patch) | |
tree | 6b749d3a8204abe94a12b7dcdff3cc7c33eadc13 /jurt/test | |
parent | 419130311a95ac43ef87be09f86dfdad003230f5 (diff) |
Added an Ant target type to gbuild, that can be used to call Ant to build
a deliverable. Added Ant support files that provide build infrastructure
that can be used by Java projects, including testing with JUnit at
compile time, processing of external dependencies, using the IDL
toolchain (idlc, regmerge, javamaker), and general build support like
compiling into class files, building the JAR file and cleaning. These
features require Ant version >= 1.9.1.
Ported main/jurt to gbuild and this Ant infrastructure.
Patch by: me
Notes
Notes:
ignore: obsolete
Diffstat (limited to 'jurt/test')
7 files changed, 0 insertions, 1145 deletions
diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java deleted file mode 100644 index 6bf32cffb5b6..000000000000 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************** - * - * 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 com.sun.star.lib.uno.protocols.urp; - -import org.junit.Test; -import static org.junit.Assert.*; - -public final class Cache_Test { - @Test public void test0() { - Cache c = new Cache(0); - boolean[] f = new boolean[1]; - int i; - i = c.add(f, "a"); - assertTrue(i == Cache.NOT_CACHED && !f[0]); - i = c.add(f, "a"); - assertTrue(i == Cache.NOT_CACHED && !f[0]); - i = c.add(f, "b"); - assertTrue(i == Cache.NOT_CACHED && !f[0]); - i = c.add(f, "a"); - assertTrue(i == Cache.NOT_CACHED && !f[0]); - } - - @Test public void test1() { - Cache c = new Cache(1); - boolean[] f = new boolean[1]; - int i; - i = c.add(f, "a"); - assertTrue(i == 0 && !f[0]); - i = c.add(f, "a"); - assertTrue(i == 0 && f[0]); - i = c.add(f, "b"); - assertTrue(i == 0 && !f[0]); - i = c.add(f, "b"); - assertTrue(i == 0 && f[0]); - i = c.add(f, "a"); - assertTrue(i == 0 && !f[0]); - } - - @Test public void test2() { - Cache c = new Cache(2); - boolean[] f = new boolean[1]; - int i; - i = c.add(f, "a"); - assertTrue(i == 0 && !f[0]); - i = c.add(f, "a"); - assertTrue(i == 0 && f[0]); - i = c.add(f, "b"); - assertTrue(i == 1 && !f[0]); - i = c.add(f, "b"); - assertTrue(i == 1 && f[0]); - i = c.add(f, "a"); - assertTrue(i == 0 && f[0]); - i = c.add(f, "c"); - assertTrue(i == 1 && !f[0]); - i = c.add(f, "b"); - assertTrue(i == 0 && !f[0]); - } - - @Test public void test3() { - Cache c = new Cache(3); - boolean[] f = new boolean[1]; - int i; - i = c.add(f, "a"); - assertTrue(i == 0 && !f[0]); - i = c.add(f, "a"); - assertTrue(i == 0 && f[0]); - i = c.add(f, "b"); - assertTrue(i == 1 && !f[0]); - i = c.add(f, "a"); - assertTrue(i == 0 && f[0]); - i = c.add(f, "c"); - assertTrue(i == 2 && !f[0]); - i = c.add(f, "d"); - assertTrue(i == 1 && !f[0]); - i = c.add(f, "d"); - assertTrue(i == 1 && f[0]); - } - - @Test public void testNothingLostFromLruList() { - // Regardless in what order arbitrary values from 0, ..., 3 are inserted - // into a size-4 cache, afterwards adding -1, ..., -4 must return each - // possible index in the range from 0, ..., 3 exactly once (so their sum - // must be 6); this code systematically tests all such arbitrary ways up - // to length 8 (the code arguably violates recommendations for writing - // good tests, but actually helped track down an error in the Cache - // implementation): - int[] a = new int[8]; - for (int i = 0; i < a.length; ++i) { - for (int j = 0; j < i; ++j) { - a[j] = 0; - } - for (;;) { - Cache c = new Cache(4); - for (int k = 0; k < i; ++k) { - c.add(new boolean[1], a[k]); - } - assertEquals( - 6, - (c.add(new boolean[1], -1) + c.add(new boolean[1], -2) + - c.add(new boolean[1], -3) + c.add(new boolean[1], -4))); - int j = i - 1; - while (j >= 0 && a[j] == 3) { - --j; - } - if (j < 0) { - break; - } - ++a[j]; - for (int k = j + 1; k < i; ++k) { - a[k] = 0; - } - } - } - } -} diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java deleted file mode 100644 index c706619ba749..000000000000 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java +++ /dev/null @@ -1,358 +0,0 @@ -/************************************************************** - * - * 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 com.sun.star.lib.uno.protocols.urp; - -import com.sun.star.lib.uno.typedesc.TypeDescription; -import com.sun.star.uno.Any; -import com.sun.star.uno.IBridge; -import com.sun.star.uno.Type; -import com.sun.star.uno.TypeClass; -import com.sun.star.uno.XInterface; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import org.junit.Test; -import static org.junit.Assert.*; - -public final class Marshaling_Test { - @Test public void test() throws Exception { - short cacheSize = (short)256; - TestBridge testBridge = new TestBridge(); - Marshal marshal = new Marshal(testBridge, cacheSize); - - TestObject testObject = new TestObject(); - - TestPrimitiveSeqStruct x = new TestPrimitiveSeqStruct(); - x.zAny = new Object[]{new Integer(1), new Double(2) }; - - - Object data[] = new Object[] { - new com.sun.star.uno.RuntimeException("testRuntimeException"), - new com.sun.star.uno.Exception("testException"), - new Boolean(true), - new Byte((byte)47), - new Character('k'), - new Double(0.12345), - TestEnum.B, - new Float(0.5678), - new Integer(0), - new Integer(128), - new Integer(0x0f00), - new Integer(0x0f0000), - new Integer(0x0f000000), - new Integer(-128), - new Integer(0xff00), - new Integer(0xff0000), - new Integer(0xff000000), - new Long(666L), - new Short((short)444), - new String("blabla"), - new Integer(10), // Any as object - new Integer(10), // Any as object - new Any(new Type(Integer.class), new Integer(10)), // Any as Any - new Any(new Type(Integer.class), new Integer(10)), // Any as Any - null, - new TestPrimitiveStruct(), - x, //new TestPrimitiveSeqStruct(), - new byte[]{1,2,3,4,5,6,7}, // primitive sequence - new int[]{7,6,5,4,3,2,1}, // primitive sequence - new Object[]{new Integer(123), new String("hallo")}, // any sequence - new TestPrimitiveStruct[]{new TestPrimitiveStruct(), new TestPrimitiveStruct()}, // sequence of primitive structs - new TestPrimitiveSeqStruct[]{new TestPrimitiveSeqStruct(), new TestPrimitiveSeqStruct()}, // sequence of primitive structs - new TestNestedStruct(), - new TestNestedSeqStruct(), - new Type(Void.class), - new Type(String.class), - new Type(Object.class), - new Type(Byte.class), - new Type(Integer.class), - new Type(Double.class), - new Type(Float.class), - new Type(Character.class), - new Type(Short.class), - new Type(Boolean.class), - new Type(void.class), - new Type(byte.class), - new Type(int.class), - new Type(double.class), - new Type(float.class), - new Type(char.class), - new Type(short.class), - new Type(boolean.class), - new Type(Class.forName("[Ljava.lang.String;")), - new Type(Class.forName("[Ljava.lang.Object;")), - new Type(Class.forName("[B")), - new Type(Class.forName("[Z")), - new Type("boolean"), - new Type("byte"), - new Type("char"), - new Type("short"), - new Type("long"), - new Type("hyper"), - new Type("float"), - new Type("double"), - new Type("string"), - new Type("void"), - new Type("any"), - new Type( - "com.sun.star.lib.uno.protocols.urp.TestEnum", TypeClass.ENUM), - new Type("[]boolean", TypeClass.SEQUENCE), - new Type("[][]byte", TypeClass.SEQUENCE), - new Type("[][][]char", TypeClass.SEQUENCE), - new Type("[][][][]short", TypeClass.SEQUENCE), - new Type("[][][][][]any", TypeClass.SEQUENCE), - new Type("com.sun.star.uno.XInterface", TypeClass.INTERFACE), - new Type("[]com.sun.star.uno.XInterface", TypeClass.SEQUENCE), - testObject, - testObject, - new TestInterfaceStruct(testObject, null) - }; - - TypeDescription dataTypes[] = new TypeDescription[] { - TypeDescription.getTypeDescription(com.sun.star.uno.RuntimeException.class), - TypeDescription.getTypeDescription(com.sun.star.uno.Exception.class), - TypeDescription.getTypeDescription(Boolean.class), - TypeDescription.getTypeDescription(Byte.class), - TypeDescription.getTypeDescription(Character.class), - TypeDescription.getTypeDescription(Double.class), - TypeDescription.getTypeDescription(TestEnum.class), - TypeDescription.getTypeDescription(Float.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Integer.class), - TypeDescription.getTypeDescription(Long.class), - TypeDescription.getTypeDescription(Short.class), - TypeDescription.getTypeDescription(String.class), - TypeDescription.getTypeDescription(Object.class), - TypeDescription.getTypeDescription(Any.class), - TypeDescription.getTypeDescription(Any.class), - TypeDescription.getTypeDescription(Object.class), - TypeDescription.getTypeDescription(XInterface.class), - TypeDescription.getTypeDescription(TestPrimitiveStruct.class), - TypeDescription.getTypeDescription(TestPrimitiveSeqStruct.class), - TypeDescription.getTypeDescription(Class.forName("[B")), - TypeDescription.getTypeDescription(Class.forName("[I")), - TypeDescription.getTypeDescription(Class.forName("[Lcom.sun.star.uno.Any;")), - TypeDescription.getTypeDescription( - Class.forName( - "[Lcom.sun.star.lib.uno.protocols.urp." - + "TestPrimitiveStruct;")), - TypeDescription.getTypeDescription( - Class.forName( - "[Lcom.sun.star.lib.uno.protocols.urp." - + "TestPrimitiveSeqStruct;")), - TypeDescription.getTypeDescription(TestNestedStruct.class), - TypeDescription.getTypeDescription(TestNestedSeqStruct.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(Type.class), - TypeDescription.getTypeDescription(XInterface.class), - TypeDescription.getTypeDescription(XInterface.class), - TypeDescription.getTypeDescription(TestInterfaceStruct.class), - }; - - - Unmarshal unmarshal = new Unmarshal(testBridge, cacheSize); - for(int i = 0; i < dataTypes.length; ++ i) { - Object op1 = data[i]; - marshal.writeValue(dataTypes[i], data[i]); - - unmarshal.reset(marshal.reset()); - - Object op2 = unmarshal.readValue(dataTypes[i]); - - if(op1 instanceof Any) - op1 = ((Any)op1).getObject(); - - assertTrue(compareObjects(op1, op2)); - } - } - - private static boolean compareArrays(Object op1, Object op2) throws Exception { - boolean result = true; - if((op1.getClass().getComponentType() == op2.getClass().getComponentType()) - && (Array.getLength(op1) == Array.getLength(op2))) - { - Class zClass = op1.getClass().getComponentType(); - - for(int i = 0; i < Array.getLength(op1); ++ i) - result = result & compareObjects(Array.get(op1, i), Array.get(op2, i)); - } - - return result; - } - - private static boolean compareInterfaces(XInterface op1, XInterface op2) { - return op1 == op2; - } - - private static boolean compareStructs(Class zClass, Object op1, Object op2) throws Exception { - boolean result = true; - - Field fields[] = zClass.getFields(); - - for(int i = 0; i < fields.length && result; ++ i) { - if((fields[i].getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) == 0) { // neither static nor transient ? - result = result & compareObjects(fields[i].get(op1), fields[i].get(op2)); - - if(!result) - System.err.println("blabal :" + fields[i]); - } - } - - return result; - } - - private static boolean compareStructs(Object op1, Object op2) throws Exception { - boolean result = true; - - if(op1.getClass() != op2.getClass()) - result = false; - else { - result = compareStructs(op1.getClass(), op1, op2); - } - - return result; - } - - private static boolean compareThrowable(Throwable op1, Throwable op2) throws Exception { - boolean result = true; - - if(op1.getClass() != op2.getClass()) - result = false; - else { - result = compareStructs(op1.getClass(), op1, op2); - - result = result & op1.getMessage().equals(op2.getMessage()); - } - - return result; - } - - private static boolean compareObjects(Object op1, Object op2) throws Exception { - boolean result = false; - - if(op1 == op2) - result = true; - - else if(op1.getClass().isPrimitive() && op2.getClass().isPrimitive()) - result = op1.equals(op2); - - else if(op1.getClass() == Byte.class && op2.getClass() == Byte.class) - result = op1.equals(op2); - - else if(op1.getClass() == Type.class && op2.getClass() == Type.class) - result = op1.equals(op2); - - else if(op1.getClass() == Boolean.class && op2.getClass() == Boolean.class) - result = op1.equals(op2); - - else if(op1.getClass() == Short.class && op2.getClass() == Short.class) - result = op1.equals(op2); - - else if(Throwable.class.isAssignableFrom(op1.getClass()) && Throwable.class.isAssignableFrom(op2.getClass())) - result = compareThrowable((Throwable)op1, (Throwable)op2); - - else if(op1.getClass() == Integer.class && op2.getClass() == Integer.class) - result = op1.equals(op2); - - else if(op1.getClass() == Character.class && op2.getClass() == Character.class) - result = op1.equals(op2); - - else if(op1.getClass() == Long.class && op2.getClass() == Long.class) - result = op1.equals(op2); - - else if(op1.getClass() == Void.class && op2.getClass() == Void.class) - result = op1.equals(op2); - - else if(op1.getClass() == Float.class && op2.getClass() == Float.class) - result = op1.equals(op2); - - else if(op1.getClass() == Double.class && op2.getClass() == Double.class) - result = op1.equals(op2); - - else if(op1.getClass().isArray() && op2.getClass().isArray()) - result = compareArrays(op1, op2); - - else if(op1.getClass() == Void.class || op2.getClass() == void.class) // write nothing ? - result = true; - - else if(XInterface.class.isAssignableFrom(op1.getClass()) && XInterface.class.isAssignableFrom(op2.getClass())) - result = compareInterfaces((XInterface)op1, (XInterface)op2); - - else if(op1.getClass() == String.class && op2.getClass() == String.class) // is it a String ? - result = ((String)op1).equals((String)op2); - - else if(op1.getClass() == Type.class && op2.getClass() == Type.class) // types? - result = op1.equals(op2); - - else // otherwise it must be a struct - result = compareStructs(op1, op2); - - return result; - } -} diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java deleted file mode 100644 index 1191d5961330..000000000000 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java +++ /dev/null @@ -1,312 +0,0 @@ -/************************************************************** - * - * 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 com.sun.star.lib.uno.protocols.urp; - -import com.sun.star.lib.uno.environments.remote.Message; -import com.sun.star.lib.uno.environments.remote.IProtocol; -import com.sun.star.lib.uno.environments.remote.ThreadId; -import com.sun.star.lib.uno.typedesc.TypeDescription; -import com.sun.star.uno.Any; -import com.sun.star.uno.IBridge; -import com.sun.star.uno.Type; -import com.sun.star.uno.XInterface; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.util.LinkedList; -import org.junit.Test; -import static org.junit.Assert.*; - -public final class Protocol_Test { - @Test public void test() throws Exception { - IBridge iBridge = new TestBridge(); - PipedInputStream inA = new PipedInputStream(); - PipedOutputStream outA = new PipedOutputStream(inA); - PipedInputStream inB = new PipedInputStream(); - PipedOutputStream outB = new PipedOutputStream(inB); - Endpoint iSender = new Endpoint(iBridge, inA, outB); - Endpoint iReceiver = new Endpoint(iBridge, inB, outA); - - TestObject testObject = new TestObject(); - String oId = (String)iBridge.mapInterfaceTo(testObject, new Type(XInterface.class)); - - testCall(iSender, iReceiver, oId); - testCallWithInParameter(iSender, iReceiver, oId); - testCallWithOutParameter(iSender, iReceiver, oId); - testCallWithInOutParameter(iSender, iReceiver, oId); - testCallWithResult(iSender, iReceiver, oId); - testCallWhichRaisesException(iSender, iReceiver, oId); - testCallWithIn_Out_InOut_Paramters_and_result(iSender, iReceiver, oId); - testCallWhichReturnsAny(iSender, iReceiver, oId); - } - - public void testCall( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - // send an ordinary request - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "method", new ThreadId(new byte[] { 0, 1 }), new Object[0]); - iReceiver.readMessage(); - - // send a reply - iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null); - iSender.readMessage(); - } - - public void testCallWithInParameter( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - // send an ordinary request - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "methodWithInParameter", new ThreadId(new byte[] { 0, 1 }), - new Object[] { "hallo" }); - Message iMessage = iReceiver.readMessage(); - Object[] t_params = iMessage.getArguments(); - assertEquals("hallo", (String)t_params[0]); - - // send a reply - iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null); - iMessage = iSender.readMessage(); - } - - public void testCallWithOutParameter( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - Object params[] = new Object[]{new String[1]}; - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "methodWithOutParameter", new ThreadId(new byte[] { 0, 1 }), - params); - Message iMessage = iReceiver.readMessage(); - - - Object[] t_params = iMessage.getArguments(); - ((String [])t_params[0])[0] = "testString"; - - // send an exception as reply - iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null); - iSender.readMessage(); - - assertEquals("testString", ((String [])params[0])[0]); - } - - public void testCallWithInOutParameter( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - Object params[] = new Object[]{new String[]{"inString"}}; - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "methodWithInOutParameter", new ThreadId(new byte[] { 0, 1 }), - params); - Message iMessage = iReceiver.readMessage(); - - - Object[] t_params = iMessage.getArguments(); - assertEquals("inString", ((String [])t_params[0])[0]); - - // provide reply - ((String [])t_params[0])[0] = "outString"; - - // send an exception as reply - iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null); - iSender.readMessage(); - - assertEquals("outString", ((String [])params[0])[0]); - } - - public void testCallWithResult( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - // send an ordinary request - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "methodWithResult", new ThreadId(new byte[] { 0, 1 }), - new Object[0]); - iReceiver.readMessage(); - - // send a reply - iReceiver.writeReply( - false, new ThreadId(new byte[] { 0, 1 }), "resultString"); - Message iMessage = iSender.readMessage(); - Object result = iMessage.getResult(); - - assertEquals("resultString", result); - } - - public void testCallWhichRaisesException( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - // send a second request - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "method", new ThreadId(new byte[] { 0, 1 }), new Object[0]); - iReceiver.readMessage(); - - // send an exception as reply - iReceiver.writeReply( - true, new ThreadId(new byte[] { 0, 1 }), - new com.sun.star.uno.RuntimeException("test the exception")); - Message iMessage = iSender.readMessage(); - - Object result = iMessage.getResult(); - - assertTrue(result instanceof com.sun.star.uno.RuntimeException); - } - - public void testCallWithIn_Out_InOut_Paramters_and_result( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - Object params[] = new Object[]{"hallo", new String[1], new String[]{"inOutString"}}; - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "MethodWithIn_Out_InOut_Paramters_and_result", - new ThreadId(new byte[] { 0, 1 }), params); - Message iMessage = iReceiver.readMessage(); - - Object[] t_params = iMessage.getArguments(); - - assertEquals("hallo", (String)t_params[0]); - - assertEquals("inOutString", ((String [])t_params[2])[0]); - - ((String [])t_params[1])[0] = "outString"; - ((String [])t_params[2])[0] = "inOutString_res"; - - // send an exception as reply - iReceiver.writeReply( - false, new ThreadId(new byte[] { 0, 1 }), "resultString"); - iMessage = iSender.readMessage(); - - Object result = iMessage.getResult(); - assertEquals("outString", ((String [])params[1])[0]); - - assertEquals("inOutString_res", ((String [])params[2])[0]); - - assertEquals("resultString", result); - } - - public void testCallWhichReturnsAny( - Endpoint iSender, Endpoint iReceiver, String oId) throws Exception - { - // send an ordinary request - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "returnAny", new ThreadId(new byte[] { 0, 1 }), null); - iReceiver.readMessage(); - // send a reply - iReceiver.writeReply( - false, new ThreadId(new byte[] { 0, 1 }), Any.VOID); - Message iMessage = iSender.readMessage(); - Object result = iMessage.getResult(); - assertTrue( - result instanceof Any && - ((TypeDescription.getTypeDescription(((Any) result).getType()). - getZClass()) == - void.class)); - - // send an ordinary request - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "returnAny", new ThreadId(new byte[] { 0, 1 }), null); - iReceiver.readMessage(); - // send a reply - iReceiver.writeReply( - false, new ThreadId(new byte[] { 0, 1 }), - new Any(XInterface.class, null)); - iMessage = iSender.readMessage(); - result = iMessage.getResult(); - assertNull(result); - - // send an ordinary request - iSender.writeRequest( - oId, TypeDescription.getTypeDescription(TestXInterface.class), - "returnAny", new ThreadId(new byte[] { 0, 1 }), null); - iReceiver.readMessage(); - // send a reply - iReceiver.writeReply( - false, new ThreadId(new byte[] { 0, 1 }), new Integer(501)); - iMessage = iSender.readMessage(); - result = iMessage.getResult(); - assertEquals(501, result); - } - - private static final class Endpoint { - public Endpoint(IBridge bridge, InputStream input, OutputStream output) - throws IOException - { - protocol = new urp(bridge, null, input, output); - new Thread() { - public void run() { - for (;;) { - Object o; - try { - o = protocol.readMessage(); - } catch (IOException e) { - o = e; - } - synchronized (queue) { - queue.addLast(o); - } - } - } - }.start(); - protocol.init(); - } - - public Message readMessage() throws IOException { - for (;;) { - synchronized (queue) { - if (!queue.isEmpty()) { - Object o = queue.removeFirst(); - if (o instanceof Message) { - return (Message) o; - } else { - throw (IOException) o; - } - } - } - } - } - - public boolean writeRequest( - String oid, TypeDescription type, String function, ThreadId tid, - Object[] arguments) - throws IOException - { - return protocol.writeRequest(oid, type, function, tid, arguments); - } - - public void writeReply(boolean exception, ThreadId tid, Object result) - throws IOException - { - protocol.writeReply(exception, tid, result); - } - - private final IProtocol protocol; - private final LinkedList queue = new LinkedList(); - } -} diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/TestBridge.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/TestBridge.java deleted file mode 100644 index bc5ca7fca24e..000000000000 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/TestBridge.java +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************** - * - * 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 com.sun.star.lib.uno.protocols.urp; - -import java.io.IOException; - -import java.util.Hashtable; - - -import com.sun.star.uno.IBridge; -import com.sun.star.uno.IEnvironment; -import com.sun.star.uno.Type; - - -class TestBridge implements IBridge { - static public final boolean DEBUG = false; - - Hashtable _hashtable = new Hashtable(); - - IEnvironment _source ;//= new com.sun.star.lib.uno.environments.java.java_environment(null); - - - class MyEnv implements IEnvironment { - public Object getContext() { - return null; - } - - public String getName() { - return null; - } - - public Object registerInterface(Object object, String oId[], Type type) { - return null; - } - - public void revokeInterface(String oId, Type type) { - } - - public Object getRegisteredInterface(String oid, Type type) { - Object object = _hashtable.get(oid); - - if(DEBUG) System.err.println("##### " + getClass().getName() + ".getRegisteredInterface:" + oid + " " + object); - - return object; - } - - public String getRegisteredObjectIdentifier(Object object) { - return null; - } - - public void list() { - } - } - - TestBridge() { - _source = new MyEnv(); - } - - public Object mapInterfaceTo(Object object, Type type) { - if (object == null) { - return null; - } else { - String oid = ">" + object.toString() + type.toString() + "<"; - _hashtable.put(oid, object); - return oid; - } - } - - public Object mapInterfaceFrom(Object object, Type type) { - String oid = (String)object; - - return _hashtable.get(oid); - } - - public IEnvironment getSourceEnvironment() { - return _source; - } - - public IEnvironment getTargetEnvironment() { - return null; - } - - public void acquire() {} - - public void release() {} - - public void reset() throws IOException {} - - public void dispose() throws InterruptedException, IOException {} -} - diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/TestObject.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/TestObject.java deleted file mode 100644 index 1adf091bb7ae..000000000000 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/TestObject.java +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************** - * - * 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 com.sun.star.lib.uno.protocols.urp; - - - -class TestObject implements TestXInterface { - public void method1( /*IN*/java.lang.Object itf ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - } - - public void method2( /*OUT*/java.lang.Object[] itf ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - } - - public void method3( /*INOUT*/java.lang.Object[] itf ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - } - - public Object method4( ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - return null; - } - - public Object returnAny( ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - return null; - } - - - public void method() throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - } - - public void methodWithInParameter( /*IN*/String text ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - } - - public void methodWithOutParameter( /*OUT*/String[] text ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - } - - public void methodWithInOutParameter( /*INOUT*/String[] text ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - } - - public String methodWithResult( ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - return "TestObject_resultString"; - } - - public String MethodWithIn_Out_InOut_Paramters_and_result( /*IN*/String text, /*OUT*/String[] outtext, /*INOUT*/String[] inouttext ) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException { - return "TestObject_resultString"; - } -} - diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/interfaces.idl b/jurt/test/com/sun/star/lib/uno/protocols/urp/interfaces.idl deleted file mode 100644 index 4cbb33695093..000000000000 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/interfaces.idl +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************** - * - * 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. - * - *************************************************************/ - - - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif - -#ifndef __com_sun_star_beans_XPropertySet_idl_ -#include <com/sun/star/beans/XPropertySet.idl> -#endif - -#ifndef __com_sun_star_uno_Exception_idl__ -#include <com/sun/star/uno/Exception.idl> -#endif - -#ifndef __com_sun_star_uno_Exception_idl__ -#include <com/sun/star/uno/Any.idl> -#endif - - -module com { module sun { module star { module lib { module uno { -module protocols { module urp { - - struct TestPrimitiveStruct { - boolean zBool; - short zShort; - unsigned short zUShort; - long zLong; - unsigned long zULong; - hyper zHyper; - unsigned hyper zUHyper; - float zFloat; - double zDouble; - char zChar; - byte zByte; - string zString; - any zAny; - }; - - struct TestPrimitiveSeqStruct { - sequence<boolean> zBool; - sequence<short> zShort; - sequence<unsigned short> zUShort; - sequence<long> zLong; - sequence<unsigned long> zULong; - sequence<hyper> zHyper; - sequence<unsigned hyper> zUHyper; - sequence<float> zFloat; - sequence<double> zDouble; - sequence<char> zChar; - sequence<byte> zByte; - sequence<string> zString; - sequence<any> zAny; - }; - - struct TestNestedStruct { - TestPrimitiveStruct primitiveStruct; - TestPrimitiveSeqStruct primitiveSeqStruct; - }; - - struct TestNestedSeqStruct { - sequence< sequence< long > > val; - }; - - interface TestXInterface : com::sun::star::uno::XInterface { - void method1([in] com::sun::star::uno::XInterface itf) raises( com::sun::star::uno::Exception ); - void method2([out] com::sun::star::uno::XInterface itf) raises( com::sun::star::uno::Exception ); - void method3([inout] com::sun::star::uno::XInterface itf) raises( com::sun::star::uno::Exception ); - com::sun::star::uno::XInterface method4() raises( com::sun::star::uno::Exception ); - - any returnAny() raises( com::sun::star::uno::Exception ); - - void method() raises( com::sun::star::uno::Exception ); - void methodWithInParameter([in] string text) raises( com::sun::star::uno::Exception ); - void methodWithOutParameter([out] string text) raises( com::sun::star::uno::Exception ); - void methodWithInOutParameter([inout] string text) raises( com::sun::star::uno::Exception ); - string methodWithResult() raises( com::sun::star::uno::Exception ); - - string MethodWithIn_Out_InOut_Paramters_and_result([in] string text, [out] string outtext, [inout] string inouttext) raises( com::sun::star::uno::Exception ); - }; - - struct TestInterfaceStruct - { - com::sun::star::uno::XInterface hallo; - - com::sun::star::beans::XPropertySet hallo2; - }; - - enum TestEnum { - A = 7, - B = 8, - C = 11 - }; - -}; }; }; }; }; }; }; diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk b/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk deleted file mode 100644 index 53d4f7d2680b..000000000000 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk +++ /dev/null @@ -1,47 +0,0 @@ -#************************************************************** -# -# 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. -# -#************************************************************** - - - -.IF "$(OOO_SUBSEQUENT_TESTS)" == "" -nothing .PHONY: -.ELSE - -PRJ := ..$/..$/..$/..$/..$/..$/..$/.. -PRJNAME := jurt -TARGET := test_com_sun_star_lib_uno_protocols_urp - -.IF "$(OOO_JUNIT_JAR)" != "" -PACKAGE := com$/sun$/star$/lib$/uno$/protocols$/urp -JAVATESTFILES := \ - Cache_Test.java \ - Marshaling_Test.java \ - Protocol_Test.java -JAVAFILES := \ - TestBridge.java \ - TestObject.java -JARFILES := ridl.jar -IDLTESTFILES := interfaces.idl -.END - -.INCLUDE: javaunittest.mk - -.END |