Author: batosai
Date: 2008-08-20 19:10:33 +0000 (Wed, 20 Aug 2008)
New Revision: 22065

Added:
   trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java
Modified:
   trunk/apps/WoT/src/plugins/WoT/WebInterface.java
   trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
Log:
Added a test class to check to WoT calculation process (bug #2518)

Modified: trunk/apps/WoT/src/plugins/WoT/WebInterface.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WebInterface.java    2008-08-20 18:54:43 UTC 
(rev 22064)
+++ trunk/apps/WoT/src/plugins/WoT/WebInterface.java    2008-08-20 19:10:33 UTC 
(rev 22065)
@@ -273,4 +273,30 @@
        private HTMLNode getPageNode() {
                return pm.getPageNode("Web of Trust", null);
        }
+
+       public String makeTestPage() {
+               HTMLNode pageNode = getPageNode();
+               HTMLNode contentNode = pm.getContentNode(pageNode);
+               HTMLNode box = pm.getInfobox("WoT test results");
+               HTMLNode boxContent = pm.getContentNode(box);
+               
+               boxContent.addChild("pre", new WotTestDrive(wot,db).fullTest());
+                               
+               contentNode.addChild(box);
+               return pageNode.generate();
+       }
+
+       public String makeTestWarningPage() {
+               HTMLNode pageNode = getPageNode();
+               HTMLNode contentNode = pm.getContentNode(pageNode);
+               HTMLNode box = pm.getInfobox("WoT testDrive");
+               HTMLNode boxContent = pm.getContentNode(box);
+               
+               boxContent.addChild("p", "Warning ! These tests will destroy 
your database, you might want to backup 'WoT.db4o' in your freenet 
directory...");
+               HTMLNode form = pr.addFormChild(boxContent, SELF_URI + 
"/wotTestDrive", "form");
+               form.addChild("input", new String[] { "type", "name", "value" 
}, new String[] { "submit", "confirm", "Perform self tests !" });
+                               
+               contentNode.addChild(box);
+               return pageNode.generate();
+       }
 }

Modified: trunk/apps/WoT/src/plugins/WoT/WoTplugin.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-20 18:54:43 UTC 
(rev 22064)
+++ trunk/apps/WoT/src/plugins/WoT/WoTplugin.java       2008-08-20 19:10:33 UTC 
(rev 22065)
@@ -98,6 +98,9 @@
                        if(page.equals("/knownidentities")) {
                                return web.makeKnownIdentitiesPage();
                        }
+                       if(page.equals("/wotTestDrive")) {
+                               return web.makeTestWarningPage();
+                       }
                        else {
                                return web.makeHomePage();
                        }
@@ -136,6 +139,9 @@
                                setTrust(request);
                                return 
web.makeKnownIdentitiesPage(request.getPartAsString("truster", 1024));
                        }
+                       else if (page.equals("/wotTestDrive")) {
+                               return web.makeTestPage();
+                       }
                        else {
                                return web.makeHomePage();
                        }

Added: trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java                            
(rev 0)
+++ trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java    2008-08-20 19:10:33 UTC 
(rev 22065)
@@ -0,0 +1,31 @@
+/**
+ * This code is part of WoT, a plugin for Freenet. It is distributed 
+ * under the GNU General Public License, version 2 (or at your option
+ * any later version). See http://www.gnu.org/ for details of the GPL.
+ */
+package plugins.WoT;
+
+import com.db4o.ObjectContainer;
+
+/**
+ * A local Identity (it belongs to the user)
+ * 
+ * @author Julien Cornuwel (batosai at freenetproject.org)
+ *
+ */
+public class WotTestDrive {
+
+       WoT wot;
+       ObjectContainer db;
+       
+       public WotTestDrive(WoT wot, ObjectContainer db) {
+               this.wot = wot;
+               this.db = db;
+       }
+       
+       public String fullTest() {
+               String result = "";
+               
+               return result;
+       }
+}


Reply via email to