Skip to content
Permalink
Browse files

- Test de l'intégration de Handle

  • Loading branch information...
miledrousset committed May 15, 2017
1 parent 9e68832 commit b43dccfdf8c913d538482525f10d42fc1c3d0bde
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
@@ -4,7 +4,7 @@

<groupId>trd</groupId>
<artifactId>opentheso</artifactId>
<version>4.2.5</version>
<version>4.3.0</version>
<packaging>war</packaging>

<name>opentheso</name>
@@ -76,6 +76,12 @@
<artifactId>skos-api-onejar</artifactId>
<version>4</version>
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-model</artifactId>
<version>2.1.4</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
@@ -3136,7 +3136,10 @@ public boolean isTopConcept(HikariDataSource ds,
nodeConceptTree1.setStatusConcept("");
} else {
nodeConceptTree1.setTitle(resultSet.getString("lexical_value"));
nodeConceptTree1.setStatusConcept(resultSet.getString("status"));
if(resultSet.getString("status") == null)
nodeConceptTree1.setStatusConcept("");
else
nodeConceptTree1.setStatusConcept(resultSet.getString("status"));
}
nodeConceptTree1.setHaveChildren(
haveChildren(ds, idThesaurus, nodeConceptTree1.getIdConcept())
@@ -24,6 +24,7 @@
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@@ -71,6 +72,96 @@ public void setUp() {
@After
public void tearDown() {
}


/*********************************
*********************************
*
* Test OK
*
*********************************
*********************************
*/

/**
* Fonction pour récupérer l'identifiant Handle non sécurisé
*
* OKKKKKK pour la récupération des identifiants
*
*/
@Test
public void curlGetHandle() {

String output ="";
String xmlRecord = "";
try {
// String query = "20.500.11942/TEST";
String requete = "http://cchum-isi-handle01.in2p3.fr:8001/api/handles/20.500.11942/TEST";

URL myURL = new URL(requete);// + URLEncoder.encode(query, "utf8"));
HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
myURLConnection.setRequestMethod("GET");
// myURLConnection.setRequestProperty("X-Parse-Application-Id", "");
// myURLConnection.setRequestProperty("X-Parse-REST-API-Key", "");
myURLConnection.setRequestProperty("Content-Type", "application/json");
myURLConnection.setUseCaches(false);
myURLConnection.setDoInput(true);
myURLConnection.setDoOutput(true);
myURLConnection.connect();

// JSONObject jsonParam = new JSONObject();
// jsonParam.put("score", "73453");

OutputStream os = myURLConnection.getOutputStream();
// os.write(URLEncoder.encode(jsonParam.toString(),"UTF-8").getBytes());

BufferedReader br = new BufferedReader(new InputStreamReader((myURLConnection.getInputStream())));


while ((output = br.readLine()) != null) {
xmlRecord += output;
}
byte[] bytes = xmlRecord.getBytes();
xmlRecord = new String(bytes, Charset.forName("UTF-8"));

os.close();
} catch (UnsupportedEncodingException ex) {
System.out.println(ex);
} catch (IOException ex) {
System.out.println(ex);
}

System.out.println(xmlRecord);
}

























/**
* PUT mais ne marche pas encore.
*/


@Test
/*
@@ -138,18 +229,27 @@ public boolean verify(String hostname, SSLSession session) {
*/
conn.setDoOutput(true);


// -d '{"index":1,"type":"URL",
// "data":{"format":"string","value":"http://www.huma-num.fr"},"ttl":86400,"permissions":"1110"}'
String data = "{\"index\":1,\"type\":\"URL\"," +
"\"data\":{\"format\":\"string\",\"value\":\"http://www.opentheso3.mom.fr\"},\"ttl\":86400,\"permissions\":\"1110\"}";
String data = "{\"index\":1,\"type\":\"URL\","
+ "\"data\":{\"format\":\"string\",\"value\":\"http://www.opentheso3.mom.fr\"},\"ttl\":86400,\"permissions\":\"1110\"}";

OutputStream os = conn.getOutputStream();

OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
OutputStreamWriter out = new OutputStreamWriter(os);
out.write(data);


System.out.println(out.toString());//Files.copy(Paths.get("/home/myNewFile.txt"), out));

InputStream in = conn.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(in);

out.close();

OutputStream os = conn.getOutputStream();
// os.write(URLEncoder.encode(jsonParam.toString(),"UTF-8").getBytes());
in.close();

// os.write(URLEncoder.encode(jsonParam.toString(),"UTF-8").getBytes());

BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));

@@ -162,16 +262,26 @@ public boolean verify(String hostname, SSLSession session) {
System.out.println(xmlRecord);
os.close();

/* try (OutputStream out = conn.getOutputStream()) {
/* try (OutputStream out = conn.getOutputStream()) {
System.out.println(out.toString());//Files.copy(Paths.get("/home/myNewFile.txt"), out));
}*/

} catch (MalformedURLException ex) {
Logger.getLogger(HandleTest.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(HandleTest.class.getName()).log(Level.SEVERE, null, ex);
}
}












public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
@@ -227,53 +337,7 @@ public void getHandle() {
}*/
/**
* Fonction pour récupérer l'identifiant Handle non sécurisé
*/
/* @Test
public void curlGetHandle() {
String output ="";
String xmlRecord = "";
try {
// String query = "20.500.11942/TEST";
String requete = "http://cchum-isi-handle01.in2p3.fr:8001/api/handles/20.500.11942/TEST";
URL myURL = new URL(requete);// + URLEncoder.encode(query, "utf8"));
HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
myURLConnection.setRequestMethod("GET");
// myURLConnection.setRequestProperty("X-Parse-Application-Id", "");
// myURLConnection.setRequestProperty("X-Parse-REST-API-Key", "");
myURLConnection.setRequestProperty("Content-Type", "application/json");
myURLConnection.setUseCaches(false);
myURLConnection.setDoInput(true);
myURLConnection.setDoOutput(true);
myURLConnection.connect();
// JSONObject jsonParam = new JSONObject();
// jsonParam.put("score", "73453");
OutputStream os = myURLConnection.getOutputStream();
// os.write(URLEncoder.encode(jsonParam.toString(),"UTF-8").getBytes());
BufferedReader br = new BufferedReader(new InputStreamReader((myURLConnection.getInputStream())));

while ((output = br.readLine()) != null) {
xmlRecord += output;
}
byte[] bytes = xmlRecord.getBytes();
xmlRecord = new String(bytes, Charset.forName("UTF-8"));
os.close();
} catch (UnsupportedEncodingException ex) {
System.out.println(ex);
} catch (IOException ex) {
System.out.println(ex);
}
System.out.println(xmlRecord);
}*/
/**
* Fonction pour récupérer l'identifiant Handle ( sécurisé mais ne marche
* pas encore )

0 comments on commit b43dccf

Please sign in to comment.
You can’t perform that action at this time.