gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r24710 - in gnunet-java: bin test/org/gnunet/statistics


From: gnunet
Subject: [GNUnet-SVN] r24710 - in gnunet-java: bin test/org/gnunet/statistics
Date: Mon, 5 Nov 2012 12:15:23 +0100

Author: dold
Date: 2012-11-05 12:15:23 +0100 (Mon, 05 Nov 2012)
New Revision: 24710

Modified:
   gnunet-java/bin/gnunet-statistics
   gnunet-java/test/org/gnunet/statistics/StatisticsTest.java
Log:
added tests

Modified: gnunet-java/bin/gnunet-statistics
===================================================================
--- gnunet-java/bin/gnunet-statistics   2012-11-05 10:57:02 UTC (rev 24709)
+++ gnunet-java/bin/gnunet-statistics   2012-11-05 11:15:23 UTC (rev 24710)
@@ -1,12 +1,12 @@
 #!/bin/sh
 
-DIR=`dirname $0`
-
-if [ "$GNJ_IS_INSTALLED" = "true" ];
+if [ "%GNJ_INSTALLED" = "true" ];
 then
-    export CLASSPATH="%INSTALL_PATH%/share/java/*"
+    export CLASSPATH="%INSTALL_PATH/share/java/*"
 else
-    export CLASSPATH="$DIR/../build/:$DIR/../lib/*"
+    DIR=`dirname $0`
+    # if we are in the development environment use class files directly 
instead of jar
+    export 
CLASSPATH="$DIR/../build-gradle/classes/main/:$DIR/../build-gradle/resources/main/:$DIR/../lib/*"
 fi
 
 java -ea org.gnunet.statistics.Statistics "$@"

Modified: gnunet-java/test/org/gnunet/statistics/StatisticsTest.java
===================================================================
--- gnunet-java/test/org/gnunet/statistics/StatisticsTest.java  2012-11-05 
10:57:02 UTC (rev 24709)
+++ gnunet-java/test/org/gnunet/statistics/StatisticsTest.java  2012-11-05 
11:15:23 UTC (rev 24710)
@@ -146,6 +146,71 @@
     }
 
 
+    @Test
+    public void test_watch_restart() {
+        Program.configureLogging("DEBUG");
+        final TestingSubsystem ts = new TestingSubsystem("statistics");
+
+        final Statistics stat = new Statistics(ts.getConfiguration());
+
+        stat.watch("gnj-test", "test", new StatisticsReceiver() {
+            @Override
+            public void onReceive(String subsystem, String name, long value) {
+                System.out.println("received update!");
+            }
+        });
+
+        Scheduler.addDelayed(new RelativeTime(300), new Scheduler.Task() {
+            @Override
+            public void run(Scheduler.RunContext ctx) {
+                stat.destroy();
+            }
+        });
+
+        Scheduler.run();
+    }
+
+
+    @Test
+    public void test_watch_simple() {
+        Program.configureLogging("DEBUG");
+        final TestingSubsystem ts = new TestingSubsystem("statistics");
+
+        final Statistics stat = new Statistics(ts.getConfiguration());
+
+        stat.watch("gnj-test", "test", new StatisticsReceiver() {
+            @Override
+            public void onReceive(String subsystem, String name, long value) {
+                System.out.println("received update!");
+            }
+        });
+
+        Scheduler.addDelayed(new RelativeTime(100), new Scheduler.Task() {
+            @Override
+            public void run(Scheduler.RunContext ctx) {
+                stat.set("gnj-test", "test", 42, false);
+            }
+        });
+
+
+        Scheduler.addDelayed(new RelativeTime(200), new Scheduler.Task() {
+            @Override
+            public void run(Scheduler.RunContext ctx) {
+                ts.restart();
+            }
+        });
+
+        Scheduler.addDelayed(new RelativeTime(300), new Scheduler.Task() {
+            @Override
+            public void run(Scheduler.RunContext ctx) {
+                stat.destroy();
+            }
+        });
+
+        Scheduler.run();
+    }
+
+
     //@Test(timeout = 10000)
     public void test_watch() {
         Program.configureLogging("DEBUG");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]