Fixings on the ISRegistry testsuite

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@14367 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2009-07-29 21:25:22 +00:00
parent eb5b601a70
commit 9968239d8e
8 changed files with 125 additions and 90 deletions

View File

@ -6,5 +6,6 @@
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIBS"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/GCORELIBS"/>
<classpathentry combineaccessrules="false" kind="src" path="/DISTRO.RESOURCES"/> <classpathentry combineaccessrules="false" kind="src" path="/DISTRO.RESOURCES"/>
<classpathentry combineaccessrules="false" kind="src" path="/GCF.05x"/> <classpathentry combineaccessrules="false" kind="src" path="/GCF.05x"/>
<classpathentry kind="lib" path="/Dependencies/ISREGISTRY/org.gcube.informationsystem.registry.stubs.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -3,7 +3,7 @@
Version 0.5 Version 0.5
REQUIRED INPUT PROPERTIES INPUT PROPERTIES
This buildfile assumes that the following properties have or may have been defined in a "build.properties" file This buildfile assumes that the following properties have or may have been defined in a "build.properties" file
in the configuration directory of the service (or else using the -D flag on the command line). in the configuration directory of the service (or else using the -D flag on the command line).
@ -24,6 +24,9 @@ package.<n>: (optional) The package name of the stubs generated from WSDL and/
etics.build: (optional) Set to 'true', it indicates that build structures and procedures etics.build: (optional) Set to 'true', it indicates that build structures and procedures
should be optimised for remote builds in ETICS. If it is omitted, this buildfile will optimise build structures and procedures should be optimised for remote builds in ETICS. If it is omitted, this buildfile will optimise build structures and procedures
for local builds. for local builds.
full.stubs: (optional) Set to 'false', it excludes auxiliary stub code placed under ${package}/stubs when building the stub distribution.
It is intended to simplify realignment of auxiliary and standard stub in IDE environments in case the latter change in non backwards-compatible ways.
After re-alignment, the property is typically left to its default of 'true' to restore a joint build of all stub code.
--> -->
@ -83,9 +86,10 @@ etics.build: (optional) Set to 'true', it indicates that build structures a
</if> </if>
<property name="full.stubs" value="true"/>
<property name="stubs.package" value="${package}.${stubs.dir.name}"/> <property name="stubs.package" value="${package}.${stubs.dir.name}"/>
<property name="stubs.dir.name" value="stubs" /> <!-- auxiliary stub classes --> <property name="stubs.dir.name" value="stubs" /> <!-- auxiliary stub classes -->
<property name="stubs.dir" value="${source.dir}/${package.dir}${stubs.dir.name}" /> <property name="stubs.dir" value="${source.dir}/${package.dir}/${stubs.dir.name}" />
<available file="${stubs.dir}" property="stubs.dir.present"/> <available file="${stubs.dir}" property="stubs.dir.present"/>
<!-- temporary build locations --> <!-- temporary build locations -->
@ -391,7 +395,8 @@ etics.build: (optional) Set to 'true', it indicates that build structures a
</target> </target>
<target name="buildService" depends="processWSDLs" description="compiles service implementation"> <target name="buildService" depends="processWSDLs" description="compiles service implementation">
<javac srcdir="${source.dir}" destdir="${build.class.dir}" debug="${java.debug}" deprecation="${java.deprecation}"> <javac srcdir="${source.dir}" destdir="${build.class.dir}" debug="${java.debug}" deprecation="${java.deprecation}"
excludes="org/gcube/common/vremanagement/deployer/stubs/**">
<classpath> <classpath>
<fileset dir="${lib.location}"> <fileset dir="${lib.location}">
<include name="**/*.jar" /> <include name="**/*.jar" />
@ -429,6 +434,7 @@ etics.build: (optional) Set to 'true', it indicates that build structures a
<!-- Stub Build tasks --> <!-- Stub Build tasks -->
<target name="buildStubs" depends="processWSDLs,generateStubs" description="build service stubs"> <target name="buildStubs" depends="processWSDLs,generateStubs" description="build service stubs">
<if name="full.stubs" value="true">
<if name="stubs.dir.present"> <if name="stubs.dir.present">
<copy toDir="${build.stubs.src.dir}/${package.dir}/${stubs.dir.name}" overwrite="true"> <copy toDir="${build.stubs.src.dir}/${package.dir}/${stubs.dir.name}" overwrite="true">
<fileset dir="${stubs.dir}" casesensitive="yes"> <fileset dir="${stubs.dir}" casesensitive="yes">
@ -436,6 +442,7 @@ etics.build: (optional) Set to 'true', it indicates that build structures a
</fileset> </fileset>
</copy> </copy>
</if> </if>
</if>
<javac srcdir="${build.stubs.src.dir}" destdir="${build.stubs.class.dir}" debug="${java.debug}" deprecation="${java.deprecation}" description="compile stub classes"> <javac srcdir="${build.stubs.src.dir}" destdir="${build.stubs.class.dir}" debug="${java.debug}" deprecation="${java.deprecation}" description="compile stub classes">
<include name="**/*.java" /> <include name="**/*.java" />
<classpath> <classpath>

View File

@ -1,8 +1,9 @@
package org.gcube.informationsystem.registry.test; package org.gcube.informationsystem.registry.stubs.testsuite;
import java.io.FileReader; import java.io.FileReader;
import java.io.StringWriter; import java.io.StringWriter;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType; import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext; import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
@ -12,14 +13,13 @@ import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.resources.GCUBERunningInstance; import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.resources.GCUBEService; import org.gcube.common.core.resources.GCUBEService;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.ServiceMap.ServiceType;
import org.gcube.common.core.security.GCUBESecurityManagerImpl; import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.CreateResourceMessage; import org.gcube.informationsystem.registry.stubs.CreateResourceMessage;
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType; import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator; import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
/** /**
* GCUBE resource registration tester * {@link GCUBEResource} registration tester
* *
* @author Manuele Simi (CNR-ISTI) * @author Manuele Simi (CNR-ISTI)
* *
@ -28,24 +28,36 @@ public class RegistryRegistrationTest {
/** /**
* *
* @param args parameters: * @param args
* parameters:
* <ul> * <ul>
* <li> resource file * <li>factory URI
* <li> resource type * <li>resource file
* <li> caller scope * <li>resource type
* <li>caller scope
* *
* @throws Exception if the registration fails * @throws Exception
* if the registration fails
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
if (args.length != 3) { if (args.length != 4) {
printUsage(); printUsage();
} }
for (String param : args) System.out.println("param "+ param);
// get the scope and the factory URI // get the scope and the factory URI
GCUBEScope scope = GCUBEScope.getScope(args[2]); GCUBEScope scope = GCUBEScope.getScope(args[2]);
EndpointReferenceType factoryEPR = scope.getServiceMap().getEndpoints(ServiceType.ISICAllRegistrationPT).iterator().next();
EndpointReferenceType factoryEPR = new EndpointReferenceType();
try {
factoryEPR.setAddress(new Address(args[0]));
} catch (Exception e) {
e.printStackTrace();
Runtime.getRuntime().exit(1);
}
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator(); RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
@ -55,18 +67,16 @@ public class RegistryRegistrationTest {
} }
}; };
// ExtendedGSSCredential cred = org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]);
// managerSec.useCredentials(cred);
// load the resource // load the resource
GCUBEResource resource = getResource(args[1], new FileReader(args[0])); GCUBEResource resource = getResource(args[3], new FileReader(args[1]));
RegistryFactoryPortType registryFactoryPortType = null; RegistryFactoryPortType registryFactoryPortType = null;
try { try {
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR); registryFactoryPortType = registryLocator
.getRegistryFactoryPortTypePort(factoryEPR);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.exit(1); Runtime.getRuntime().exit(1);
} }
CreateResourceMessage message = new CreateResourceMessage(); CreateResourceMessage message = new CreateResourceMessage();
@ -81,38 +91,47 @@ public class RegistryRegistrationTest {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
Runtime.getRuntime().exit(1);
} }
} }
/** /**
* Loads the specific GCUBEResource class * Loads the specific GCUBEResource class
* @param type the resource type *
* @param file the file representation of the profile * @param type
* the resource type
* @param file
* the file representation of the profile
* @return the resource class * @return the resource class
* @throws Exception if the loading fails * @throws Exception
* if the loading fails
*/ */
static GCUBEResource getResource(String type, FileReader file) throws Exception { static GCUBEResource getResource(String type, FileReader file)
throws Exception {
if (type.compareTo("Service") == 0) { if (type.compareTo("Service") == 0) {
GCUBEService service = GHNContext.getImplementation(GCUBEService.class); GCUBEService service = GHNContext
.getImplementation(GCUBEService.class);
service.load(file); service.load(file);
return (GCUBEResource) service; return (GCUBEResource) service;
} } else if (type.compareTo("RunningInstance") == 0) {
else if (type.compareTo("RunningInstance") == 0) { GCUBERunningInstance instance = GHNContext
GCUBERunningInstance instance = GHNContext.getImplementation(GCUBERunningInstance.class); .getImplementation(GCUBERunningInstance.class);
instance.load(file); instance.load(file);
return (GCUBEResource) instance; return (GCUBEResource) instance;
} else if (type.compareTo("GHN") == 0) { } else if (type.compareTo("GHN") == 0) {
GCUBEHostingNode node = GHNContext.getImplementation(GCUBEHostingNode.class); GCUBEHostingNode node = GHNContext
.getImplementation(GCUBEHostingNode.class);
node.load(file); node.load(file);
return (GCUBEResource) node; return (GCUBEResource) node;
} else if (type.compareTo("GenericResource") == 0) { } else if (type.compareTo("GenericResource") == 0) {
GCUBEGenericResource generic = GHNContext.getImplementation(GCUBEGenericResource.class); GCUBEGenericResource generic = GHNContext
.getImplementation(GCUBEGenericResource.class);
generic.load(file); generic.load(file);
return (GCUBEResource) generic; return (GCUBEResource) generic;
} }
throw new Exception( type + " is an invalid resource type"); throw new Exception(type + " is an invalid resource type");
} }
@ -120,8 +139,10 @@ public class RegistryRegistrationTest {
* Prints tester usage syntax * Prints tester usage syntax
*/ */
static void printUsage() { static void printUsage() {
System.out.println("RegistryRegistrationTest <resource file> <resource type> <caller scope>"); System.out
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource"); .println("RegistryRegistrationTest <factory URI> <resource file> <resource type> <caller scope>");
System.out
.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
System.exit(1); System.exit(1);
} }
} }

