Skip to content

Commit

Permalink
Unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
markewallace committed Jun 20, 2014
1 parent f16099a commit d8ad4c2
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
ActivityDescendantsSinceTest.class,
ActivityNodeChildrenSinceTest.class,
ActivityDescendantsSortByTest.class,
ActivityFeedEnhTest.class//,
//MakeActivityPublicTest.class,
//GetActivityReplyNodeTagsTest.class
ActivityFeedEnhTest.class,
MakeActivityPublicTest.class,
GetActivityReplyNodeTagsTest.class
})
public class ActivitiesEnhTestSuite {
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,39 @@ public void testConcurrentFileUploads() {

}

@Test
public void testMultipleFileUploads() {

String url = System.getProperty("ServerUrl");
String userstr = System.getProperty("Users");

String[] userstrs = StringUtil.splitString(userstr, ',');
String[][] users = new String[userstrs.length][2];
for (int i=0; i<userstrs.length; i++) {
users[i] = StringUtil.splitString(userstrs[i], ':');
}

ActivityClient[] clients = ActivityClient.createClients(url, users);

try {
long start = System.currentTimeMillis();

Activity activity = clients[0].createActivity(clients);

Thread thread1 = clients[0].uploadFiles(activity, 20);
Thread thread2 = clients[0].uploadFiles(activity, 20);

thread1.join();
thread2.join();

long duration = System.currentTimeMillis() - start;
System.out.println("Completed test: "+duration+"(ms)");
} catch (Exception e) {
System.err.println("Error uploading activity files: "+e.getMessage());
e.printStackTrace();
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void testDescendantsCreatedSince() throws ClientServicesException, XMLExc
ActivityNode node = nodes.get(2);

Map<String, String> params = new HashMap<String, String>();
System.out.println(node.getPublished().getTime());
params.put("since", "" + node.getPublished().getTime());
params.put("rangeId", "created");
EntityList<ActivityNode> activityNodes = activityService.getActivityNodeDescendants(activity.getActivityUuid(), params);
Expand Down Expand Up @@ -145,12 +146,16 @@ public void testDescendantsCreatedSinceUntil() throws ClientServicesException, X
params.put("since", "" + sinceNode.getPublished().getTime());
params.put("until", "" + untilNode.getPublished().getTime());
params.put("rangeId", "created");
System.out.println("since="+sinceNode.getPublished().getTime());
System.out.println("until="+untilNode.getPublished().getTime());
EntityList<ActivityNode> activityNodes = activityService.getActivityNodeDescendants(activity.getActivityUuid(), params);
System.out.println("Nodes:" + activityNodes.size() +
" created since: " + dateFormat.format(sinceNode.getPublished()) +
" until: " + dateFormat.format(untilNode.getPublished()));
dumpNodes(activityNodes);

activity = null;

Assert.assertEquals(2, activityNodes.size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,32 @@ public void testDescendantsModifiedSort() throws ClientServicesException, XMLExc

params.put("sortOrder", "desc");
EntityList<ActivityNode> activityChildren = activityService.getActivityNodeChildren(activity.getActivityUuid(), params);
System.out.println("\nActivity shildren sorted descending by modification date");
System.out.println("\nActivity children sorted descending by modification date");
for (ActivityNode node : activityChildren) {
System.out.println(node.getTitle() + " modified: " + dateFormat.format(node.getUpdated()));
}
}

@Test
public void testDescendantsTitleModifiedSort() throws ClientServicesException, XMLException {
long start = System.currentTimeMillis();
activity = createActivity("ActivityDescendantsModifiedSort-"+start);

List<ActivityNode> nodes = createActivityDescendants(activity);
org.junit.Assert.assertNotNull(nodes);

Map<String, String> params = new HashMap<String, String>();
params.put("sortfields", "title,modified");
params.put("sortorder", "desc,asc");
EntityList<ActivityNode> activityDescendants = activityService.getActivityNodeDescendants(activity.getActivityUuid(), params);
System.out.println("\nActivity descendants sorted descending by title and ascending by modification date");
for (ActivityNode node : activityDescendants) {
System.out.println(node.getTitle() + " modified: " + dateFormat.format(node.getUpdated()));
}

params.put("sortorder", "asc,desc");
EntityList<ActivityNode> activityChildren = activityService.getActivityNodeChildren(activity.getActivityUuid(), params);
System.out.println("\nActivity children sorted ascending by title and descending by modification date");
for (ActivityNode node : activityChildren) {
System.out.println(node.getTitle() + " modified: " + dateFormat.format(node.getUpdated()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ public void testReduceFieldsToSingleNode() throws ClientServicesException, XMLEx
Field movedDateField = read.getFieldByName(dateField.getName());
Assert.assertTrue(movedDateField instanceof DateField);
Assert.assertEquals("test_date", ((DateField)movedDateField).getName());
Assert.assertEquals(2000, ((DateField)movedDateField).getPosition());
Assert.assertEquals(3000, ((DateField)movedDateField).getPosition());
Assert.assertNotNull(((DateField)movedDateField).getDate());

// Check hidden text field
Field movedHiddenTextField = read.getFieldByName(hiddenTextField.getName());
Assert.assertTrue(movedHiddenTextField instanceof TextField);
Assert.assertTrue(((TextField)movedHiddenTextField).isHidden());
Assert.assertEquals("test_hidden_text", ((TextField)movedHiddenTextField).getName());
Assert.assertEquals(3000, ((TextField)movedHiddenTextField).getPosition());
Assert.assertEquals(2000, ((TextField)movedHiddenTextField).getPosition());
Assert.assertEquals("Hidden_Text_Field", ((TextField)movedHiddenTextField).getSummary());

// Delete the activities again
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ActivityNodeChildrenSinceTest extends BaseActivityServiceTest {
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");

@Test
public void testDescendantsUpdatedSince() throws ClientServicesException, XMLException {
public void testNodeChildrenUpdatedSince() throws ClientServicesException, XMLException {
long start = System.currentTimeMillis();
activity = createActivity("ActivityDescendantsUpdatedSince-"+start);

Expand All @@ -53,7 +53,7 @@ public void testDescendantsUpdatedSince() throws ClientServicesException, XMLExc
}

@Test
public void testDescendantsUpdatedUntil() throws ClientServicesException, XMLException {
public void testNodeChildrenUpdatedUntil() throws ClientServicesException, XMLException {
long start = System.currentTimeMillis();
activity = createActivity("ActivityDescendantsUpdatedUntil-"+start);

Expand All @@ -70,7 +70,7 @@ public void testDescendantsUpdatedUntil() throws ClientServicesException, XMLExc
}

@Test
public void testDescendantsUpdatedSinceUntil() throws ClientServicesException, XMLException {
public void testNodeChildrenUpdatedSinceUntil() throws ClientServicesException, XMLException {
long start = System.currentTimeMillis();
activity = createActivity("ActivityDescendantsUpdatedSinceUntil-"+start);

Expand All @@ -91,7 +91,7 @@ public void testDescendantsUpdatedSinceUntil() throws ClientServicesException, X
}

@Test
public void testDescendantsCreatedSince() throws ClientServicesException, XMLException {
public void testNodeChildrenCreatedSince() throws ClientServicesException, XMLException {
long start = System.currentTimeMillis();
activity = createActivity("ActivityDescendantsCreatedSince-"+start);

Expand All @@ -109,7 +109,7 @@ public void testDescendantsCreatedSince() throws ClientServicesException, XMLExc
}

@Test
public void testDescendantsCreatedUntil() throws ClientServicesException, XMLException {
public void testNodeChildrenCreatedUntil() throws ClientServicesException, XMLException {
long start = System.currentTimeMillis();
activity = createActivity("ActivityDescendantsCreatedUntil-"+start);

Expand All @@ -127,7 +127,7 @@ public void testDescendantsCreatedUntil() throws ClientServicesException, XMLExc
}

@Test
public void testDescendantsCreatedSinceUntil() throws ClientServicesException, XMLException {
public void testNodeChildrenCreatedSinceUntil() throws ClientServicesException, XMLException {
long start = System.currentTimeMillis();
activity = createActivity("ActivityDescendantsCreatedSinceUntil-"+start);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ protected List<ActivityNode> createActivityDescendants(String activityUuid, int

for (int i=0; i<count; i++) {
long now = System.currentTimeMillis();
String title = "Descendant-" + now;
String title = i + ". Descendant-" + now;
activityNodes.add(createActivityNode(activityUuid, title));

try {
Expand Down Expand Up @@ -316,7 +316,7 @@ protected List<ActivityNode> createActivityDescendants(Activity activity) throws
}

protected void dumpNodes(List<ActivityNode> nodes) {
System.out.println(" TITLE PUBLISHED UPDATED");
System.out.println(" TITLE PUBLISHED UPDATED");
for (ActivityNode node : nodes) {
String title = node.getTitle();
Date create = new Date(Long.parseLong(title.substring(title.indexOf('-')+1)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum ActivityXPath implements FieldEntry {
priority("./a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/priority']/@term"),
defaultView("./a:category[@scheme='http://www.ibm.com/xmlns/prod/sn/default-view']/@term"),
deleted("./a:category[@term='deleted']"),
reply("./a:category[@term='reply']"),
external("./a:category[@term='external']"),
completed("./a:category[@term='completed']"),
template("./a:category[@term='template']"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ public void setTags(List<String> tags) {
super.setBaseTags(tags);
}

/**
* Returns true if the node is a reply.
*
* Flag that is only present on an node that is a reply.
*
* @return
*/
public boolean isReply() {
return exists(ActivityXPath.reply);
}

/**
* Returns true if the node is deleted.
*
Expand Down

0 comments on commit d8ad4c2

Please sign in to comment.