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:
parent
eb5b601a70
commit
9968239d8e
|
@ -6,5 +6,6 @@
|
|||
<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="/GCF.05x"/>
|
||||
<classpathentry kind="lib" path="/Dependencies/ISREGISTRY/org.gcube.informationsystem.registry.stubs.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
25
build.xml
25
build.xml
|
@ -3,7 +3,7 @@
|
|||
|
||||
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
|
||||
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
|
||||
should be optimised for remote builds in ETICS. If it is omitted, this buildfile will optimise build structures and procedures
|
||||
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>
|
||||
|
||||
|
||||
<property name="full.stubs" value="true"/>
|
||||
<property name="stubs.package" value="${package}.${stubs.dir.name}"/>
|
||||
<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"/>
|
||||
|
||||
<!-- temporary build locations -->
|
||||
|
@ -391,7 +395,8 @@ etics.build: (optional) Set to 'true', it indicates that build structures a
|
|||
</target>
|
||||
|
||||
<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>
|
||||
<fileset dir="${lib.location}">
|
||||
<include name="**/*.jar" />
|
||||
|
@ -429,12 +434,14 @@ etics.build: (optional) Set to 'true', it indicates that build structures a
|
|||
<!-- Stub Build tasks -->
|
||||
|
||||
<target name="buildStubs" depends="processWSDLs,generateStubs" description="build service stubs">
|
||||
<if name="stubs.dir.present">
|
||||
<copy toDir="${build.stubs.src.dir}/${package.dir}/${stubs.dir.name}" overwrite="true">
|
||||
<fileset dir="${stubs.dir}" casesensitive="yes">
|
||||
<exclude name="**/*.class" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<if name="full.stubs" value="true">
|
||||
<if name="stubs.dir.present">
|
||||
<copy toDir="${build.stubs.src.dir}/${package.dir}/${stubs.dir.name}" overwrite="true">
|
||||
<fileset dir="${stubs.dir}" casesensitive="yes">
|
||||
<exclude name="**/*.class" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</if>
|
||||
</if>
|
||||
<javac srcdir="${build.stubs.src.dir}" destdir="${build.stubs.class.dir}" debug="${java.debug}" deprecation="${java.deprecation}" description="compile stub classes">
|
||||
<include name="**/*.java" />
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package org.gcube.informationsystem.registry.test;
|
||||
package org.gcube.informationsystem.registry.stubs.testsuite;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
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.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.GCUBEService;
|
||||
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.informationsystem.registry.stubs.CreateResourceMessage;
|
||||
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
|
||||
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
|
||||
|
||||
/**
|
||||
* GCUBE resource registration tester
|
||||
* {@link GCUBEResource} registration tester
|
||||
*
|
||||
* @author Manuele Simi (CNR-ISTI)
|
||||
*
|
||||
|
@ -28,24 +28,36 @@ public class RegistryRegistrationTest {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param args parameters:
|
||||
* <ul>
|
||||
* <li> resource file
|
||||
* <li> resource type
|
||||
* <li> caller scope
|
||||
* @param args
|
||||
* parameters:
|
||||
* <ul>
|
||||
* <li>factory URI
|
||||
* <li>resource file
|
||||
* <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 {
|
||||
|
||||
if (args.length != 3) {
|
||||
if (args.length != 4) {
|
||||
printUsage();
|
||||
}
|
||||
|
||||
for (String param : args) System.out.println("param "+ param);
|
||||
|
||||
// get the scope and the factory URI
|
||||
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();
|
||||
|
||||
|
@ -55,18 +67,16 @@ public class RegistryRegistrationTest {
|
|||
}
|
||||
};
|
||||
|
||||
// ExtendedGSSCredential cred = org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]);
|
||||
// managerSec.useCredentials(cred);
|
||||
|
||||
// load the resource
|
||||
GCUBEResource resource = getResource(args[1], new FileReader(args[0]));
|
||||
GCUBEResource resource = getResource(args[3], new FileReader(args[1]));
|
||||
|
||||
RegistryFactoryPortType registryFactoryPortType = null;
|
||||
try {
|
||||
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
|
||||
registryFactoryPortType = registryLocator
|
||||
.getRegistryFactoryPortTypePort(factoryEPR);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
Runtime.getRuntime().exit(1);
|
||||
}
|
||||
CreateResourceMessage message = new CreateResourceMessage();
|
||||
|
||||
|
@ -81,38 +91,47 @@ public class RegistryRegistrationTest {
|
|||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Runtime.getRuntime().exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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) {
|
||||
GCUBEService service = GHNContext.getImplementation(GCUBEService.class);
|
||||
GCUBEService service = GHNContext
|
||||
.getImplementation(GCUBEService.class);
|
||||
service.load(file);
|
||||
return (GCUBEResource) service;
|
||||
}
|
||||
else if (type.compareTo("RunningInstance") == 0) {
|
||||
GCUBERunningInstance instance = GHNContext.getImplementation(GCUBERunningInstance.class);
|
||||
} else if (type.compareTo("RunningInstance") == 0) {
|
||||
GCUBERunningInstance instance = GHNContext
|
||||
.getImplementation(GCUBERunningInstance.class);
|
||||
instance.load(file);
|
||||
return (GCUBEResource) instance;
|
||||
} else if (type.compareTo("GHN") == 0) {
|
||||
GCUBEHostingNode node = GHNContext.getImplementation(GCUBEHostingNode.class);
|
||||
GCUBEHostingNode node = GHNContext
|
||||
.getImplementation(GCUBEHostingNode.class);
|
||||
node.load(file);
|
||||
return (GCUBEResource) node;
|
||||
} else if (type.compareTo("GenericResource") == 0) {
|
||||
GCUBEGenericResource generic = GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||
GCUBEGenericResource generic = GHNContext
|
||||
.getImplementation(GCUBEGenericResource.class);
|
||||
generic.load(file);
|
||||
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
|
||||
*/
|
||||
static void printUsage() {
|
||||
System.out.println("RegistryRegistrationTest <resource file> <resource type> <caller scope>");
|
||||
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
|
||||
System.out
|
||||
.println("RegistryRegistrationTest <factory URI> <resource file> <resource type> <caller scope>");
|
||||
System.out
|
||||
.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.informationsystem.registry.test;
|
||||
package org.gcube.informationsystem.registry.stubs.testsuite;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.StringWriter;
|
Binary file not shown.
Binary file not shown.
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue