Skip to content
Snippets Groups Projects
Commit 1791f301 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman :boom:
Browse files

Changed the unit test to be more useful.

parent eac0306b
Branches master
No related tags found
No related merge requests found
package com.syncleus.tutorial.jackrabbit.hello; package com.syncleus.tutorial.jackrabbit.hello;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
...@@ -19,6 +20,7 @@ import org.apache.jackrabbit.core.TransientRepository; ...@@ -19,6 +20,7 @@ import org.apache.jackrabbit.core.TransientRepository;
public class AppTest public class AppTest
extends TestCase extends TestCase
{ {
private static final String MESSAGE = "Hello, World!";
/** /**
* Create the test case * Create the test case
* *
...@@ -45,14 +47,25 @@ public class AppTest ...@@ -45,14 +47,25 @@ public class AppTest
Repository repo = new TransientRepository(); Repository repo = new TransientRepository();
Session session = repo.login( Session session = repo.login(
new SimpleCredentials("admin","admin".toCharArray())); new SimpleCredentials("admin","admin".toCharArray()));
Node root = session.getRootNode(); try {
Node root = session.getRootNode();
NodeIterator i = root.getNodes();
while(i.hasNext()){ // Store content
Node node = i.nextNode(); Node hello = root.addNode("hello");
System.out.println(node.getName()); Node world = hello.addNode("world");
world.setProperty("message", MESSAGE);
session.save();
// Retrieve content
Node node = root.getNode("hello/world");
Assert.assertEquals(MESSAGE, node.getProperty("message").getString());
// Remove content
root.getNode("hello").remove();
session.save();
} }
finally {
session.logout(); session.logout();
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment