refs #2222: Move infrastructure tests outside of components junit tests
https://support.d4science.org/issues/2222 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@124095 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3e98a86740
commit
d84645b3b4
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.vremanagement.executor;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.net.URI;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint.Profile;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint.Profile.DeploymentData;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint.Profile.Function.Parameter;
|
||||
import org.gcube.common.resources.gcore.Resources;
|
||||
import org.gcube.utils.TestUtility;
|
||||
import org.gcube.vremanagement.executor.plugin.PluginDeclaration;
|
||||
import org.gcube.vremanagement.executor.pluginmanager.PluginManager;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
|
||||
*
|
||||
*/
|
||||
public class GCoreEndPointCreationTest {
|
||||
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(GCoreEndPointCreationTest.class);
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
SecurityTokenProvider.instance.set(TestUtility.TOKEN);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
SecurityTokenProvider.instance.reset();
|
||||
}
|
||||
|
||||
protected static GCoreEndpoint createGCoreEndpoint(){
|
||||
logger.debug("Getting Available Plugins and their own supported capabilities");
|
||||
PluginManager pluginManager = PluginManager.getInstance();
|
||||
|
||||
//ContextProvider.get().application();
|
||||
GCoreEndpoint gCoreEndpoint = new GCoreEndpoint();
|
||||
|
||||
Profile profile = gCoreEndpoint.profile();
|
||||
profile.serviceId("serviceid");
|
||||
profile.ghnId("nodeid");
|
||||
profile.serviceClass("serviceClass");
|
||||
profile.serviceName("serviceName");
|
||||
profile.version("version");
|
||||
profile.description("description");
|
||||
profile.endpoints().add().nameAndAddress("name",URI.create("http://acme.org"));
|
||||
|
||||
/*
|
||||
profile.serviceClass(ContextProvider.get().configuration().serviceClass());
|
||||
profile.serviceName(ContextProvider.get().configuration().name());
|
||||
profile.version(ContextProvider.get().configuration().version());
|
||||
profile.description(ContextProvider.get().configuration().description());
|
||||
*/
|
||||
|
||||
DeploymentData deploymentData = profile.newDeploymentData();
|
||||
deploymentData.activationTime(Calendar.getInstance());
|
||||
|
||||
Map<String, PluginDeclaration> availablePlugins = pluginManager.getAvailablePlugins();
|
||||
for(String pluginName : availablePlugins.keySet()){
|
||||
PluginDeclaration pluginDeclaration = availablePlugins.get(pluginName);
|
||||
|
||||
deploymentData.plugins().add().service("",pluginName, pluginDeclaration.getVersion()).pluginPackage("").version(pluginDeclaration.getVersion());
|
||||
|
||||
|
||||
Map<String, String> pluginCapabilities = pluginDeclaration.getSupportedCapabilities();
|
||||
for(String capabilityName : pluginCapabilities.keySet()){
|
||||
Parameter parameter = new Parameter();
|
||||
parameter.nameAndValues(capabilityName, pluginCapabilities.get(capabilityName));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return gCoreEndpoint;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void logCreatedGCoreEndpoint() throws Exception {
|
||||
GCoreEndpoint gCoreEndpoint = createGCoreEndpoint();
|
||||
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
Resources.marshal(gCoreEndpoint, stringWriter);
|
||||
|
||||
logger.debug("Created {} for scope {}:\n{}",
|
||||
GCoreEndpoint.class.getSimpleName(),
|
||||
TestUtility.getScopeFromToken(), stringWriter);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue