Old test-suite removed

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/ResourceManager@55949 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2012-06-22 20:50:20 +00:00
parent 8f9c3e0a98
commit cee9d77c51
10 changed files with 0 additions and 834 deletions

View File

@ -1,68 +0,0 @@
package org.gcube.vremanagement.resourcemanager.impl.resources.types;
import java.util.Observable;
import java.util.Observer;
import junit.framework.TestCase;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResourceFactory;
import org.gcube.vremanagement.resourcemanager.impl.resources.types.MultiKeysMap;
public class MultiKeysTester extends TestCase {
MultiKeysMap<String, String, ScopedResource> map;
public void createMap() {
this.map = new MultiKeysMap<String, String, ScopedResource>();
}
public void addObserver() {
this.createMap();
//map.addObserver(new CollectionWatcher());
}
public void populateMap() throws Exception {
ScopedResource ghn = ScopedResourceFactory.newResource("ID1", GCUBEHostingNode.TYPE,GCUBEScope.getScope("/gcube"));
map.put(ghn.getId(), ghn.getType(), ghn);
ScopedResource ghn2 = ScopedResourceFactory.newResource("ID2", GCUBEHostingNode.TYPE, GCUBEScope.getScope("/gcube"));
map.put(ghn2.getId(), ghn2.getType(), ghn2);
ScopedResource ri = ScopedResourceFactory.newResource("RI1", GCUBERunningInstance.TYPE, GCUBEScope.getScope("/gcube"));
map.put(ri.getId(), ri.getType(), ri);
printMap(map);
map.removeValuesBySecondaryKey(ri.getType());
printMap(map);
map.removeValue(ghn);
printMap(map);
}
public void printMap(MultiKeysMap<String, String, ScopedResource> map) {
System.out.println("Values by KEY1:");
for (String key1 : map.primaryKeySet()) {
for (ScopedResource resource : map.getValuesByPrimaryKey(key1))
System.out.println( key1 + " ->" +resource.getId());
}
System.out.println("Values by KEY2:");
for (String key2 : map.secondaryKeySet()) {
for (ScopedResource resource : map.getValuesBySecondaryKey(key2))
System.out.println( key2 + " ->" +resource.getId());
}
System.out.println("Values:");
for (ScopedResource resource : map.values()) {
System.out.println(resource.getId());
}
}
public class CollectionWatcher implements Observer {
public void update(Observable o, Object arg) {
System.out.println("Notified");
}
}
}

View File

