Skip to content

Commit

Permalink
Add @test annotations to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freemansoft committed Mar 20, 2024
1 parent ea09033 commit 5b6a144
Show file tree
Hide file tree
Showing 36 changed files with 332 additions and 190 deletions.
5 changes: 5 additions & 0 deletions src/test/com/jacob/com/ActiveXComponentFactoryTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.test.BaseTestCase;

Expand All @@ -18,6 +20,7 @@ public class ActiveXComponentFactoryTest extends BaseTestCase {
* too. Unfortunately, it requires that the runner of the test verify via
* the "Windows Task Manager"
*/
@Test
public void testMultipleInstances() {
ComThread.InitMTA();
String mApplicationId = "Word.Application";
Expand All @@ -40,6 +43,7 @@ public void testMultipleInstances() {
* single running instance. It requires that a user physically watch the
* "Windows Task Manager" to verify only one copy of MS Word is executing
*/
@Test
public void testOnlyOneInstance() {
ComThread.InitMTA();
String mApplicationId = "Word.Application";
Expand All @@ -59,6 +63,7 @@ public void testOnlyOneInstance() {
/**
* Test that verifies function of the ActiveXComponentFactory
*/
@Test
public void testActiveXComponentFactory() {
ComThread.InitSTA(true);
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
Expand All @@ -11,11 +13,12 @@
* Eclipse). Look in the docs area at the Jacob usage document for command line
* options.
*/
public class DispatchNullProgramId extends BaseTestCase {
public class DispatchNullProgramIdTest extends BaseTestCase {

/**
* Verify that dispatch constructors are protected from null program ids.
*/
@Test
public void testNullProgramId() {
try {
String nullParam = null;
Expand Down
3 changes: 3 additions & 0 deletions src/test/com/jacob/com/DispatchTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.activeX.ActiveXComponent;
import com.jacob.test.BaseTestCase;

Expand All @@ -15,6 +17,7 @@ public class DispatchTest extends BaseTestCase {
/**
* Verify this detects word's exit
*/
@Test
public void testDispatchHasExited() {
String pid = "Word.Application";
ActiveXComponent axc = new ActiveXComponent(pid);
Expand Down
4 changes: 4 additions & 0 deletions src/test/com/jacob/com/DispatchValidDispatchTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
Expand All @@ -15,6 +17,7 @@ public class DispatchValidDispatchTest extends BaseTestCase {
* force an IllegalArgumentException to verify the utility method throws
* correctly.
*/
@Test
public void testThrowIllegalArgumentException() {
try {
Dispatch.call(null, 0);
Expand All @@ -29,6 +32,7 @@ public void testThrowIllegalArgumentException() {
* force an IllegalStateException to verify the utility method throws
* correctly.
*/
@Test
public void testThrowIllegalStateException() {
try {
Dispatch foo = new Dispatch();
Expand Down
21 changes: 13 additions & 8 deletions src/test/com/jacob/com/JacobDeadlockTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
Expand All @@ -17,9 +19,9 @@
* <p>
* This test will fail with debug logging turned on because of the amount of
* time it takes to write the debug output.
*
*
* @author jsamarziya
*
*
*/
public class JacobDeadlockTest extends BaseTestCase {
private static final long TIMEOUT = 5000l;
Expand All @@ -32,11 +34,11 @@ public static class TestThread extends Thread {

/**
* constructor for ThestThread
*
*
* @param id
* @param initCOM
* @param writeOutput
*
*
*/
public TestThread(int id, boolean initCOM, boolean writeOutput) {
this.id = id;
Expand Down Expand Up @@ -71,9 +73,10 @@ private void log(String message) {
/**
* This test shows that if ComThread.Init() is called explicitly, no problem
* occurs.
*
*
* @throws InterruptedException
*/
@Test
public void testShowNoProblemIfCOMIsInitialized()
throws InterruptedException {
runTest(2, true, false);
Expand All @@ -83,21 +86,23 @@ public void testShowNoProblemIfCOMIsInitialized()
/**
* This test shows that if only one thread is creating COM objects, no
* problem occurs.
*
*
* @throws InterruptedException
*/
@Test
public void testShowNoProblemIfSingleThreaded() throws InterruptedException {
runTest(1, false, false);
runTest(1, true, false);
}

/**
* Runs the test with two threads, which don't initialize the COM thread.
*
*
* This test will always fail.
*
*
* @throws InterruptedException
*/
@Test
public void testShowDeadlockProblem() throws InterruptedException {
runTest(2, false, true);
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/com/jacob/com/JacobObjectTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
Expand All @@ -14,6 +16,7 @@ public class JacobObjectTest extends BaseTestCase {
/**
* verify the build version and date functions work correctly
*/
@Test
public void testBuildVersion() {
System.out.println("build version is " + JacobReleaseInfo.getBuildVersion());
System.out.println("build date is " + JacobReleaseInfo.getBuildDate());
Expand Down
21 changes: 12 additions & 9 deletions src/test/com/jacob/com/LibraryLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
* be compiled and added to the classpath. You will need to refresh the release
* directory so that eclipse knows about jacob.jar. Otherwise you will get a
* "jar not found" dialog.
*
*
* <p>
* May need to run with some command line options (including from inside
* Eclipse). Look in the docs area at the Jacob usage document for command line
* options.
*
*
* @author clay_shooter
*
*
*/
public class LibraryLoaderTest {

/**
* verify the architecture switches work
*/
@Test
public void testArchitectureVersions() {
System.out.println("running on 32Bit? VM"
+ LibraryLoader.shouldLoad32Bit());
Expand Down Expand Up @@ -72,16 +73,18 @@ public void testDLLNameContainsProcessorAndVersion() {
// we build the package and run the unit tests on X86
Assert.assertTrue(LibraryLoader.getPreferredDLLName()
+ "should have contained "
+ LibraryLoader.DLL_NAME_MODIFIER_32_BIT, LibraryLoader
.getPreferredDLLName().contains(
LibraryLoader.DLL_NAME_MODIFIER_32_BIT));
+ LibraryLoader.DLL_NAME_MODIFIER_32_BIT,
LibraryLoader
.getPreferredDLLName().contains(
LibraryLoader.DLL_NAME_MODIFIER_32_BIT));
} else {
// we build the package and run the unit tests on X86
Assert.assertTrue(LibraryLoader.getPreferredDLLName()
+ "should have contained "
+ LibraryLoader.DLL_NAME_MODIFIER_64_BIT, LibraryLoader
.getPreferredDLLName().contains(
LibraryLoader.DLL_NAME_MODIFIER_64_BIT));
+ LibraryLoader.DLL_NAME_MODIFIER_64_BIT,
LibraryLoader
.getPreferredDLLName().contains(
LibraryLoader.DLL_NAME_MODIFIER_64_BIT));
}
}
}
13 changes: 8 additions & 5 deletions src/test/com/jacob/com/ROT2Test.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
* This test class exists to test the WeakRefernce implementation .
*
*
* It is not useful if there isn't one at this time
*
*
* <p>
* May need to run with some command line options (including from inside
* Eclipse). Look in the docs area at the Jacob usage document for command line
Expand All @@ -17,6 +19,7 @@ public class ROT2Test extends BaseTestCase {
/**
* runs a multi-threaded test
*/
@Test
public void testDoesNotBlowUp() {
ROT2TestThread threads[] = new ROT2TestThread[4];
for (int i = 0; i < threads.length; i++) {
Expand All @@ -39,7 +42,7 @@ public class ROT2TestThread extends Thread {
/**
* @param arg0
* @param iStartCount
* the initial number of threads
* the initial number of threads
*/
public ROT2TestThread(String arg0, int iStartCount) {
super(arg0);
Expand All @@ -51,7 +54,7 @@ public ROT2TestThread(String arg0, int iStartCount) {
* A semi-complex series of steps to put the ROT under stress. 1)
* discard half the objects we've created 2) if size is greater than 1
* but not a even number, add 1 new object 3) stop when size is 1.
*
*
* @see java.lang.Runnable#run()
*/
public void run() {
Expand Down Expand Up @@ -112,7 +115,7 @@ public void run() {
/**
* Another test would be to override this to always return the same
* name. That would really screw the ROT!
*
*
* @see java.lang.Object#toString()
*/
public String toString() {
Expand Down
13 changes: 8 additions & 5 deletions src/test/com/jacob/com/ROT3Test.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
* This tries to exercise ROT's garbage collection This is named this way
* because the build.xml ignores files ending in Test when building the binary
* zip file
*
*
* This will eventually be changed to a unit test.
*
*
* <p>
* May need to run with some command line options (including from inside
* Eclipse). Look in the docs area at the Jacob usage document for command line
Expand All @@ -19,6 +21,7 @@ public class ROT3Test extends BaseTestCase {
/**
* runs a multi-threaded test
*/
@Test
public void testROTVersion3() {
ROT3TestThread threads[] = new ROT3TestThread[4];
for (int i = 0; i < threads.length; i++) {
Expand All @@ -41,7 +44,7 @@ public class ROT3TestThread extends Thread {
/**
* @param arg0
* @param iStartCount
* the number of initial threads
* the number of initial threads
*/
public ROT3TestThread(String arg0, int iStartCount) {
super(arg0);
Expand All @@ -53,7 +56,7 @@ public ROT3TestThread(String arg0, int iStartCount) {
* A semi-complex series of steps to put the ROT under stress. 1)
* discard half the objects we've created 2) if size is greater than 1
* but not a even number, add 1 new object 3) stop when size is 1.
*
*
* @see java.lang.Runnable#run()
*/
@SuppressWarnings("deprecation")
Expand Down Expand Up @@ -131,7 +134,7 @@ public void run() {
/**
* Another test would be to overide this to always return the same name.
* That would really screw the ROT!
*
*
* @see java.lang.Object#toString()
*/
public String toString() {
Expand Down
8 changes: 6 additions & 2 deletions src/test/com/jacob/com/ROTTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.jacob.com;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
* This tries to exercise ROT's garbage collection
*
*
* This will eventually be changed to a unit test.
* <p>
* May need to run with some command line options (including from inside
Expand All @@ -18,6 +20,7 @@ public class ROTTest extends BaseTestCase {
* value of false means instances of the class are not put in the ROT Any o
* ther value means they are
*/
@Test
public void testDontFillROTSystemProperty() {
debug("testDontFillROTSystemProperty: started");
// Make sure the class is loaded before running any of the tests
Expand Down Expand Up @@ -53,8 +56,9 @@ public void testDontFillROTSystemProperty() {

/**
* Needs documentation. This test looks broken
*
*
*/
@Test
public void testGCBehavior() {
int sizeBeforeBuild = 0;
int sizeAfterBuild = 0;
Expand Down
4 changes: 4 additions & 0 deletions src/test/com/jacob/com/VariantDateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.Date;

import org.junit.Test;

import com.jacob.test.BaseTestCase;

/**
Expand All @@ -16,6 +18,7 @@ public class VariantDateTest extends BaseTestCase {
/**
* verify the conversion of Variants into java dates
*/
@Test
public void testVariantDate() {
Date now = new Date();
Variant holder = new Variant();
Expand All @@ -33,6 +36,7 @@ public void testVariantDate() {
* verify that the Variant constructor accepts Java dates and converts them
* correctly
*/
@Test
public void testVariantDateToJavaObject() {
Date now = new Date();
Variant holder = new Variant(now);
Expand Down
Loading

0 comments on commit 5b6a144

Please sign in to comment.