summaryrefslogtreecommitdiff
path: root/jurt/test
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2010-12-10 14:37:57 +0100
committersb <sb@openoffice.org>2010-12-10 14:37:57 +0100
commit4eb067284ed88651b0a8c89813515f0b88b2bb04 (patch)
tree34a15913b8777630065f34d782b2e1e9c3371ad1 /jurt/test
parent0d2b12deb5d2a78d795ac39b36d51170ef0439de (diff)
sb135: #i116046# fixed jurt.com.sun.star.lib.uno.protocols.urp.Cache typo, adapted corresponding tests plus solenv/inc/javaunittest.mk to JUnit framework
Diffstat (limited to 'jurt/test')
-rw-r--r--jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java100
-rw-r--r--jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java17
-rw-r--r--jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java45
-rw-r--r--jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk9
4 files changed, 103 insertions, 68 deletions
diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java
index 31d3454bde48..2deb525adeac 100644
--- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java
+++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java
@@ -27,80 +27,114 @@
package com.sun.star.lib.uno.protocols.urp;
-import complexlib.ComplexTestCase;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public final class Cache_Test extends ComplexTestCase {
- public String[] getTestMethodNames() {
- return new String[] { "test0", "test1", "test2", "test3" };
- }
-
- public void test0() {
+public final class Cache_Test {
+ @Test public void test0() {
Cache c = new Cache(0);
boolean[] f = new boolean[1];
int i;
i = c.add(f, "a");
- assure("1", i == Cache.NOT_CACHED && !f[0]);
+ assertTrue(i == Cache.NOT_CACHED && !f[0]);
i = c.add(f, "a");
- assure("2", i == Cache.NOT_CACHED && !f[0]);
+ assertTrue(i == Cache.NOT_CACHED && !f[0]);
i = c.add(f, "b");
- assure("3", i == Cache.NOT_CACHED && !f[0]);
+ assertTrue(i == Cache.NOT_CACHED && !f[0]);
i = c.add(f, "a");
- assure("4", i == Cache.NOT_CACHED && !f[0]);
+ assertTrue(i == Cache.NOT_CACHED && !f[0]);
}
- public void test1() {
+ @Test public void test1() {
Cache c = new Cache(1);
boolean[] f = new boolean[1];
int i;
i = c.add(f, "a");
- assure("1", i == 0 && !f[0]);
+ assertTrue(i == 0 && !f[0]);
i = c.add(f, "a");
- assure("2", i == 0 && f[0]);
+ assertTrue(i == 0 && f[0]);
i = c.add(f, "b");
- assure("3", i == 0 && !f[0]);
+ assertTrue(i == 0 && !f[0]);
i = c.add(f, "b");
- assure("4", i == 0 && f[0]);
+ assertTrue(i == 0 && f[0]);
i = c.add(f, "a");
- assure("5", i == 0 && !f[0]);
+ assertTrue(i == 0 && !f[0]);
}
- public void test2() {
+ @Test public void test2() {
Cache c = new Cache(2);
boolean[] f = new boolean[1];
int i;
i = c.add(f, "a");
- assure("1", i == 0 && !f[0]);
+ assertTrue(i == 0 && !f[0]);
i = c.add(f, "a");
- assure("2", i == 0 && f[0]);
+ assertTrue(i == 0 && f[0]);
i = c.add(f, "b");
- assure("3", i == 1 && !f[0]);
+ assertTrue(i == 1 && !f[0]);
i = c.add(f, "b");
- assure("4", i == 1 && f[0]);
+ assertTrue(i == 1 && f[0]);
i = c.add(f, "a");
- assure("5", i == 0 && f[0]);
+ assertTrue(i == 0 && f[0]);
i = c.add(f, "c");
- assure("6", i == 1 && !f[0]);
+ assertTrue(i == 1 && !f[0]);
i = c.add(f, "b");
- assure("7", i == 0 && !f[0]);
+ assertTrue(i == 0 && !f[0]);
}
- public void test3() {
+ @Test public void test3() {
Cache c = new Cache(3);
boolean[] f = new boolean[1];
int i;
i = c.add(f, "a");
- assure("1", i == 0 && !f[0]);
+ assertTrue(i == 0 && !f[0]);
i = c.add(f, "a");
- assure("3", i == 0 && f[0]);
+ assertTrue(i == 0 && f[0]);
i = c.add(f, "b");
- assure("5", i == 1 && !f[0]);
+ assertTrue(i == 1 && !f[0]);
i = c.add(f, "a");
- assure("3", i == 0 && f[0]);
+ assertTrue(i == 0 && f[0]);
i = c.add(f, "c");
- assure("7", i == 2 && !f[0]);
+ assertTrue(i == 2 && !f[0]);
i = c.add(f, "d");
- assure("9", i == 1 && !f[0]);
+ assertTrue(i == 1 && !f[0]);
i = c.add(f, "d");
- assure("11", i == 1 && f[0]);
+ assertTrue(i == 1 && f[0]);
+ }
+
+ @Test public void testNothingLostFromLruList() {
+ // Regardless in what order arbitrary values from 0, ..., 3 are inserted
+ // into a size-4 cache, afterwards adding -1, ..., -4 must return each
+ // possible index in the range from 0, ..., 3 exactly once (so their sum
+ // must be 6); this code systematically tests all such arbitrary ways up
+ // to length 8 (the code arguably violates recommendations for writing
+ // good tests, but actually helped track down an error in the Cache
+ // implementation):
+ int[] a = new int[8];
+ for (int i = 0; i < a.length; ++i) {
+ for (int j = 0; j < i; ++j) {
+ a[j] = 0;
+ }
+ for (;;) {
+ Cache c = new Cache(4);
+ for (int k = 0; k < i; ++k) {
+ c.add(new boolean[1], a[k]);
+ }
+ assertEquals(
+ 6,
+ (c.add(new boolean[1], -1) + c.add(new boolean[1], -2) +
+ c.add(new boolean[1], -3) + c.add(new boolean[1], -4)));
+ int j = i - 1;
+ while (j >= 0 && a[j] == 3) {
+ --j;
+ }
+ if (j < 0) {
+ break;
+ }
+ ++a[j];
+ for (int k = j + 1; k < i; ++k) {
+ a[k] = 0;
+ }
+ }
+ }
}
}
diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java
index 4c01e9acc9c6..2621006faf95 100644
--- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java
+++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java
@@ -32,21 +32,14 @@ import com.sun.star.uno.IBridge;
import com.sun.star.uno.Type;
import com.sun.star.uno.TypeClass;
import com.sun.star.uno.XInterface;
-import complexlib.ComplexTestCase;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public final class Marshaling_Test extends ComplexTestCase {
- public String getTestObjectName() {
- return getClass().getName();
- }
-
- public String[] getTestMethodNames() {
- return new String[] { "test" };
- }
-
- public void test() throws Exception {
+public final class Marshaling_Test {
+ @Test public void test() throws Exception {
short cacheSize = (short)256;
TestBridge testBridge = new TestBridge();
Marshal marshal = new Marshal(testBridge, cacheSize);
@@ -239,7 +232,7 @@ public final class Marshaling_Test extends ComplexTestCase {
if(op1 instanceof Any)
op1 = ((Any)op1).getObject();
- assure("", compareObjects(op1, op2));
+ assertTrue(compareObjects(op1, op2));
}
}
diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java
index 393720c9756d..6a74710625e9 100644
--- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java
+++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java
@@ -34,20 +34,17 @@ import com.sun.star.uno.Any;
import com.sun.star.uno.IBridge;
import com.sun.star.uno.Type;
import com.sun.star.uno.XInterface;
-import complexlib.ComplexTestCase;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.util.LinkedList;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public final class Protocol_Test extends ComplexTestCase {
- public String[] getTestMethodNames() {
- return new String[] { "test" };
- }
-
- public void test() throws Exception {
+public final class Protocol_Test {
+ @Test public void test() throws Exception {
IBridge iBridge = new TestBridge();
PipedInputStream inA = new PipedInputStream();
PipedOutputStream outA = new PipedOutputStream(inA);
@@ -93,7 +90,7 @@ public final class Protocol_Test extends ComplexTestCase {
new Object[] { "hallo" });
Message iMessage = iReceiver.readMessage();
Object[] t_params = iMessage.getArguments();
- assure("", "hallo".equals((String)t_params[0]));
+ assertEquals("hallo", (String)t_params[0]);
// send a reply
iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null);
@@ -118,7 +115,7 @@ public final class Protocol_Test extends ComplexTestCase {
iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null);
iSender.readMessage();
- assure("", "testString".equals(((String [])params[0])[0]));
+ assertEquals("testString", ((String [])params[0])[0]);
}
public void testCallWithInOutParameter(
@@ -133,7 +130,7 @@ public final class Protocol_Test extends ComplexTestCase {
Object[] t_params = iMessage.getArguments();
- assure("", "inString".equals(((String [])t_params[0])[0]));
+ assertEquals("inString", ((String [])t_params[0])[0]);
// provide reply
((String [])t_params[0])[0] = "outString";
@@ -142,7 +139,7 @@ public final class Protocol_Test extends ComplexTestCase {
iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null);
iSender.readMessage();
- assure("", "outString".equals(((String [])params[0])[0]));
+ assertEquals("outString", ((String [])params[0])[0]);
}
public void testCallWithResult(
@@ -161,7 +158,7 @@ public final class Protocol_Test extends ComplexTestCase {
Message iMessage = iSender.readMessage();
Object result = iMessage.getResult();
- assure("", "resultString".equals(result));
+ assertEquals("resultString", result);
}
public void testCallWhichRaisesException(
@@ -181,7 +178,7 @@ public final class Protocol_Test extends ComplexTestCase {
Object result = iMessage.getResult();
- assure("", result instanceof com.sun.star.uno.RuntimeException);
+ assertTrue(result instanceof com.sun.star.uno.RuntimeException);
}
public void testCallWithIn_Out_InOut_Paramters_and_result(
@@ -196,9 +193,9 @@ public final class Protocol_Test extends ComplexTestCase {
Object[] t_params = iMessage.getArguments();
- assure("", "hallo".equals((String)t_params[0]));
+ assertEquals("hallo", (String)t_params[0]);
- assure("", "inOutString".equals(((String [])t_params[2])[0]));
+ assertEquals("inOutString", ((String [])t_params[2])[0]);
((String [])t_params[1])[0] = "outString";
((String [])t_params[2])[0] = "inOutString_res";
@@ -209,11 +206,11 @@ public final class Protocol_Test extends ComplexTestCase {
iMessage = iSender.readMessage();
Object result = iMessage.getResult();
- assure("", "outString".equals(((String [])params[1])[0]));
+ assertEquals("outString", ((String [])params[1])[0]);
- assure("", "inOutString_res".equals(((String [])params[2])[0]));
+ assertEquals("inOutString_res", ((String [])params[2])[0]);
- assure("", "resultString".equals(result));
+ assertEquals("resultString", result);
}
public void testCallWhichReturnsAny(
@@ -229,9 +226,11 @@ public final class Protocol_Test extends ComplexTestCase {
false, new ThreadId(new byte[] { 0, 1 }), Any.VOID);
Message iMessage = iSender.readMessage();
Object result = iMessage.getResult();
- assure("", result instanceof Any
- && (TypeDescription.getTypeDescription(((Any) result).getType()).
- getZClass() == void.class));
+ assertTrue(
+ result instanceof Any &&
+ ((TypeDescription.getTypeDescription(((Any) result).getType()).
+ getZClass()) ==
+ void.class));
// send an ordinary request
iSender.writeRequest(
@@ -244,7 +243,7 @@ public final class Protocol_Test extends ComplexTestCase {
new Any(XInterface.class, null));
iMessage = iSender.readMessage();
result = iMessage.getResult();
- assure("", result == null);
+ assertNull(result);
// send an ordinary request
iSender.writeRequest(
@@ -256,7 +255,7 @@ public final class Protocol_Test extends ComplexTestCase {
false, new ThreadId(new byte[] { 0, 1 }), new Integer(501));
iMessage = iSender.readMessage();
result = iMessage.getResult();
- assure("", result.equals(new Integer(501)));
+ assertEquals(501, result);
}
private static final class Endpoint {
diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk b/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk
index c6e66558b65d..8403b2bd71ed 100644
--- a/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk
+++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk
@@ -24,10 +24,16 @@
# for a copy of the LGPLv3 License.
#
#*************************************************************************
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
PRJ := ..$/..$/..$/..$/..$/..$/..$/..
PRJNAME := jurt
TARGET := test_com_sun_star_lib_uno_protocols_urp
+.IF "$(OOO_JUNIT_JAR)" != ""
PACKAGE := com$/sun$/star$/lib$/uno$/protocols$/urp
JAVATESTFILES := \
Cache_Test.java \
@@ -38,5 +44,8 @@ JAVAFILES := \
TestObject.java
JARFILES := ridl.jar
IDLTESTFILES := interfaces.idl
+.END
.INCLUDE: javaunittest.mk
+
+.END