kinow / testlink-java-api

TestLink Java API
http://kinow.github.io/testlink-java-api/
MIT License
64 stars 88 forks source link

Exception thrown when calling createTestCase() #35

Closed fmlyman02 closed 5 years ago

fmlyman02 commented 10 years ago

I've created some simple calls to the api method's. Here's a snippet:

TestSuite ts = null;
TestCase  tc = null;
TestProject project = null;
TestPlan tp = null;

 // Create a Test Project  
        try {
                project = api.createTestProject(
                                "TestLink Java API Test", //testProjectName
                                "TJAT", //testProjectPrefix
                                "Testing Java API Intergration", //notes
                                true, //enableRequirements
                                true, //enableTestPriority
                                true, //enableAutomation
                                false, //enableInventory
                                true, //isActive
                                false); //isPublic
        } catch (TestLinkAPIException e) {
                e.printStackTrace( System.err );
                System.exit(-1);
        }       

    // Create a Test Plan
    try {
         tp = api.createTestPlan("TestLink API Test Plan", "TestLink Java API Project", "Testing TestLink JAVA API", true, false);       
    } catch (TestLinkAPIException e) {
            e.printStackTrace( System.err );
            System.exit(-1);
    }       

    // Create Test Suite
    try {
       TestProject testLinkProject = api.getTestProjectByName("TestLink Java API Project");

       ts = api.createTestSuite(testLinkProject.getId(), "TestLink TestSuite", "Testing TestLink JAVA API library integration", null, 1, true, ActionOnDuplicate.CREATE_NEW_VERSION);
       System.out.println( "Created Test Suite: " + ts.getName() );
    } catch (TestLinkAPIException e) {
       e.printStackTrace( System.err );
       System.exit(1);
    }       

  // Create Test Case
    List<TestCaseStep> steps = new ArrayList<TestCaseStep>();
    TestCaseStep step = new TestCaseStep();
    step.setNumber(1);
    step.setExpectedResults("User name appeared in top menu.");
    step.setExecutionType(null);
    step.setActions("Go to login screen and enter user credentials.");
    steps.add(step);

    try {
    tc = api.createTestCase("TestLink TestCase", ts.getId(), project.getId(), "ValidUserLogin", "TestLink TestCase Summary", steps, null, null, null, new Integer(10), null, true, ActionOnDuplicate.GENERATE_NEW);
   } catch (TestLinkAPIException e) {
      e.printStackTrace( System.err );
      System.exit(1);
   }
   }

The problem I am encountering is that this appears to create the test case successfully, but the code throws an exception.

Exception I am seeing is:

Exception in thread "main" br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException: Error creating test plan: Failed to parse server's response: Expected methodResponse element, got pre
at br.eti.kinoshita.testlinkjavaapi.TestCaseService.createTestCase(TestCaseService.java:128)
at br.eti.kinoshita.testlinkjavaapi.TestLinkAPI.createTestCase(TestLinkAPI.java:742)
at com.directv.TestLinkCheck.main(TestLinkCheck.java:140)
Caused by: org.apache.xmlrpc.client.XmlRpcClientException: Failed to parse server's response: Expected methodResponse element, got pre
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:188)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at br.eti.kinoshita.testlinkjavaapi.BaseService.executeXmlRpcCall(BaseService.java:90)
at br.eti.kinoshita.testlinkjavaapi.TestCaseService.createTestCase(TestCaseService.java:119)
... 2 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 6; Expected methodResponse element, got pre
at org.apache.xmlrpc.parser.XmlRpcResponseParser.startElement(XmlRpcResponseParser.java:101)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:186)
... 11 more

If someone could provide me with some insight of what I may be doing wrong in the call, that would really help my understanding of the usage. Thanks

kinow commented 5 years ago

Closing as outdated (mea culpa for not looking into it earlier).

Tested with the following code:

        TestCase createdTestCase = api.createTestCase("My TC", testSuiteId, testProjectId, "admin", "Created!", Collections.emptyList(), null,
                TestCaseStatus.FINAL, TestImportance.HIGH, ExecutionType.AUTOMATED, 1, null, false, null);
        System.out.println(createdTestCase);

Which contains just the last part of your example code. The response:

TestCase [id=6, name=My TC, testSuiteId=2, testProjectId=1, authorLogin=admin, summary=Created!, steps=[], preconditions=null, testCaseStatus=7, testImportance=3, executionType=2, executionOrder=null, order=1, internalId=null, fullExternalId=null, checkDuplicatedName=false, actionOnDuplicatedName=null, versionId=null, version=1, parentId=null, customFields=null, executionStatus=null, platform=null, featureId=null, keywords= null]

Tested with latest code, almost ready to be released and compatible with 1.9.19.