B-1_14-DEV merge back to main

This commit is contained in:
clay_shooter
2008-02-02 01:38:25 +00:00
parent cd58b57a99
commit df0ba33797
97 changed files with 12208 additions and 8816 deletions

View File

@@ -1,8 +1,12 @@
package com.jacob.test.vbscript;
import com.jacob.com.*;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComException;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.DispatchEvents;
import com.jacob.com.Variant;
import com.jacob.test.BaseTestCase;
import com.jacob.activeX.*;
/**
* In this case the component is created and used in the same thread and it's an
@@ -33,7 +37,7 @@ public class ScriptTest extends BaseTestCase {
String scriptCommand = getSampleVPScriptForEval();
String lang = "VBScript";
ActiveXComponent sC = new ActiveXComponent("ScriptControl");
sControl = (Dispatch) sC.getObject();
sControl = sC.getObject();
Dispatch.put(sControl, "Language", lang);
ScriptTestErrEvents te = new ScriptTestErrEvents();
de = new DispatchEvents(sControl, te);

View File

@@ -1,8 +1,14 @@
package com.jacob.test.vbscript;
import com.jacob.com.*;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComException;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.DispatchEvents;
import com.jacob.com.DispatchProxy;
import com.jacob.com.STA;
import com.jacob.com.Variant;
import com.jacob.test.BaseTestCase;
import com.jacob.activeX.*;
/**
* This example demonstrates how to make calls between two different STA's.
@@ -21,8 +27,9 @@ import com.jacob.activeX.*;
* multiple threads to access a Dispatch pointer, then create that many
* DispatchProxy objects.
* <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.
* 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.
*/
public class ScriptTest2 extends BaseTestCase {
@@ -31,8 +38,8 @@ public class ScriptTest2 extends BaseTestCase {
ComThread.InitSTA();
ScriptTestSTA script = new ScriptTestSTA();
try {
Thread.sleep(1000);
} catch (InterruptedException ie){
Thread.sleep(1000);
} catch (InterruptedException ie) {
// should we get this?
}
@@ -50,7 +57,7 @@ public class ScriptTest2 extends BaseTestCase {
System.out.println("called quit");
} catch (ComException e) {
e.printStackTrace();
fail("caught exception"+e);
fail("caught exception" + e);
} finally {
Integer I = null;
for (int i = 1; i < 1000000; i++) {
@@ -63,11 +70,11 @@ public class ScriptTest2 extends BaseTestCase {
public class ScriptTestSTA extends STA {
public DispatchEvents de = null;
public DispatchEvents de = null;
public Dispatch sControl = null;
public Dispatch sControl = null;
public DispatchProxy sCon = null;
public DispatchProxy sCon = null;
public boolean OnInit() {
try {

View File

@@ -26,8 +26,9 @@ import com.jacob.test.BaseTestCase;
* multiple threads to access a Dispatch pointer, then create that many
* DispatchProxy objects.
* <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.
* 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.
*/
public class ScriptTest2ActiveX extends BaseTestCase {
public static ActiveXComponent sC;
@@ -42,9 +43,9 @@ public class ScriptTest2ActiveX extends BaseTestCase {
ScriptTest2ActiveXSTA script = new ScriptTest2ActiveXSTA();
try {
Thread.sleep(1000);
} catch (InterruptedException ie){
// should we get this?
}
} catch (InterruptedException ie) {
// should we get this?
}
// get a thread-local Dispatch from sCon
ActiveXComponent sc = new ActiveXComponent(sCon.toDispatch());
@@ -60,7 +61,7 @@ public class ScriptTest2ActiveX extends BaseTestCase {
System.out.println("called quit");
} catch (ComException e) {
e.printStackTrace();
fail("blew up with Com Exception "+e);
fail("blew up with Com Exception " + e);
} finally {
Integer I = null;
for (int i = 1; i < 1000000; i++) {

View File

@@ -1,8 +1,12 @@
package com.jacob.test.vbscript;
import com.jacob.com.*;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComException;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.DispatchEvents;
import com.jacob.com.Variant;
import com.jacob.test.BaseTestCase;
import com.jacob.activeX.*;
/**
* Here we create the ScriptControl component in a separate MTA thread and then
@@ -10,8 +14,9 @@ import com.jacob.activeX.*;
* MTA thread. If you try to create it as an STA then you will not be able to
* make calls into a component running in another thread.
* <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.
* 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.
*/
public class ScriptTest3 extends BaseTestCase {
@@ -29,13 +34,15 @@ public class ScriptTest3 extends BaseTestCase {
ScriptTest3Inner script = new ScriptTest3Inner();
script.start();
try {
Thread.sleep(1000);
} catch (InterruptedException ie){
Thread.sleep(1000);
} catch (InterruptedException ie) {
// should we get this?
}
Variant result = Dispatch.call(sControl, "Eval", getSampleVPScriptForEval());
System.out.println("eval(" + getSampleVPScriptForEval() + ") = " + result);
Variant result = Dispatch.call(sControl, "Eval",
getSampleVPScriptForEval());
System.out.println("eval(" + getSampleVPScriptForEval() + ") = "
+ result);
System.out.println("setting quit");
ScriptTest3.quit = true;
} catch (ComException e) {
@@ -54,13 +61,14 @@ public class ScriptTest3 extends BaseTestCase {
System.out.println("OnInit");
String lang = "VBScript";
sC = new ActiveXComponent("ScriptControl");
sControl = (Dispatch) sC.getObject();
sControl = sC.getObject();
Dispatch.put(sControl, "Language", lang);
ScriptTestErrEvents te = new ScriptTestErrEvents();
de = new DispatchEvents(sControl, te);
System.out.println("sControl=" + sControl);
while (!quit)
while (!quit) {
sleep(100);
}
ComThread.Release();
} catch (Exception e) {
e.printStackTrace();

View File

@@ -1,8 +1,11 @@
package com.jacob.test.vbscript;
import com.jacob.com.*;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComException;
import com.jacob.com.ComThread;
import com.jacob.com.DispatchEvents;
import com.jacob.com.Variant;
import com.jacob.test.BaseTestCase;
import com.jacob.activeX.*;
/**
* Here we create the ScriptControl component in a separate MTA thread and then
@@ -33,9 +36,8 @@ public class ScriptTest3ActiveX extends BaseTestCase {
}
Variant result = sC.invoke("Eval", getSampleVPScriptForEval());
System.out
.println("eval(" + getSampleVPScriptForEval()
+ ") = " + result);
System.out.println("eval(" + getSampleVPScriptForEval() + ") = "
+ result);
System.out.println("setting quit");
ScriptTest3ActiveX.quit = true;
} catch (ComException e) {
@@ -58,8 +60,9 @@ public class ScriptTest3ActiveX extends BaseTestCase {
ScriptTestErrEvents te = new ScriptTestErrEvents();
de = new DispatchEvents(sC, te);
System.out.println("sControl=" + sC);
while (!quit)
while (!quit) {
sleep(100);
}
ComThread.Release();
} catch (Exception e) {
e.printStackTrace();

View File

@@ -1,52 +1,53 @@
package com.jacob.test.vbscript;
import com.jacob.com.*;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComException;
import com.jacob.com.ComThread;
import com.jacob.com.DispatchEvents;
import com.jacob.com.Variant;
import com.jacob.test.BaseTestCase;
import com.jacob.activeX.*;
/**
* In this case the component is created and used in the same thread
* and it's an Apartment Threaded component, so we call InitSTA.
* In this case the component is created and used in the same thread and it's an
* Apartment Threaded component, so we call InitSTA.
* <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.
*/
public class ScriptTestActiveX extends BaseTestCase {
public void testActiveXScript() {
public void testActiveXScript() {
ComThread.InitSTA(true);
DispatchEvents de = null;
DispatchEvents de = null;
try {
String lang = "VBScript";
ActiveXComponent sC = new ActiveXComponent("ScriptControl");
sC.setProperty("Language",lang);
ScriptTestErrEvents te = new ScriptTestErrEvents();
de = new DispatchEvents(sC, te);
if (de == null){
System.out.println("null returned when trying to create DispatchEvents");
}
Variant result;
result = sC.invoke("Eval",getSampleVPScriptForEval());
// call it twice to see the objects reused
result = sC.invoke("Eval",getSampleVPScriptForEval());
// call it 3 times to see the objects reused
result = sC.invoke("Eval",getSampleVPScriptForEval());
System.out.println("eval("+getSampleVPScriptForEval()+") = "+ result);
} catch (ComException e) {
e.printStackTrace();
}
finally
{
Integer I = null;
for(int i=1;i<1000000;i++)
{
I = new Integer(i);
}
System.out.println(I);
try {
String lang = "VBScript";
ActiveXComponent sC = new ActiveXComponent("ScriptControl");
sC.setProperty("Language", lang);
ScriptTestErrEvents te = new ScriptTestErrEvents();
de = new DispatchEvents(sC, te);
if (de == null) {
System.out
.println("null returned when trying to create DispatchEvents");
}
Variant result;
result = sC.invoke("Eval", getSampleVPScriptForEval());
// call it twice to see the objects reused
result = sC.invoke("Eval", getSampleVPScriptForEval());
// call it 3 times to see the objects reused
result = sC.invoke("Eval", getSampleVPScriptForEval());
System.out.println("eval(" + getSampleVPScriptForEval() + ") = "
+ result);
} catch (ComException e) {
e.printStackTrace();
} finally {
Integer I = null;
for (int i = 1; i < 1000000; i++) {
I = new Integer(i);
}
System.out.println(I);
ComThread.Release();
ComThread.quitMainSTA();
}
}
}
}
}

View File

@@ -4,17 +4,16 @@ 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
* 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 void Error(Variant[] args)
{
System.out.println("java callback for error!");
}
public void Timeout(Variant[] args)
{
System.out.println("java callback for error!");
}
public void Error(Variant[] args) {
System.out.println("java callback for error!");
}
public void Timeout(Variant[] args) {
System.out.println("java callback for error!");
}
}