77 lines
2.4 KiB
Java
77 lines
2.4 KiB
Java
package org.gcube.spatial.data.sdi.test;
|
|
|
|
import static org.junit.Assume.assumeTrue;
|
|
|
|
import java.net.MalformedURLException;
|
|
import java.nio.file.Paths;
|
|
import java.util.List;
|
|
|
|
import javax.ws.rs.core.Application;
|
|
import javax.ws.rs.core.GenericType;
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
import org.gcube.sdi.test.GCubeSDITest;
|
|
import org.gcube.spatial.data.sdi.LocalConfiguration;
|
|
import org.gcube.spatial.data.sdi.SDIService;
|
|
import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
|
import org.gcube.spatial.data.sdi.model.metadata.TemplateDescriptor;
|
|
import org.glassfish.jersey.test.JerseyTest;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.Test;
|
|
|
|
public class MainTest extends JerseyTest implements GCubeSDITest{
|
|
|
|
// @BeforeClass
|
|
// public static void init() throws MalformedURLException {
|
|
// LocalConfiguration.init(Paths.get("src/main/webapp/WEB-INF/config.properties").toUri().toURL());
|
|
// }
|
|
|
|
|
|
@Override
|
|
protected Application configure() {
|
|
return new SDIService();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
public void getConfiguration(){
|
|
assumeTrue(isTestInfrastructureEnabled());
|
|
System.out.println(target(ServiceConstants.INTERFACE).request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
|
}
|
|
//
|
|
@Test
|
|
public void getGeoServer(){
|
|
assumeTrue(isTestInfrastructureEnabled());
|
|
System.out.println(target(ServiceConstants.GeoServer.INTERFACE).path("configuration/geoserver1.dev.d4science.org").request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
|
}
|
|
|
|
@Test
|
|
public void testGetTemplateList(){
|
|
assumeTrue(isTestInfrastructureEnabled());
|
|
List<TemplateDescriptor> result=target(ServiceConstants.Metadata.INTERFACE).
|
|
path(ServiceConstants.Metadata.LIST_METHOD).
|
|
request(MediaType.APPLICATION_JSON_TYPE).get().
|
|
readEntity(new GenericType<List<TemplateDescriptor>>() {});
|
|
System.out.println(result);
|
|
}
|
|
|
|
@Test
|
|
public void testHealthReport() {
|
|
assumeTrue(isTestInfrastructureEnabled());
|
|
System.out.println(target(ServiceConstants.INTERFACE).path("status").request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
|
System.out.println(target(ServiceConstants.INTERFACE).path("status").request(MediaType.APPLICATION_XML_TYPE).get(String.class));
|
|
}
|
|
|
|
|
|
//
|
|
// @Test
|
|
// public void getSwagger(){
|
|
// String path="gcube/service/swagger.json";
|
|
// System.out.println(target(path).getUri());
|
|
// System.out.println(target(path).request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
|
// }
|
|
}
|