Skip to content
Browse files

Add range in junit dependency and little code refactor

  • Loading branch information...
1 parent 1909e4e commit aaf3c62a208b1846b5d058198213a006ba3f774e @richard-julien committed Mar 22, 2012
Showing with 17 additions and 16 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 client/pom.xml
  3. +15 −15 client/src/test/java/io/iron/ironworker/client/APIClientTest.java
View
1 .gitignore
@@ -2,3 +2,4 @@
*.iml
**/target/*
.gitignore.swp
+.DS_Store
View
2 client/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.10</version>
+ <version>[4.0,4.10)</version>
</dependency>
</dependencies>
</project>
View
30 client/src/test/java/io/iron/ironworker/client/APIClientTest.java
@@ -27,7 +27,7 @@
public static String IRON_IO_PROJECT_ID = "IRON_IO_PROJECT_ID";
public static Map<String, Object> IRON_IO_PARAMS = null;
//Default worker
- public static final String WORKER_NAME = randomUUID().toString();
+ public static final String WORKER_NAME = "UnitWorkerTest2";
public static final String WORKER_FILE = "runner.rb";
public static final String WORKER_FILE_ZIP = "hello_world_worker.zip";
public static final String WORKER_RUNTIME = "ruby";
@@ -67,7 +67,7 @@ public void shouldCodesCreate() throws APIException {
public void shouldCodesList() throws APIException {
APIClient client = new APIClient(_ironToken, _ironProjectId);
JsonObject codesList = client.codesList(IRON_IO_PARAMS);
- assertNotNull("Codes list could not be null", codesList);
+ assertNotNull(codesList);
JsonArray codes = codesList.getAsJsonArray("codes");
JsonObject code = fetchCodeFromName(codes, WORKER_NAME);
_codeId = checkCodePackageValidity(code);
@@ -93,7 +93,7 @@ public void shouldCodesRevisions() throws APIException {
public void shouldCodesDownload() throws APIException, IOException {
APIClient client = new APIClient(_ironToken, _ironProjectId);
byte[] byteFromIron = client.codesDownload(_codeId, IRON_IO_PARAMS);
- InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(WORKER_FILE);
+ InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(WORKER_FILE_ZIP);
byte[] bytesFromClient = IOUtils.toByteArray(resourceAsStream);
assertArrayEquals(bytesFromClient, byteFromIron);
}
@@ -102,7 +102,7 @@ public void shouldCodesDownload() throws APIException, IOException {
public void shouldCodesDelete() throws APIException {
APIClient client = new APIClient(_ironToken, _ironProjectId);
JsonObject deleteMessage = client.codesDelete(_codeId);
- assertNotNull("Delete message could not be null", deleteMessage);
+ assertNotNull(deleteMessage);
assertEquals("Deleted", deleteMessage.get("msg").getAsString());
}
@@ -112,11 +112,11 @@ public void shouldCodesDelete() throws APIException {
* @param revision the json object that represent a revision
*/
private void checkCodeRevisionValidity(JsonObject revision) {
- assertNotNull("Revision object could not be null", revision);
- assertNotNull("Revision id could not be null", revision.get("id").getAsString());
- assertNotNull("Code id could not be null", revision.get("code_id").getAsString());
- assertNotNull("Project id could not be null", revision.get("project_id").getAsString());
- assertEquals("1", revision.get("rev").getAsString());
+ assertNotNull(revision);
+ assertNotNull(revision.get("id").getAsString());
+ assertNotNull(revision.get("code_id").getAsString());
+ assertNotNull(revision.get("project_id").getAsString());
+ assertNotNull(revision.get("rev").getAsString());
assertEquals(WORKER_RUNTIME, revision.get("runtime").getAsString());
assertEquals(WORKER_NAME, revision.get("name").getAsString());
assertEquals(WORKER_FILE, revision.get("file_name").getAsString());
@@ -129,11 +129,11 @@ private void checkCodeRevisionValidity(JsonObject revision) {
* @return id of the code
*/
private String checkCodePackageValidity(JsonObject code) {
- assertNotNull("Code object could not be null", code);
+ assertNotNull(code);
String id = code.get("id").getAsString();
- assertNotNull("Code id could not be null", id);
- assertNotNull("Project id could not be null", code.get("project_id").getAsString());
- assertNotNull("Lastest change could not be null", code.get("latest_change").getAsString());
+ assertNotNull(id);
+ assertNotNull(code.get("project_id").getAsString());
+ assertNotNull(code.get("latest_change").getAsString());
return id;
}
@@ -147,12 +147,12 @@ private String checkCodePackageValidity(JsonObject code) {
private JsonObject fetchCodeFromName(JsonArray codes, String name) {
for (JsonElement code : codes) {
String codeName = code.getAsJsonObject().get("name").getAsString();
- assertNotNull("Worker name could not be null", codeName);
+ assertNotNull(codeName);
if (codeName.equals(name)) {
return code.getAsJsonObject();
}
}
- throw new IllegalArgumentException("Can't find previously uploaded worker" + name);
+ throw new IllegalArgumentException("Can't find previously uploaded worker name : " + name + " in " + codes);
}
}

0 comments on commit aaf3c62

Please sign in to comment.
Something went wrong with that request. Please try again.