Created
October 24, 2011 00:34
-
-
Save kinow/1308128 to your computer and use it in GitHub Desktop.
TestLink Java API BaseTest for TestNG tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.eti.kinoshita.testlinkjavaapi; | |
import java.io.File; | |
import java.io.IOException; | |
import java.net.URL; | |
import org.apache.commons.io.FileUtils; | |
import org.testng.annotations.AfterClass; | |
import org.testng.annotations.BeforeClass; | |
public class BaseTest | |
{ | |
protected TestLinkAPI api; | |
protected HttpTestServer server; | |
/** | |
* Set up method that creates the instance of the TestLink API. | |
*/ | |
@BeforeClass | |
protected void setUp() | |
throws Exception | |
{ | |
this.server = new HttpTestServer(); | |
this.loadXMLRPCMockData( "tl.checkDevKey.xml" ); | |
this.server.start(); | |
this.api = new TestLinkAPI(new URL("http://localhost:"+this.server.getPort()+"/testlink/lib/api/xmlrpc.php"), "devKey"); | |
} | |
public void loadXMLRPCMockData( String xmlFile ) | |
{ | |
URL url = getClass().getResource( "/br/eti/kinoshita/testlinkjavaapi/testdata/" + xmlFile ); | |
String filePath = url.getFile(); | |
File file = new File(filePath); | |
String mockXml; | |
try | |
{ | |
mockXml = FileUtils.readFileToString(file); | |
} catch (IOException e) | |
{ | |
throw new RuntimeException(e); | |
} | |
this.server.setMockResponseBody(mockXml); | |
} | |
@AfterClass(alwaysRun=true) | |
public void tearDown() | |
throws Exception | |
{ | |
this.server.stop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment