Testing
This commit is contained in:
parent
3403f04e6e
commit
096165d7f2
|
@ -11,7 +11,7 @@ import org.gcube.spatial.data.clients.model.engine.Engine;
|
|||
import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GSTests implements GCubeSDITest{
|
||||
public class GSTests extends GCubeSDITest{
|
||||
|
||||
|
||||
protected GSRESTClient getClient() throws RemoteException, Exception {
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.spatial.data.sdi;
|
|||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
|
@ -13,9 +14,10 @@ import org.gcube.spatial.data.sdi.model.metadata.TemplateInvocationBuilder;
|
|||
import org.gcube.spatial.data.sdi.plugins.SDIAbstractPlugin;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MetadataTests implements GCubeSDITest{
|
||||
public class MetadataTests extends GCubeSDITest{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void getAvailableTemplatesTest() throws IllegalArgumentException, URISyntaxException{
|
||||
|
@ -29,18 +31,46 @@ public class MetadataTests implements GCubeSDITest{
|
|||
@Test
|
||||
public void pushMetadata() throws IllegalArgumentException, URISyntaxException{
|
||||
assumeTrue(isTestInfrastructureEnabled());
|
||||
File toPubilsh=Paths.get("src/test/resources/toEnrichMeta.xml").toFile();
|
||||
File metadata=Paths.get("src/test/resources/toPublishMeta").toFile();
|
||||
|
||||
// Metadata meta=SDIAbstractPlugin.metadata().at(new URI("http://"+sdiHostname+"/sdi-service/gcube/service")).build();
|
||||
Metadata meta=SDIAbstractPlugin.metadata().build();
|
||||
System.out.println(meta.pushMetadata(toPubilsh));
|
||||
|
||||
MetadataPublishOptions opts=new MetadataPublishOptions(new TemplateInvocationBuilder().threddsOnlineResources("my_hostname", "some_dataset.nc", "myPersonalCatalog").get());
|
||||
opts.setGeonetworkCategory("service");
|
||||
opts.setValidate(false);
|
||||
System.out.println(meta.pushMetadata(toPubilsh, opts));
|
||||
for(File f:metadata.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".xml");
|
||||
}
|
||||
})) {
|
||||
|
||||
// System.out.println(meta.pushMetadata(f));
|
||||
MetadataPublishOptions opts=new MetadataPublishOptions(new TemplateInvocationBuilder().threddsOnlineResources("my_hostname", "some_dataset.nc", "myPersonalCatalog").get());
|
||||
opts.setGeonetworkCategory("service");
|
||||
opts.setValidate(false);
|
||||
System.out.println(meta.pushMetadata(f, opts));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Test
|
||||
// public void validate() throws IllegalArgumentException, URISyntaxException{
|
||||
// assumeTrue(isTestInfrastructureEnabled());
|
||||
// File metadata=Paths.get("src/test/resources/toPublishMeta").toFile();
|
||||
//
|
||||
// Metadata meta=SDIAbstractPlugin.metadata().build();
|
||||
// for(File f:metadata.listFiles(new FilenameFilter() {
|
||||
// @Override
|
||||
// public boolean accept(File dir, String name) {
|
||||
// return name.endsWith(".xml");
|
||||
// }
|
||||
// })) {
|
||||
//
|
||||
//// System.out.println(meta.pushMetadata(f));
|
||||
// MetadataPublishOptions opts=new MetadataPublishOptions(new TemplateInvocationBuilder().threddsOnlineResources("my_hostname", "some_dataset.nc", "myPersonalCatalog").get());
|
||||
// opts.setGeonetworkCategory("service");
|
||||
// opts.setValidate(false);
|
||||
// System.out.println(meta.pushMetadata(f, opts));
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
|||
import org.gcube.spatial.data.sdi.plugins.SDIAbstractPlugin;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SDITests implements GCubeSDITest{
|
||||
public class SDITests extends GCubeSDITest{
|
||||
|
||||
@Test
|
||||
public void getScopeConfiguration() throws RemoteException, IllegalArgumentException, MalformedURLException {
|
||||
|
|
|
@ -4,51 +4,21 @@ import static org.junit.Assume.assumeTrue;
|
|||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
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.data.transfer.library.client.AuthorizationFilter;
|
||||
import org.gcube.sdi.test.GCubeSDITest;
|
||||
import org.gcube.spatial.data.clients.model.engine.Engine;
|
||||
import org.gcube.spatial.data.sdi.SDIService;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.metadata.TemplateApplicationReport;
|
||||
import org.gcube.spatial.data.sdi.model.ScopeConfiguration;
|
||||
import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
||||
import org.gcube.spatial.data.sdi.model.metadata.TemplateDescriptor;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.junit.Before;
|
||||
import org.gcube.spatial.data.sdi.model.metadata.TemplateInvocationBuilder;
|
||||
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().register(RequestFilter.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void configureClient(ClientConfig config) {
|
||||
// TODO Auto-generated method stub
|
||||
super.configureClient(config);
|
||||
|
||||
config.register(AuthorizationFilter.class);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setContext() {
|
||||
assumeTrue(isTestInfrastructureEnabled());
|
||||
setTestContext();
|
||||
}
|
||||
public class MainTest extends ServiceTest{
|
||||
|
||||
|
||||
@Test
|
||||
|
@ -76,11 +46,11 @@ public class MainTest extends JerseyTest implements GCubeSDITest{
|
|||
@Test
|
||||
public void testGetTemplateList(){
|
||||
assumeTrue(isTestInfrastructureEnabled());
|
||||
target(ServiceConstants.Metadata.INTERFACE).
|
||||
List<TemplateDescriptor> result=target(ServiceConstants.Metadata.INTERFACE).
|
||||
path(ServiceConstants.Metadata.LIST_METHOD).
|
||||
request(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON).
|
||||
get(new GenericType<List<TemplateDescriptor>>() {});
|
||||
// System.out.println(result);
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -90,12 +60,20 @@ public class MainTest extends JerseyTest implements GCubeSDITest{
|
|||
System.out.println(target(ServiceConstants.INTERFACE).path("status").request(MediaType.APPLICATION_XML_TYPE).get(String.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void publishMetadata() {
|
||||
assumeTrue(isTestInfrastructureEnabled());
|
||||
|
||||
// push
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// @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));
|
||||
// private void publishMetadataFile(File toPublish) {
|
||||
// TemplateInvocationBuilder builder=new TemplateInvocationBuilder();
|
||||
// builder.threddsOnlineResources("localhost", "someFileName.sc", "newCatalog");
|
||||
// TemplateApplicationReport report=manager.applyMetadataTemplates(Paths.get("src/test/resources/xml/toEnrichMetadata.xml").toFile(), builder.get());
|
||||
// System.out.println(report);
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -7,19 +7,13 @@ import java.nio.file.Paths;
|
|||
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.gcube.sdi.test.GCubeSDITest;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.metadata.MetadataTemplateManagerImpl;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.metadata.TemplateApplicationReport;
|
||||
import org.gcube.spatial.data.sdi.model.metadata.TemplateInvocationBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MetadataApplicationTest implements GCubeSDITest{
|
||||
public class MetadataApplicationTest extends ServiceTest{
|
||||
|
||||
@Before
|
||||
public void setContext() {
|
||||
setTestContext();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package org.gcube.spatial.data.sdi.test;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
import org.gcube.data.transfer.library.client.AuthorizationFilter;
|
||||
import org.gcube.sdi.test.GCubeSDITest;
|
||||
import org.gcube.spatial.data.sdi.SDIService;
|
||||
import org.glassfish.jersey.client.ClientConfig;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
public class ServiceTest extends JerseyTest {
|
||||
|
||||
// @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().register(RequestFilter.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void configureClient(ClientConfig config) {
|
||||
// TODO Auto-generated method stub
|
||||
super.configureClient(config);
|
||||
|
||||
config.register(AuthorizationFilter.class);
|
||||
}
|
||||
|
||||
public static boolean isTestInfrastructureEnabled() {
|
||||
return GCubeSDITest.isTestInfrastructureEnabled();
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setContext() {
|
||||
assumeTrue(isTestInfrastructureEnabled());
|
||||
GCubeSDITest.setTestContext();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.sdi.test;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import org.gcube.sdi.test.client.SimpleSDIManagerClient;
|
||||
import org.gcube.spatial.data.sdi.interfaces.SDIManagement;
|
||||
import org.gcube.spatial.data.sdi.model.ScopeConfiguration;
|
||||
|
@ -7,9 +9,9 @@ import org.gcube.spatial.data.sdi.model.faults.RemoteException;
|
|||
import org.junit.BeforeClass;
|
||||
|
||||
|
||||
public interface GCubeSDITest {
|
||||
public class GCubeSDITest {
|
||||
|
||||
public default String getContext() {
|
||||
public static String getContext() {
|
||||
String testContext=System.getProperty("testContext");
|
||||
if(testContext==null) {
|
||||
// trying with env
|
||||
|
@ -22,22 +24,22 @@ public interface GCubeSDITest {
|
|||
|
||||
|
||||
|
||||
public default boolean isTestInfrastructureEnabled() {
|
||||
public static boolean isTestInfrastructureEnabled() {
|
||||
return getContext()!=null;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public default void setTestContext() {
|
||||
if(isTestInfrastructureEnabled())
|
||||
TokenSetter.set(getContext());
|
||||
public static void setTestContext() {
|
||||
assumeTrue(isTestInfrastructureEnabled());
|
||||
TokenSetter.set(getContext());
|
||||
}
|
||||
|
||||
|
||||
public default ScopeConfiguration scopeConfiguration() throws RemoteException {
|
||||
public static ScopeConfiguration scopeConfiguration() throws RemoteException {
|
||||
return SimpleSDIManagerClient.contextService().build().getConfiguration();
|
||||
}
|
||||
|
||||
public default SDIManagement manager() throws RemoteException {
|
||||
public static SDIManagement manager() throws RemoteException {
|
||||
return SimpleSDIManagerClient.contextService().build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue