I'm currently trying out the testlink java api and have looked at some sample code of how to create a simple test case. I've found this example from http://testlinkjavaapi.sourceforge.net:
Code: Select all
List<TestCaseStep> steps = new ArrayList<TestCaseStep>();
TestCaseStep step = new TestCaseStep();
step.setNumber(1);
step.setExpectedResults("User name appeared in top menu.");
step.setExecutionType(ExecutionType.MANUAL);
step.setActions("Go to login screen and enter user credentials.");
steps.add(step);
TestCase tc = api.createTestCase(
"TcName", // testCaseName
new Integer(2), // testSuiteId
new Integer(1), // testProjectId
"admin", // authorLogin
"No summary", // summary
steps, // steps
null, // preconditions
TestImportance.HIGH, // importance
ExecutionType.MANUAL, // execution
new Integer(10), // order
null, // internalId
null, // checkDuplicatedName
null); // actionOnDuplicatedName
System.out.println("Test case with steps created");
Code: Select all
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);
}
}
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 me understand.
Thank You in advance for your precious time.