implementing Publisher

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@131453 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-09-16 11:39:26 +00:00
parent 806d689504
commit d999232149
2 changed files with 36 additions and 8 deletions

View File

@ -1,7 +1,6 @@
package org.gcube.informationsystem.resourceregistry.publisher.proxy;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -173,10 +172,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
protected HttpURLConnection getConnection(URL url, HTTPMETHOD method)
throws Exception {
/*
if(method!=HTTPMETHOD.POST && httpInputs.getUrlParameters()!=null){
url = new URL(url + "?" + httpInputs.getUrlParameters());
}
*/
url = new URL(url + "?" + httpInputs.getUrlParameters());
//}
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
@ -197,13 +197,16 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
connection.setRequestProperty("User-Agent", ResourceRegistryPublisher.class.getSimpleName());
connection.setRequestMethod(method.toString());
/*
if(method==HTTPMETHOD.POST){
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(httpInputs.getUrlParameters());
wr.flush();
wr.close();
}
}*/
return connection;
}

View File

@ -107,6 +107,10 @@ public class ResourceRegistryPublisherTest {
logger.debug("Created : {}", createdEService);
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) createdEService.getIdentificationFacets().get(0);
logger.debug("Created : {}", softwareFacet);
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
networkingFacet.setIPAddress("146.48.87.183");
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
@ -140,13 +144,34 @@ public class ResourceRegistryPublisherTest {
logger.debug("Created : {}", createdHostingNode);
logger.debug("Going to delete : {}", hostingNode);
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode);
CPUFacet createdCPUFacet = (CPUFacet) createdHostingNode.getIdentificationFacets().get(0);
logger.debug("Created : {}", createdCPUFacet);
logger.debug("Going to delete : {}", createdHostingNode);
boolean deleted = resourceRegistryPublisher.deleteResource(createdHostingNode);
Assert.assertTrue(deleted);
logger.debug("Going to delete : {}", createdCPUFacet);
deleted = resourceRegistryPublisher.deleteFacet(createdCPUFacet);
Assert.assertTrue(deleted);
logger.debug("Going to delete : {}", createdNetworkingFacet);
deleted = resourceRegistryPublisher.deleteFacet(createdNetworkingFacet);
Assert.assertTrue(deleted);
logger.debug("Going to delete : {}", createdSoftwareFacet);
deleted = resourceRegistryPublisher.deleteFacet(createdSoftwareFacet);
Assert.assertTrue(deleted);
logger.debug("Going to delete : {}", createdEService);
deleted = resourceRegistryPublisher.deleteResource(createdEService);
Assert.assertTrue(deleted);
}
@Test
public void testCreateAndDeleteEntitiesAndRelations() throws Exception {
EService eService = new EServiceImpl();