Search in sources :

Example 1 with TestLinkAPI

use of br.eti.kinoshita.testlinkjavaapi.TestLinkAPI in project elastest-torm by elastest.

the class TestLinkService method init.

@PostConstruct
public void init() {
    if (!etEtmTestLinkHost.equals("none")) {
        if (etEtmTestLinkServiceName.equals(etEtmTestLinkHost)) {
            etEtmTestLinkHost = etEtmTestLinkContainerName;
        }
        try {
            // Default development
            this.testLinkHost = this.dockerService.getContainerIpByNetwork(etEtmTestLinkHost, etDockerNetwork);
            this.testLinkPort = etEtmTestLinkPort;
            // If not development, start socat
            if (!etPublicHost.equals("localhost")) {
                try {
                    String testLinkIp = UtilTools.doPing(etEtmTestLinkHost);
                    logger.info("Real TestLink Ip: {}", testLinkIp);
                    SocatBindedPort socatBindedPort = dockerService.bindingPort(testLinkIp, etEtmTestLinkPort, etDockerNetwork);
                    this.testLinkHost = etPublicHost;
                    this.testLinkPort = socatBindedPort.getListenPort();
                } catch (Exception e) {
                    logger.error("Cannot get Testlink socat data", e);
                    this.testLinkHost = etEtmTestLinkHost;
                    this.testLinkPort = etEtmTestLinkPort;
                }
            }
            String url = this.getTestLinkUrl() + "/lib/api/xmlrpc/v1/xmlrpc.php";
            try {
                testlinkURL = new URL(url);
            } catch (MalformedURLException mue) {
                mue.printStackTrace();
            }
            try {
                api = new TestLinkAPI(testlinkURL, devKey);
            } catch (TestLinkAPIException te) {
                logger.error(te.getMessage());
            }
        } catch (Exception e) {
            logger.error("Cannot get TestLink container ip");
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) TestLinkAPIException(br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException) SocatBindedPort(io.elastest.etm.model.SocatBindedPort) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) MalformedURLException(java.net.MalformedURLException) TestLinkAPIException(br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException) URL(java.net.URL) TestLinkAPI(br.eti.kinoshita.testlinkjavaapi.TestLinkAPI) PostConstruct(javax.annotation.PostConstruct)

Aggregations

TestLinkAPI (br.eti.kinoshita.testlinkjavaapi.TestLinkAPI)1 TestLinkAPIException (br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException)1 SocatBindedPort (io.elastest.etm.model.SocatBindedPort)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 PostConstruct (javax.annotation.PostConstruct)1 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)1