Skip to content

Commit

Permalink
adding config.properties for token and project_id
Browse files Browse the repository at this point in the history
  • Loading branch information
d-kononov committed Sep 8, 2015
1 parent c200baf commit 6cd444a
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions src/test/java/io/iron/test/IronWorkerTest.java
Expand Up @@ -5,6 +5,10 @@
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.Properties;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import java.io.IOException;

Expand All @@ -14,19 +18,30 @@ public class IronWorkerTest {

@Before
public void setUp() throws Exception {
client = new Client("WRxxxxxxxxxxxxxxxxxxxxxxZ0c", "52f4419d13a66a0009000004");
Properties prop = new Properties();
InputStream input = null;
try {
input = new FileInputStream("config.properties");
} catch(FileNotFoundException fnfe) {
System.out.println("config.properties not found");
input = new FileInputStream("../../config.properties"); //maven release hack
}
prop.load(input);
String token = prop.getProperty("token");
String projectId = prop.getProperty("project_id");
client = new Client(token, projectId);
}

@Test
public void testCreatingTask() throws IOException, APIException {
String id = client.createTask("HelloWorkerMono").getId();
String id = client.createTask("MonoWorker101").getId();

Assert.assertTrue(id.length() > 0);
}

@Test
public void testViewingTaskInfoAfterTaskCreation() throws IOException, APIException {
TaskEntity task = client.createTask("HelloWorkerMono");
TaskEntity task = client.createTask("MonoWorker101");

Assert.assertTrue(task.getId().length() > 0);
Assert.assertNull(task.getCodeId());
Expand All @@ -39,7 +54,7 @@ public void testViewingTaskInfoAfterTaskCreation() throws IOException, APIExcept

@Test
public void testGetTaskInfo() throws IOException, APIException, InterruptedException {
String id = client.createTask("HelloWorkerMono").getId();
String id = client.createTask("MonoWorker101").getId();
Thread.sleep(1000);
TaskEntity task = client.getTask(id);

Expand All @@ -54,7 +69,7 @@ public void testGetTaskInfo() throws IOException, APIException, InterruptedExcep

@Test
public void testTaskReloadInfo() throws IOException, APIException, InterruptedException {
TaskEntity task = client.createTask("HelloWorkerMono");
TaskEntity task = client.createTask("MonoWorker101");
Thread.sleep(1000);
client.reload(task);

Expand All @@ -69,14 +84,14 @@ public void testTaskReloadInfo() throws IOException, APIException, InterruptedEx

@Test
public void testSchedulingTask() throws IOException, APIException {
String id = client.createSchedule("HelloWorkerMono").getId();
String id = client.createSchedule("MonoWorker101").getId();

Assert.assertTrue(id.length() > 0);
}

@Test
public void testSchedulingInfo() throws IOException, APIException, InterruptedException {
String id = client.createSchedule("HelloWorkerMono").getId();
String id = client.createSchedule("MonoWorker101").getId();
Thread.sleep(1000);
ScheduleEntity schedule = client.getSchedule(id);

Expand All @@ -90,7 +105,7 @@ public void testSchedulingInfo() throws IOException, APIException, InterruptedEx

@Test
public void testReloadSchedule() throws IOException, APIException, InterruptedException {
ScheduleEntity schedule = client.createSchedule("HelloWorkerMono");
ScheduleEntity schedule = client.createSchedule("MonoWorker101");
Thread.sleep(1000);
client.reload(schedule);

Expand Down

0 comments on commit 6cd444a

Please sign in to comment.