Author: batosai
Date: 2008-08-31 17:02:36 +0000 (Sun, 31 Aug 2008)
New Revision: 22284

Modified:
   trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java
Log:
Some more tests

Modified: trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java    2008-08-31 16:38:48 UTC 
(rev 22283)
+++ trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java    2008-08-31 17:02:36 UTC 
(rev 22284)
@@ -5,6 +5,7 @@
  */
 package plugins.WoT;

+import java.net.MalformedURLException;
 import java.util.Date;

 import com.db4o.ObjectContainer;
@@ -111,10 +112,59 @@
                }
                out.append("OK\n");             

-               ObjectSet<Score> scores = db.queryByExample(Score.class);
-               while (scores.hasNext()) out.append(scores.next().toString() + 
"\n"); 
+               out.append("* Make a trust b again (different value):");
+               try {
+                       wot.setTrust(new Trust(a,b,90));
+                       
+                       ObjectSet<Trust> trusts = 
db.queryByExample(Trust.class);
+                       if(trusts.size() != 3) {
+                               out.append("NOK\n");
+                               while (trusts.hasNext()) 
out.append(trusts.next().toString() + "\n"); 
+                       }
+                       
+                       ObjectSet<Score> scores = 
db.queryByExample(Score.class);
+                       if(scores.size() != 9) {
+                               out.append("NOK\n");
+                               while (scores.hasNext()) 
out.append(scores.next().toString() + "\n"); 
+                       }
+               } catch (Exception e) {
+                       out.append(e.getMessage());
+               }
+               out.append("OK\n");     

+               Identity storedA = null;
+               out.append("* Try to fetch existing identity (a):");
+               try {
+                       storedA = 
wot.getIdentityByURI(a.getRequestURI().toString());
+                       out.append("OK\n");
+               } catch (UnknownIdentityException e) {
+                       out.append("NOK\n");
+               } catch (Exception e) {
+                       out.append("\n"+e.getMessage());
+               }

+               Identity storedB = null;
+               out.append("* Try to fetch existing identity (b):");
+               try {
+                       storedB = 
wot.getIdentityByURI(b.getRequestURI().toString());
+                       out.append("OK\n");
+               } catch (UnknownIdentityException e) {
+                       out.append("NOK\n");
+               } catch (Exception e) {
+                       out.append("\n"+e.getMessage());
+               }
+               
+               out.append("* Try to fetch existing trust relationship (a -> 
b):");
+               try {
+                       ObjectSet<Trust> trustResult = db.queryByExample(new 
Trust(storedA, storedB, 0, null));
+                       if(trustResult.size() == 1) out.append("OK\n");
+                       else out.append("NOK\n");
+               } catch (Exception e) {
+                       out.append("\n" + e.getMessage());
+               }
+
+               
+               
                // Empty the database after tests
                ObjectSet<Object> remaining = db.queryByExample(new Object());
                while(remaining.hasNext()) db.delete(remaining.next());


Reply via email to