2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.cdm
.remote
;
11 import org
.apache
.logging
.log4j
.LogManager
;
12 import org
.apache
.logging
.log4j
.Logger
;
13 import org
.junit
.Assert
;
14 import org
.junit
.Before
;
15 import org
.springframework
.web
.client
.RestTemplate
;
18 * @author a.kohlbecker
21 public class WebServiceTestBase
extends Assert
{
23 private static final Logger logger
= LogManager
.getLogger();
25 private int port
= 9180;
26 private String baseUri
= "";
28 RestTemplate template
= new RestTemplate();
32 if(System
.getProperty("sun.java.command") != null && System
.getProperty("sun.java.command").startsWith("org.eclipse.jdt.internal.junit.runner.RemoteTestRunner")){
34 logger
.info(" setUp() : \n" +
35 "==================================================================\n" +
36 " Eclipse ide detected, expecting cdm remote instance at port 8080 \n" +
37 "==================================================================");
39 baseUri
= String
.format("http://localhost:%1$d", port
);
40 logger
.info("cdm remote instance url: " + baseUri
);
43 public String
getBaseUri() {
47 public String
httpGetJson(String endPoint
, String query
) {
48 StringBuilder uri
= new StringBuilder(baseUri
);
49 if(endPoint
!= null) {
53 uri
.append("?").append(query
);
55 logger
.debug("httpGetJson: " + uri
.toString());
56 return template
.getForObject(uri
.toString(), String
.class);