Kaydet (Commit) 5e0c6ab6 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Make ridljar JunitTests work

üst 73da209a
......@@ -28,7 +28,6 @@
$(eval $(call gb_JunitTest_JunitTest,ridljar_typedesc))
$(eval $(call gb_JunitTest_add_jars,ridljar_typedesc,\
$(OUTDIR)/bin/OOoRunnerLight.jar \
$(OUTDIR)/bin/ridl.jar \
))
......@@ -36,4 +35,8 @@ $(eval $(call gb_JunitTest_add_sourcefiles,ridljar_typedesc,\
ridljar/test/com/sun/star/lib/uno/typedesc/TypeDescription_Test \
))
$(eval $(call gb_JunitTest_add_classes,ridljar_typedesc,\
com.sun.star.lib.uno.typedesc.TypeDescription_Test \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
......@@ -28,7 +28,6 @@
$(eval $(call gb_JunitTest_JunitTest,ridljar_uno))
$(eval $(call gb_JunitTest_add_jars,ridljar_uno,\
$(OUTDIR)/bin/OOoRunnerLight.jar \
$(OUTDIR)/bin/ridl.jar \
))
......@@ -38,4 +37,10 @@ $(eval $(call gb_JunitTest_add_sourcefiles,ridljar_uno,\
ridljar/test/com/sun/star/uno/UnoRuntime_Test \
))
$(eval $(call gb_JunitTest_add_classes,ridljar_uno,\
com.sun.star.uno.Any_Test \
com.sun.star.uno.Type_Test \
com.sun.star.uno.UnoRuntime_Test \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
......@@ -36,4 +36,8 @@ $(eval $(call gb_JunitTest_add_sourcefiles,ridljar_util,\
ridljar/test/com/sun/star/lib/util/WeakMap_Test \
))
$(eval $(call gb_JunitTest_add_classes,ridljar_util,\
com.sun.star.lib.util.WeakMap_Test \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
......@@ -37,19 +37,11 @@ import com.sun.star.uno.Type;
import com.sun.star.uno.TypeClass;
import com.sun.star.uno.XInterface;
import com.sun.star.uno.XNamingService;
import complexlib.ComplexTestCase;
import org.junit.Test;
import static org.junit.Assert.*;
public final class TypeDescription_Test extends ComplexTestCase {
public String getTestObjectName() {
return getClass().getName();
}
public String[] getTestMethodNames() {
return new String[] { "test", "testUnsigned",
"testGetMethodDescription", "testSequence" };
}
public void test() throws Exception {
public final class TypeDescription_Test {
@Test public void test() throws Exception {
ITypeDescription voidTD = TypeDescription.getTypeDescription(
void.class);
ITypeDescription stringTD = TypeDescription.getTypeDescription(
......@@ -141,21 +133,23 @@ public final class TypeDescription_Test extends ComplexTestCase {
"com.sun.star.uno.XNamingService"));
}
public void testUnsigned() throws ClassNotFoundException {
assure("TypeDescription for UNSIGNED LONG",
TypeDescription.getTypeDescription(Type.UNSIGNED_LONG).
getTypeName().equals("unsigned long"));
@Test public void testUnsigned() throws ClassNotFoundException {
assertEquals(
"TypeDescription for UNSIGNED LONG", "unsigned long",
(TypeDescription.getTypeDescription(Type.UNSIGNED_LONG).
getTypeName()));
}
public void testGetMethodDescription() {
@Test public void testGetMethodDescription() {
TypeDescription td = TypeDescription.getTypeDescription(XDerived.class);
td.getMethodDescription("fn");
}
public void testSequence() throws ClassNotFoundException {
assure(
TypeDescription.getTypeDescription("[]unsigned short").
getComponentType().getTypeName().equals("unsigned short"));
@Test public void testSequence() throws ClassNotFoundException {
assertEquals(
"unsigned short",
(TypeDescription.getTypeDescription("[]unsigned short").
getComponentType().getTypeName()));
}
public interface XBase extends XInterface {
......@@ -182,27 +176,31 @@ public final class TypeDescription_Test extends ComplexTestCase {
public void test(String prefix, int index,
IMethodDescription description) {
assure(prefix + "; getIndex", description.getIndex() == index);
assure(prefix + "; getMethod",
(description.getMethod() == null) == buildIn);
assure(prefix + "; isOneway", description.isOneway() == oneWay);
assertEquals(prefix + "; getIndex", index, description.getIndex());
assertEquals(
prefix + "; getMethod", buildIn,
description.getMethod() == null);
assertEquals(prefix + "; isOneway", oneWay, description.isOneway());
ITypeDescription[] in = description.getInSignature();
assure(prefix + "; getInSignature",
in.length == inParameters.length);
assertEquals(
prefix + "; getInSignature", inParameters.length, in.length);
for (int i = 0; i < in.length; ++i) {
assure(prefix + "; getInSignature " + i,
in[i].equals(inParameters[i]));
assertEquals(
prefix + "; getInSignature " + i, inParameters[i], in[i]);
}
ITypeDescription[] out = description.getOutSignature();
assure(prefix + "; getOutSignature",
out.length == outParameters.length);
assertEquals(
prefix + "; getOutSignature", outParameters.length, out.length);
for (int i = 0; i < out.length; ++i) {
assure(prefix + "; getOutSignature " + i,
out[i] == null ? outParameters[i] == null
: out[i].equals(outParameters[i]));
assertTrue(
prefix + "; getOutSignature " + i,
(out[i] == null
? outParameters[i] == null
: out[i].equals(outParameters[i])));
}
assure(prefix + "; getReturnSignature",
description.getReturnSignature().equals(returnValue));
assertEquals(
prefix + "; getReturnSignature", returnValue,
description.getReturnSignature());
}
private final boolean buildIn;
......@@ -230,21 +228,24 @@ public final class TypeDescription_Test extends ComplexTestCase {
public void test(String prefix, Object[] data,
ITypeDescription description) throws Exception {
assure(prefix + "; getTypeName",
description.getTypeName().equals(data[0]));
assure(prefix + "; equals",
description.equals(TypeDescription.getTypeDescription(
(String)data[0])));
assure(prefix + "; getArrayTypeName",
description.getArrayTypeName().equals(data[1]));
assure(prefix + "; getZClass", description.getZClass() == data[2]);
assure(prefix + "; getTypeClass",
description.getTypeClass() == data[3]);
assure(prefix + "; getComponentType",
description.getComponentType() == null);
assertEquals(
prefix + "; getTypeName", data[0], description.getTypeName());
assertEquals(
prefix + "; equals",
TypeDescription.getTypeDescription((String)data[0]),
description);
assertEquals(
prefix + "; getArrayTypeName", data[1],
description.getArrayTypeName());
assertSame(
prefix + "; getZClass", data[2], description.getZClass());
assertSame(
prefix + "; getTypeClass", data[3], description.getTypeClass());
assertNull(
prefix + "; getComponentType", description.getComponentType());
IMethodDescription[] mds = description.getMethodDescriptions();
assure(
assertTrue(
prefix + "; getMethodDescriptions",
mds == null
? methodSignatures == null
......@@ -259,8 +260,9 @@ public final class TypeDescription_Test extends ComplexTestCase {
for (int i = 0; i < methodNames.length; ++i) {
IMethodDescription md = description.getMethodDescription(
i + methodOffset);
assure(prefix + "; getMethodDescription " + (i + methodOffset),
md != null);
assertNotNull(
prefix + "; getMethodDescription " + (i + methodOffset),
md);
methodSignatures[i].test(
prefix + "; getMethodDescription " + (i + methodOffset),
i + methodOffset, md);
......@@ -268,15 +270,15 @@ public final class TypeDescription_Test extends ComplexTestCase {
for (int i = 0; i < methodNames.length; ++i) {
IMethodDescription md = description.getMethodDescription(
methodNames[i]);
assure(prefix + "; getMethodDescription " + methodNames[i],
md != null);
assertNotNull(
prefix + "; getMethodDescription " + methodNames[i], md);
methodSignatures[i].test(
prefix + "; getMethodDescription " + methodNames[i],
i + methodOffset, md);
}
IFieldDescription[] fds = description.getFieldDescriptions();
assure(
assertTrue(
prefix + "; getFieldDescriptions",
fds == null
? fieldSignatures == null
......@@ -291,8 +293,8 @@ public final class TypeDescription_Test extends ComplexTestCase {
}
ITypeDescription supert = description.getSuperType();
assure(prefix + "; getSuperType",
(supert == null) == (data.length < 6));
assertEquals(
prefix + "; getSuperType", data.length < 6, supert == null);
if (supert != null && data[5] != null) {
_superType.test(prefix + "; getSuperType", (Object[]) data[5],
supert);
......
......@@ -27,45 +27,42 @@
package com.sun.star.lib.util;
import complexlib.ComplexTestCase;
import org.junit.Test;
import util.WaitUnreachable;
import static org.junit.Assert.*;
public final class WeakMap_Test extends ComplexTestCase {
public String[] getTestMethodNames() {
return new String[] { "test" };
}
public void test() {
public final class WeakMap_Test {
@Test public void test() {
WeakMap m = new WeakMap();
assure("", m.size() == 0);
assure("", m.isEmpty());
assure("", !m.containsKey("key1"));
assure("", !m.containsValue(null));
assertEquals(0, m.size());
assertTrue(m.isEmpty());
assertFalse(m.containsKey("key1"));
assertFalse(m.containsValue(null));
WaitUnreachable u1 = new WaitUnreachable(new Object());
m.put("key1", u1.get());
WaitUnreachable u2 = new WaitUnreachable(new Disposable());
m.put("key2", u2.get());
assure("", m.size() == 2);
assure("", !m.isEmpty());
assure("", m.containsKey("key1"));
assure("", m.containsKey("key2"));
assure("", !m.containsKey("key3"));
assure("", m.containsValue(m.get("key1")));
assure("", m.containsValue(m.get("key2")));
assure("", WeakMap.getValue(m.get("key1")).equals(u1.get()));
assure("", WeakMap.getValue(m.get("key2")).equals(u2.get()));
assure("", m.values().size() == 2);
assure("", m.values().contains(m.get("key1")));
assure("", m.values().contains(m.get("key2")));
assertEquals(2, m.size());
assertFalse(m.isEmpty());
assertTrue(m.containsKey("key1"));
assertTrue(m.containsKey("key2"));
assertFalse(m.containsKey("key3"));
assertTrue(m.containsValue(m.get("key1")));
assertTrue(m.containsValue(m.get("key2")));
assertEquals(u1.get(), WeakMap.getValue(m.get("key1")));
assertEquals(u2.get(), WeakMap.getValue(m.get("key2")));
assertEquals(2, m.values().size());
assertTrue(m.values().contains(m.get("key1")));
assertTrue(m.values().contains(m.get("key2")));
u1.waitUnreachable();
assure("", WeakMap.getValue(m.get("key1")) == null);
assertNull(WeakMap.getValue(m.get("key1")));
((Disposable) u2.get()).dispose();
assure("", WeakMap.getValue(m.get("key2")) == null);
assertNull(WeakMap.getValue(m.get("key2")));
m.clear();
u2.waitUnreachable();
assure("", m.size() == 0);
assertEquals(0, m.size());
m.put("key2", new Object());
assure("", m.size() == 1);
assertEquals(1, m.size());
}
// This simple class (single listener, no synchronization) exploits
......
......@@ -27,32 +27,27 @@
package com.sun.star.uno;
import complexlib.ComplexTestCase;
import org.junit.Test;
import static org.junit.Assert.*;
public final class Any_Test extends ComplexTestCase {
public String[] getTestMethodNames() {
return new String[] { "testAnyAny", "testComplete" };
}
public void testAnyAny() {
public final class Any_Test {
@Test public void testAnyAny() {
boolean caught = false;
try {
new Any(Type.ANY, null);
} catch (IllegalArgumentException e) {
caught = true;
}
assure(caught);
assertTrue(caught);
}
public void testComplete() {
assure(Any.complete(Any.VOID) == Any.VOID);
assure(
Any.complete(new Integer(10)).equals(
new Any(Type.LONG, new Integer(10))));
assure(
Any.complete(null).equals(
new Any(new Type(XInterface.class), null)));
@Test public void testComplete() {
assertSame(Any.VOID, Any.complete(Any.VOID));
assertEquals(
new Any(Type.LONG, new Integer(10)), Any.complete(new Integer(10)));
assertEquals(
new Any(new Type(XInterface.class), null), Any.complete(null));
XInterface x = new XInterface() {};
assure(Any.complete(x).equals(new Any(new Type(XInterface.class), x)));
assertEquals(new Any(new Type(XInterface.class), x), Any.complete(x));
}
}
......@@ -27,85 +27,92 @@
package com.sun.star.uno;
import complexlib.ComplexTestCase;
import org.junit.Test;
import static org.junit.Assert.*;
public final class Type_Test extends ComplexTestCase {
public String[] getTestMethodNames() {
return new String[] { "testZClass", "testIsSupertypeOf" };
}
public void testZClass() {
assure("VOID", new Type("void").getZClass() == void.class);
assure("BOOLEAN", new Type("boolean").getZClass() == boolean.class);
assure("BYTE", new Type("byte").getZClass() == byte.class);
assure("SHORT", new Type("short").getZClass() == short.class);
assure("UNSIGNED SHORT",
new Type("unsigned short").getZClass() == short.class);
assure("LONG", new Type("long").getZClass() == int.class);
assure("UNSIGNED LONG",
new Type("unsigned long").getZClass() == int.class);
assure("HYPER", new Type("hyper").getZClass() == long.class);
assure("UNSIGNED HYPER",
new Type("unsigned hyper").getZClass() == long.class);
assure("FLOAT", new Type("float").getZClass() == float.class);
assure("DOUBLE", new Type("double").getZClass() == double.class);
assure("CHAR", new Type("char").getZClass() == char.class);
assure("STRING", new Type("string").getZClass() == String.class);
assure("TYPE", new Type("type").getZClass() == Type.class);
assure("ANY", new Type("any").getZClass() == Object.class);
assure("sequence of BOOLEAN",
new Type("[]boolean", TypeClass.SEQUENCE).getZClass()
== boolean[].class);
assure("sequence of sequence of XComponentContext",
new Type("[][]com.sun.star.uno.XComponentContext",
TypeClass.SEQUENCE).getZClass()
== XComponentContext[][].class);
assure("enum TypeClass",
new Type("com.sun.star.uno.TypeClass",
TypeClass.ENUM).getZClass() == TypeClass.class);
assure("struct Uik",
new Type("com.sun.star.uno.Uik", TypeClass.STRUCT).getZClass()
== Uik.class);
assure("exception Exception",
new Type("com.sun.star.uno.Exception",
TypeClass.EXCEPTION).getZClass()
== com.sun.star.uno.Exception.class);
assure("exception RuntimeException",
new Type("com.sun.star.uno.RuntimeException",
TypeClass.EXCEPTION).getZClass()
== com.sun.star.uno.RuntimeException.class);
assure("exception DeploymentException",
new Type("com.sun.star.uno.DeploymentException",
TypeClass.EXCEPTION).getZClass()
== DeploymentException.class);
assure("interface XInterface",
new Type("com.sun.star.uno.XInterface",
TypeClass.INTERFACE).getZClass() == XInterface.class);
assure("interface XComponentContext",
new Type("com.sun.star.uno.XComponentContext",
TypeClass.INTERFACE).getZClass()
== XComponentContext.class);
public final class Type_Test {
@Test public void testZClass() {
assertSame("VOID", void.class, new Type("void").getZClass());
assertSame("BOOLEAN", boolean.class, new Type("boolean").getZClass());
assertSame("BYTE", byte.class, new Type("byte").getZClass());
assertSame("SHORT", short.class, new Type("short").getZClass());
assertSame(
"UNSIGNED SHORT", short.class,
new Type("unsigned short").getZClass());
assertSame("LONG", int.class, new Type("long").getZClass());
assertSame(
"UNSIGNED LONG", int.class, new Type("unsigned long").getZClass());
assertSame("HYPER", long.class, new Type("hyper").getZClass());
assertSame(
"UNSIGNED HYPER", long.class,
new Type("unsigned hyper").getZClass());
assertSame("FLOAT", float.class, new Type("float").getZClass());
assertSame("DOUBLE", double.class, new Type("double").getZClass());
assertSame("CHAR", char.class, new Type("char").getZClass());
assertSame("STRING", String.class, new Type("string").getZClass());
assertSame("TYPE", Type.class, new Type("type").getZClass());
assertSame("ANY", Object.class, new Type("any").getZClass());
assertSame(
"sequence of BOOLEAN", boolean[].class,
new Type("[]boolean", TypeClass.SEQUENCE).getZClass());
assertSame(
"sequence of sequence of XComponentContext",
XComponentContext[][].class,
(new Type(
"[][]com.sun.star.uno.XComponentContext", TypeClass.SEQUENCE).
getZClass()));
assertSame(
"enum TypeClass", TypeClass.class,
new Type("com.sun.star.uno.TypeClass", TypeClass.ENUM).getZClass());
assertSame(
"struct Uik", Uik.class,
new Type("com.sun.star.uno.Uik", TypeClass.STRUCT).getZClass());
assertSame(
"exception Exception", com.sun.star.uno.Exception.class,
(new Type("com.sun.star.uno.Exception", TypeClass.EXCEPTION).
getZClass()));
assertSame(
"exception RuntimeException",
com.sun.star.uno.RuntimeException.class,
(new Type("com.sun.star.uno.RuntimeException", TypeClass.EXCEPTION).
getZClass()));
assertSame(
"exception DeploymentException", DeploymentException.class,
(new Type(
"com.sun.star.uno.DeploymentException", TypeClass.EXCEPTION).
getZClass()));
assertSame(
"interface XInterface", XInterface.class,
(new Type("com.sun.star.uno.XInterface", TypeClass.INTERFACE).
getZClass()));
assertSame(
"interface XComponentContext", XComponentContext.class,
(new Type(
"com.sun.star.uno.XComponentContext", TypeClass.INTERFACE).
getZClass()));
assure(new Type(boolean.class).getZClass() == boolean.class);
assure(new Type(Boolean.class).getZClass() == boolean.class);
assure(new Type(boolean[].class).getZClass() == boolean[].class);
assure(new Type(Boolean[].class).getZClass() == boolean[].class);
assertSame(boolean.class, new Type(boolean.class).getZClass());
assertSame(boolean.class, new Type(Boolean.class).getZClass());
assertSame(boolean[].class, new Type(boolean[].class).getZClass());
assertSame(boolean[].class, new Type(Boolean[].class).getZClass());
}
public void testIsSupertypeOf() {
@Test public void testIsSupertypeOf() {
Type ifc = new Type(com.sun.star.uno.XInterface.class);
Type ctx = new Type(com.sun.star.uno.XComponentContext.class);
Type exc = new Type(com.sun.star.uno.RuntimeException.class);
assure("LONG :> LONG", Type.LONG.isSupertypeOf(Type.LONG));
assure("not ANY :> XInterface", !Type.ANY.isSupertypeOf(ifc));
assure("ANY :> ANY", Type.ANY.isSupertypeOf(Type.ANY));
assure("not ANY :> LONG", !Type.ANY.isSupertypeOf(Type.LONG));
assure("not XInterface :> ANY", !ifc.isSupertypeOf(Type.ANY));
assure("XInterface :> XInterface", ifc.isSupertypeOf(ifc));
assure("XInterface :> XComponentContext", ifc.isSupertypeOf(ctx));
assure("not XComponentContext :> XInterface", !ctx.isSupertypeOf(ifc));
assure("XComponentContext :> XComponentContext",
ctx.isSupertypeOf(ctx));
assure("not XInterface :> RuntimeException", !ifc.isSupertypeOf(exc));
assertTrue("LONG :> LONG", Type.LONG.isSupertypeOf(Type.LONG));
assertFalse("not ANY :> XInterface", Type.ANY.isSupertypeOf(ifc));
assertTrue("ANY :> ANY", Type.ANY.isSupertypeOf(Type.ANY));
assertFalse("not ANY :> LONG", Type.ANY.isSupertypeOf(Type.LONG));
assertFalse("not XInterface :> ANY", ifc.isSupertypeOf(Type.ANY));
assertTrue("XInterface :> XInterface", ifc.isSupertypeOf(ifc));
assertTrue("XInterface :> XComponentContext", ifc.isSupertypeOf(ctx));
assertFalse(
"not XComponentContext :> XInterface", ctx.isSupertypeOf(ifc));
assertTrue(
"XComponentContext :> XComponentContext", ctx.isSupertypeOf(ctx));
assertFalse(
"not XInterface :> RuntimeException", ifc.isSupertypeOf(exc));
}
}
......@@ -28,68 +28,55 @@
package com.sun.star.uno;
import com.sun.star.beans.Optional;
import complexlib.ComplexTestCase;
import org.junit.Test;
import static org.junit.Assert.*;
public final class UnoRuntime_Test extends ComplexTestCase {
public String getTestObjectName() {
return getClass().getName();
}
public String[] getTestMethodNames() {
return new String[] {
"test_generateOid", "test_queryInterface", "test_areSame",
"test_completeValue", "test_currentContext" };
}
public void test_generateOid() {
public final class UnoRuntime_Test {
@Test public void test_generateOid() {
// Test if UnoRuntime generates an OID for a simple class:
assure("Test1", UnoRuntime.generateOid(new Test1()) != null);
assertNotNull("Test1", UnoRuntime.generateOid(new Test1()));
// Test if UnoRuntime generates an OID for a class implementing
// IQueryInterface and returning null from getOid:
assure("Test2", UnoRuntime.generateOid(new Test2()) != null);
assertNotNull("Test2", UnoRuntime.generateOid(new Test2()));
// Test if a delegator object has the same OID as its creator:
Test4 test4 = new Test4();
Ifc ifc = UnoRuntime.queryInterface(Ifc.class, test4);
assure(
"Test4",
UnoRuntime.generateOid(test4).equals(UnoRuntime.generateOid(ifc)));
assertEquals(
"Test4", UnoRuntime.generateOid(ifc),
UnoRuntime.generateOid(test4));
}
public void test_queryInterface() {
@Test public void test_queryInterface() {
// Test if a query for an interface which is not supported returns null:
assure(
"Test1",
UnoRuntime.queryInterface(Ifc.class, new Test1()) == null);
assertNull("Test1", UnoRuntime.queryInterface(Ifc.class, new Test1()));
// Test if a query for an interface which is supported through
// IQueryInterface succeeds:
assure(
"Test2",
UnoRuntime.queryInterface(Ifc.class, new Test2()) != null);
assertNotNull(
"Test2", UnoRuntime.queryInterface(Ifc.class, new Test2()));
// Test if a query for an interface which is directly supported (through
// inheritance) succeeds:
assure(
"Test3",
UnoRuntime.queryInterface(Ifc.class, new Test3()) != null);
assertNotNull(
"Test3", UnoRuntime.queryInterface(Ifc.class, new Test3()));
}
public void test_areSame() {
assure(
@Test public void test_areSame() {
assertTrue(
UnoRuntime.areSame(
new Any(Type.UNSIGNED_LONG, new Integer(3)),
new Any(Type.UNSIGNED_LONG, new Integer(3))));
assure(
!UnoRuntime.areSame(
assertFalse(
UnoRuntime.areSame(
new Any(Type.UNSIGNED_LONG, new Integer(3)), new Integer(3)));
assure(!UnoRuntime.areSame(new int[] { 1 }, new int[] { 1, 2 }));
assure(
assertFalse(UnoRuntime.areSame(new int[] { 1 }, new int[] { 1, 2 }));
assertTrue(
UnoRuntime.areSame(
TypeClass.UNSIGNED_LONG,
new Any(new Type(TypeClass.class), TypeClass.UNSIGNED_LONG)));
assure(
assertTrue(
UnoRuntime.areSame(
new Any(
new Type("com.sun.star.beans.Optional<unsigned long>"),
......@@ -97,33 +84,32 @@ public final class UnoRuntime_Test extends ComplexTestCase {
new Any(
new Type("com.sun.star.beans.Optional<unsigned long>"),
new Optional(false, new Integer(0)))));
assure(!UnoRuntime.areSame(new Test1(), new Test2()));
assertFalse(UnoRuntime.areSame(new Test1(), new Test2()));
Test2 test2 = new Test2();
assure(
assertTrue(
"Test2",
UnoRuntime.areSame(
UnoRuntime.queryInterface(Ifc.class, test2), test2));
}
public void test_completeValue() {
assure(
UnoRuntime.completeValue(Type.UNSIGNED_LONG, null).equals(
new Integer(0)));
@Test public void test_completeValue() {
assertEquals(
new Integer(0), UnoRuntime.completeValue(Type.UNSIGNED_LONG, null));
Object v = UnoRuntime.completeValue(
new Type("[][]unsigned long"), null);
assure(v instanceof int[][]);
assure(((int[][]) v).length == 0);
assure(
UnoRuntime.completeValue(new Type(TypeClass.class), null) ==
TypeClass.VOID);
assertTrue(v instanceof int[][]);
assertEquals(0, ((int[][]) v).length);
assertSame(
TypeClass.VOID,
UnoRuntime.completeValue(new Type(TypeClass.class), null));
v = UnoRuntime.completeValue(
new Type("com.sun.star.beans.Optional<unsigned long>"), null);
assure(v instanceof Optional);
assure(!((Optional) v).IsPresent);
assure(((Optional) v).Value == null);
assertTrue(v instanceof Optional);
assertFalse(((Optional) v).IsPresent);
assertNull(((Optional) v).Value);
}
public void test_currentContext() throws InterruptedException {
@Test public void test_currentContext() throws InterruptedException {
TestThread t1 = new TestThread();
TestThread t2 = new TestThread();
t1.start();
......@@ -132,10 +118,10 @@ public final class UnoRuntime_Test extends ComplexTestCase {
t2.join();
Object v1 = t1.context.getValueByName("");
Object v2 = t2.context.getValueByName("");
assure("", t1.context != t2.context);
assure("", v1 == t1);
assure("", v2 == t2);
assure("", v1 != v2);
assertFalse(t1.context == t2.context);
assertTrue(v1 == t1);
assertTrue(v2 == t2);
assertFalse(v1 == v2);
}
private interface Ifc extends XInterface {}
......@@ -194,13 +180,14 @@ public final class UnoRuntime_Test extends ComplexTestCase {
private final class TestThread extends Thread {
public void run() {
assure("", UnoRuntime.getCurrentContext() == null);
//TODO: JUnit does not notice if these asserts fail:
assertNull(UnoRuntime.getCurrentContext());
context = new TestCurrentContext();
UnoRuntime.setCurrentContext(context);
assure("", UnoRuntime.getCurrentContext() == context);
assure("", context.getValueByName("") == this);
assertSame(context, UnoRuntime.getCurrentContext());
assertSame(this, context.getValueByName(""));
UnoRuntime.setCurrentContext(null);
assure("", UnoRuntime.getCurrentContext() == null);
assertNull(UnoRuntime.getCurrentContext());
}
public XCurrentContext context = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment