Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Help needed. Using JACOB with ALM OTA.

Help
2012-07-16
2013-05-20
  • I have created a piece of code in vbscript through which I am able to create test scripts in ALM via OTA. Now I am trying to do the same thing through Java using JACOB as the Java 2 Com bridge and I have been able to create an empty test script using this, but I am not sure how to set the various field values.

    VBScript Code (That works perfectly):

               Set tdc = CreateObject("TDAPIOLE80.TDConnection")
               If (tdc Is Nothing) Then
                 MSGBOX "Connection is not created"
               Else
                MSGBOX "Connection is created"
               End If
               tdc.InitConnectionEx connectionString
               tdc.Login userName, password
               tdc.Connect domain, project
               Set TreeMgr = tdc.TreeManager
               Set testFolder = TreeMgr.NodeByPath(uploadDirectoryPath)
               Set testFactory = testFolder.TestFactory
               Set testItem = testFactory.AddItem (NULL)
               testItem.Field("TS_DESCRIPTION")="Test script description"
               …

    Java code (Only that much that works)

         ActiveXComponent almConnection=new ActiveXComponent("TDAPIOLE80.TDConnection");
        Dispatch.call(almConnection, "InitConnectionEx", "conn string");       
        Dispatch.call(almConnection, "login", "uname","pword");
        Dispatch.call(almConnection, "connect","project","domain");    
        Dispatch treeMgr=Dispatch.get(almConnection, "TreeManager").toDispatch();
        Dispatch testFolder=Dispatch.call(treeMgr,"NodeByPath", "project path").toDispatch();
        Dispatch testFactory=Dispatch.get(testFolder, "TestFactory").toDispatch();             
        Dispatch testItem=Dispatch.call(testFactory,"AddItem","TO_BE_DELETED_SCRIPT9").toDispatch();

    Now the issue is the last line in the VBScript code,

                testItem.Field("TS_DESCRIPTION")="Test script description"

    How do I code this in Java using JACOB? Please help. I have done a lot of google searching, but haven't found anything substantial.

     
  • BrianDrian
    BrianDrian
    2012-12-29

    Variant v = Dispatch.invoke(testItem,
    "Field",
    Dispatch.Put,
    new Object {TS_DESCRIPTION, new Variant ("Any desription you need")},
    new int);

    jobs a good un.

     
  • BrianDrian
    BrianDrian
    2012-12-29

    TS_DESCRIPTION should be quoted

    "TS_DESCRIPTION"