Author: batosai
Date: 2008-09-07 13:47:24 +0000 (Sun, 07 Sep 2008)
New Revision: 22525

Modified:
   trunk/plugins/WoT/src/plugins/WoT/IdentityTest.java
Log:
Test the persistence of Identities. 
Reveals a problem on using a ByteArrayWrapper as identifier.
I'll switch back to String.

Modified: trunk/plugins/WoT/src/plugins/WoT/IdentityTest.java
===================================================================
--- trunk/plugins/WoT/src/plugins/WoT/IdentityTest.java 2008-09-07 12:38:51 UTC 
(rev 22524)
+++ trunk/plugins/WoT/src/plugins/WoT/IdentityTest.java 2008-09-07 13:47:24 UTC 
(rev 22525)
@@ -19,6 +19,7 @@
  */
 public class IdentityTest extends TestCase {

+       private String uri = "USK at 
yGvITGZzrY1vUZK-4AaYLgcjZ7ysRqNTMfdcO8gS-LY,-ab5bJVD3Lp-LXEQqBAhJpMKrKJ19RnNaZMIkusU79s,AQACAAE/WoT/0";
        private Identity identity;
        private ObjectContainer db;

@@ -28,13 +29,11 @@

        protected void setUp() throws Exception {
                super.setUp();
-               identity = new Identity("USK at 
MF2Vc6FRgeFMZJ0s2l9hOop87EYWAydUZakJzL0OfV8,fQeN-RMQZsUrDha2LCJWOMFk1-EiXZxfTnBT8NEgY00,AQACAAE/WoT/0",
-                               "Seed Identity",
-                               "true",
-                               "boostrap");
+               identity = new Identity(uri, "test", "true", "bar");

                db = Db4o.openFile("identityTest.db4o");
                db.store(identity);
+               db.commit();
        }

        protected void tearDown() throws Exception {
@@ -48,7 +47,7 @@
        }

        public void testGetByURI() throws MalformedURLException, 
UnknownIdentityException, DuplicateIdentityException {
-               assertNotNull(Identity.getByURI(db, "USK at 
MF2Vc6FRgeFMZJ0s2l9hOop87EYWAydUZakJzL0OfV8,fQeN-RMQZsUrDha2LCJWOMFk1-EiXZxfTnBT8NEgY00,AQACAAE/WoT/0"));
+               assertNotNull(Identity.getByURI(db, uri));
        }

        public void testContexts() throws InvalidParameterException  {
@@ -77,5 +76,12 @@
                        fail();
                } catch (InvalidParameterException e) {}
        }
-
+       
+       public void testPersistence() throws MalformedURLException, 
UnknownIdentityException, DuplicateIdentityException {
+               db.close();
+               // TODO Force a garbage collection/finalization
+               db = Db4o.openFile("scoreTest.db4o");
+               
+               assertNotNull(Identity.getByURI(db, uri));
+       }
 }


Reply via email to