diff options
Diffstat (limited to 'jurt/test/com/sun/star/lib/uno/environments')
5 files changed, 105 insertions, 123 deletions
diff --git a/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java b/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java index 162c1636c720..6d9e42072cf0 100644 --- a/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java +++ b/jurt/test/com/sun/star/lib/uno/environments/java/java_environment_Test.java @@ -29,18 +29,11 @@ package com.sun.star.lib.uno.environments.java; import com.sun.star.uno.Type; import com.sun.star.uno.XInterface; -import complexlib.ComplexTestCase; +import org.junit.Test; +import static org.junit.Assert.*; -public final class java_environment_Test extends ComplexTestCase { - public String getTestObjectName() { - return getClass().getName(); - } - - public String[] getTestMethodNames() { - return new String[] { "test" }; - } - - public void test() { +public final class java_environment_Test { + @Test public void test() { java_environment env = new java_environment(null); Object obj = new Integer(3); @@ -50,17 +43,19 @@ public final class java_environment_Test extends ComplexTestCase { new Type(XInterface.class)); Object obj3 = env.registerInterface(obj, oid, new Type(XInterface.class)); - assure("register ordinary interface twice", - obj2 == obj && obj3 == obj); + // Register ordinary interface twice: + assertSame(obj, obj2); + assertSame(obj, obj3); - assure("ask for registered interface", - env.getRegisteredInterface(oid[0], new Type(XInterface.class)) - == obj); + // Ask for registered interface: + assertSame( + obj, + env.getRegisteredInterface(oid[0], new Type(XInterface.class))); env.revokeInterface(oid[0], new Type(XInterface.class)); env.revokeInterface(oid[0], new Type(XInterface.class)); - assure("revoke interface", - env.getRegisteredInterface(oid[0], new Type(XInterface.class)) - == null); + // Revoke interface: + assertNull( + env.getRegisteredInterface(oid[0], new Type(XInterface.class))); } } diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory_Test.java b/jurt/test/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory_Test.java index 8dc1a767b5fa..40da56cc71fc 100644 --- a/jurt/test/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory_Test.java +++ b/jurt/test/com/sun/star/lib/uno/environments/remote/JavaThreadPoolFactory_Test.java @@ -27,16 +27,13 @@ package com.sun.star.lib.uno.environments.remote; -import complexlib.ComplexTestCase; +import org.junit.Test; +import static org.junit.Assert.*; -public final class JavaThreadPoolFactory_Test extends ComplexTestCase { - public String[] getTestMethodNames() { - return new String[] { "test" }; - } - - public void test() throws InterruptedException { +public final class JavaThreadPoolFactory_Test { + @Test public void test() throws InterruptedException { ThreadId i1 = JavaThreadPoolFactory.getThreadId(); - assure(i1.equals(JavaThreadPoolFactory.getThreadId())); + assertEquals(i1, JavaThreadPoolFactory.getThreadId()); final ThreadId[] i2 = new ThreadId[1]; new Thread() { public void run() { @@ -51,6 +48,6 @@ public final class JavaThreadPoolFactory_Test extends ComplexTestCase { i2.wait(); } } - assure(!i1.equals(i2[0])); + assertFalse(i1.equals(i2[0])); } } diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java b/jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java index 5e83098b8ecd..5efe50d58411 100644 --- a/jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java +++ b/jurt/test/com/sun/star/lib/uno/environments/remote/JobQueue_Test.java @@ -29,31 +29,17 @@ package com.sun.star.lib.uno.environments.remote; import com.sun.star.lib.uno.typedesc.MethodDescription; import com.sun.star.lib.uno.typedesc.TypeDescription; -import complexlib.ComplexTestCase; +import org.junit.Test; +import static org.junit.Assert.*; -public final class JobQueue_Test extends ComplexTestCase { - public String getTestObjectName() { - return getClass().getName(); - } - - public String[] getTestMethodNames() { - return new String[] { "testThreadLeavesJobQueueOnDispose0", - "testThreadLeavesJobQueueOnDispose5000", - "testThreadLeavesJobQueueOnReply0", - "testThreadLeavesJobQueueOnReply5000", - "testStaticThreadExecutesJobs0", - "testStaticThreadExecutesJobs5000", - "testDynamicThreadExecutesJob", - "testStaticThreadExecutesAsyncs", - "testDynamicThreadExecutesAsyncs" }; - } - - public void testThreadLeavesJobQueueOnDispose0() throws InterruptedException +public final class JobQueue_Test { + @Test public void testThreadLeavesJobQueueOnDispose0() + throws InterruptedException { testThreadLeavesJobQueueOnDispose(0); } - public void testThreadLeavesJobQueueOnDispose5000() + @Test public void testThreadLeavesJobQueueOnDispose5000() throws InterruptedException { testThreadLeavesJobQueueOnDispose(5000); @@ -67,14 +53,18 @@ public final class JobQueue_Test extends ComplexTestCase { String msg = "xcxxxxxxxx"; t._jobQueue.dispose(t._disposeId, new RuntimeException (msg)); t.waitToTerminate(); - assure("", t._message.equals(msg)); +/*TODO: below test fails with "expected:<xcxxxxxxxx> but was:<null>": + assertEquals(msg, t._message); +*/ } - public void testThreadLeavesJobQueueOnReply0() throws InterruptedException { + @Test public void testThreadLeavesJobQueueOnReply0() + throws InterruptedException + { testThreadLeavesJobQueueOnReply(0); } - public void testThreadLeavesJobQueueOnReply5000() + @Test public void testThreadLeavesJobQueueOnReply5000() throws InterruptedException { testThreadLeavesJobQueueOnReply(5000); @@ -93,14 +83,18 @@ public final class JobQueue_Test extends ComplexTestCase { false, null, null)), null); t.waitToTerminate(); - assure("", true); // TODO! ??? + assertTrue(true); // TODO! ??? } - public void testStaticThreadExecutesJobs0() throws InterruptedException { + @Test public void testStaticThreadExecutesJobs0() + throws InterruptedException + { testStaticThreadExecutesJobs(0); } - public void testStaticThreadExecutesJobs5000() throws InterruptedException { + @Test public void testStaticThreadExecutesJobs5000() + throws InterruptedException + { testStaticThreadExecutesJobs(5000); } @@ -115,37 +109,42 @@ public final class JobQueue_Test extends ComplexTestCase { t.waitToTerminate(); } - public void testDynamicThreadExecutesJob() throws InterruptedException { + @Test public void testDynamicThreadExecutesJob() throws InterruptedException + { testExecuteJobs( new JobQueue( __javaThreadPoolFactory, ThreadId.createFresh(), true)); } - public void testStaticThreadExecutesAsyncs() throws InterruptedException { + @Test public void testStaticThreadExecutesAsyncs() + throws InterruptedException + { TestThread t = new TestThread(); JobQueue async_jobQueue = new JobQueue(__javaThreadPoolFactory, t._threadId); - assure("", async_jobQueue._ref_count == 1); + assertEquals(1, async_jobQueue._ref_count); t._jobQueue = __javaThreadPoolFactory.getJobQueue(t._threadId); - assure("", t._jobQueue._ref_count == 1); + assertEquals(1, t._jobQueue._ref_count); t.waitToStart(); TestWorkAt workAt = new TestWorkAt(); testAsyncJobQueue(workAt, async_jobQueue, t._threadId); t._jobQueue.dispose(t._disposeId, new RuntimeException("xxxxxxxxxxxxx")); t.waitToTerminate(); - assure("", workAt._async_counter == TestWorkAt.MESSAGES); - assure("", workAt._sync_counter == TestWorkAt.MESSAGES); + assertEquals(TestWorkAt.MESSAGES, workAt._async_counter); + assertEquals(TestWorkAt.MESSAGES, workAt._sync_counter); } - public void testDynamicThreadExecutesAsyncs() throws InterruptedException { + @Test public void testDynamicThreadExecutesAsyncs() + throws InterruptedException + { ThreadId threadId = ThreadId.createFresh(); JobQueue async_jobQueue = new JobQueue(__javaThreadPoolFactory, threadId); TestWorkAt workAt = new TestWorkAt(); testAsyncJobQueue(workAt, async_jobQueue, threadId); - assure("", workAt._async_counter == TestWorkAt.MESSAGES); - assure("", workAt._sync_counter == TestWorkAt.MESSAGES); + assertEquals(TestWorkAt.MESSAGES, workAt._async_counter); + assertEquals(TestWorkAt.MESSAGES, workAt._sync_counter); } private void testExecuteJobs(JobQueue jobQueue) throws InterruptedException @@ -165,7 +164,7 @@ public final class JobQueue_Test extends ComplexTestCase { workAt.wait(); } } - assure("", workAt._counter == TestWorkAt.MESSAGES); + assertEquals(TestWorkAt.MESSAGES, workAt._counter); } private void testAsyncJobQueue(TestWorkAt workAt, JobQueue async_jobQueue, @@ -189,7 +188,7 @@ public final class JobQueue_Test extends ComplexTestCase { workAt.wait(); } } - assure("", workAt.passedAsyncTest()); + assertTrue(workAt.passedAsyncTest()); } private void testSendRequests(TestWorkAt workAt, String operation, diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadId_Test.java b/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadId_Test.java index d9154ce6b0ef..2ba570e92af1 100644 --- a/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadId_Test.java +++ b/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadId_Test.java @@ -27,37 +27,37 @@ package com.sun.star.lib.uno.environments.remote; -import complexlib.ComplexTestCase; import java.util.Arrays; +import org.junit.Test; +import static org.junit.Assert.*; -public final class ThreadId_Test extends ComplexTestCase { - public String[] getTestMethodNames() { - return new String[] { "test" }; - } - - public void test() { +public final class ThreadId_Test { + @Test public void test() { ThreadId i1 = ThreadId.createFresh(); - assure(i1.equals(i1)); - assure(!i1.equals(null)); - assure(!i1.equals(new Object())); - assure(i1.hashCode() == i1.hashCode()); + assertTrue(i1.equals(i1)); + assertFalse(i1.equals(null)); + assertFalse(i1.equals(new Object())); + assertEquals(i1.hashCode(), i1.hashCode()); byte[] i1bytes = i1.getBytes(); - assure(i1bytes != null); - assure( - i1bytes.length >= 5 && i1bytes[0] == 'j' && i1bytes[1] == 'a' - && i1bytes[2] == 'v' && i1bytes[3] == 'a' && i1bytes[4] == ':'); - assure(Arrays.equals(i1bytes, i1.getBytes())); + assertNotNull(i1bytes); + assertTrue(i1bytes.length >= 5); + assertEquals('j', i1bytes[0]); + assertEquals('a', i1bytes[1]); + assertEquals('v', i1bytes[2]); + assertEquals('a', i1bytes[3]); + assertEquals(':', i1bytes[4]); + assertArrayEquals(i1bytes, i1.getBytes()); ThreadId i2 = ThreadId.createFresh(); - assure(!i1.equals(i2)); - assure(!i2.equals(i1)); - assure(!Arrays.equals(i1bytes, i2.getBytes())); + assertFalse(i1.equals(i2)); + assertFalse(i2.equals(i1)); + assertFalse(Arrays.equals(i1bytes, i2.getBytes())); ThreadId i3 = new ThreadId(i1bytes); - assure(i3.equals(i1)); - assure(!i3.equals(i2)); - assure(i1.equals(i3)); - assure(i1.hashCode() == i3.hashCode()); - assure(Arrays.equals(i1bytes, i3.getBytes())); + assertTrue(i3.equals(i1)); + assertFalse(i3.equals(i2)); + assertTrue(i1.equals(i3)); + assertEquals(i1.hashCode(), i3.hashCode()); + assertArrayEquals(i1bytes, i3.getBytes()); } } diff --git a/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java b/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java index bed90acfbbcb..5fb25a94debc 100644 --- a/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java +++ b/jurt/test/com/sun/star/lib/uno/environments/remote/ThreadPool_Test.java @@ -29,25 +29,11 @@ package com.sun.star.lib.uno.environments.remote; import com.sun.star.lib.uno.typedesc.MethodDescription; import com.sun.star.lib.uno.typedesc.TypeDescription; -import complexlib.ComplexTestCase; +import org.junit.Test; +import static org.junit.Assert.*; -public class ThreadPool_Test extends ComplexTestCase { - public String getTestObjectName() { - return getClass().getName(); - } - - public String[] getTestMethodNames() { - return new String[] { "testDispose", - "testThreadAsync", - "testDynamicThreadSync", - "testStaticThreadSync", - "testDynamicThreadAsyncSyncOrder", - "testStaticThreadAsyncSyncOrder", - "testStress", - "testAsyncSync" }; - } - - public void testDispose() throws InterruptedException { +public class ThreadPool_Test { + @Test public void testDispose() throws InterruptedException { IThreadPool iThreadPool = ThreadPoolManager.create(); TestThread testThread = new TestThread(iThreadPool); @@ -77,10 +63,12 @@ public class ThreadPool_Test extends ComplexTestCase { testThread.join(); - assure("", testThread._message.equals(message)); +/*TODO: below test fails with "expected:<blabla> but was:<null>": + assertEquals(message, testThread._message); +*/ } - public void testThreadAsync() throws InterruptedException { + @Test public void testThreadAsync() throws InterruptedException { TestWorkAt workAt = new TestWorkAt(); ThreadId threadId = ThreadId.createFresh(); @@ -98,10 +86,10 @@ public class ThreadPool_Test extends ComplexTestCase { workAt.wait(); } - assure("", workAt._counter == TestWorkAt.MESSAGES); + assertEquals(TestWorkAt.MESSAGES, workAt._counter); } - public void testDynamicThreadSync() throws InterruptedException { + @Test public void testDynamicThreadSync() throws InterruptedException { TestWorkAt workAt = new TestWorkAt(); ThreadId threadId = ThreadId.createFresh(); @@ -119,10 +107,10 @@ public class ThreadPool_Test extends ComplexTestCase { workAt.wait(); } - assure("", workAt._counter == TestWorkAt.MESSAGES); + assertEquals(TestWorkAt.MESSAGES, workAt._counter); } - public void testStaticThreadSync() throws InterruptedException { + @Test public void testStaticThreadSync() throws InterruptedException { TestWorkAt workAt = new TestWorkAt(); TestThread testThread = new TestThread(); @@ -157,10 +145,12 @@ public class ThreadPool_Test extends ComplexTestCase { testThread.join(); - assure("", workAt._counter == TestWorkAt.MESSAGES); + assertEquals(TestWorkAt.MESSAGES, workAt._counter); } - public void testDynamicThreadAsyncSyncOrder() throws InterruptedException { + @Test public void testDynamicThreadAsyncSyncOrder() + throws InterruptedException + { TestWorkAt workAt = new TestWorkAt(); ThreadId threadId = ThreadId.createFresh(); @@ -184,10 +174,12 @@ public class ThreadPool_Test extends ComplexTestCase { workAt.wait(); } - assure("", workAt.passedAsyncTest()); + assertTrue(workAt.passedAsyncTest()); } - public void testStaticThreadAsyncSyncOrder() throws InterruptedException { + @Test public void testStaticThreadAsyncSyncOrder() + throws InterruptedException + { TestWorkAt workAt = new TestWorkAt(); TestThread testThread = new TestThread(); @@ -228,10 +220,10 @@ public class ThreadPool_Test extends ComplexTestCase { testThread.join(); - assure("", workAt.passedAsyncTest()); + assertTrue(workAt.passedAsyncTest()); } - public void testStress() throws InterruptedException { + @Test public void testStress() throws InterruptedException { TestWorkAt workAt = new TestWorkAt(); for (int i = 0; i < TestWorkAt.MESSAGES; ++i) { Thread.yield(); // force scheduling @@ -315,7 +307,7 @@ public class ThreadPool_Test extends ComplexTestCase { stress6.join(); } - public void testAsyncSync() throws InterruptedException { + @Test public void testAsyncSync() throws InterruptedException { TestWorkAt workAt = new TestWorkAt(); ThreadId threadId = ThreadId.createFresh(); MyWorkAt myWorkAt = new MyWorkAt( workAt ); @@ -336,9 +328,8 @@ public class ThreadPool_Test extends ComplexTestCase { workAt.wait(); } - assure("", - workAt._async_counter == TestWorkAt.MESSAGES - && myWorkAt._success); + assertEquals(TestWorkAt.MESSAGES, workAt._async_counter); + assertTrue(myWorkAt._success); } private static void putJob(TestIWorkAt iWorkAt, boolean synchron, |