@ -1,101 +0,0 @@
package org.gcube.vremanagement.resourcemanager.impl.state;
import java.util.HashSet;
import java.util.Set;
import org.gcube.common.core.resources.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResource;
import org.gcube.vremanagement.resourcemanager.impl.resources.ScopedResourceFactory;
import com.thoughtworks.xstream.XStream;
import junit.framework.Assert;
import junit.framework.TestCase;
/**
*
* JUnit test class for {@link ScopeState}
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public class ResourceListTest extends TestCase {
private static final String SCOPE = "/gcube/devsec";
private static final String NAME = "test-list";
private static final String DESCRIPTION = "This is a test for scoped resources";
private ScopeState list;
public ResourceListTest(String name) {
super(name);
list = new ScopeState();
list.initialize(GCUBEScope.getScope(SCOPE), NAME, false, DESCRIPTION);
}
protected void setUp() throws Exception {
}
protected void tearDown() throws Exception {
XStream stream = new XStream();
stream.processAnnotations(ScopeState.class);
System.out.println(stream.toXML(list));
}
public void testAddResource()throws Exception {
Set<ScopedResource> resourceToAdd = new HashSet<ScopedResource>();
ScopedResource ghn = ScopedResourceFactory.newResource("ID1", GCUBEHostingNode.TYPE, GCUBEScope.getScope(SCOPE));
resourceToAdd.add(ghn);
list.addResources(resourceToAdd);
Assert.assertEquals(1, list.getResourcesByType(ghn.getType()).size());
ScopedResource ghn2 = ScopedResourceFactory.newResource("ID2", GCUBEHostingNode.TYPE, GCUBEScope.getScope(SCOPE));
resourceToAdd.add(ghn2);
list.addResources(resourceToAdd);
Assert.assertEquals(2, list.getResourcesByType(ghn2.getType()).size());
ScopedResource ri = ScopedResourceFactory.newResource("RI1", GCUBERunningInstance.TYPE, GCUBEScope.getScope(SCOPE));
ri.setHostedON("node1.p:8080");
resourceToAdd.add(ri);
list.addResources(resourceToAdd);
Assert.assertEquals(3, list.getResourcesByType(ri.getType()).size());
}
public void testGetResourcesByType() {
fail("Not yet implemented");
}
public void testChangeDescription() {
list.changeDescription("This is a new description");
}
public void testRemoveAllResourcesByType() {
fail("Not yet implemented");
}
public void testRemoveResource() throws Exception {
Set<ScopedResource> resourceToRemove = new HashSet<ScopedResource>();
ScopedResource ghn = ScopedResourceFactory.newResource("ID1", GCUBEHostingNode.TYPE, GCUBEScope.getScope(SCOPE));
resourceToRemove.add(ghn);
list.removeResources(resourceToRemove);
}
public void testCleanList() {
//list.r
}
public void testAddObserver() {
fail("Not yet implemented");
}
public void testDeleteObserver() {
fail("Not yet implemented");
}
}

View File

@ -1,110 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
/**
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public class AddResourceTest {
protected static Properties resources = new Properties();
/**
* @param args
*/
public static void main(String[] args) {
if ((args.length < 2) || (args.length > 3))
AddResourceTest.printUsage();
try {
resources.load(AddResourceTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
Runtime.getRuntime().exit(1);
}
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
endpoint.setAddress(new Address(args[0]));
ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
if (args.length == 3) {
GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
} else {
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(resources.getProperty("callerScope").trim()));
}
AddResourcesParameters add = new AddResourcesParameters();
if (new Integer(resources.getProperty("numOfServicesToAdd")) > 0) {
// prepare the list of service to ask to deploy
ServiceItem[] servicelist = new ServiceItem[new Integer(resources.getProperty("numOfServicesToAdd"))];
for (int i = 1 ; i < (servicelist.length +1); i++) {
servicelist[i-1] = new ServiceItem();
servicelist[i-1].setServiceClass(resources.getProperty("service." + i + ".class"));
servicelist[i-1].setServiceName(resources.getProperty("service." + i + ".name"));
servicelist[i-1].setServiceVersion(resources.getProperty("service." + i + ".version"));
if (resources.getProperty("service." + i + ".GHN") != null)
servicelist[i-1].setGHN(resources.getProperty("service." + i + ".GHN"));
}
ServiceList l = new ServiceList();
l.setService(servicelist);
//set the set of GHN, if any
if (resources.getProperty("GHNSet") != null) {
String[] ghns = resources.getProperty("GHNSet").split(",");
l.setGHN(ghns);
}
add.setServices(l);
}
if (new Integer(resources.getProperty("numOfResourcesToAdd")) > 0) {
ResourceItem[] resourcelist = new ResourceItem[new Integer(resources.getProperty("numOfResourcesToAdd"))];
for (int i = 1 ; i < (resourcelist.length +1); i++) {
resourcelist[i-1] = new ResourceItem();
resourcelist[i-1].setID(resources.getProperty("resource." + i + ".id"));
resourcelist[i-1].setType(resources.getProperty("resource." + i + ".type"));
}
ResourceList r = new ResourceList();
r.setResource(resourcelist);
add.setResources(r);
}
add.setTargetScope(resources.getProperty("targetScope"));
System.out.println ("Sending the Resource request....");
String reportID = pt.addResources(add);
System.out.println ("Returned report ID: " + reportID);
} catch (Exception e) {
e.printStackTrace();
}
}
static void printUsage() {
System.out.println("AddResourceTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file>");
System.out.println("or");
System.out.println("AddResourceTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file> <identity>");
System.exit(1);
}
}

View File

@ -1,130 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.CreateScopeParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.OptionsParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ScopeOption;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
public class CreateScopeTest {
protected static Properties resources = new Properties();
protected static String[] optionNames = new String[] {"creator", "designer", "endTime", "startTime",
"description", "displayName", "securityenabled"};
protected static GCUBEClientLog logger = new GCUBEClientLog(CreateScopeTest.class);
/**
* @param args
*/
public static void main(String[] args) {
if ((args.length < 2) || (args.length > 3))
CreateScopeTest.printUsage();
try {
resources.load(CreateScopeTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
logger.error("Unable to load the properties file",e1);
Runtime.getRuntime().exit(1);
}
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
endpoint.setAddress(new Address(args[0]));
ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
if (args.length == 3) {
GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
} else {
pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(resources.getProperty("callerScope").trim()), 90000);
}
logger.info("Setting the Scope parameters...");
OptionsParameters options = new OptionsParameters();
ScopeOption[] scopeOptionList = new ScopeOption[optionNames.length];
for (int i=0; i < optionNames.length; i++)
if (resources.getProperty(optionNames[i]) != null) {
logger.info("Setting prop " + optionNames[i]);
scopeOptionList[i] = new ScopeOption(optionNames[i], resources.getProperty(optionNames[i]));
}
options.setScopeOptionList(scopeOptionList);
// prepare the list of services to be deployed
AddResourcesParameters add = new AddResourcesParameters();
if (new Integer(resources.getProperty("numOfServicesToAdd")) > 0) {
ServiceItem[] servicelist = new ServiceItem[new Integer(resources.getProperty("numOfServicesToAdd"))];
for (int i = 1 ; i < (servicelist.length +1); i++) {
servicelist[i-1] = new ServiceItem();
servicelist[i-1].setServiceClass(resources.getProperty("service." + i + ".class"));
servicelist[i-1].setServiceName(resources.getProperty("service." + i + ".name"));
servicelist[i-1].setServiceVersion(resources.getProperty("service." + i + ".version"));
if (resources.getProperty("service." + i + ".GHN") != null)
servicelist[i-1].setGHN(resources.getProperty("service." + i + ".GHN"));
}
ServiceList l = new ServiceList();
l.setService(servicelist);
//set the set of GHN, if any
if (resources.getProperty("GHNSet") != null) {
String[] ghns = resources.getProperty("GHNSet").split(",");
l.setGHN(ghns);
}
add.setServices(l);
}
//prepare the list of resources to join to the new VRE
if (new Integer(resources.getProperty("numOfResourcesToAdd")) > 0) {
ResourceItem[] resourcelist = new ResourceItem[new Integer(resources.getProperty("numOfResourcesToAdd"))];
for (int i = 1 ; i < (resourcelist.length +1); i++) {
resourcelist[i-1] = new ResourceItem();
resourcelist[i-1].setID(resources.getProperty("resource." + i + ".id"));
resourcelist[i-1].setType(resources.getProperty("resource." + i + ".type"));
}
ResourceList r = new ResourceList();
r.setResource(resourcelist);
add.setResources(r);
}
add.setTargetScope(resources.getProperty("targetScope"));
//ready to start...
logger.info("Sending the creation request....");
CreateScopeParameters params = new CreateScopeParameters();
params.setName(resources.getProperty("targetScope"));
params.setOptionsParameters(options);
params.setAddResourcesParameters(add);
String reportID = pt.createScope(params);
logger.info("Returned report ID: " + reportID);
} catch (Exception e) {
logger.fatal("Failed to create VRE",e);
}
}
static void printUsage() {
System.out.println("CreateScopeTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file>");
System.out.println("or");
System.out.println("CreateScopeTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file> <identity>");
System.exit(1);
}
}

View File

@ -1,57 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.DisposeScopeParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
public class DisposeScopeTest {
protected static GCUBEClientLog logger = new GCUBEClientLog(DisposeScopeTest.class);
/**
* @param args
*/
public static void main(String[] args) {
if ((args.length < 2) || (args.length > 3))
DisposeScopeTest.printUsage();
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
endpoint.setAddress(new Address(args[0]));
ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
if (args.length == 3) {
GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(args[1].trim()), securityManager);
} else {
pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(args[1].trim()));
}
logger.info("Sending the destroy request....");
String reportID = pt.disposeScope(new DisposeScopeParameters(args[1]));
logger.info("Returned report ID: " + reportID);
} catch (Exception e) {
logger.fatal("Failed to dispose the VRE",e);
}
}
static void printUsage() {
System.out.println("DisposeScopeTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager <scope>");
System.out.println("or");
System.out.println("DisposeScopeTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager <scope> <identity>");
System.exit(1);
}
}

View File

@ -1,61 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite;
import java.util.Calendar;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
public class GetReportTest {
/**
* @param args
*/
public static void main(String[] args) {
if ((args.length < 3) || (args.length > 4))
GetReportTest.printUsage();
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
endpoint.setAddress(new Address(args[0]));
ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
if (args.length == 4) {
GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[3], true);
securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(args[1]), securityManager);
} else {
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(args[1]), 90000);
}
System.out.println(Calendar.getInstance().getTime().toString());
String report = pt.getReport(args[2]);
System.out.println(Calendar.getInstance().getTime().toString());
System.out.println ("REPORT");
System.out.println ("************");
System.out.println (report);
System.out.println ("************");
} catch (Exception e) {
e.printStackTrace();
}
}
static void printUsage() {
System.out.println("GetReportTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager <scope> <session>");
System.out.println("or");
System.out.println("GetReportTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager <scope> <session> <identity>");
System.exit(1);
}
}

View File

@ -1,98 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.RemoveResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
public class RemoveResourceTest {
protected static Properties resources = new Properties();
/**
* @param args
*/
public static void main(String[] args) {
if ((args.length < 2) || (args.length > 3))
RemoveResourceTest.printUsage();
try {
resources.load(RemoveResourceTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
Runtime.getRuntime().exit(1);
}
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
endpoint.setAddress(new Address(args[0]));
ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
if (args.length == 3) {
GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
} else {
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(resources.getProperty("callerScope").trim() ));
}
RemoveResourcesParameters params = new RemoveResourcesParameters();
if (new Integer(resources.getProperty("numOfResourcesToRemove")) > 0) {
ResourceItem[] resourcelist = new ResourceItem[new Integer(resources.getProperty("numOfResourcesToRemove"))];
for (int i = 1 ; i < (resourcelist.length +1); i++) {
resourcelist[i-1] = new ResourceItem();
resourcelist[i-1].setID(resources.getProperty("resource." + i + ".id"));
resourcelist[i-1].setType(resources.getProperty("resource." + i + ".type"));
}
ResourceList r = new ResourceList();
r.setResource(resourcelist);
params.setResources(r);
}
if (new Integer(resources.getProperty("numOfServicesToRemove")) > 0) {
ServiceItem[] servicelist = new ServiceItem[new Integer(resources.getProperty("numOfServicesToRemove"))];
for (int i = 1 ; i < (servicelist.length +1); i++) {
servicelist[i-1] = new ServiceItem();
servicelist[i-1].setServiceClass(resources.getProperty("service." + i + ".class"));
servicelist[i-1].setServiceName(resources.getProperty("service." + i + ".name"));
servicelist[i-1].setServiceVersion(resources.getProperty("service." + i + ".version"));
}
ServiceList l = new ServiceList();
l.setService(servicelist);
params.setServices(l);
}
params.setTargetScope(resources.getProperty("targetScope").trim());
System.out.println ("Sending the Remove Resource request....");
String reportID = pt.removeResources(params);
System.out.println ("Returned report ID: " + reportID);
} catch (Exception e) {
e.printStackTrace();
}
}
static void printUsage() {
System.out.println("RemoveResourceTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file>");
System.out.println("or");
System.out.println("RemoveResourceTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file> <identity>");
System.exit(1);
}
}

View File

