Пример #1
0
 @Test
 public void testOnEventAdded() throws RepositoryException, InterruptedException {
   try {
     // Perform SUT
     Node root = session.getRootNode();
     Node hello = root.addNode("helloWorld");
     hello.setProperty("message", "Hello, World!");
     session.save();
   } finally {
     // logout
     // This is when the observers are fired
     session.logout();
   }
   // ModeShape uses background threads for event firing and similar
   // activities.
   // let's give it 5 seconds to run, then check the bags.
   Thread.sleep(5000);
   // Check that node was added
   assertEquals(1, counter.getCountForType(Event.NODE_ADDED));
   // Properties jcr:primaryType and message added
   // ModeShape adds a few extra properties.
   assertEquals(4, counter.getCountForType(Event.PROPERTY_ADDED));
 }
Пример #2
0
 @After
 public void cleanUp() throws Exception {
   counter.resetBag();
 }