2525: readme and test updates
authorradhika <radhika@curoverse.com>
Sun, 4 May 2014 02:17:30 +0000 (22:17 -0400)
committerradhika <radhika@curoverse.com>
Sun, 4 May 2014 02:17:30 +0000 (22:17 -0400)
sdk/java/README
sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java
sdk/java/src/test/resources/create_user.json [deleted file]

index a336e6fc02c72a8f37ce5fa4178005817aa137a3..e4cc2035ed6f288fdc1e7815ced6217ed80c345e 100644 (file)
@@ -7,6 +7,8 @@
 
   - This document highlights the details as to how to use the SDK.
 
+  - The Java SDK requires Java 6 or later
+  
   - The Java SDK is used as a maven project. Hence, you would need a working
       maven environment to be able to build the source code.
 
@@ -25,7 +27,8 @@
          API server needs to be passed to the SDK using environment variables or
          during the construction of the Arvados instance.
          
-  - If you would like to use environment variables, below are the details.
+  - Below are the details about the environment variables and example setup
+         statements for a .bashrc file.
        
       1. ARVADOS_API_TOKEN
       
index 7f7bfabe1d16e80dcb2ed7bd70fc4f1c2ed8ba25..644365ce08b140346bf5fe85f0ecc9e014e5f4a2 100644 (file)
@@ -1,6 +1,10 @@
 package org.arvados.sdk.java;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -115,9 +119,6 @@ public class ArvadosTest {
   public void testCreateUser() throws Exception {
     Arvados arv = new Arvados("arvados", "v1");
 
-    File file = new File(getClass().getResource( "/create_user.json" ).toURI());
-    String filePath = file.getPath();
-
     Map<String, Object> params = new HashMap<String, Object>();
     params.put("user", "{}");
     String response = arv.call("users", "create", params);
@@ -125,15 +126,15 @@ public class ArvadosTest {
     JSONParser parser = new JSONParser();
     JSONObject jsonObject = (JSONObject) parser.parse(response);
     assertEquals("Expected kind to be user", "arvados#user", jsonObject.get("kind"));
-    
+
     Object uuid = jsonObject.get("uuid");
     assertNotNull("Expected uuid for first user", uuid);
-    
+
     // delete the object
     params = new HashMap<String, Object>();
     params.put("uuid", uuid);
     response = arv.call("users", "delete", params);
-    
+
     // invoke users.get with the system user uuid
     params = new HashMap<String, Object>();
     params.put("uuid", uuid);
@@ -182,10 +183,10 @@ public class ArvadosTest {
     JSONParser parser = new JSONParser();
     JSONObject jsonObject = (JSONObject) parser.parse(response);
     assertEquals("Expected kind to be user", "arvados#user", jsonObject.get("kind"));
-    
+
     Object uuid = jsonObject.get("uuid");
     assertNotNull("Expected uuid for first user", uuid);
-    
+
     // update this user
     params = new HashMap<String, Object>();
     params.put("user", "{}");
@@ -195,10 +196,10 @@ public class ArvadosTest {
     parser = new JSONParser();
     jsonObject = (JSONObject) parser.parse(response);
     assertEquals("Expected kind to be user", "arvados#user", jsonObject.get("kind"));
-    
+
     uuid = jsonObject.get("uuid");
     assertNotNull("Expected uuid for first user", uuid);
-    
+
     // delete the object
     params = new HashMap<String, Object>();
     params.put("uuid", uuid);
@@ -242,7 +243,7 @@ public class ArvadosTest {
     assertNotNull ("expected exception", caught);
     assertTrue ("Expected 404 when unsupported version is used", caught.getMessage().contains("404 Not Found"));
   }
-  
+
   /**
    * Test unsupported api version api
    * @throws Exception
@@ -261,7 +262,7 @@ public class ArvadosTest {
     assertNotNull ("expected exception", caught);
     assertTrue ("Expected ERROR: 404 not found", caught.getMessage().contains("ERROR: resource not found"));
   }
-  
+
   /**
    * Test unsupported api version api
    * @throws Exception
@@ -290,10 +291,17 @@ public class ArvadosTest {
     Arvados arv = new Arvados("arvados", "v1");
 
     File file = new File(getClass().getResource( "/first_pipeline.json" ).toURI());
-    String filePath = file.getPath();
+    byte[] data = new byte[(int)file.length()];
+    try {
+      FileInputStream is = new FileInputStream(file);
+      is.read(data);
+      is.close();
+    }catch(Exception e) {
+      e.printStackTrace();
+    }
 
     Map<String, Object> params = new HashMap<String, Object>();
-    params.put("pipeline_template", "{}");                          // TBD - read file and send
+    params.put("pipeline_template", new String(data));
     String response = arv.call("pipeline_templates", "create", params);
 
     JSONParser parser = new JSONParser();
@@ -301,7 +309,7 @@ public class ArvadosTest {
     assertEquals("Expected kind to be user", "arvados#pipelineTemplate", jsonObject.get("kind"));
     String uuid = (String)jsonObject.get("uuid");
     assertNotNull("Expected uuid for pipeline template", uuid);
-    
+
     // get the pipeline
     params = new HashMap<String, Object>();
     params.put("uuid", uuid);
@@ -311,7 +319,7 @@ public class ArvadosTest {
     jsonObject = (JSONObject) parser.parse(response);
     assertEquals("Expected kind to be user", "arvados#pipelineTemplate", jsonObject.get("kind"));
     assertEquals("Expected uuid for pipeline template", uuid, jsonObject.get("uuid"));
-    
+
     // delete the object
     params = new HashMap<String, Object>();
     params.put("uuid", uuid);
@@ -371,7 +379,7 @@ public class ArvadosTest {
     // make the request again with limit
     params = new HashMap<String, Object>();
     params.put("limit", numUsersListItems-1);
-    
+
     response = arv.call("users", "list", params);
 
     parser = new JSONParser();
@@ -400,11 +408,11 @@ public class ArvadosTest {
     /*
     String[] filters = new String[1];
     filters[0] = "name != 'can_manage'";
-    
+
     params.put("filters", filters);
     response = arv.call("links", "list", params);
     assertTrue("Expected links.list in response", response.contains("arvados#linkList"));
-    */   
+     */   
   }
 
 }
\ No newline at end of file
diff --git a/sdk/java/src/test/resources/create_user.json b/sdk/java/src/test/resources/create_user.json
deleted file mode 100644 (file)
index 0967ef4..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{}