On Friday 22 August 2008 18:11, batosai at freenetproject.org wrote:
> Author: batosai
> Date: 2008-08-22 17:11:36 +0000 (Fri, 22 Aug 2008)
> New Revision: 22100
>
> Modified:
> trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java
> Log:
> Further testing of the WoT behaviour.
You still need to wipe the database before and after, no? AFAICS you deleted
this below.
>
> Modified: trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java
> ===================================================================
> --- trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java 2008-08-22 16:37:33 UTC
(rev 22099)
> +++ trunk/apps/WoT/src/plugins/WoT/WotTestDrive.java 2008-08-22 17:11:36 UTC
(rev 22100)
> @@ -9,6 +9,8 @@
>
> import com.db4o.ObjectContainer;
> import com.db4o.ObjectSet;
> +import com.db4o.ext.DatabaseClosedException;
> +import com.db4o.ext.Db4oIOException;
>
> import freenet.client.HighLevelSimpleClient;
> import freenet.keys.FreenetURI;
> @@ -34,47 +36,99 @@
> public String fullTest() {
>
> StringBuffer out = new StringBuffer();
> +
> + out.append("* Create 3 identities:");
> + OwnIdentity a = createIdentity(out,"a");
> + OwnIdentity b = createIdentity(out,"b");
> + OwnIdentity c = createIdentity(out,"c");
> + out.append("\n");
>
> - // Empty database
> - ObjectSet<Object> all = db.queryByExample(Object.class);
> - while(all.hasNext()) db.delete(all.next());
> + out.append("* Make a trust b:");
> + try {
> + wot.setTrust(new Trust(a,b,100));
> +
> + ObjectSet<Trust> trusts =
> db.queryByExample(Trust.class);
> + if(trusts.size() != 1) {
> + out.append("NOK\n");
> + while (trusts.hasNext())
> out.append(trusts.next().toString() + "\n");
> + }
> +
> + ObjectSet<Score> scores =
> db.queryByExample(Score.class);
> + if(scores.size() != 4) {
> + out.append("NOK\n");
> + while (scores.hasNext())
> out.append(scores.next().toString() + "\n");
> + }
> + } catch (Exception e) {
> + out.append(e.getMessage());
> + }
> + out.append("OK\n");
> +
> + out.append("* Make b trust c:");
> + try {
> + wot.setTrust(new Trust(b,c,100));
> +
> + ObjectSet<Trust> trusts =
> db.queryByExample(Trust.class);
> + if(trusts.size() != 2) {
> + out.append("NOK\n");
> + while (trusts.hasNext())
> out.append(trusts.next().toString() + "\n");
> + }
> +
> + ObjectSet<Score> scores =
> db.queryByExample(Score.class);
> + if(scores.size() != 6) {
> + out.append("NOK\n");
> + while (scores.hasNext())
> out.append(scores.next().toString() + "\n");
> + }
> + } catch (Exception e) {
> + out.append(e.getMessage());
> + }
> + out.append("OK\n");
>
> - out.append("* Create identity with keys:");
> - createIdentityWithKeys(out,
> - "SSK at
> AJpdMz4qaNiMX3MGmHCPvsP9wE~Rzk1M9cfA5abjnzKT,6dg0VehJynirCW1zYU2g1Yss4Ss~2BWst-oeje0HQEU,AQECAAE/WoT",
>
> - "SSK at
> h5Lcp80DUPSidjbzmz632D6JpZo2chDCsP4d6TzK~1E,6dg0VehJynirCW1zYU2g1Yss4Ss~2BWst-oeje0HQEU,AQACAAE/WoT");
> + out.append("* Make c trust a:");
> + try {
> + wot.setTrust(new Trust(c,a,100));
> +
> + 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");
>
> - out.append("* Create identity without keys:");
> - createIdentityWithoutKeys(out);
> + ObjectSet<Score> scores = db.queryByExample(Score.class);
> + while (scores.hasNext()) out.append(scores.next().toString() +
> "\n");
>
> - // Empty database
> - all = db.queryByExample(Object.class);
> - while(all.hasNext()) db.delete(all.next());
>
> return out.toString();
> }
>
> - private void createIdentityWithKeys(StringBuffer out, String insertURI,
String requestURI) {
> + private OwnIdentity createIdentity(StringBuffer out, String nickName) {
>
> + OwnIdentity id = null;
> + FreenetURI[] keypair = client.generateKeyPair("WoT");
> try {
> - OwnIdentity test1 = new OwnIdentity(insertURI,
> requestURI, new Date(0),
new Date(), "Test1", "true");
> + id = new OwnIdentity(keypair[0].toString(),
> keypair[1].toString(), new
Date(0), new Date(), nickName, "true");
>
> - test1.addContext("Testing", db);
> - db.store(test1);
> + id.addContext("Testing", db);
> + db.store(id);
>
> - Score score = new Score(test1, test1, 100, 0, 100); //
> We need to
initialize the trust tree
> + Score score = new Score(id, id, 100, 0, 100); // We
> need to initialize
the trust tree
> db.store(score);
>
> - out.append("OK\n");
> + out.append("OK");
> } catch (InvalidParameterException e) {
> out.append("NOK\n");
> out.append(e.getMessage());
> }
> + return id;
> }
>
> - private void createIdentityWithoutKeys(StringBuffer out) {
> - FreenetURI[] keypair = client.generateKeyPair("WoT");
> - createIdentityWithKeys(out, keypair[0].toString(),
keypair[1].toString());
> - }
> -
> }
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080830/24df20d7/attachment.pgp>