From 5b6a14440b36b9a82fa8cf7e0fc45964eaf1c6be Mon Sep 17 00:00:00 2001 From: Joe Freeman Date: Tue, 19 Mar 2024 23:11:20 -0400 Subject: [PATCH] Add @Test annotations to tests --- .../com/ActiveXComponentFactoryTest.java | 5 + ...Id.java => DispatchNullProgramIdTest.java} | 5 +- src/test/com/jacob/com/DispatchTest.java | 3 + .../jacob/com/DispatchValidDispatchTest.java | 4 + src/test/com/jacob/com/JacobDeadlockTest.java | 21 ++-- src/test/com/jacob/com/JacobObjectTest.java | 3 + src/test/com/jacob/com/LibraryLoaderTest.java | 21 ++-- src/test/com/jacob/com/ROT2Test.java | 13 ++- src/test/com/jacob/com/ROT3Test.java | 13 ++- src/test/com/jacob/com/ROTTest.java | 8 +- src/test/com/jacob/com/VariantDateTest.java | 4 + src/test/com/jacob/com/VariantTest.java | 64 ++++++++---- .../com/jacob/com/VariantUtilitiesTest.java | 11 +- src/test/com/jacob/test/BaseTestCase.java | 6 +- .../jacob/test/errors/UnicodeErrorTest.java | 13 ++- .../com/jacob/test/events/ExcelEventTest.java | 3 + src/test/com/jacob/test/events/IETest.java | 98 +++++++++--------- .../jacob/test/events/IETestActiveXProxy.java | 7 +- .../com/jacob/test/events/WordEventTest.java | 5 +- .../com/jacob/test/excel/ControllerTest.java | 96 +++++++++-------- .../jacob/test/powerpoint/PowerpointTest.java | 44 ++++---- .../test/safearray/SafeArrayBasicTest.java | Bin 20006 -> 20888 bytes .../test/safearray/SafeArrayContents.java | 5 +- .../test/safearray/SafeArrayDispatchTest.java | 3 + ...eArrayLeak.java => SafeArrayLeakTest.java} | 7 +- .../test/safearray/SafeArrayReleaseTest.java | 21 ++-- .../SafeArrayStringConstructorTest.java | 6 +- ...aExcel.java => SafeArrayViaExcelTest.java} | 5 +- .../com/jacob/test/vbscript/ScriptTest.java | 4 + .../com/jacob/test/vbscript/ScriptTest2.java | 3 + .../test/vbscript/ScriptTest2ActiveX.java | 3 + .../com/jacob/test/vbscript/ScriptTest3.java | 3 + .../test/vbscript/ScriptTest3ActiveX.java | 3 + .../test/vbscript/ScriptTestActiveX.java | 4 + .../test/vbscript/ScriptTestErrEvents.java | 3 +- .../com/jacob/test/windowsmedia/WMPlayer.java | 5 +- 36 files changed, 332 insertions(+), 190 deletions(-) rename src/test/com/jacob/com/{DispatchNullProgramId.java => DispatchNullProgramIdTest.java} (92%) rename src/test/com/jacob/test/safearray/{SafeArrayLeak.java => SafeArrayLeakTest.java} (97%) rename src/test/com/jacob/test/safearray/{SafeArrayViaExcel.java => SafeArrayViaExcelTest.java} (96%) diff --git a/src/test/com/jacob/com/ActiveXComponentFactoryTest.java b/src/test/com/jacob/com/ActiveXComponentFactoryTest.java index 71f4c26..edc0157 100644 --- a/src/test/com/jacob/com/ActiveXComponentFactoryTest.java +++ b/src/test/com/jacob/com/ActiveXComponentFactoryTest.java @@ -1,5 +1,7 @@ package com.jacob.com; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.test.BaseTestCase; @@ -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"; @@ -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"; @@ -59,6 +63,7 @@ public void testOnlyOneInstance() { /** * Test that verifies function of the ActiveXComponentFactory */ + @Test public void testActiveXComponentFactory() { ComThread.InitSTA(true); try { diff --git a/src/test/com/jacob/com/DispatchNullProgramId.java b/src/test/com/jacob/com/DispatchNullProgramIdTest.java similarity index 92% rename from src/test/com/jacob/com/DispatchNullProgramId.java rename to src/test/com/jacob/com/DispatchNullProgramIdTest.java index 5146562..4531ad6 100644 --- a/src/test/com/jacob/com/DispatchNullProgramId.java +++ b/src/test/com/jacob/com/DispatchNullProgramIdTest.java @@ -1,5 +1,7 @@ package com.jacob.com; +import org.junit.Test; + import com.jacob.test.BaseTestCase; /** @@ -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; diff --git a/src/test/com/jacob/com/DispatchTest.java b/src/test/com/jacob/com/DispatchTest.java index 5cbde73..914f04a 100644 --- a/src/test/com/jacob/com/DispatchTest.java +++ b/src/test/com/jacob/com/DispatchTest.java @@ -1,5 +1,7 @@ package com.jacob.com; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.test.BaseTestCase; @@ -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); diff --git a/src/test/com/jacob/com/DispatchValidDispatchTest.java b/src/test/com/jacob/com/DispatchValidDispatchTest.java index 54bf635..12fec15 100644 --- a/src/test/com/jacob/com/DispatchValidDispatchTest.java +++ b/src/test/com/jacob/com/DispatchValidDispatchTest.java @@ -1,5 +1,7 @@ package com.jacob.com; +import org.junit.Test; + import com.jacob.test.BaseTestCase; /** @@ -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); @@ -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(); diff --git a/src/test/com/jacob/com/JacobDeadlockTest.java b/src/test/com/jacob/com/JacobDeadlockTest.java index 1639fed..39e3c0e 100644 --- a/src/test/com/jacob/com/JacobDeadlockTest.java +++ b/src/test/com/jacob/com/JacobDeadlockTest.java @@ -1,5 +1,7 @@ package com.jacob.com; +import org.junit.Test; + import com.jacob.test.BaseTestCase; /** @@ -17,9 +19,9 @@ *

* 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; @@ -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; @@ -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); @@ -83,9 +86,10 @@ 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); @@ -93,11 +97,12 @@ public void testShowNoProblemIfSingleThreaded() throws InterruptedException { /** * 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); } diff --git a/src/test/com/jacob/com/JacobObjectTest.java b/src/test/com/jacob/com/JacobObjectTest.java index 47da8a7..86e4ddb 100644 --- a/src/test/com/jacob/com/JacobObjectTest.java +++ b/src/test/com/jacob/com/JacobObjectTest.java @@ -1,5 +1,7 @@ package com.jacob.com; +import org.junit.Test; + import com.jacob.test.BaseTestCase; /** @@ -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()); diff --git a/src/test/com/jacob/com/LibraryLoaderTest.java b/src/test/com/jacob/com/LibraryLoaderTest.java index 3da467e..4a41eb0 100644 --- a/src/test/com/jacob/com/LibraryLoaderTest.java +++ b/src/test/com/jacob/com/LibraryLoaderTest.java @@ -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. - * + * *

* 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()); @@ -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)); } } } diff --git a/src/test/com/jacob/com/ROT2Test.java b/src/test/com/jacob/com/ROT2Test.java index ff30cf1..43188af 100644 --- a/src/test/com/jacob/com/ROT2Test.java +++ b/src/test/com/jacob/com/ROT2Test.java @@ -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 - * + * *

* 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 @@ -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++) { @@ -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); @@ -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() { @@ -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() { diff --git a/src/test/com/jacob/com/ROT3Test.java b/src/test/com/jacob/com/ROT3Test.java index 798c420..87f4fca 100644 --- a/src/test/com/jacob/com/ROT3Test.java +++ b/src/test/com/jacob/com/ROT3Test.java @@ -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. - * + * *

* 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 @@ -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++) { @@ -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); @@ -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") @@ -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() { diff --git a/src/test/com/jacob/com/ROTTest.java b/src/test/com/jacob/com/ROTTest.java index 38b032b..89e28a0 100644 --- a/src/test/com/jacob/com/ROTTest.java +++ b/src/test/com/jacob/com/ROTTest.java @@ -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. *

* May need to run with some command line options (including from inside @@ -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 @@ -53,8 +56,9 @@ public void testDontFillROTSystemProperty() { /** * Needs documentation. This test looks broken - * + * */ + @Test public void testGCBehavior() { int sizeBeforeBuild = 0; int sizeAfterBuild = 0; diff --git a/src/test/com/jacob/com/VariantDateTest.java b/src/test/com/jacob/com/VariantDateTest.java index 892422f..8bd585d 100644 --- a/src/test/com/jacob/com/VariantDateTest.java +++ b/src/test/com/jacob/com/VariantDateTest.java @@ -2,6 +2,8 @@ import java.util.Date; +import org.junit.Test; + import com.jacob.test.BaseTestCase; /** @@ -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(); @@ -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); diff --git a/src/test/com/jacob/com/VariantTest.java b/src/test/com/jacob/com/VariantTest.java index 6dcedec..f19c7f8 100644 --- a/src/test/com/jacob/com/VariantTest.java +++ b/src/test/com/jacob/com/VariantTest.java @@ -4,11 +4,13 @@ import java.math.BigInteger; import java.util.Date; +import org.junit.Test; + import com.jacob.test.BaseTestCase; /** * runs through some of the get and set methods on Variant - * + * *

* 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 @@ -22,8 +24,9 @@ public class VariantTest extends BaseTestCase { *

* It compares the toJavaObject() for a byref against the toJavaObject() for * the regular. - * + * */ + @Test public void testByRefToJavaObject() { Variant v = null; Variant vByRef = null; @@ -91,6 +94,7 @@ public void testByRefToJavaObject() { /** * try and test VT_I8. This should only work on 64 bit machines */ + @Test public void testLong() { Variant v = null; Variant vByRef = null; @@ -112,6 +116,7 @@ public void testLong() { /** * do some testing around currencies */ + @Test public void testCurrencyHandling() { Variant v = null; Variant vByRef = null; @@ -145,8 +150,9 @@ public void testCurrencyHandling() { /** * 4/2007 bug report toObject on dispatch tries to call getDispatchRef * instead of getDispatch so toString() on dispatch blows up. - * + * */ + @Test public void testDispatchToJavaObject() { Variant v2 = new Variant(); v2.putNothing(); @@ -156,8 +162,9 @@ public void testDispatchToJavaObject() { /** * see what happens when we conver to by ref - * + * */ + @Test public void testSomeChangeVT() { Variant v; // the code shows e shouldn't need to use a returned Variant but the @@ -193,8 +200,9 @@ public void testSomeChangeVT() { /** * make sure variant with no backing store works. - * + * */ + @Test public void testUninitializedVariant() { Variant v; // Variants created without parameters are auto set to VariantEmpty @@ -224,9 +232,10 @@ public void testUninitializedVariant() { } /** - * + * * verify the toString() method does not do type conversion */ + @Test public void testToStringDoesNotConvert() { Variant v; v = new Variant(true); @@ -256,6 +265,7 @@ public void testToStringDoesNotConvert() { /** * Exercise ToString special cases */ + @Test public void testToStringEmptyValues() { Variant v; // create an empty variant @@ -283,6 +293,7 @@ public void testToStringEmptyValues() { * Verify that booleans can be released. Part of the suite that checks all * types. */ + @Test public void testSafeReleaseBoolean() { Variant v; v = new Variant(true); @@ -316,8 +327,9 @@ public void testSafeReleaseBoolean() { /** * verify the constant values aren't released with safeRelease - * + * */ + @Test public void testSafeReleaseConstant() { // System.out.println("Using Static constant Variant - should never // throw access violation"); @@ -349,8 +361,9 @@ public void testSafeReleaseConstant() { * this used to try and and create an access violation but that didn't work * and now the methods on the Variant are smarter about working after a * release - * + * */ + @Test public void testSafeReleaseString() { String mTestString = "Guitar Hero"; Variant v = new Variant(mTestString); @@ -369,8 +382,9 @@ public void testSafeReleaseString() { /** * verifies objectIsAConstant works as expected - * + * */ + @Test public void testObjectIsAConstant() { Variant v = new Variant("d"); if (!v.objectIsAConstant(Variant.VT_FALSE)) { @@ -396,8 +410,9 @@ public void testObjectIsAConstant() { /** * tests put and get methods looking for obvious defects - * + * */ + @Test public void testPutsAndGets() { Variant v = new Variant(); @@ -481,6 +496,7 @@ public void testPutsAndGets() { /** * verify decimal works right */ + @Test public void testDecimalConversion() { Variant v = new Variant(); v.changeType(Variant.VariantDecimal); @@ -505,8 +521,9 @@ public void testDecimalConversion() { * for(BigDecimal i in 79228162514264337593543950330.0 .. * 79228162514264337593543950341.0) { com.jacob.com.Variant dv = new * com.jacob.com.Variant(i, false) println i + " : " + dv.getDecimal() } - * + * */ + @Test public void testLargeDecimals() { // the largest decimal number, not in hex is // 7922816251426433759354395033.0 @@ -568,12 +585,14 @@ public void testLargeDecimals() { + modifiedDecimal.scale()); System.out.println("integer piece after rounding without scale is " + VariantUtilities.roundToMSDecimal(modifiedDecimal) - .unscaledValue().toString(16) + " scale=: " + .unscaledValue().toString(16) + + " scale=: " + modifiedDecimal.scale()); System.out.println("integer piece after rounding with scale 30 is " + VariantUtilities .roundToMSDecimal(modifiedDecimal.setScale(30)) - .unscaledValue().toString(16) + " scale=: " + .unscaledValue().toString(16) + + " scale=: " + modifiedDecimal.scale()); try { testVariant.putDecimal(VariantUtilities @@ -592,12 +611,14 @@ public void testLargeDecimals() { + modifiedDecimal.scale()); System.out.println("integer piece after rounding without scale is " + VariantUtilities.roundToMSDecimal(modifiedDecimal) - .unscaledValue().toString(16) + " scale=: " + .unscaledValue().toString(16) + + " scale=: " + modifiedDecimal.scale()); System.out.println("integer piece after rounding with scale 30 is " + VariantUtilities .roundToMSDecimal(modifiedDecimal.setScale(30)) - .unscaledValue().toString(16) + " scale=: " + .unscaledValue().toString(16) + + " scale=: " + modifiedDecimal.scale()); testVariant.putDecimal(VariantUtilities .roundToMSDecimal(modifiedDecimal.setScale(30))); @@ -608,8 +629,9 @@ public void testLargeDecimals() { * Spin up a lot of threads and have them all create variants 3/2007 there * have been several reports in multi-threaded servers that show init() * failing - * + * */ + @Test public void testManyThreadedInit() { VariantInitTestThread threads[] = new VariantInitTestThread[75]; @@ -643,7 +665,7 @@ public void testManyThreadedInit() { /** * a class to create variants in separate threads - * + * */ class VariantInitTestThread extends Thread { private boolean isComplete = false; @@ -652,9 +674,9 @@ class VariantInitTestThread extends Thread { /** * @param newThreadName - * the name for the thread + * the name for the thread * @param iStartCount - * number of threads to start with + * number of threads to start with */ public VariantInitTestThread(String newThreadName, int iStartCount) { super(newThreadName); @@ -664,7 +686,7 @@ public VariantInitTestThread(String newThreadName, int iStartCount) { /** * getter so master can see if thread is done - * + * * @return state of complete flag */ public boolean isComplete() { @@ -673,7 +695,7 @@ public boolean isComplete() { /** * Blow out a bunch of Variants - * + * * @see java.lang.Runnable#run() */ @Override diff --git a/src/test/com/jacob/com/VariantUtilitiesTest.java b/src/test/com/jacob/com/VariantUtilitiesTest.java index 423ca25..8d999b3 100644 --- a/src/test/com/jacob/com/VariantUtilitiesTest.java +++ b/src/test/com/jacob/com/VariantUtilitiesTest.java @@ -3,17 +3,20 @@ import java.util.Arrays; import java.util.Date; +import org.junit.Test; + import com.jacob.test.BaseTestCase; /** * This class should test some of the converter capabilities - * + * */ public class VariantUtilitiesTest extends BaseTestCase { /** * verifies our unpacking stuff */ + @Test public void testObjectsToVariants() { Object testArray[] = new Object[] { Integer.valueOf(1), Integer.valueOf(2) }; @@ -30,6 +33,7 @@ public void testObjectsToVariants() { /** * test nested arrays */ + @Test public void testObjectsToVariantNestedArray() { Object testArray[] = new Object[] { Integer.valueOf(1), Integer.valueOf(2) }; @@ -44,6 +48,7 @@ public void testObjectsToVariantNestedArray() { * verify that dispatch can convert from object to variant and that the * variant holds the right value */ + @Test public void testConverters() { Date testDate = new Date(); Variant fromDate = VariantUtilities.objectToVariant(testDate); @@ -61,6 +66,7 @@ public void testConverters() { } + @Test public void testPrimitiveByteArray() { byte[] arr = new byte[] { 1, 2, 3 }; @@ -78,6 +84,7 @@ public void testPrimitiveByteArray() { assertTrue(Arrays.equals(bytes, arr)); } + @Test public void testPrimitiveIntArray() { int[] arr = new int[] { 1000, 2000, 3 }; @@ -95,6 +102,7 @@ public void testPrimitiveIntArray() { assertTrue(Arrays.equals(ints, arr)); } + @Test public void testPrimitiveDoubleArray() { double[] arr = new double[] { 1000, 2000, 3 }; @@ -112,6 +120,7 @@ public void testPrimitiveDoubleArray() { assertTrue(Arrays.equals(doubles, arr)); } + @Test public void testPrimitiveLongArray() { long[] arr = new long[] { 0xcafebabecafebabeL, 42, 0xbabecafebabeL }; diff --git a/src/test/com/jacob/test/BaseTestCase.java b/src/test/com/jacob/test/BaseTestCase.java index acbd062..24b1d4e 100644 --- a/src/test/com/jacob/test/BaseTestCase.java +++ b/src/test/com/jacob/test/BaseTestCase.java @@ -2,6 +2,9 @@ import java.net.URL; +import org.junit.Before; +import org.junit.Test; + import junit.framework.TestCase; import com.jacob.com.JacobObject; @@ -23,7 +26,7 @@ */ public class BaseTestCase extends TestCase { - @SuppressWarnings("unused") + @Before protected void setUp() { // verify we have run with the dll in the lib path try { @@ -40,6 +43,7 @@ protected void setUp() { /** * this test exists just to test the setup. */ + @Test public void testSetup() { JacobObject foo = new JacobObject(); assertNotNull(foo); diff --git a/src/test/com/jacob/test/errors/UnicodeErrorTest.java b/src/test/com/jacob/test/errors/UnicodeErrorTest.java index b4a4f1c..1bfb15a 100644 --- a/src/test/com/jacob/test/errors/UnicodeErrorTest.java +++ b/src/test/com/jacob/test/errors/UnicodeErrorTest.java @@ -1,15 +1,18 @@ package com.jacob.test.errors; import com.jacob.test.BaseTestCase; + +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; /** * This test verifies patch SF 1794811 . It shows how unicode filenames throw * exceptions in 1.13M4 and earlier. - * + * * @author justme84 - * + * */ public class UnicodeErrorTest extends BaseTestCase { @@ -17,6 +20,7 @@ public class UnicodeErrorTest extends BaseTestCase { * verifies that messages can now have unicode in them like when the file * names have unicode characters */ + @Test public void testUnicodeCharactersInErrorMessage() { ActiveXComponent application = new ActiveXComponent("Word.Application"); ActiveXComponent documents = application @@ -27,8 +31,9 @@ public void testUnicodeCharactersInErrorMessage() { fail("Should have thrown an exception"); } catch (ComException e) { assertTrue("Error message should contain file name with unicode " - + "characters in it. " + e.getMessage(), e.getMessage() - .indexOf(fileName) > 0); + + "characters in it. " + e.getMessage(), + e.getMessage() + .indexOf(fileName) > 0); } } } \ No newline at end of file diff --git a/src/test/com/jacob/test/events/ExcelEventTest.java b/src/test/com/jacob/test/events/ExcelEventTest.java index e84c51d..3742182 100644 --- a/src/test/com/jacob/test/events/ExcelEventTest.java +++ b/src/test/com/jacob/test/events/ExcelEventTest.java @@ -1,5 +1,7 @@ package com.jacob.test.events; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.ComThread; @@ -26,6 +28,7 @@ public class ExcelEventTest extends BaseTestCase { * * @param args */ + @Test public void testExcelWithInvocationProxy() { ComThread.InitSTA(); // we are going to listen to events on Application. diff --git a/src/test/com/jacob/test/events/IETest.java b/src/test/com/jacob/test/events/IETest.java index 845de86..5ac1c01 100644 --- a/src/test/com/jacob/test/events/IETest.java +++ b/src/test/com/jacob/test/events/IETest.java @@ -1,5 +1,7 @@ package com.jacob.test.events; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComThread; import com.jacob.com.Dispatch; @@ -9,7 +11,7 @@ /** * This test runs fine against jdk 1.4 and 1.5 - * + * * This demonstrates the new event handling code in jacob 1.7 This example will * open up IE and print out some of the events it listens to as it navigates to * web sites. contributed by Niels Olof Bouvin mailto:n.o.bouvin@daimi.au.dk and @@ -32,6 +34,7 @@ public class IETest extends BaseTestCase { /** * runs the IE test and feeds it commands */ + @Test public void testRunIECleanly() { runTheTest(true, testUrls); } @@ -39,13 +42,14 @@ public void testRunIECleanly() { /** * runs the IE test and feeds it commands */ + @Test public void testRunIETerminateWithoutWait() { runTheTest(false, testUrls); } /** * The actual work of running the test. - * + * * @param waitForQuit * @param urls */ @@ -99,11 +103,11 @@ class IETestThread extends Thread { /** * constructor for the test thread - * + * * @param beNeat - * should we wait until quit received + * should we wait until quit received * @param urls - * the web pages we will navigate to + * the web pages we will navigate to */ public IETestThread(boolean beNeat, String urls[]) { super(); @@ -184,9 +188,9 @@ public void run() { public class IEEvents { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void BeforeNavigate2(Variant[] args) { System.out.println("IEEvents Received (" @@ -196,9 +200,9 @@ public void BeforeNavigate2(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void CommandStateChange(Variant[] args) { System.out.println("IEEvents Received (" @@ -208,9 +212,9 @@ public void CommandStateChange(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void DocumentComplete(Variant[] args) { System.out.println("IEEvents Received (" @@ -220,9 +224,9 @@ public void DocumentComplete(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void DownloadBegin(Variant[] args) { System.out.println("IEEvents Received (" @@ -232,9 +236,9 @@ public void DownloadBegin(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void DownloadComplete(Variant[] args) { System.out.println("IEEvents Received (" @@ -244,9 +248,9 @@ public void DownloadComplete(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void NavigateError(Variant[] args) { System.out.println("IEEvents Received (" @@ -256,9 +260,9 @@ public void NavigateError(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void NavigateComplete2(Variant[] args) { System.out.println("IEEvents Received (" @@ -268,9 +272,9 @@ public void NavigateComplete2(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void NewWindow2(Variant[] args) { System.out.println("IEEvents Received (" @@ -280,9 +284,9 @@ public void NewWindow2(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void OnFullScreen(Variant[] args) { System.out.println("IEEvents Received (" @@ -292,9 +296,9 @@ public void OnFullScreen(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void OnMenuBar(Variant[] args) { System.out.println("IEEvents Received (" @@ -304,9 +308,9 @@ public void OnMenuBar(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void OnQuit(Variant[] args) { System.out.println("IEEvents Received (" @@ -317,9 +321,9 @@ public void OnQuit(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void OnStatusBar(Variant[] args) { System.out.println("IEEvents Received (" @@ -329,9 +333,9 @@ public void OnStatusBar(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void OnTheaterMode(Variant[] args) { System.out.println("IEEvents Received (" @@ -341,9 +345,9 @@ public void OnTheaterMode(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void OnToolBar(Variant[] args) { System.out.println("IEEvents Received (" @@ -353,9 +357,9 @@ public void OnToolBar(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void OnVisible(Variant[] args) { System.out.println("IEEvents Received (" @@ -365,9 +369,9 @@ public void OnVisible(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void ProgressChange(Variant[] args) { System.out.println("IEEvents Received (" @@ -377,9 +381,9 @@ public void ProgressChange(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void PropertyChange(Variant[] args) { System.out.println("IEEvents Received (" @@ -389,9 +393,9 @@ public void PropertyChange(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void SetSecureLockIcon(Variant[] args) { System.out.println("IEEvents Received (" @@ -401,9 +405,9 @@ public void SetSecureLockIcon(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void StatusTextChange(Variant[] args) { System.out.println("IEEvents Received (" @@ -413,9 +417,9 @@ public void StatusTextChange(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void TitleChange(Variant[] args) { System.out.println("IEEvents Received (" @@ -425,9 +429,9 @@ public void TitleChange(Variant[] args) { /** * Internet explorer event this proxy can receive - * + * * @param args - * the COM Variant objects that this event passes in. + * the COM Variant objects that this event passes in. */ public void WindowClosing(Variant[] args) { System.out.println("IEEvents Received (" diff --git a/src/test/com/jacob/test/events/IETestActiveXProxy.java b/src/test/com/jacob/test/events/IETestActiveXProxy.java index 9c59188..a21b4ff 100644 --- a/src/test/com/jacob/test/events/IETestActiveXProxy.java +++ b/src/test/com/jacob/test/events/IETestActiveXProxy.java @@ -1,5 +1,7 @@ package com.jacob.test.events; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.activeX.ActiveXDispatchEvents; import com.jacob.com.ComThread; @@ -9,7 +11,7 @@ /** * This test runs fine against jdk 1.4 and 1.5 - * + * * This demonstrates the new event handling code in jacob 1.7 This example will * open up IE and print out some of the events it listens to as it havigates to * web sites. contributed by Niels Olof Bouvin mailto:n.o.bouvin@daimi.au.dk and @@ -18,7 +20,7 @@ * 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. - * + * * @TODO: THIS TEST HANGS under windows 10 on whatever version it is for 2020/09 */ @@ -27,6 +29,7 @@ public class IETestActiveXProxy extends BaseTestCase { /** * the main test method that builds up the connection and runs the test */ + @Test public void testIEActiveProxyCallback() { // this line starts the pump but it runs fine without it ComThread.startMainSTA(); diff --git a/src/test/com/jacob/test/events/WordEventTest.java b/src/test/com/jacob/test/events/WordEventTest.java index bc81b73..f7c5073 100644 --- a/src/test/com/jacob/test/events/WordEventTest.java +++ b/src/test/com/jacob/test/events/WordEventTest.java @@ -1,5 +1,7 @@ package com.jacob.test.events; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.DispatchEvents; @@ -22,9 +24,10 @@ public class WordEventTest extends BaseTestCase { /** * load up word, register for events and make stuff happen - * + * * @param args */ + @Test public void testCaptureWordEvents() { String pid = "Word.Application"; String typeLibLocation = null; diff --git a/src/test/com/jacob/test/excel/ControllerTest.java b/src/test/com/jacob/test/excel/ControllerTest.java index efd6d4b..10d1061 100644 --- a/src/test/com/jacob/test/excel/ControllerTest.java +++ b/src/test/com/jacob/test/excel/ControllerTest.java @@ -5,6 +5,9 @@ import java.util.List; import java.util.StringTokenizer; +import org.junit.Before; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComThread; import com.jacob.com.Dispatch; @@ -14,27 +17,28 @@ /** * this test verifies that you can call toString() on a Variant extracted from * Excel that contains a 2 dimensional array of doubles. 1.14M5 and earlier blew - * up on this because two objects pointed at the same windows memory space SF 1840487 + * up on this because two objects pointed at the same windows memory space SF + * 1840487 */ public class ControllerTest extends BaseTestCase { private Controller controller; + @Before protected void setUp() { controller = new Controller(); } + @Test public void testGetColumnA() { - List list = controller.getColumnA(super - .getWindowsFilePathToPackageResource("teste.xls", this - .getClass())); + List list = controller.getColumnA(super.getWindowsFilePathToPackageResource("teste.xls", this + .getClass())); assertEquals(50, list.size()); } public void testGetColumnB() { - List list = controller.getColumnB(super - .getWindowsFilePathToPackageResource("teste.xls", this - .getClass())); + List list = controller.getColumnB(super.getWindowsFilePathToPackageResource("teste.xls", this + .getClass())); assertEquals(40, list.size()); } @@ -83,7 +87,7 @@ public void executaExcelCallBack(String path, String password) { false, // Readonly 5, // Format password // Password - ).toDispatch(); + ).toDispatch(); Dispatch sheets = Dispatch.call(workbook, "Worksheets") .toDispatch(); @@ -116,7 +120,7 @@ public void executaExcelCallBack(String path, String password) { } /** - * Constante para configurar a planilha em modo "Calculation" automático + * Constante para configurar a planilha em modo "Calculation" autom�tico */ public static final int CALC_AUTOMATICO = -4105; @@ -126,15 +130,15 @@ public void executaExcelCallBack(String path, String password) { public static final int CALC_MANUAL = -4135; /** - * Escreve um determinado valor em uma célula da pasta em questão. O - * valor é escrito configurando a propriedade Value da célula - * + * Escreve um determinado valor em uma c�lula da pasta em quest�o. O + * valor � escrito configurando a propriedade Value da c�lula + * * @param celula - - * célula para escrever novo valor - * @param sheet - - * pasta da planilha em questão - * @param valor - - * valor a ser escrito na celula + * c�lula para escrever novo valor + * @param sheet - + * pasta da planilha em quest�o + * @param valor - + * valor a ser escrito na celula */ public void informarValorCelula(String celula, Dispatch sheet, String valor) { @@ -145,14 +149,14 @@ public void informarValorCelula(String celula, Dispatch sheet, } /** - * Obtem o valor de contido em uma célula. O valor representa o conteúdo - * da propriedade Value da célula - * + * Obtem o valor de contido em uma c�lula. O valor representa o conte�do + * da propriedade Value da c�lula + * * @param celula - - * célula a ser lida - * @param sheet - - * pasta da planilha que contém a célula - * @return - conteúdo da propriedade Value + * c�lula a ser lida + * @param sheet - + * pasta da planilha que cont�m a c�lula + * @return - conte�do da propriedade Value */ public Variant obterValorCelula(String celula, Dispatch sheet) { System.out.println("Entered obterValorCelula"); @@ -163,18 +167,18 @@ public Variant obterValorCelula(String celula, Dispatch sheet) { } /** - * Obtem referência para a célua ou conjunto de células especificado no + * Obtem refer�ncia para a c�lua ou conjunto de c�lulas especificado no * parametro - * + * * @param celula - - * Referência para célula ou conjunto de células. A String - * "A1" referencia a coluna A e linha 1. A Sting "A1:A10" - * referencia as células compreendidas no intervalo entre a - * célua A1 e a célula A10 - * @param sheet - - * pasta da planilha qye contém as células - * @return - referencia para um célula ou conjunto de células, - * dependendo do parâmetro passado + * Refer�ncia para c�lula ou conjunto de c�lulas. A String + * "A1" referencia a coluna A e linha 1. A Sting "A1:A10" + * referencia as c�lulas compreendidas no intervalo entre a + * c�lua A1 e a c�lula A10 + * @param sheet - + * pasta da planilha qye cont�m as c�lulas + * @return - referencia para um c�lula ou conjunto de c�lulas, + * dependendo do par�metro passado */ public Dispatch obterCelula(String celula, Dispatch sheet) { System.out.println("Entered obterCelula"); @@ -185,13 +189,13 @@ public Dispatch obterCelula(String celula, Dispatch sheet) { } /** - * Obtem os valores de um conjunto de células - * + * Obtem os valores de um conjunto de c�lulas + * * @param celulas - - * Referência para conjunto de células - * @param sheet - - * Pasta que contém as cálulas referenciadas - * @return - Lista onde cada elemento é o valor de uma célula + * Refer�ncia para conjunto de c�lulas + * @param sheet - + * Pasta que cont�m as c�lulas referenciadas + * @return - Lista onde cada elemento � o valor de uma c�lula * referenciada na conjunto */ public List obterValoresRange(String celulas, Dispatch sheet) { @@ -200,7 +204,7 @@ public List obterValoresRange(String celulas, Dispatch sheet) { // obtem valor das celulas como um Variant Variant var = obterValorCelula(celulas, sheet); - // toString da Variant é interpretado por um StringTokenizer e os + // toString da Variant � interpretado por um StringTokenizer e os // tokens // inseridos na lista de retorno String arrayAsString = null; @@ -216,12 +220,12 @@ public List obterValoresRange(String celulas, Dispatch sheet) { } /** - * Método para execução de ação a ser executada em planilha excel. - * - * @param xl - - * Referencia para aplicação excel + * M�todo para execu��o de a��o a ser executada em planilha excel. + * + * @param xl - + * Referencia para aplica��o excel * @param sheets - - * Referencia para conjunto de pastas da planilha + * Referencia para conjunto de pastas da planilha */ public void executa(ActiveXComponent xl, Dispatch sheets) { diff --git a/src/test/com/jacob/test/powerpoint/PowerpointTest.java b/src/test/com/jacob/test/powerpoint/PowerpointTest.java index 906ce72..33342a9 100644 --- a/src/test/com/jacob/test/powerpoint/PowerpointTest.java +++ b/src/test/com/jacob/test/powerpoint/PowerpointTest.java @@ -1,11 +1,13 @@ package com.jacob.test.powerpoint; -/** - * $Id$ - * - * This is really more of a multi threaded tester +import org.junit.Test; + +/** + * $Id$ + * + * This is really more of a multi threaded tester *

- * May need to run with some command line options (including from inside Eclipse). + * 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. */ import com.jacob.activeX.ActiveXComponent; @@ -15,13 +17,14 @@ import com.jacob.test.BaseTestCase; /** - * + * * power point test program posted to sourceforge to demonstrate memory problem. * The submitter stated they had the problem on windows 2000 with office 2000 I * have been unable to duplicate on windows XP with office 2003. I am adding * this to the tree just in case we need to come back to it. *

- * This test was modified for office 2007 to synchronize communication with Excel. + * This test was modified for office 2007 to synchronize communication with + * Excel. * Office 2003 didn't require this. *

* This relies on BaseTestCase to provide the root path to the file under test @@ -36,9 +39,10 @@ public class PowerpointTest extends BaseTestCase { /** * main program that lets us run this as a test - * + * * @param args */ + @Test public void testPowerpoint() { ComThread.InitMTA(); @@ -98,7 +102,7 @@ public class PowerpointTestThread extends Thread { /** * thread constructor - * + * * @param threadID * @param comPowerpoint */ @@ -124,17 +128,17 @@ public void run() { // multi-threaded requests than office 2007 // office 2003 could handle 5 threads @ 50 iterations // office 2007 can only handle 1 thread at a time - synchronized(comPowerpoint){ - Dispatch comPresentations = Dispatch.get(comPowerpoint, - "Presentations").toDispatch(); - Dispatch comPresentation = Dispatch.call( - comPresentations, - "Open", - getWindowsFilePathToPackageResource("test" - + threadID + ".ppt", this.getClass()), - new Integer(0), new Integer(0), new Integer(0)) - .toDispatch(); - Dispatch.call(comPresentation, "Close"); + synchronized (comPowerpoint) { + Dispatch comPresentations = Dispatch.get(comPowerpoint, + "Presentations").toDispatch(); + Dispatch comPresentation = Dispatch.call( + comPresentations, + "Open", + getWindowsFilePathToPackageResource("test" + + threadID + ".ppt", this.getClass()), + new Integer(0), new Integer(0), new Integer(0)) + .toDispatch(); + Dispatch.call(comPresentation, "Close"); } } } catch (ComFailException cfe) { diff --git a/src/test/com/jacob/test/safearray/SafeArrayBasicTest.java b/src/test/com/jacob/test/safearray/SafeArrayBasicTest.java index 96e210686d74b78e8ddd56ef4a68cad0d4ebba72..329adb2cbdc122645d61e8293df00d689ae44192 100644 GIT binary patch literal 20888 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 * 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 @@ -87,6 +89,7 @@ public static void printArray(char a[]) { System.out.println("]"); } + @Test public void testSafeArrayContents() { // int System.out.println("Int"); diff --git a/src/test/com/jacob/test/safearray/SafeArrayDispatchTest.java b/src/test/com/jacob/test/safearray/SafeArrayDispatchTest.java index 43796f8..f1681cc 100644 --- a/src/test/com/jacob/test/safearray/SafeArrayDispatchTest.java +++ b/src/test/com/jacob/test/safearray/SafeArrayDispatchTest.java @@ -1,5 +1,7 @@ package com.jacob.test.safearray; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.Dispatch; @@ -11,6 +13,7 @@ * Test class to verify dispatch with SafeArray */ public class SafeArrayDispatchTest extends BaseTestCase { + @Test public void testDispatchWithSafeArray() { try { String scriptCommand = "1+(2*4)-3"; diff --git a/src/test/com/jacob/test/safearray/SafeArrayLeak.java b/src/test/com/jacob/test/safearray/SafeArrayLeakTest.java similarity index 97% rename from src/test/com/jacob/test/safearray/SafeArrayLeak.java rename to src/test/com/jacob/test/safearray/SafeArrayLeakTest.java index f0405bc..f98093a 100644 --- a/src/test/com/jacob/test/safearray/SafeArrayLeak.java +++ b/src/test/com/jacob/test/safearray/SafeArrayLeakTest.java @@ -1,5 +1,7 @@ package com.jacob.test.safearray; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComThread; import com.jacob.com.Dispatch; @@ -19,13 +21,14 @@ * cycle. Running the same program with setString(r,c,String) does not show the * same symptoms */ -public class SafeArrayLeak extends BaseTestCase { +public class SafeArrayLeakTest extends BaseTestCase { /** * ---------------------------------------------------------------------------------------------------------------------------- - * + * * ---------------------------------------------------------------------------------------------------------------------------- */ + @Test public void testLeakWithSetString() { ActiveXComponent xl = null; diff --git a/src/test/com/jacob/test/safearray/SafeArrayReleaseTest.java b/src/test/com/jacob/test/safearray/SafeArrayReleaseTest.java index 1ea6de3..4d3245f 100644 --- a/src/test/com/jacob/test/safearray/SafeArrayReleaseTest.java +++ b/src/test/com/jacob/test/safearray/SafeArrayReleaseTest.java @@ -1,5 +1,7 @@ package com.jacob.test.safearray; +import org.junit.Test; + import com.jacob.com.ComThread; import com.jacob.com.SafeArray; import com.jacob.com.Variant; @@ -14,38 +16,38 @@ * SF 1085370 In my understatnding, an instance of SafeArray java class has a * value of a pointer to VARIANT structure that contains a pointer to a * SAFEARRAY strucuture. - * + * * On the other hand, we can create a Variant object from the SafeArray object * like this: SafeArray sa = ...; Variant val = new Variant(sa); the val object * has a pointer to another VARIANT structure that contains a pointer to the * same SAFEARRAY structure. - * + * * In this case, the val object has a pointer to another VARIANT that contains a * pointer to the same SAFEARRAY like this: - * + * * +-----------+ |SafeArray | +------------+ | m_pV--->VARIANT(a) | * +-----------+ | VT_ARRAY| +---------+ | parray---->SAFEARRAY| +------------+ * +^--------+ | +-----------+ | |Variant | +------------+ | | * m_pVariant--->VARIANT(b) | | +-----------+ | VT_ARRAY| | | parray-----+ * +------------+ - * + * * When previous objects are rereased by ComThread.Release(), first the * VARIANT(a) is released by VariantClear() function, and second the VARIANT(b) * is released by VariantClear() function too. But the SAFEARRAY was already * released by the VARIANT(a). - * + * * So, in my enviroment (WinXP + J2SDK 1.4.1) the following java program is * sometimes crash with EXCEPTION_ACCESS_VIOLATION. - * - * + * + * * To solve this problem, it is nessesary to copy the SAFEARRAY like this: - * + * * +-----------+ |Variant | +------------+ | m_pVariant--->VARIANT(a) | * +-----------+ | VT_ARRAY| +---------+ | parray---->SAFEARRAY| +------------+ * +|--------+ | +-----------+ | copySA() |SafeArray | +------------+ | | * m_pV--->VARIANT(b) | V +-----------+ | VT_ARRAY| +---------+ | * parray---->SAFEARRAY| +------------+ +---------+ - * + * *

* 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 @@ -58,6 +60,7 @@ public class SafeArrayReleaseTest extends BaseTestCase { /** * verifies the release works on SafeArray */ + @Test public void testSaveArrayRelease() { int count; System.out.println("Starting test for max = " + MAX); diff --git a/src/test/com/jacob/test/safearray/SafeArrayStringConstructorTest.java b/src/test/com/jacob/test/safearray/SafeArrayStringConstructorTest.java index 293bf6e..3423616 100644 --- a/src/test/com/jacob/test/safearray/SafeArrayStringConstructorTest.java +++ b/src/test/com/jacob/test/safearray/SafeArrayStringConstructorTest.java @@ -1,11 +1,13 @@ package com.jacob.test.safearray; +import org.junit.Test; + import com.jacob.com.SafeArray; import com.jacob.test.BaseTestCase; /** * Test case provided #41 Fix for SafeArray(String) constructor - * + * * In the current release of Jacob, SafeArray.java contains a constructor which * takes a string as a single argument. The documentation claims that this * method converts a string to a VT_UI1 array. Using this method as written @@ -13,6 +15,8 @@ * from Java chars, which are 16-bit unsigned integers (which would be VT_UI2). */ public class SafeArrayStringConstructorTest extends BaseTestCase { + + @Test public void testStringConstructor() { // The line below will throw ComFailException using jacob 1.17-M2 // without the patch. diff --git a/src/test/com/jacob/test/safearray/SafeArrayViaExcel.java b/src/test/com/jacob/test/safearray/SafeArrayViaExcelTest.java similarity index 96% rename from src/test/com/jacob/test/safearray/SafeArrayViaExcel.java rename to src/test/com/jacob/test/safearray/SafeArrayViaExcelTest.java index d71a612..9ff6bee 100644 --- a/src/test/com/jacob/test/safearray/SafeArrayViaExcel.java +++ b/src/test/com/jacob/test/safearray/SafeArrayViaExcelTest.java @@ -1,5 +1,7 @@ package com.jacob.test.safearray; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.Dispatch; import com.jacob.com.SafeArray; @@ -15,11 +17,12 @@ *

* This relies on BaseTestCase to provide the root path to the file under test */ -public class SafeArrayViaExcel extends BaseTestCase { +public class SafeArrayViaExcelTest extends BaseTestCase { /** * verify safe arrays work with standard applications, Excel in this case */ + @Test public void testSafeArrayViaExcel() { ActiveXComponent xl = new ActiveXComponent("Excel.Application"); diff --git a/src/test/com/jacob/test/vbscript/ScriptTest.java b/src/test/com/jacob/test/vbscript/ScriptTest.java index 755f8d4..cc6314a 100644 --- a/src/test/com/jacob/test/vbscript/ScriptTest.java +++ b/src/test/com/jacob/test/vbscript/ScriptTest.java @@ -1,5 +1,7 @@ package com.jacob.test.vbscript; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.ComThread; @@ -18,6 +20,7 @@ */ public class ScriptTest extends BaseTestCase { + @Test public void testStupidSpeedTest() { String lang = "VBScript"; ActiveXComponent sC = new ActiveXComponent("ScriptControl"); @@ -28,6 +31,7 @@ public void testStupidSpeedTest() { } } + @Test public void testCreatingDispatchEvents() { ComThread.InitSTA(true); DispatchEvents de = null; diff --git a/src/test/com/jacob/test/vbscript/ScriptTest2.java b/src/test/com/jacob/test/vbscript/ScriptTest2.java index 0fe91ea..f7e05d2 100644 --- a/src/test/com/jacob/test/vbscript/ScriptTest2.java +++ b/src/test/com/jacob/test/vbscript/ScriptTest2.java @@ -1,5 +1,7 @@ package com.jacob.test.vbscript; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.ComThread; @@ -33,6 +35,7 @@ */ public class ScriptTest2 extends BaseTestCase { + @Test public void testScript2() { try { ComThread.InitSTA(); diff --git a/src/test/com/jacob/test/vbscript/ScriptTest2ActiveX.java b/src/test/com/jacob/test/vbscript/ScriptTest2ActiveX.java index 58c7898..b50f373 100644 --- a/src/test/com/jacob/test/vbscript/ScriptTest2ActiveX.java +++ b/src/test/com/jacob/test/vbscript/ScriptTest2ActiveX.java @@ -1,5 +1,7 @@ package com.jacob.test.vbscript; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.ComThread; @@ -37,6 +39,7 @@ public class ScriptTest2ActiveX extends BaseTestCase { public static DispatchProxy sCon = null; + @Test public void testActiveXSTA() { try { ComThread.InitSTA(); diff --git a/src/test/com/jacob/test/vbscript/ScriptTest3.java b/src/test/com/jacob/test/vbscript/ScriptTest3.java index 2745ec6..6b8608c 100644 --- a/src/test/com/jacob/test/vbscript/ScriptTest3.java +++ b/src/test/com/jacob/test/vbscript/ScriptTest3.java @@ -1,5 +1,7 @@ package com.jacob.test.vbscript; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.ComThread; @@ -28,6 +30,7 @@ public class ScriptTest3 extends BaseTestCase { public static boolean quit = false; + @Test public void testScript() { try { ComThread.InitMTA(); diff --git a/src/test/com/jacob/test/vbscript/ScriptTest3ActiveX.java b/src/test/com/jacob/test/vbscript/ScriptTest3ActiveX.java index e75b268..f05cf20 100644 --- a/src/test/com/jacob/test/vbscript/ScriptTest3ActiveX.java +++ b/src/test/com/jacob/test/vbscript/ScriptTest3ActiveX.java @@ -1,5 +1,7 @@ package com.jacob.test.vbscript; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.ComThread; @@ -24,6 +26,7 @@ public class ScriptTest3ActiveX extends BaseTestCase { public static boolean quit = false; + @Test public void testYetAnotherScriptTest() { try { ComThread.InitMTA(); diff --git a/src/test/com/jacob/test/vbscript/ScriptTestActiveX.java b/src/test/com/jacob/test/vbscript/ScriptTestActiveX.java index 210db85..187437b 100644 --- a/src/test/com/jacob/test/vbscript/ScriptTestActiveX.java +++ b/src/test/com/jacob/test/vbscript/ScriptTestActiveX.java @@ -1,5 +1,7 @@ package com.jacob.test.vbscript; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComException; import com.jacob.com.ComThread; @@ -16,6 +18,8 @@ * options. */ public class ScriptTestActiveX extends BaseTestCase { + + @Test public void testActiveXScript() { ComThread.InitSTA(true); DispatchEvents de = null; diff --git a/src/test/com/jacob/test/vbscript/ScriptTestErrEvents.java b/src/test/com/jacob/test/vbscript/ScriptTestErrEvents.java index c0700bf..ce829a1 100644 --- a/src/test/com/jacob/test/vbscript/ScriptTestErrEvents.java +++ b/src/test/com/jacob/test/vbscript/ScriptTestErrEvents.java @@ -1,13 +1,12 @@ package com.jacob.test.vbscript; import com.jacob.com.Variant; -import com.jacob.test.BaseTestCase; /** * Extracted from ScriptTest so everyone can see this Made a test solely because * it made the ant test easier */ -public class ScriptTestErrEvents extends BaseTestCase { +public class ScriptTestErrEvents { public void Error(Variant[] args) { System.out.println("java callback for error!"); diff --git a/src/test/com/jacob/test/windowsmedia/WMPlayer.java b/src/test/com/jacob/test/windowsmedia/WMPlayer.java index 0cd6237..3326201 100644 --- a/src/test/com/jacob/test/windowsmedia/WMPlayer.java +++ b/src/test/com/jacob/test/windowsmedia/WMPlayer.java @@ -7,12 +7,14 @@ *

* this doesn't actually play for some reason. It always says the length is 0. *

- * May need to run with some command line options (including from inside Eclipse). + * 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. *

*/ import java.io.File; +import org.junit.Test; + import com.jacob.activeX.ActiveXComponent; import com.jacob.com.Dispatch; import com.jacob.com.Variant; @@ -23,6 +25,7 @@ public class WMPlayer extends BaseTestCase { /** * This should demo the media player but it doesn't */ + @Test public void testOpenWMPlayer() { // this file exists in windows 7 installations File file = new File(