jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Florent Guillaume ...@nuxeo.com>
Subject refresh after copy
Date Mon, 14 Apr 2008 19:30:49 GMT
Hi,

I must be missing something about how refresh() works.
The following is tested in Jackrabbit 1.3.3 and 1.4.2, and the last  
two assertions always fail.
Could someone point me in the right direction? How do I refresh my  
node to get the persistent state?

Thanks,
Florent


import javax.jcr.Node;
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.apache.jackrabbit.core.TransientRepository;
import junit.framework.TestCase;

public class TestRefresh extends TestCase {

     public static void testRefresh() throws Exception {
         Repository repository = new TransientRepository();
         Session session = repository.login(new  
SimpleCredentials("username",
                 "password".toCharArray()));
         try {
             Node root = session.getRootNode();

             Node hello = root.addNode("hello");
             hello.addNode("world");
             assertEquals(1, hello.getNodes().getSize());
             session.save();

             session.getWorkspace().copy("/hello/world", "/hello/foo");
             assertEquals(1, hello.getNodes().getSize());
             assertFalse(hello.hasNode("foo"));

             session.refresh(false); // following fails even if true
             assertEquals(2, hello.getNodes().getSize()); // FAILS!
             assertTrue(hello.hasNode("foo")); // FAILS!
         } finally {
             session.logout();
         }
     }
}

-- 
Florent Guillaume, Director of R&D, Nuxeo
Open Source Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87




Mime
View raw message