added another junit test

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@173904 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-10-31 11:01:52 +00:00
parent addfc794c2
commit 680d468dc9
1 changed files with 82 additions and 1 deletions

View File

@ -44,6 +44,7 @@ public class TestResolvers {
String storageHubId = "2019b881-083b-444a-81be-8abee4b91020";
String url = String.format("%s/shub/%s",URI_RESOLVER_SERVICE_ENDPOINT,storageHubId);
logger.info("Request to URL: "+url);
URL toURL;
int status;
try {
@ -81,11 +82,12 @@ public class TestResolvers {
* Storage hub test.
* @throws Exception
*/
@Test
//@Test
public void storageIDTest() throws Exception{
String storageID = "clZ2YmxTYytETzVLaHkwMjM3TmVETTFMb256YVRMS3lHbWJQNStIS0N6Yz0";
String url = String.format("%s/%s",URI_RESOLVER_SERVICE_ENDPOINT,storageID);
logger.info("Request to URL: "+url);
URL toURL;
int status;
try {
@ -119,6 +121,85 @@ public class TestResolvers {
}
}
/**
* Storage hub test.
* @throws Exception
*/
@Test
public void catalogueResolverTest() throws Exception{
String entityName = "sarda-sarda";
String entityContext = "ctlg";
String vreName = "devVRE";
String url = String.format("%s/%s/%s/%s",URI_RESOLVER_SERVICE_ENDPOINT,entityContext, vreName, entityName);
logger.info("Request to URL: "+url);
URL toURL;
int status;
try {
toURL = new URL(url);
HttpURLConnection con = (HttpURLConnection) toURL.openConnection();
con.setRequestMethod("GET");
con.connect();
status = con.getResponseCode();
System.out.println("Response status is: "+status);
if(status==HttpStatus.SC_OK){
System.out.println("Response: \n"+getContentReponse(con.getInputStream()));
}else{
System.out.println("\nError on resolving the Catalogue URL: "+toURL);
System.out.println("Response: \n"+getContentReponse(con.getInputStream()));
}
//con.setRequestProperty("Content-Type", "application/json");
//con.setConnectTimeout(5000);
//con.setReadTimeout(5000)
}
catch (Exception e) {
// TODO Auto-generated catch block
logger.error("Error: ",e);
throw e;
}
}
// /**
// * Storage hub test.
// * @throws Exception
// */
// @Test
// public void createCatalogueURLTest() throws Exception{
//
// String entityName = "sarda-sarda";
// String entityContext = "ctlg";
// String vreName = "devVRE";
//
// String url = String.format("%s/%s/%s/%s",URI_RESOLVER_SERVICE_ENDPOINT,entityContext, vreName, entityName);
// logger.info("Request to URL: "+url);
// URL toURL;
// int status;
// try {
// toURL = new URL(url);
// HttpURLConnection con = (HttpURLConnection) toURL.openConnection();
// con.setRequestMethod("GET");
// con.connect();
// status = con.getResponseCode();
// System.out.println("Response status is: "+status);
// if(status==HttpStatus.SC_OK){
// System.out.println("Response: \n"+getContentReponse(con.getInputStream()));
// }else{
// System.out.println("\nError on resolving the Catalogue URL: "+toURL);
// System.out.println("Response: \n"+getContentReponse(con.getInputStream()));
// }
// //con.setRequestProperty("Content-Type", "application/json");
// //con.setConnectTimeout(5000);
// //con.setReadTimeout(5000)
//
// }
// catch (Exception e) {
// // TODO Auto-generated catch block
// logger.error("Error: ",e);
// throw e;
// }
// }
/**
* Gets the content reponse.