View File

@ -0,0 +1,52 @@
package org.gcube.informationsystem.registry.stubs.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.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
public class RegistryRemoveTest {
public static void main(String[] args) throws Exception {
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return true;
}
};
EndpointReferenceType factoryEPR = new EndpointReferenceType();
RegistryFactoryPortType registryFactoryPortType = null;
try {
factoryEPR.setAddress(new Address(args[0]));
registryFactoryPortType = registryLocator
.getRegistryFactoryPortTypePort(factoryEPR);
} catch (Exception e) {
e.printStackTrace();
}
RemoveResourceMessage message = new RemoveResourceMessage();
// managerSec.useCredentials(cred);
registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(
registryFactoryPortType, GCUBEScope.getScope(args[2]),
managerSec);
try {
message.setType(args[3]);
message.setUniqueID(args[1]);
registryFactoryPortType.removeResource(message);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Profile with ID " + args[1]
+ "has been succesfully removed");
}
}

View File

@ -1,4 +1,4 @@
package org.gcube.informationsystem.registry.test; package org.gcube.informationsystem.registry.stubs.testsuite;
import java.io.FileReader; import java.io.FileReader;
import java.io.StringWriter; import java.io.StringWriter;

View File

@ -1,46 +0,0 @@
package org.gcube.informationsystem.registry.test;
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.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
public class RegistryRemoveTest {
public static void main (String[]args ) throws Exception {
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return true;}};
EndpointReferenceType factoryEPR = new EndpointReferenceType();
RegistryFactoryPortType registryFactoryPortType= null;
try {
factoryEPR.setAddress(new Address(args[0]));
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
}catch(Exception e){
e.printStackTrace();
}
RemoveResourceMessage message = new RemoveResourceMessage();
//managerSec.useCredentials(cred);
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope(args[2]),managerSec);
try {
message.setType(args[3]);
message.setUniqueID(args[1]);
registryFactoryPortType.removeResource(message);
} catch(Exception e) {
e.printStackTrace();
}
System.out.println("Profile with ID "+ args[1]+ "has been succesfully removed");
}
}