Fixed test
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@134931 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ffdc507202
commit
02de4c1b0d
|
@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MultiContextTest {
|
public class MultiContextTest {
|
||||||
|
|
||||||
|
@ -62,128 +62,135 @@ public class MultiContextTest {
|
||||||
public MultiContextTest() {
|
public MultiContextTest() {
|
||||||
entityManagementImpl = new EntityManagementImpl();
|
entityManagementImpl = new EntityManagementImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateEServiceHostingNode() throws Exception {
|
public void testCreateEServiceHostingNode() throws Exception {
|
||||||
ScopeProvider.instance.set("/gcube/devNext");
|
ScopeProvider.instance.set("/gcube/devNext");
|
||||||
|
|
||||||
EService eService = new EServiceImpl();
|
EService eService = new EServiceImpl();
|
||||||
|
|
||||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
||||||
softwareFacet.setGroup("InformationSystem");
|
softwareFacet.setGroup("InformationSystem");
|
||||||
softwareFacet.setName("resource-registry");
|
softwareFacet.setName("resource-registry");
|
||||||
softwareFacet.setVersion("1.1.0");
|
softwareFacet.setVersion("1.1.0");
|
||||||
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(eService, softwareFacet, null);
|
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(
|
||||||
|
eService, softwareFacet, null);
|
||||||
eService.addFacet(isIdentifiedBy);
|
eService.addFacet(isIdentifiedBy);
|
||||||
|
|
||||||
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
||||||
accessPointFacet.setEndpoint(new URI("http://localhost"));
|
accessPointFacet.setEndpoint(new URI("http://localhost"));
|
||||||
accessPointFacet.setEntryName("port1");
|
accessPointFacet.setEntryName("port1");
|
||||||
eService.addFacet(accessPointFacet);
|
eService.addFacet(accessPointFacet);
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
EventFacet eventFacet = new EventFacetImpl();
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
eventFacet.setDate(Calendar.getInstance().getTime());
|
||||||
eventFacet.setValue("Created");
|
eventFacet.setValue("Created");
|
||||||
eService.addFacet(eventFacet);
|
eService.addFacet(eventFacet);
|
||||||
|
|
||||||
ServiceStateFacet serviceStateFacet = new ServiceStateFacetImpl();
|
ServiceStateFacet serviceStateFacet = new ServiceStateFacetImpl();
|
||||||
serviceStateFacet.setValue("ready");
|
serviceStateFacet.setValue("ready");
|
||||||
eService.addFacet(serviceStateFacet);
|
eService.addFacet(serviceStateFacet);
|
||||||
|
|
||||||
LicenseFacet licenseFacet = new LicenseFacetImpl();
|
LicenseFacet licenseFacet = new LicenseFacetImpl();
|
||||||
licenseFacet.setName("EUPL");
|
licenseFacet.setName("EUPL");
|
||||||
licenseFacet.setTextURL(new URL("https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11"));
|
licenseFacet
|
||||||
|
.setTextURL(new URL(
|
||||||
|
"https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11"));
|
||||||
eService.addFacet(licenseFacet);
|
eService.addFacet(licenseFacet);
|
||||||
|
|
||||||
String json = entityManagementImpl.createResource(EService.NAME, Entities.marshal(eService));
|
String json = entityManagementImpl.createResource(EService.NAME,
|
||||||
|
Entities.marshal(eService));
|
||||||
logger.debug("Created : {}", json);
|
logger.debug("Created : {}", json);
|
||||||
eService = Entities.unmarshal(EService.class, json);
|
eService = Entities.unmarshal(EService.class, json);
|
||||||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ----- */
|
/* ----- */
|
||||||
|
|
||||||
HostingNode hostingNode = new HostingNodeImpl();
|
HostingNode hostingNode = new HostingNodeImpl();
|
||||||
|
|
||||||
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
||||||
networkingFacet.setIPAddress("146.48.87.183");
|
networkingFacet.setIPAddress("146.48.87.183");
|
||||||
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
||||||
networkingFacet.setDomainName("isti.cnr.it");
|
networkingFacet.setDomainName("isti.cnr.it");
|
||||||
networkingFacet.setMask("255.255.248.0");
|
networkingFacet.setMask("255.255.248.0");
|
||||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
networkingFacet.setBroadcastAddress("146.48.87.255");
|
||||||
|
|
||||||
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<HostingNode, NetworkingFacet>(hostingNode, networkingFacet, null);
|
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<HostingNode, NetworkingFacet>(
|
||||||
|
hostingNode, networkingFacet, null);
|
||||||
hostingNode.addFacet(isIdentifiedByHNNF);
|
hostingNode.addFacet(isIdentifiedByHNNF);
|
||||||
|
|
||||||
|
|
||||||
CPUFacet cpuFacet = new CPUFacetImpl();
|
CPUFacet cpuFacet = new CPUFacetImpl();
|
||||||
cpuFacet.setClockSpeed("1 GHz");
|
cpuFacet.setClockSpeed("1 GHz");
|
||||||
cpuFacet.setModel("Opteron");
|
cpuFacet.setModel("Opteron");
|
||||||
cpuFacet.setVendor("AMD");
|
cpuFacet.setVendor("AMD");
|
||||||
hostingNode.addFacet(cpuFacet);
|
hostingNode.addFacet(cpuFacet);
|
||||||
|
|
||||||
|
|
||||||
MemoryFacet ram = new MemoryFacetImpl();
|
MemoryFacet ram = new MemoryFacetImpl();
|
||||||
ram.setSize(8);
|
ram.setSize(8);
|
||||||
ram.setUnit(MemoryUnit.GB);
|
ram.setUnit(MemoryUnit.GB);
|
||||||
ram.setUsed(2);
|
ram.setUsed(2);
|
||||||
|
|
||||||
HasVolatileMemory<HostingNode, MemoryFacet> hasVolatileMemory =
|
HasVolatileMemory<HostingNode, MemoryFacet> hasVolatileMemory = new HasVolatileMemoryImpl<HostingNode, MemoryFacet>(
|
||||||
new HasVolatileMemoryImpl<HostingNode, MemoryFacet>(hostingNode, ram, null);
|
hostingNode, ram, null);
|
||||||
hostingNode.addFacet(hasVolatileMemory);
|
hostingNode.addFacet(hasVolatileMemory);
|
||||||
|
|
||||||
|
|
||||||
MemoryFacet disk = new MemoryFacetImpl();
|
MemoryFacet disk = new MemoryFacetImpl();
|
||||||
disk.setSize(256);
|
disk.setSize(256);
|
||||||
disk.setUnit(MemoryUnit.GB);
|
disk.setUnit(MemoryUnit.GB);
|
||||||
disk.setUsed(120);
|
disk.setUsed(120);
|
||||||
|
|
||||||
HasPersistentMemory<HostingNode, MemoryFacet> hasPersistentMemory =
|
HasPersistentMemory<HostingNode, MemoryFacet> hasPersistentMemory = new HasPersistentMemoryImpl<HostingNode, MemoryFacet>(
|
||||||
new HasPersistentMemoryImpl<HostingNode, MemoryFacet>(hostingNode, disk, null);
|
hostingNode, disk, null);
|
||||||
hostingNode.addFacet(hasPersistentMemory);
|
hostingNode.addFacet(hasPersistentMemory);
|
||||||
|
|
||||||
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, null);
|
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(
|
||||||
|
hostingNode, eService, null);
|
||||||
hostingNode.attachResource(hosts);
|
hostingNode.attachResource(hosts);
|
||||||
|
|
||||||
String hnJson = entityManagementImpl.createResource(HostingNode.NAME, Entities.marshal(hostingNode));
|
String hnJson = entityManagementImpl.createResource(HostingNode.NAME,
|
||||||
|
Entities.marshal(hostingNode));
|
||||||
logger.debug("Created : {}", hnJson);
|
logger.debug("Created : {}", hnJson);
|
||||||
hostingNode = Entities.unmarshal(HostingNode.class, hnJson);
|
hostingNode = Entities.unmarshal(HostingNode.class, hnJson);
|
||||||
logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode);
|
logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode);
|
||||||
|
|
||||||
|
|
||||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
UUID uuid = hostingNode.getHeader().getUUID();
|
UUID uuid = hostingNode.getHeader().getUUID();
|
||||||
boolean addedToContext = entityManagementImpl.addResourceToContext(uuid);
|
boolean addedToContext = entityManagementImpl
|
||||||
|
.addResourceToContext(uuid);
|
||||||
Assert.assertTrue(addedToContext);
|
Assert.assertTrue(addedToContext);
|
||||||
|
|
||||||
|
|
||||||
String hnString = entityManagementImpl.readResource(uuid);
|
String hnString = entityManagementImpl.readResource(uuid);
|
||||||
HostingNode readHN = Entities.unmarshal(HostingNode.class, hnString);
|
HostingNode readHN = Entities.unmarshal(HostingNode.class, hnString);
|
||||||
Assert.assertTrue(readHN.getHeader().getUUID().compareTo(uuid)==0);
|
Assert.assertTrue(readHN.getHeader().getUUID().compareTo(uuid) == 0);
|
||||||
|
|
||||||
|
|
||||||
UUID eServiceUUID = eService.getHeader().getUUID();
|
UUID eServiceUUID = eService.getHeader().getUUID();
|
||||||
try {
|
try {
|
||||||
entityManagementImpl.readResource(eServiceUUID);
|
entityManagementImpl.readResource(eServiceUUID);
|
||||||
}catch(ResourceNotFoundException e){
|
} catch (ResourceNotFoundException e) {
|
||||||
logger.debug("Resource with {} Not Found as Expected", uuid.toString());
|
logger.debug("Resource with {} Not Found as Expected",
|
||||||
|
uuid.toString());
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
boolean deleted = entityManagementImpl.deleteResource(uuid);
|
entityManagementImpl.deleteResource(uuid);
|
||||||
Assert.assertTrue(deleted);
|
} catch (ResourceNotFoundException e) {
|
||||||
|
logger.debug("Resource with {} Not Found as Expected",
|
||||||
deleted = entityManagementImpl.deleteResource(eService.getHeader().getUUID());
|
uuid.toString());
|
||||||
Assert.assertTrue(deleted);
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
entityManagementImpl.deleteResource(eService.getHeader().getUUID());
|
||||||
|
} catch (ResourceNotFoundException e) {
|
||||||
|
logger.debug("Resource with {} Not Found as Expected",
|
||||||
|
uuid.toString());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void addTest() throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException{
|
public void addTest() throws ResourceNotFoundException,
|
||||||
|
ContextNotFoundException, ResourceRegistryException {
|
||||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||||
entityManagementImpl.addResourceToContext(UUID.fromString(""));
|
entityManagementImpl.addResourceToContext(UUID.fromString(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue