diff options
Diffstat (limited to 'bridges/test/java_uno/any')
-rw-r--r-- | bridges/test/java_uno/any/TestAny.java | 2267 | ||||
-rw-r--r-- | bridges/test/java_uno/any/TestJni.java | 48 | ||||
-rw-r--r-- | bridges/test/java_uno/any/TestRemote.java | 64 | ||||
-rw-r--r-- | bridges/test/java_uno/any/makefile.mk | 127 | ||||
-rw-r--r-- | bridges/test/java_uno/any/test_javauno_any.map | 6 | ||||
-rw-r--r-- | bridges/test/java_uno/any/transport.cxx | 111 | ||||
-rw-r--r-- | bridges/test/java_uno/any/types.idl | 42 |
7 files changed, 2665 insertions, 0 deletions
diff --git a/bridges/test/java_uno/any/TestAny.java b/bridges/test/java_uno/any/TestAny.java new file mode 100644 index 000000000000..43e8bf542479 --- /dev/null +++ b/bridges/test/java_uno/any/TestAny.java @@ -0,0 +1,2267 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package test.java_uno.anytest; + +import com.sun.star.uno.Any; +import com.sun.star.uno.Enum; +import com.sun.star.uno.Type; +import com.sun.star.uno.TypeClass; +import com.sun.star.uno.XInterface; +import java.lang.reflect.Array; + +final class TestAny { + public static boolean test(XTransport transport, boolean createTypes) { + boolean success = true; + + // Sanity check for com.sun.star.uno.Type: + success &= testType(void.class, TypeClass.VOID, "void"); + success &= testType(boolean.class, TypeClass.BOOLEAN, "boolean"); + success &= testType(byte.class, TypeClass.BYTE, "byte"); + success &= testType(short.class, TypeClass.SHORT, "short"); + success &= testType(int.class, TypeClass.LONG, "long"); + success &= testType(long.class, TypeClass.HYPER, "hyper"); + success &= testType(float.class, TypeClass.FLOAT, "float"); + success &= testType(double.class, TypeClass.DOUBLE, "double"); + success &= testType(char.class, TypeClass.CHAR, "char"); + success &= testType(String.class, TypeClass.STRING, "string"); + success &= testType(Type.class, TypeClass.TYPE, "type"); + success &= testType(Any.class, TypeClass.ANY, "any"); + success &= testType(boolean[].class, TypeClass.SEQUENCE, "[]boolean"); + success &= testType(byte[].class, TypeClass.SEQUENCE, "[]byte"); + success &= testType(short[].class, TypeClass.SEQUENCE, "[]short"); + success &= testType(int[].class, TypeClass.SEQUENCE, "[]long"); + success &= testType(long[].class, TypeClass.SEQUENCE, "[]hyper"); + success &= testType(float[].class, TypeClass.SEQUENCE, "[]float"); + success &= testType(double[].class, TypeClass.SEQUENCE, "[]double"); + success &= testType(char[].class, TypeClass.SEQUENCE, "[]char"); + success &= testType(String[].class, TypeClass.SEQUENCE, "[]string"); + success &= testType(Type[].class, TypeClass.SEQUENCE, "[]type"); + success &= testType(Any[].class, TypeClass.SEQUENCE, "[]any"); + success &= testType(Enum1[].class, TypeClass.SEQUENCE, + "[]" + Enum1.class.getName()); + success &= testType(BaseStruct[].class, TypeClass.SEQUENCE, + "[]" + BaseStruct.class.getName()); + success &= testType(DerivedStruct[].class, TypeClass.SEQUENCE, + "[]" + DerivedStruct.class.getName()); + success &= testType(XInterface[].class, TypeClass.SEQUENCE, + "[]" + XInterface.class.getName()); + success &= testType(BaseInterface[].class, TypeClass.SEQUENCE, + "[]" + BaseInterface.class.getName()); + success &= testType(DerivedInterface[].class, TypeClass.SEQUENCE, + "[]" + DerivedInterface.class.getName()); + success &= testType(boolean[][].class, TypeClass.SEQUENCE, + "[][]boolean"); + success &= testType(byte[][].class, TypeClass.SEQUENCE, "[][]byte"); + success &= testType(short[][].class, TypeClass.SEQUENCE, "[][]short"); + success &= testType(int[][].class, TypeClass.SEQUENCE, "[][]long"); + success &= testType(long[][].class, TypeClass.SEQUENCE, "[][]hyper"); + success &= testType(float[][].class, TypeClass.SEQUENCE, "[][]float"); + success &= testType(double[][].class, TypeClass.SEQUENCE, "[][]double"); + success &= testType(char[][].class, TypeClass.SEQUENCE, "[][]char"); + success &= testType(String[][].class, TypeClass.SEQUENCE, "[][]string"); + success &= testType(Type[][].class, TypeClass.SEQUENCE, "[][]type"); + success &= testType(Any[][].class, TypeClass.SEQUENCE, "[][]any"); + success &= testType(Enum1[][].class, TypeClass.SEQUENCE, + "[][]" + Enum1.class.getName()); + success &= testType(BaseStruct[][].class, TypeClass.SEQUENCE, + "[][]" + BaseStruct.class.getName()); + success &= testType(DerivedStruct[][].class, TypeClass.SEQUENCE, + "[][]" + DerivedStruct.class.getName()); + success &= testType(XInterface[][].class, TypeClass.SEQUENCE, + "[][]" + XInterface.class.getName()); + success &= testType(BaseInterface[][].class, TypeClass.SEQUENCE, + "[][]" + BaseInterface.class.getName()); + success &= testType(DerivedInterface[][].class, TypeClass.SEQUENCE, + "[][]" + DerivedInterface.class.getName()); + success &= testType(Enum1.class, TypeClass.ENUM, Enum1.class.getName()); + success &= testType(BaseStruct.class, TypeClass.STRUCT, + BaseStruct.class.getName()); + success &= testType(DerivedStruct.class, TypeClass.STRUCT, + DerivedStruct.class.getName()); + success &= testType(com.sun.star.uno.Exception.class, + TypeClass.EXCEPTION, + com.sun.star.uno.Exception.class.getName()); + success &= testType(com.sun.star.uno.RuntimeException.class, + TypeClass.EXCEPTION, + com.sun.star.uno.RuntimeException.class.getName()); + success &= testType(XInterface.class, TypeClass.INTERFACE, + XInterface.class.getName()); + success &= testType(BaseInterface.class, TypeClass.INTERFACE, + BaseInterface.class.getName()); + success &= testType(DerivedInterface.class, TypeClass.INTERFACE, + DerivedInterface.class.getName()); + + // VOID: + success &= testMapAny(transport, Any.VOID, new CompareBoxed()); + + // BOOLEAN: + success &= testMapAny(transport, Boolean.FALSE, new CompareBoxed()); + success &= testMapAny(transport, Boolean.TRUE, new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.BOOLEAN, Boolean.FALSE), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.BOOLEAN, Boolean.TRUE), + new CompareUnboxed()); + + // BYTE: + success &= testMapAny(transport, new Byte((byte) -128), + new CompareBoxed()); + success &= testMapAny(transport, new Byte((byte) 0), + new CompareBoxed()); + success &= testMapAny(transport, new Byte((byte) 127), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.BYTE, new Byte((byte) -128)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.BYTE, new Byte((byte) 0)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.BYTE, new Byte((byte) 127)), + new CompareUnboxed()); + + // SHORT: + success &= testMapAny(transport, new Short((short) -32768), + new CompareBoxed()); + success &= testMapAny(transport, new Short((short) 0), + new CompareBoxed()); + success &= testMapAny(transport, new Short((short) 32767), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.SHORT, + new Short((short) -32768)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.SHORT, new Short((short) 0)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.SHORT, new Short((short) 32767)), + new CompareUnboxed()); + + // UNSIGNED SHORT: + success &= testMapAny(transport, + new Any(Type.UNSIGNED_SHORT, + new Short((short) 0)), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.UNSIGNED_SHORT, + new Short((short) -32768)), + new CompareBoxed()); + + // LONG: + success &= testMapAny(transport, new Integer(-2147483648), + new CompareBoxed()); + success &= testMapAny(transport, new Integer(0), + new CompareBoxed()); + success &= testMapAny(transport, new Integer(2147483647), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.LONG, new Integer(-2147483648)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.LONG, new Integer(0)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.LONG, new Integer(2147483647)), + new CompareUnboxed()); + + // UNSIGNED LONG: + success &= testMapAny(transport, + new Any(Type.UNSIGNED_LONG, new Integer(0)), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.UNSIGNED_LONG, + new Integer(-2147483648)), + new CompareBoxed()); + + // HYPER: + success &= testMapAny(transport, new Long(-9223372036854775808L), + new CompareBoxed()); + success &= testMapAny(transport, new Long(0L), new CompareBoxed()); + success &= testMapAny(transport, new Long(9223372036854775807L), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.HYPER, + new Long(-9223372036854775808L)), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.HYPER, new Long(0L)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.HYPER, + new Long(9223372036854775807L)), + new CompareUnboxed()); + + // UNSIGNED HYPER: + success &= testMapAny(transport, + new Any(Type.UNSIGNED_HYPER, new Long(0L)), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.UNSIGNED_HYPER, + new Long(-9223372036854775808L)), + new CompareBoxed()); + + // FLOAT: + success &= testMapAny(transport, new Float(Float.NEGATIVE_INFINITY), + new CompareBoxed()); + success &= testMapAny(transport, new Float(Float.MIN_VALUE), + new CompareBoxed()); + success &= testMapAny(transport, new Float(-0.0f), + new CompareBoxed()); + success &= testMapAny(transport, new Float(0.0f), + new CompareBoxed()); + success &= testMapAny(transport, new Float(Float.MAX_VALUE), + new CompareBoxed()); + success &= testMapAny(transport, new Float(Float.POSITIVE_INFINITY), + new CompareBoxed()); + success &= testMapAny(transport, new Float(Float.NaN), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.FLOAT, + new Float(Float.NEGATIVE_INFINITY)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.FLOAT, + new Float(Float.MIN_VALUE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.FLOAT, new Float(-0.0f)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.FLOAT, new Float(0.0f)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.FLOAT, + new Float(Float.MAX_VALUE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.FLOAT, + new Float(Float.POSITIVE_INFINITY)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.FLOAT, new Float(Float.NaN)), + new CompareUnboxed()); + + // DOUBLE: + success &= testMapAny(transport, + new Double(Double.NEGATIVE_INFINITY), + new CompareBoxed()); + success &= testMapAny(transport, new Double(Double.MIN_VALUE), + new CompareBoxed()); + success &= testMapAny(transport, new Double(-0.0f), + new CompareBoxed()); + success &= testMapAny(transport, new Double(0.0f), + new CompareBoxed()); + success &= testMapAny(transport, new Double(Double.MAX_VALUE), + new CompareBoxed()); + success &= testMapAny(transport, + new Double(Double.POSITIVE_INFINITY), + new CompareBoxed()); + success &= testMapAny(transport, new Double(Double.NaN), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.DOUBLE, + new Double(Double.NEGATIVE_INFINITY)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.DOUBLE, + new Double(Double.MIN_VALUE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.DOUBLE, new Double(-0.0)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.DOUBLE, new Double(0.0)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.DOUBLE, + new Double(Double.MAX_VALUE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.DOUBLE, + new Double(Double.POSITIVE_INFINITY)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.DOUBLE, new Double(Double.NaN)), + new CompareUnboxed()); + + // CHAR: + success &= testMapAny(transport, new Character('\u0000'), + new CompareBoxed()); + success &= testMapAny(transport, new Character('\uDBFF'), + new CompareBoxed()); + success &= testMapAny(transport, new Character('\uFFFD'), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(Type.CHAR, new Character('\u0000')), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.CHAR, new Character('\uDBFF')), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.CHAR, new Character('\uFFFD')), + new CompareUnboxed()); + + // STRING: + success &= testMapAny(transport, "", new CompareBoxed()); + success &= testMapAny(transport, "\uD800\uDC00", + new CompareBoxed()); + success &= testMapAny(transport, "Test", new CompareBoxed()); + success &= testMapAny(transport, new Any(Type.STRING, ""), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.STRING, "\uD800\uDC00"), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.STRING, "Test"), + new CompareUnboxed()); + + // TYPE: + success &= testMapAny(transport, Type.VOID, new CompareBoxed()); + success &= testMapAny(transport, Type.BOOLEAN, new CompareBoxed()); + success &= testMapAny(transport, Type.BYTE, new CompareBoxed()); + success &= testMapAny(transport, Type.SHORT, new CompareBoxed()); + success &= testMapAny(transport, Type.UNSIGNED_SHORT, + new CompareBoxed()); + success &= testMapAny(transport, Type.LONG, new CompareBoxed()); + success &= testMapAny(transport, Type.UNSIGNED_LONG, + new CompareBoxed()); + success &= testMapAny(transport, Type.HYPER, new CompareBoxed()); + success &= testMapAny(transport, Type.UNSIGNED_HYPER, + new CompareBoxed()); + success &= testMapAny(transport, Type.FLOAT, new CompareBoxed()); + success &= testMapAny(transport, Type.DOUBLE, new CompareBoxed()); + success &= testMapAny(transport, Type.CHAR, new CompareBoxed()); + success &= testMapAny(transport, Type.STRING, new CompareBoxed()); + success &= testMapAny(transport, Type.TYPE, new CompareBoxed()); + success &= testMapAny(transport, Type.ANY, new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]boolean", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]byte", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]short", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]unsigned short", + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]long", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]unsigned long", + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]hyper", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]unsigned hyper", + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]float", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]double", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]char", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]string", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]type", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]any", TypeClass.SEQUENCE), + new CompareBoxed()); + if (createTypes) { + success &= testMapAny(transport, + new Type("[]" + Enum1.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]" + BaseStruct.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]" + DerivedStruct.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + } + success &= testMapAny(transport, + new Type("[]" + XInterface.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]" + BaseInterface.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[]" + + DerivedInterface.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]boolean", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]byte", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]short", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]unsigned short", + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]long", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]unsigned long", + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]hyper", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]unsigned hyper", + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]float", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]double", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]char", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]string", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]type", TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]any", TypeClass.SEQUENCE), + new CompareBoxed()); + if (createTypes) { + success &= testMapAny(transport, + new Type("[][]" + Enum1.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]" + BaseStruct.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]" + + DerivedStruct.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + } + success &= testMapAny(transport, + new Type("[][]" + XInterface.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]" + + BaseInterface.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type("[][]" + + DerivedInterface.class.getName(), + TypeClass.SEQUENCE), + new CompareBoxed()); + if (createTypes) { + success &= testMapAny(transport, new Type(Enum1.class.getName(), + TypeClass.ENUM), + new CompareBoxed()); + success &= testMapAny(transport, + new Type(BaseStruct.class.getName(), + TypeClass.STRUCT), + new CompareBoxed()); + success &= testMapAny(transport, + new Type(DerivedStruct.class.getName(), + TypeClass.STRUCT), + new CompareBoxed()); + } + success &= testMapAny(transport, + new Type( + com.sun.star.uno.Exception.class. + getName(), + TypeClass.EXCEPTION), + new CompareBoxed()); + if (createTypes) { + success &= testMapAny(transport, + new Type(BaseException.class.getName(), + TypeClass.EXCEPTION), + new CompareBoxed()); + success &= testMapAny(transport, + new Type(DerivedException.class.getName(), + TypeClass.EXCEPTION), + new CompareBoxed()); + } + success &= testMapAny(transport, + new Type( + com.sun.star.uno.RuntimeException.class. + getName(), + TypeClass.EXCEPTION), + new CompareBoxed()); + if (createTypes) { + success &= testMapAny(transport, + new Type( + BaseRuntimeException.class.getName(), + TypeClass.EXCEPTION), + new CompareBoxed()); + success &= testMapAny(transport, + new Type( + DerivedRuntimeException.class. + getName(), + TypeClass.EXCEPTION), + new CompareBoxed()); + } + success &= testMapAny(transport, + new Type(XInterface.class.getName(), + TypeClass.INTERFACE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type(BaseInterface.class.getName(), + TypeClass.INTERFACE), + new CompareBoxed()); + success &= testMapAny(transport, + new Type(DerivedInterface.class.getName(), + TypeClass.INTERFACE), + new CompareBoxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.VOID), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.BOOLEAN), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.BYTE), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.SHORT), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, Type.UNSIGNED_SHORT), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.LONG), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, Type.UNSIGNED_LONG), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.HYPER), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, Type.UNSIGNED_HYPER), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.FLOAT), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.DOUBLE), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.CHAR), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.STRING), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.TYPE), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(Type.TYPE, Type.ANY), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]boolean", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]byte", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]short", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]unsigned short", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]long", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]unsigned long", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]hyper", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]unsigned hyper", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]float", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]double", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]char", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]string", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]type", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]any", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + if (createTypes) { + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]" + Enum1.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]" + + BaseStruct.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + "[]" + + DerivedStruct.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + } + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[]" + + XInterface.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + "[]" + + BaseInterface.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + Type.TYPE, + new Type( + "[]" + + DerivedInterface.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]boolean", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]byte", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]short", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]unsigned short", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]long", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]unsigned long", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]hyper", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]unsigned hyper", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]float", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]double", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]char", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]string", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]type", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]any", + TypeClass.SEQUENCE)), + new CompareUnboxed()); + if (createTypes) { + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]" + + Enum1.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]" + + BaseStruct.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + "[][]" + + DerivedStruct.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + } + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type("[][]" + + XInterface.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + "[][]" + + BaseInterface.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + Type.TYPE, + new Type( + "[][]" + + DerivedInterface.class.getName(), + TypeClass.SEQUENCE)), + new CompareUnboxed()); + if (createTypes) { + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type(Enum1.class.getName(), + TypeClass.ENUM)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type(BaseStruct.class.getName(), + TypeClass.STRUCT)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + DerivedStruct.class.getName(), + TypeClass.STRUCT)), + new CompareUnboxed()); + } + success &= testMapAny(transport, + new Any( + Type.TYPE, + new Type( + com.sun.star.uno.Exception.class. + getName(), + TypeClass.EXCEPTION)), + new CompareUnboxed()); + if (createTypes) { + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + BaseException.class.getName(), + TypeClass.EXCEPTION)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + Type.TYPE, + new Type( + DerivedException.class.getName(), + TypeClass.EXCEPTION)), + new CompareUnboxed()); + } + success &= testMapAny(transport, + new Any( + Type.TYPE, + new Type( + com.sun.star.uno.RuntimeException. + class.getName(), + TypeClass.EXCEPTION)), + new CompareUnboxed()); + if (createTypes) { + success &= testMapAny(transport, + new Any( + Type.TYPE, + new Type( + BaseRuntimeException.class. + getName(), + TypeClass.EXCEPTION)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + Type.TYPE, + new Type( + DerivedRuntimeException.class. + getName(), + TypeClass.EXCEPTION)), + new CompareUnboxed()); + } + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type(XInterface.class.getName(), + TypeClass.INTERFACE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + BaseInterface.class.getName(), + TypeClass.INTERFACE)), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(Type.TYPE, + new Type( + DerivedInterface.class.getName(), + TypeClass.INTERFACE)), + new CompareUnboxed()); + + // Sequence Types: + success &= testMapAny(transport, new boolean[] {}, + new CompareBoxed()); + success &= testMapAny(transport, new boolean[] { false, true }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(boolean[].class), + new boolean[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(boolean[].class), + new boolean[] { false, true }), + new CompareUnboxed()); + success &= testMapAny(transport, new byte[] {}, + new CompareBoxed()); + success &= testMapAny(transport, new byte[] { -128, 0, 127 }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(byte[].class), + new byte[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(byte[].class), + new byte[] { -128, 0, 127 }), + new CompareUnboxed()); + success &= testMapAny(transport, new short[] {}, + new CompareBoxed()); + success &= testMapAny(transport, new short[] { -32768, 0, 32767 }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(short[].class), + new short[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(short[].class), + new short[] { -32768, 0, 32767 }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type("[]unsigned short", + TypeClass.SEQUENCE), + new short[] {}), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type("[]unsigned short", + TypeClass.SEQUENCE), + new short[] { 0, -32768 }), + new CompareBoxed()); + success &= testMapAny(transport, new int[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new int[] { -2147483648, 0, 2147483647 }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(int[].class), + new int[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(int[].class), + new int[] { -2147483648, 0, + 2147483647 }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type("[]unsigned long", + TypeClass.SEQUENCE), + new int[] {}), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type("[]unsigned long", + TypeClass.SEQUENCE), + new int[] { 0, -2147483648 }), + new CompareBoxed()); + success &= testMapAny(transport, new long[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new long[] { -9223372036854775808L, 0L, + 9223372036854775807L }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(long[].class), + new long[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(long[].class), + new long[] { -9223372036854775808L, + 0L, + 9223372036854775807L }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type("[]unsigned hyper", + TypeClass.SEQUENCE), + new long[] {}), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type("[]unsigned hyper", + TypeClass.SEQUENCE), + new long[] { 0L, + -9223372036854775808L }), + new CompareBoxed()); + success &= testMapAny(transport, new float[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new float[] { Float.NEGATIVE_INFINITY, + Float.MIN_VALUE, -0.0f, 0.0f, + Float.MAX_VALUE, + Float.POSITIVE_INFINITY, + Float.NaN }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(float[].class), + new float[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(float[].class), + new float[] { Float.NEGATIVE_INFINITY, + Float.MIN_VALUE, -0.0f, + 0.0f, Float.MAX_VALUE, + Float.POSITIVE_INFINITY, + Float.NaN }), + new CompareUnboxed()); + success &= testMapAny(transport, new double[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new double[] { Double.NEGATIVE_INFINITY, + Double.MIN_VALUE, -0.0, 0.0, + Double.MAX_VALUE, + Double.POSITIVE_INFINITY, + Double.NaN }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(double[].class), + new double[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(double[].class), + new double[] { + Double.NEGATIVE_INFINITY, + Double.MIN_VALUE, -0.0, 0.0, + Double.MAX_VALUE, + Double.POSITIVE_INFINITY, + Double.NaN }), + new CompareUnboxed()); + success &= testMapAny(transport, new char[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new char[] { '\u0000', '\uDBFF', '\uFFFD' }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(char[].class), + new char[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + new Type(char[].class), + new char[] { '\u0000', '\uDBFF', + '\uFFFD' }), + new CompareUnboxed()); + success &= testMapAny(transport, new String[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new String[] { "", "\uD800\uDC00", "Test" }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(String[].class), + new String[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(String[].class), + new String[] { "", "\uD800\uDC00", + "Test" }), + new CompareUnboxed()); + success &= testMapAny(transport, new Type[] {}, new CompareBoxed()); + success &= testMapAny(transport, + new Type[] { + Type.VOID, + new Type(DerivedInterface.class.getName(), + TypeClass.INTERFACE) }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(Type[].class), + new Type[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + new Type(Type[].class), + new Type[] { + Type.VOID, + new Type( + DerivedInterface.class.getName(), + TypeClass.INTERFACE) }), + new CompareUnboxed()); + success &= testMapAny(transport, new Object[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new Object[] { Any.VOID, Boolean.FALSE }, + new CompareBoxed()); + success &= testMapAny(transport, + new Object[] { + Boolean.FALSE, + new Any(Type.BOOLEAN, Boolean.TRUE) }, + new CompareBoxed(true)); + success &= testMapAny(transport, + new Any(new Type(Any[].class), + new Object[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(Any[].class), + new Object[] { Any.VOID, + Boolean.FALSE }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(Any[].class), + new Object[] { + Boolean.FALSE, + new Any(Type.BOOLEAN, + Boolean.TRUE) }), + new CompareUnboxed(true)); + success &= testMapAny(transport, new Any[] {}, + new CompareSpecific(new Object[] {})); + success &= testMapAny(transport, + new Any[] { Any.VOID, + new Any(Type.BOOLEAN, + Boolean.TRUE) }, + new CompareSpecific( + new Object[] { Any.VOID, Boolean.TRUE })); + success &= testMapAny(transport, + new Any(new Type(Any[].class), new Any[] {}), + new CompareSpecific(new Object[] {})); + success &= testMapAny(transport, + new Any(new Type(Any[].class), + new Any[] { Any.VOID, + new Any(Type.BOOLEAN, + Boolean.TRUE) }), + new CompareSpecific( + new Object[] { Any.VOID, Boolean.TRUE })); + success &= testMapAny(transport, + new Any(new Type(Any[].class), + new Boolean[] {}), + new CompareSpecific(new Object[] {})); + success &= testMapAny(transport, + new Any(new Type(Any[].class), + new Boolean[] { Boolean.FALSE }), + new CompareSpecific( + new Object[] { Boolean.FALSE })); + if (createTypes) { + success &= testMapAny(transport, new Enum1[] {}, + new CompareBoxed()); + success &= testMapAny(transport, new Enum1[] { new Enum1(), + new Enum2() }, + new CompareSpecific( + new Enum1[] { new Enum1(), + new Enum1() })); + success &= testMapAny(transport, + new Any(new Type(Enum1[].class), + new Enum1[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(Enum1[].class), + new Enum1[] { new Enum1(), + new Enum2() }), + new CompareSpecific( + new Enum1[] { new Enum1(), + new Enum1() })); + success &= testMapAny(transport, + new Any(new Type(Enum1[].class), + new Enum2[] {}), + new CompareSpecific(new Enum1[] {})); + success &= testMapAny(transport, + new Any(new Type(Enum1[].class), + new Enum2[] { new Enum2() }), + new CompareSpecific( + new Enum1[] { new Enum1() })); + success &= testMapAny(transport, new BaseStruct[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new BaseStruct[] { new BaseStruct(), + new DerivedStruct() }, + new CompareSpecific( + new BaseStruct[] { new BaseStruct(), + new BaseStruct() })); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[].class), + new BaseStruct[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[].class), + new BaseStruct[] { + new BaseStruct(), + new DerivedStruct() }), + new CompareSpecific( + new BaseStruct[] { new BaseStruct(), + new BaseStruct() })); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[].class), + new DerivedStruct[] {}), + new CompareSpecific(new BaseStruct[] {})); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[].class), + new DerivedStruct[] { + new DerivedStruct() }), + new CompareSpecific( + new BaseStruct[] { new BaseStruct() })); + success &= testMapAny(transport, new DerivedStruct[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new DerivedStruct[] { new DerivedStruct() }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedStruct[].class), + new DerivedStruct[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedStruct[].class), + new DerivedStruct[] { + new DerivedStruct() }), + new CompareUnboxed()); + } + success &= testMapAny(transport, new XInterface[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new XInterface[] { + null, new XInterface() {}, + new BaseInterface() {}, + new DerivedInterface() {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new XInterface[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new XInterface[] { + null, new XInterface() {}, + new BaseInterface() {}, + new DerivedInterface() {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new Object[] {}), + new CompareSpecific(new XInterface[] {})); + { + XInterface if1 = new XInterface() {}; + XInterface if2 = new BaseInterface() {}; + XInterface if3 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new Object[] { null, if1, if2, + if3 }), + new CompareSpecific( + new XInterface[] { null, if1, if2, + if3 })); + } + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new BaseInterface[] {}), + new CompareSpecific(new XInterface[] {})); + { + BaseInterface if1 = new BaseInterface() {}; + BaseInterface if2 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new BaseInterface[] { null, if1, + if2 }), + new CompareSpecific( + new XInterface[] { null, if1, if2 })); + } + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new DerivedInterface[] {}), + new CompareSpecific(new XInterface[] {})); + { + DerivedInterface if1 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(XInterface[].class), + new DerivedInterface[] { null, + if1 }), + new CompareSpecific( + new XInterface[] { null, if1 })); + } + success &= testMapAny(transport, new BaseInterface[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new BaseInterface[] { + null, new BaseInterface() {}, + new DerivedInterface() {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface[].class), + new BaseInterface[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface[].class), + new BaseInterface[] { + null, new BaseInterface() {}, + new DerivedInterface() {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface[].class), + new DerivedInterface[] {}), + new CompareSpecific(new BaseInterface[] {})); + { + DerivedInterface if1 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(BaseInterface[].class), + new DerivedInterface[] { null, + if1 }), + new CompareSpecific( + new BaseInterface[] { null, if1 })); + } + success &= testMapAny(transport, new DerivedInterface[] {}, + new CompareBoxed()); + success &= testMapAny(transport, + new DerivedInterface[] { + null, new DerivedInterface() {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedInterface[].class), + new DerivedInterface[] {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedInterface[].class), + new DerivedInterface[] { + null, + new DerivedInterface() {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new boolean[][] { new boolean[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new boolean[][] { + new boolean[] { false, true } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(boolean[][].class), + new boolean[][] { new boolean[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(boolean[][].class), + new boolean[][] { + new boolean[] { false, true } }), + new CompareUnboxed()); + success &= testMapAny(transport, new byte[][] { new byte[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new byte[][] { new byte[] { -128, 0, 127 } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(byte[][].class), + new byte[][] { new byte[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(byte[][].class), + new byte[][] { + new byte[] { -128, 0, 127 } }), + new CompareUnboxed()); + success &= testMapAny(transport, new short[][] { new short[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new short[][] { + new short[] { -32768, 0, 32767 } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(short[][].class), + new short[][] { new short[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(short[][].class), + new short[][] { + new short[] { -32768, 0, + 32767 } }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type("[][]unsigned short", + TypeClass.SEQUENCE), + new short[][] { new short[] {} }), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type("[][]unsigned short", + TypeClass.SEQUENCE), + new short[][] { + new short[] { 0, -32768 } }), + new CompareBoxed()); + success &= testMapAny(transport, new int[][] { new int[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new int[][] { new int[] { -2147483648, 0, + 2147483647 } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(int[][].class), + new int[][] { new int[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(int[][].class), + new int[][] { + new int[] { -2147483648, 0, + 2147483647 } }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type("[][]unsigned long", + TypeClass.SEQUENCE), + new int[][] { new int[] {} }), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type("[][]unsigned long", + TypeClass.SEQUENCE), + new int[][] { + new int[] { 0, -2147483648 } }), + new CompareBoxed()); + success &= testMapAny(transport, new long[][] { new long[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new long[][] { + new long[] { -9223372036854775808L, 0L, + 9223372036854775807L } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(long[][].class), + new long[][] { new long[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(long[][].class), + new long[][] { + new long[] { + -9223372036854775808L, 0L, + 9223372036854775807L } }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type("[][]unsigned hyper", + TypeClass.SEQUENCE), + new long[][] { new long[] {} }), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type("[][]unsigned hyper", + TypeClass.SEQUENCE), + new long[][] { + new long[] { + 0L, + -9223372036854775808L } }), + new CompareBoxed()); + success &= testMapAny(transport, new float[][] { new float[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new float[][] { + new float[] { Float.NEGATIVE_INFINITY, + Float.MIN_VALUE, -0.0f, + 0.0f, Float.MAX_VALUE, + Float.POSITIVE_INFINITY, + Float.NaN } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(float[][].class), + new float[][] { new float[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(float[][].class), + new float[][] { + new float[] { + Float.NEGATIVE_INFINITY, + Float.MIN_VALUE, -0.0f, 0.0f, + Float.MAX_VALUE, + Float.POSITIVE_INFINITY, + Float.NaN } }), + new CompareUnboxed()); + success &= testMapAny(transport, new double[][] { new double[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new double[][] { + new double[] { Double.NEGATIVE_INFINITY, + Double.MIN_VALUE, -0.0, + 0.0, Double.MAX_VALUE, + Double.POSITIVE_INFINITY, + Double.NaN } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(double[][].class), + new double[][] { new double[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(double[][].class), + new double[][] { + new double[] { + Double.NEGATIVE_INFINITY, + Double.MIN_VALUE, -0.0, 0.0, + Double.MAX_VALUE, + Double.POSITIVE_INFINITY, + Double.NaN } }), + new CompareUnboxed()); + success &= testMapAny(transport, new char[][] { new char[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new char[][] { + new char[] { '\u0000', '\uDBFF', + '\uFFFD' } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(char[][].class), + new char[][] { new char[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + new Type(char[][].class), + new char[][] { + new char[] { '\u0000', '\uDBFF', + '\uFFFD' } }), + new CompareUnboxed()); + success &= testMapAny(transport, new String[][] { new String[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new String[][] { + new String[] { "", "\uD800\uDC00", + "Test" } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(String[][].class), + new String[][] { new String[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(String[][].class), + new String[][] { + new String[] { "", "\uD800\uDC00", + "Test" } }), + new CompareUnboxed()); + success &= testMapAny(transport, new Type[][] { new Type[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new Type[][] { + new Type[] { + Type.VOID, + new Type( + DerivedInterface.class.getName(), + TypeClass.INTERFACE) } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(Type[][].class), + new Type[][] { new Type[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + new Type(Type[][].class), + new Type[][] { + new Type[] { + Type.VOID, + new Type( + DerivedInterface.class. + getName(), + TypeClass.INTERFACE) } }), + new CompareUnboxed()); + success &= testMapAny(transport, new Object[][] { new Object[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new Object[][] { + new Object[] { Any.VOID, + Boolean.FALSE } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Object[][] { + new Object[] { + Boolean.FALSE, + new Any(Type.BOOLEAN, + Boolean.TRUE) } }, + new CompareBoxed(true)); + success &= testMapAny(transport, + new Any(new Type(Any[][].class), + new Object[][] { new Object[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(Any[][].class), + new Object[][] { + new Object[] { Any.VOID, + Boolean.FALSE } }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(Any[][].class), + new Object[][] { + new Object[] { + Boolean.FALSE, + new Any(Type.BOOLEAN, + Boolean.TRUE) } }), + new CompareUnboxed(true)); + success &= testMapAny(transport, new Any[][] { new Any[] {} }, + new CompareSpecific( + new Object[][] { new Object[] {} })); + success &= testMapAny(transport, + new Any[][] { + new Any[] { Any.VOID, + new Any(Type.BOOLEAN, + Boolean.TRUE) } }, + new CompareSpecific( + new Object[][] { + new Object[] { Any.VOID, + Boolean.TRUE } })); + success &= testMapAny(transport, + new Any(new Type(Any[][].class), + new Any[][] { new Any[] {} }), + new CompareSpecific( + new Object[][] { new Object[] {} })); + success &= testMapAny(transport, + new Any(new Type(Any[][].class), + new Any[][] { + new Any[] { + Any.VOID, + new Any(Type.BOOLEAN, + Boolean.TRUE) } }), + new CompareSpecific( + new Object[][] { + new Object[] { Any.VOID, + Boolean.TRUE } })); + success &= testMapAny(transport, + new Any(new Type(Any[][].class), + new Boolean[][] { new Boolean[] {} }), + new CompareSpecific( + new Object[][] { new Object[] {} })); + success &= testMapAny(transport, + new Any(new Type(Any[][].class), + new Boolean[][] { + new Boolean[] { + Boolean.FALSE } }), + new CompareSpecific( + new Object[][] { + new Object[] { Boolean.FALSE } })); + if (createTypes) { + success &= testMapAny(transport, new Enum1[][] { new Enum1[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new Enum1[][] { + new Enum1[] { new Enum1(), + new Enum2() } }, + new CompareSpecific( + new Enum1[][] { + new Enum1[] { new Enum1(), + new Enum1() } })); + success &= testMapAny(transport, + new Any(new Type(Enum1[][].class), + new Enum1[][] { new Enum1[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(Enum1[][].class), + new Enum1[][] { + new Enum1[] { new Enum1(), + new Enum2() } }), + new CompareSpecific( + new Enum1[][] { + new Enum1[] { new Enum1(), + new Enum1() } })); + success &= testMapAny(transport, + new Any(new Type(Enum1[][].class), + new Enum2[][] { new Enum2[] {} }), + new CompareSpecific( + new Enum1[][] { new Enum1[] {} })); + success &= testMapAny(transport, + new Any(new Type(Enum1[][].class), + new Enum2[][] { + new Enum2[] { new Enum2() } }), + new CompareSpecific( + new Enum1[][] { + new Enum1[] { new Enum1() } })); + success &= testMapAny(transport, + new BaseStruct[][] { new BaseStruct[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new BaseStruct[][] { + new BaseStruct[] { + new BaseStruct(), + new DerivedStruct() } }, + new CompareSpecific( + new BaseStruct[][] { + new BaseStruct[] { + new BaseStruct(), + new BaseStruct() } })); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[][].class), + new BaseStruct[][] { + new BaseStruct[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[][].class), + new BaseStruct[][] { + new BaseStruct[] { + new BaseStruct(), + new DerivedStruct() } }), + new CompareSpecific( + new BaseStruct[][] { + new BaseStruct[] { + new BaseStruct(), + new BaseStruct() } })); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[][].class), + new DerivedStruct[][] { + new DerivedStruct[] {} }), + new CompareSpecific( + new BaseStruct[][] { + new BaseStruct[] {} })); + success &= testMapAny(transport, + new Any(new Type(BaseStruct[][].class), + new DerivedStruct[][] { + new DerivedStruct[] { + new DerivedStruct() } }), + new CompareSpecific( + new BaseStruct[][] { + new BaseStruct[] { + new BaseStruct() } })); + success &= testMapAny(transport, + new DerivedStruct[][] { + new DerivedStruct[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new DerivedStruct[][] { + new DerivedStruct[] { + new DerivedStruct() } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedStruct[][].class), + new DerivedStruct[][] { + new DerivedStruct[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedStruct[][].class), + new DerivedStruct[][] { + new DerivedStruct[] { + new DerivedStruct() } }), + new CompareUnboxed()); + } + success &= testMapAny(transport, + new XInterface[][] { new XInterface[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new XInterface[][] { + new XInterface[] { + null, new XInterface() {}, + new BaseInterface() {}, + new DerivedInterface() {} } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface[][].class), + new XInterface[][] { + new XInterface[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + new Type(XInterface[][].class), + new XInterface[][] { + new XInterface[] { + null, new XInterface() {}, + new BaseInterface() {}, + new DerivedInterface() {} } }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface[][].class), + new Object[][] { new Object[] {} }), + new CompareSpecific( + new XInterface[][] { + new XInterface[] {} })); + { + XInterface if1 = new XInterface() {}; + XInterface if2 = new BaseInterface() {}; + XInterface if3 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(XInterface[][].class), + new Object[][] { + new Object[] { null, if1, if2, + if3 } }), + new CompareSpecific( + new XInterface[][] { + new XInterface[] { null, if1, if2, + if3 } })); + } + success &= testMapAny(transport, + new Any(new Type(XInterface[][].class), + new BaseInterface[][] { + new BaseInterface[] {} }), + new CompareSpecific( + new XInterface[][] { + new XInterface[] {} })); + { + BaseInterface if1 = new BaseInterface() {}; + BaseInterface if2 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(XInterface[][].class), + new BaseInterface[][] { + new BaseInterface[] { + null, if1, if2 } }), + new CompareSpecific( + new XInterface[][] { + new XInterface[] { + null, if1, if2 } })); + } + success &= testMapAny(transport, + new Any(new Type(XInterface[][].class), + new DerivedInterface[][] { + new DerivedInterface[] {} }), + new CompareSpecific( + new XInterface[][] { + new XInterface[] {} })); + { + DerivedInterface if1 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(XInterface[][].class), + new DerivedInterface[][] { + new DerivedInterface[] { + null, if1 } }), + new CompareSpecific( + new XInterface[][] { + new XInterface[] { + null, if1 } })); + } + success &= testMapAny(transport, + new BaseInterface[][] { + new BaseInterface[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new BaseInterface[][] { + new BaseInterface[] { + null, new BaseInterface() {}, + new DerivedInterface() {} } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface[][].class), + new BaseInterface[][] { + new BaseInterface[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + new Type(BaseInterface[][].class), + new BaseInterface[][] { + new BaseInterface[] { + null, new BaseInterface() {}, + new DerivedInterface() {} } }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface[][].class), + new DerivedInterface[][] { + new DerivedInterface[] {} }), + new CompareSpecific( + new BaseInterface[][] { + new BaseInterface[] {} })); + { + DerivedInterface if1 = new DerivedInterface() {}; + success &= testMapAny(transport, + new Any(new Type(BaseInterface[][].class), + new DerivedInterface[][] { + new DerivedInterface[] { + null, if1 } }), + new CompareSpecific( + new BaseInterface[][] { + new BaseInterface[] { + null, if1 } })); + } + success &= testMapAny(transport, + new DerivedInterface[][] { + new DerivedInterface[] {} }, + new CompareBoxed()); + success &= testMapAny(transport, + new DerivedInterface[][] { + new DerivedInterface[] { + null, new DerivedInterface() {} } }, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedInterface[][].class), + new DerivedInterface[][] { + new DerivedInterface[] {} }), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any( + new Type(DerivedInterface[][].class), + new DerivedInterface[][] { + new DerivedInterface[] { + null, + new DerivedInterface() {} } }), + new CompareUnboxed()); + + // Enum Types: + if (createTypes) { + success &= testMapAny(transport, new Enum1(), new CompareBoxed()); + success &= testMapAny(transport, new Any(new Type(Enum1.class), + new Enum1()), + new CompareUnboxed()); + success &= testMapAny(transport, new Any(new Type(Enum1.class), + new Enum2()), + new CompareSpecific(new Enum1())); + } + + // Struct Types: + if (createTypes) { + success &= testMapAny(transport, new BaseStruct(), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(BaseStruct.class), + new BaseStruct()), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseStruct.class), + new DerivedStruct()), + new CompareSpecific(new BaseStruct())); + success &= testMapAny(transport, new DerivedStruct(), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedStruct.class), + new DerivedStruct()), + new CompareUnboxed()); + } + + // Exception Types: + success &= testMapAny(transport, new com.sun.star.uno.Exception(), + new CompareClass( + com.sun.star.uno.Exception.class)); + success &= testMapAny(transport, + new Any(new Type( + com.sun.star.uno.Exception.class), + new com.sun.star.uno.Exception()), + new CompareClass( + com.sun.star.uno.Exception.class)); + success &= testMapAny(transport, + new Any(new Type( + com.sun.star.uno.Exception.class), + new BaseException()), + new CompareClass( + com.sun.star.uno.Exception.class)); + success &= testMapAny(transport, + new Any(new Type( + com.sun.star.uno.Exception.class), + new DerivedException()), + new CompareClass( + com.sun.star.uno.Exception.class)); + if (createTypes) { + success &= testMapAny(transport, new BaseException(), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(BaseException.class), + new BaseException()), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseException.class), + new DerivedException()), + new CompareSpecific(new BaseException())); + success &= testMapAny(transport, new DerivedException(), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedException.class), + new DerivedException()), + new CompareUnboxed()); + } + success &= testMapAny(transport, + new com.sun.star.uno.RuntimeException(), + new CompareClass( + com.sun.star.uno.RuntimeException.class)); + success &= testMapAny(transport, + new Any( + new Type( + com.sun.star.uno.RuntimeException. + class), + new com.sun.star.uno.RuntimeException()), + new CompareClass( + com.sun.star.uno.RuntimeException.class)); + success &= testMapAny(transport, + new Any( + new Type( + com.sun.star.uno.RuntimeException. + class), + new BaseRuntimeException()), + new CompareClass( + com.sun.star.uno.RuntimeException.class)); + success &= testMapAny(transport, + new Any( + new Type( + com.sun.star.uno.RuntimeException. + class), + new DerivedRuntimeException()), + new CompareClass( + com.sun.star.uno.RuntimeException.class)); + if (createTypes) { + success &= testMapAny(transport, new BaseRuntimeException(), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type( + BaseRuntimeException.class), + new BaseRuntimeException()), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type( + BaseRuntimeException.class), + new DerivedRuntimeException()), + new CompareSpecific( + new BaseRuntimeException())); + success &= testMapAny(transport, new DerivedRuntimeException(), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type( + DerivedRuntimeException.class), + new DerivedRuntimeException()), + new CompareUnboxed()); + } + + // Interface Types: + success &= testMapAny(transport, null, new CompareBoxed()); + success &= testMapAny(transport, new XInterface() {}, + new CompareBoxed()); + success &= testMapAny(transport, new BaseInterface() {}, + new CompareBoxed()); + success &= testMapAny(transport, new DerivedInterface() {}, + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface.class), null), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface.class), + new XInterface() {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface.class), + new BaseInterface() {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(XInterface.class), + new DerivedInterface() {}), + new CompareUnboxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface.class), null), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface.class), + new BaseInterface() {}), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(BaseInterface.class), + new DerivedInterface() {}), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedInterface.class), + null), + new CompareBoxed()); + success &= testMapAny(transport, + new Any(new Type(DerivedInterface.class), + new DerivedInterface() {}), + new CompareBoxed()); + + // Misc: + try { + transport.mapAny(new Object()); + System.out.println("BAD mapAny(Object), no exception"); + success = false; + } catch (StackOverflowError e) { + System.out.println("BAD mapAny(Object): " + e); + success = false; + } catch (RuntimeException e) {} + + return success; + } + + private TestAny() {} // do not instantiate + + private static boolean testType(Class zclass, TypeClass tclass, + String tname) { + Type t1 = new Type(zclass); + Type t2 = new Type(tname, tclass); + boolean ok = true; + if (t1.getTypeClass() != tclass) { + ok = false; + System.out.println("BAD Type(" + zclass + ").getTypeClass() = " + + t1.getTypeClass() + " != " + tclass); + } + if (!t1.getTypeName().equals(tname)) { + ok = false; + System.out.println("BAD Type(" + zclass + ").getTypeName() = " + + t1.getTypeName() + " != " + tname); + } + if (!t1.equals(t2)) { + ok = false; + System.out.println("BAD Type(" + zclass + ") != Type(" + tname + + ", " + tclass + ")"); + } + return ok; + } + + private static boolean testMapAny(XTransport transport, Object any, + Compare compare) { + Object any2 = transport.mapAny(any); + boolean eq = compare.equal(any, any2); + if (!eq) { + System.out.println("BAD mapAny(" + any + ") -> " + any2); + } + return eq; + } + + private static abstract class Compare { + public abstract boolean equal(Object o1, Object o2); + } + + private static final class CompareBoxed extends Compare { + public CompareBoxed() { + this(false); + } + + public CompareBoxed(boolean unboxInner) { + this.unboxInner = unboxInner; + } + + public boolean equal(Object o1, Object o2) { + if (o1 instanceof Any) { + return o2 instanceof Any + && ((Any) o1).getType().equals(((Any) o2).getType()) + && equalValues(((Any) o1).getObject(), + ((Any) o2).getObject()); + } else { + return equalValues(o1, o2); + } + } + + private boolean equalValues(Object o1, Object o2) { + if (o1 == null) { + return o2 == null; + } else if (o1.getClass().isArray()) { + if (!(o2 != null && o1.getClass() == o2.getClass() + && Array.getLength(o1) == Array.getLength(o2))) { + return false; + } + for (int i = 0; i < Array.getLength(o1); ++i) { + Object oo1 = Array.get(o1, i); + if (unboxInner && oo1 instanceof Any) { + oo1 = ((Any) oo1).getObject(); + } + if (!equal(oo1, Array.get(o2, i))) { + return false; + } + } + return true; + } else { + return o1.equals(o2); + } + } + + private final boolean unboxInner; + } + + private static final class CompareUnboxed extends Compare { + public CompareUnboxed() { + this(false); + } + + public CompareUnboxed(boolean unboxInner) { + this.unboxInner = unboxInner; + } + + public boolean equal(Object o1, Object o2) { + return new CompareBoxed(unboxInner).equal(((Any) o1).getObject(), + o2); + } + + private final boolean unboxInner; + } + + private static final class CompareSpecific extends Compare { + public CompareSpecific(Object specific) { + this.specific = specific; + } + + public boolean equal(Object o1, Object o2) { + return new CompareBoxed().equal(specific, o2); + } + + private final Object specific; + } + + private static final class CompareClass extends Compare { + public CompareClass(Class clazz) { + this.clazz = clazz; + } + + public boolean equal(Object o1, Object o2) { + return o2 != null && o2.getClass() == clazz; + } + + private final Class clazz; + } + + public static class Enum1 extends Enum { + public Enum1() { + super(0); + } + + public static Enum1 fromInt(int value) { + return new Enum1(); + } + + public boolean equals(Object obj) { + return obj != null && obj.getClass() == Enum1.class; + } + } + + public static class Enum2 extends Enum1 { + public boolean equals(Object obj) { + return obj != null && obj.getClass() == Enum2.class; + } + } + + public static class BaseStruct { + public boolean equals(Object obj) { + return obj != null && obj.getClass() == BaseStruct.class; + } + } + + public static class DerivedStruct extends BaseStruct { + public boolean equals(Object obj) { + return obj != null && obj.getClass() == DerivedStruct.class; + } + } + + public static class BaseException extends com.sun.star.uno.Exception { + public BaseException() {} + + public BaseException(String message) { + super(message); + } + + public boolean equals(Object obj) { + return obj != null && obj.getClass() == BaseException.class; + } + } + + public static class DerivedException extends BaseException { + public DerivedException() {} + + public DerivedException(String message) { + super(message); + } + + public boolean equals(Object obj) { + return obj != null && obj.getClass() == DerivedException.class; + } + } + + public static class BaseRuntimeException + extends com.sun.star.uno.RuntimeException + { + public BaseRuntimeException() {} + + public BaseRuntimeException(String message) { + super(message); + } + + public boolean equals(Object obj) { + return obj != null + && obj.getClass() == BaseRuntimeException.class; + } + } + + public static class DerivedRuntimeException extends BaseRuntimeException + { + public DerivedRuntimeException() {} + + public DerivedRuntimeException(String message) { + super(message); + } + + public boolean equals(Object obj) { + return obj != null + && obj.getClass() == DerivedRuntimeException.class; + } + } +} diff --git a/bridges/test/java_uno/any/TestJni.java b/bridges/test/java_uno/any/TestJni.java new file mode 100644 index 000000000000..1242c38e86b0 --- /dev/null +++ b/bridges/test/java_uno/any/TestJni.java @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package test.java_uno.anytest; + +public class TestJni +{ + static { System.loadLibrary( "test_javauno_any" ); } + private static native XTransport create_jni_transport(ClassLoader loader); + + public static void main( String args [] ) + { + if (TestAny.test( + create_jni_transport(TestJni.class.getClassLoader()), false )) + { + System.out.println( "jni any test succeeded." ); + } + else + { + System.err.println( "jni any test failed!" ); + System.exit( 1 ); + } + } +} diff --git a/bridges/test/java_uno/any/TestRemote.java b/bridges/test/java_uno/any/TestRemote.java new file mode 100644 index 000000000000..4d038559660f --- /dev/null +++ b/bridges/test/java_uno/any/TestRemote.java @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package test.java_uno.anytest; + +import com.sun.star.bridge.XInstanceProvider; +import com.sun.star.lib.TestBed; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; + +public final class TestRemote { + public static void main(String[] args) throws Exception { + boolean success = new TestBed().execute( + new Provider(), false, Client.class, 0); + System.out.println("success? " + success); + System.exit(success ? 0 : 1); + } + + public static final class Client extends TestBed.Client { + public static void main(String[] args) { + new Client().execute(); + } + + protected boolean run(XComponentContext context) throws Throwable { + XTransport transport = UnoRuntime.queryInterface( + XTransport.class, getBridge(context).getInstance("Transport")); + return TestAny.test(transport, true); + } + } + + private static final class Provider implements XInstanceProvider { + public Object getInstance(String instanceName) { + return new XTransport() { + public Object mapAny(Object any) { + return any; + } + }; + } + } +} diff --git a/bridges/test/java_uno/any/makefile.mk b/bridges/test/java_uno/any/makefile.mk new file mode 100644 index 000000000000..888fae21d3d2 --- /dev/null +++ b/bridges/test/java_uno/any/makefile.mk @@ -0,0 +1,127 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/..$/.. +PRJNAME = bridges +TARGET = test_javauno_any + +PACKAGE = test$/java_uno$/anytest + +ENABLE_EXCEPTIONS = TRUE + +.INCLUDE: settings.mk + +.IF "$(GUI)" == "WNT" +GIVE_EXEC_RIGHTS = @echo +.ELSE +GIVE_EXEC_RIGHTS = chmod +x +.ENDIF + +JAVAFILES = \ + $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES))) + +# Make sure TestBed.class is found under $(CLASSDIR)$/test: +.IF "$(XCLASSPATH)" == "" +XCLASSPATH := $(CLASSDIR)$/test +.ELSE +XCLASSPATH !:= $(XCLASSPATH)$(PATH_SEPERATOR)$(CLASSDIR)$/test +.ENDIF + +EXEC_CLASSPATH_TMP = \ + $(foreach,i,$(JARFILES) $(SOLARBINDIR)$/$i)$(PATH_SEPERATOR)$(XCLASSPATH) +EXEC_CLASSPATH = \ + $(strip $(subst,!,$(PATH_SEPERATOR) $(EXEC_CLASSPATH_TMP:s/ /!/))) + +JARFILES = juh.jar jurt.jar ridl.jar +JAVACLASSFILES = \ + $(CLASSDIR)$/$(PACKAGE)$/TestAny.class \ + $(CLASSDIR)$/$(PACKAGE)$/TestRemote.class \ + $(CLASSDIR)$/$(PACKAGE)$/TestJni.class + +#-------------------------------------------------- + +USE_DEFFILE = TRUE +ENABLE_EXCEPTIONS = TRUE +INCPRE += $(OUT)$/inc$/test + +.IF "$(debug)" != "" +.IF "$(COM)" == "MSC" +CFLAGS += -Ob0 +.ENDIF +.ENDIF + +SLOFILES= \ + $(SLO)$/transport.obj + +SHL1TARGET=$(TARGET) + +SHL1STDLIBS= \ + $(CPPUHELPERLIB) \ + $(SALHELPERLIB) \ + $(JVMACCESSLIB) \ + $(CPPULIB) \ + $(SALLIB) + +SHL1VERSIONMAP=$(TARGET).map +SHL1IMPLIB=i$(TARGET) +SHL1LIBS=$(SLB)$/$(TARGET).lib +SHL1DEF=$(MISC)$/$(SHL1TARGET).def +DEF1NAME=$(SHL1TARGET) + +.INCLUDE: target.mk + +#-------------------------------------------------- + +$(SLOFILES) : $(MISC)$/gen_files.flag +$(JAVACLASSFILES) : $(MISC)$/gen_files.flag + +ALLTAR : \ + $(OUT)$/bin$/TestRemote \ + $(OUT)$/bin$/TestJni + +$(OUT)$/bin$/TestRemote : $(JAVACLASSFILES) + -rm -f $@ + echo java -classpath ..$/class$/test$(PATH_SEPERATOR)..$/class$(PATH_SEPERATOR)$(EXEC_CLASSPATH) \ + test.java_uno.anytest.TestRemote > $@ + $(GIVE_EXEC_RIGHTS) $@ + +$(OUT)$/bin$/TestJni : $(JAVACLASSFILES) + -rm -f $@ + echo '$(AUGMENT_LIBRARY_PATH)' java -classpath \ + .$(PATH_SEPERATOR)..$/class$(PATH_SEPERATOR)$(EXEC_CLASSPATH) \ + -Djava.library.path=..$/lib test.java_uno.anytest.TestJni >> $@ + $(GIVE_EXEC_RIGHTS) $@ + +$(BIN)$/test_java_uno_anytest.rdb : types.idl + $(IDLC) -I$(PRJ) -I$(SOLARIDLDIR) -O$(BIN) $? + $(REGMERGE) $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)} + +$(MISC)$/gen_files.flag : $(BIN)$/test_java_uno_anytest.rdb + $(CPPUMAKER) -C -BUCR -O $(OUT)$/inc$/test -X $(SOLARBINDIR)$/udkapi.rdb $? + $(CPPUMAKER) -C -BUCR -O $(OUT)$/inc$/test -T com.sun.star.uno.XInterface $(SOLARBINDIR)$/udkapi.rdb + $(JAVAMAKER) -nD -BUCR -O $(CLASSDIR) -X $(SOLARBINDIR)$/udkapi.rdb $? + $(TOUCH) $@ diff --git a/bridges/test/java_uno/any/test_javauno_any.map b/bridges/test/java_uno/any/test_javauno_any.map new file mode 100644 index 000000000000..c50f7b162db7 --- /dev/null +++ b/bridges/test/java_uno/any/test_javauno_any.map @@ -0,0 +1,6 @@ +UDK_3_0_0 { + global: + Java_test_java_1uno_anytest_TestJni_create_1jni_1transport; + local: + *; +}; diff --git a/bridges/test/java_uno/any/transport.cxx b/bridges/test/java_uno/any/transport.cxx new file mode 100644 index 000000000000..4211a96f8149 --- /dev/null +++ b/bridges/test/java_uno/any/transport.cxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_bridges.hxx" + +#include "jni.h" + +#include "uno/mapping.hxx" +#include "uno/environment.hxx" +#include "jvmaccess/virtualmachine.hxx" +#include "jvmaccess/unovirtualmachine.hxx" +#include "cppuhelper/implbase1.hxx" + +#include "test/java_uno/anytest/XTransport.hpp" +#include "test/java_uno/anytest/DerivedInterface.hpp" + + +using namespace ::com::sun::star::uno; +using ::test::java_uno::anytest::XTransport; +using ::rtl::OUString; + +namespace +{ +//================================================================================================== +class Transport : public ::cppu::WeakImplHelper1< XTransport > +{ +public: + virtual Any SAL_CALL mapAny( Any const & any ) + throw (RuntimeException); +}; +//__________________________________________________________________________________________________ +Any Transport::mapAny( Any const & any ) + throw (RuntimeException) +{ + return any; +} +} + +//################################################################################################## +extern "C" JNIEXPORT jobject JNICALL Java_test_java_1uno_anytest_TestJni_create_1jni_1transport( + JNIEnv * jni_env, jclass, jobject loader ) + SAL_THROW_EXTERN_C() +{ + // publish some idl types + ::getCppuType( (Reference< XTransport > const *)0 ); + ::getCppuType( (Reference< ::test::java_uno::anytest::DerivedInterface > const *)0 ); + + Reference< XTransport > xRet( new Transport() ); + + // get java vm + JavaVM * java_vm; + OSL_VERIFY( 0 == jni_env->GetJavaVM( &java_vm ) ); + // create jvmaccess vm + ::rtl::Reference< ::jvmaccess::UnoVirtualMachine > vm; + try { + vm = new ::jvmaccess::UnoVirtualMachine( + new ::jvmaccess::VirtualMachine( + java_vm, JNI_VERSION_1_2, false, jni_env ), + loader ); + } catch ( ::jvmaccess::UnoVirtualMachine::CreationException & ) { + OSL_ASSERT( false ); + throw; + } + // create uno envs + OUString java_name( RTL_CONSTASCII_USTRINGPARAM(UNO_LB_JAVA) ); + OUString cpp_name( RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME) ); + Environment java_env, cpp_env; + uno_getEnvironment( (uno_Environment **)&java_env, java_name.pData, vm.get() ); + OSL_ASSERT( java_env.is() ); + uno_getEnvironment( (uno_Environment **)&cpp_env, cpp_name.pData, 0 ); + OSL_ASSERT( cpp_env.is() ); + + // map interface + Mapping mapping( cpp_env.get(), java_env.get() ); + OSL_ASSERT( mapping.is() ); + jobject jo_global = (jobject)mapping.mapInterface( xRet.get(), ::getCppuType( &xRet ) ); + OSL_ASSERT( 0 != jo_global ); + + // return + jobject jo_ret = jni_env->NewLocalRef( jo_global ); + jni_env->DeleteGlobalRef( jo_global ); + return jo_ret; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/test/java_uno/any/types.idl b/bridges/test/java_uno/any/types.idl new file mode 100644 index 000000000000..a7d7df5487e6 --- /dev/null +++ b/bridges/test/java_uno/any/types.idl @@ -0,0 +1,42 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <com/sun/star/uno/XInterface.idl> + + +module test { module java_uno { module anytest { + +interface XTransport : com::sun::star::uno::XInterface +{ + any mapAny([in] any a); +}; + +interface BaseInterface : com::sun::star::uno::XInterface {}; + +interface DerivedInterface : BaseInterface {}; + +}; }; }; |