@ -1,82 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.OptionsParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ScopeOption;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
/**
*
* Tester for the <em>ChangeScopeOptionTest</em> operation
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public class SetScopeOptionsTest {
protected static Properties resources = new Properties();
protected static String[] optionNames = new String[] {"creator", "designer", "endTime", "startTime",
"description", "displayName", "securityenabled"};
/**
* @param args
*/
public static void main(String[] args) {
if ((args.length < 2) || (args.length > 3))
SetScopeOptionsTest.printUsage();
try {
resources.load(SetScopeOptionsTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
Runtime.getRuntime().exit(1);
}
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
endpoint.setAddress(new Address(args[0]));
ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
if (args.length == 3) {
GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
} else {
pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(resources.getProperty("callerScope").trim()), 90000);
}
OptionsParameters options = new OptionsParameters();
ScopeOption[] scopeOptionList = new ScopeOption[optionNames.length];
for (int i=0; i < optionNames.length; i++)
scopeOptionList[i] = new ScopeOption(optionNames[i], resources.getProperty(optionNames[i]));
options.setScopeOptionList(scopeOptionList);
pt.changeScopeOptions(options);
} catch (Exception e) {
e.printStackTrace();
}
}
static void printUsage() {
System.out.println("SetScopeOptionsTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file>");
System.out.println("or");
System.out.println("SetScopeOptionsTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager <properties file> <identity>");
System.exit(1);
}
}

View File

@ -1,86 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.RemoveResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ServiceList;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
public class UndeployServiceTest {
protected static Properties resources = new Properties();
protected static GCUBEClientLog logger = new GCUBEClientLog(UndeployServiceTest.class);
/**
* @param args
*/
public static void main(String[] args) {
if ((args.length < 2) || (args.length > 3))
AddResourceTest.printUsage();
try {
resources.load(RemoveResourceTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
Runtime.getRuntime().exit(1);
}
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
endpoint.setAddress(new Address(args[0]));
ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
if (args.length == 3) {
GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
pt = GCUBERemotePortTypeContext.getProxy(pt,
GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
} else {
pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(resources.getProperty("callerScope").trim()), 90000);
}
RemoveResourcesParameters params = new RemoveResourcesParameters();
if (new Integer(resources.getProperty("numOfServicesToRemove")) > 0) {
ServiceItem[] servicelist = new ServiceItem[new Integer(resources.getProperty("numOfServicesToRemove"))];
for (int i = 1 ; i < (servicelist.length +1); i++) {
servicelist[i-1] = new ServiceItem();
servicelist[i-1].setServiceClass(resources.getProperty("service." + i + ".class"));
servicelist[i-1].setServiceName(resources.getProperty("service." + i + ".name"));
servicelist[i-1].setServiceVersion(resources.getProperty("service." + i + ".version"));
if (resources.getProperty("service." + i + ".GHN") != null)
servicelist[i-1].setGHN(resources.getProperty("service." + i + ".GHN"));
}
ServiceList l = new ServiceList();
l.setService(servicelist);
params.setServices(l);
}
params.setTargetScope(resources.getProperty("targetScope").trim());
System.out.println ("Sending the Remove Resource request....");
String reportID = pt.removeResources(params);
System.out.println ("Returned report ID: " + reportID);
} catch (Exception e) {
logger.fatal("Unable to undeploy the service(s)", e);
}
}
}

View File

@ -1,41 +0,0 @@
package org.gcube.vremanagement.resourcemanager.testsuite.security;
import org.gcube.common.core.security.GCUBEClientSecurityManager;
import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.common.core.security.context.SecurityContextFactory;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
public class Utils {
public static GCUBESecurityManager generateAndConfigureDefaultSecurityManager (String identity, final boolean isSecurityEnabled)
{
GCUBEClientLog logger = new GCUBEClientLog(Utils.class);
GCUBESecurityManager securityManager = null;
if (isSecurityEnabled)
{
try {
securityManager = SecurityContextFactory.getInstance().getSecurityContext().getDefaultSecurityManager();
logger.debug("Identity = "+identity);
((GCUBEClientSecurityManager) securityManager).setDefaultIdentityParameter(identity);
} catch (Exception e) {
logger.error("Unable to generate default security manager: trying without security...",e);
securityManager = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {return isSecurityEnabled;}
};
}
}
else
{
securityManager = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {return isSecurityEnabled;}
};
}
return securityManager;
}
}