Permalink
Browse files

Improve test framework.

  • Loading branch information...
1 parent 67281b5 commit 95a1f0f56770fe393bd0ef660033f6b4cdbc0f1f Andy Seaborne committed Mar 13, 2012
Showing with 67 additions and 26 deletions.
  1. +38 −0 log4j.properties
  2. +29 −26 src/test/java/structure/radix/TestRadix.java
View
@@ -0,0 +1,38 @@
+log4j.rootLogger=INFO, stdlog
+## log4j.rootLogger=INFO, FusekiFileLog
+
+log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
+## log4j.appender.stdlog.target=System.err
+log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+## # Example for file logging.
+## log4j.appender.FusekiFileLog=org.apache.log4j.DailyRollingFileAppender
+## log4j.appender.FusekiFileLog.DatePattern='.'yyyy-MM-dd
+## log4j.appender.FusekiFileLog.File=fuseki-log
+## log4j.appender.FusekiFileLog.layout=org.apache.log4j.PatternLayout
+## log4j.appender.FusekiFileLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+# Jetty - Fuseki catches Jetty errors and reports them.
+log4j.logger.org.eclipse.jetty=FATAL
+
+# Execution logging
+log4j.logger.com.hp.hpl.jena.arq.info=INFO
+log4j.logger.com.hp.hpl.jena.arq.exec=INFO
+
+# Everything else in Jena
+log4j.logger.com.hp.hpl.jena=WARN
+log4j.logger.org.apache.jena=WARN
+log4j.logger.org.openjena=WARN
+log4j.logger.org.openjena.riot=INFO
+
+# Joseki server
+log4j.logger.org.joseki=INFO
+
+# Fuseki
+# Server log.
+log4j.logger.org.apache.jena.fuseki.Server=INFO
+# Request log.
+log4j.logger.org.apache.jena.fuseki.Fuseki=INFO
+# Internal logs
+log4j.logger.org.apache.jena.fuseki=INFO
@@ -23,6 +23,7 @@
import java.util.List ;
import org.junit.Test ;
+import org.openjena.atlas.AtlasException ;
import org.openjena.atlas.iterator.Iter ;
import org.openjena.atlas.junit.BaseTest ;
@@ -210,20 +211,14 @@ static void test(RadixTree t, byte[]... keys)
for ( byte[]k : keys )
{
byte[] v = valFromKey(k) ;
- t.insert(k, v) ;
- t.check() ;
- assertTrue(t.contains(k)) ;
+ insert(t, k, v) ;
}
count(t, keys.length) ;
check(t, keys) ;
if ( keys.length > 0 )
assertFalse(t.isEmpty()) ;
for ( byte[]k : keys )
- {
- t.delete(k) ;
- t.check() ;
- assertFalse(t.contains(k)) ;
- }
+ delete(t, k) ;
assertTrue(t.isEmpty()) ;
}
@@ -241,24 +236,32 @@ static void check(RadixTree t, byte[] ... keys)
assertTrue("Not found: Key: "+RLib.str(k), t.contains(k)) ;
}
-// private static void insert(RadixTree t, byte[] key, byte[] value)
-// {
-// t.insert(key, value) ;
-// t.check();
-// RadixNode n = t.find(key) ;
-// assertNotNull(n) ;
-// assertEquals(key.length, n.lenFinish) ;
-// }
-//
-// private static void delete(RadixTree trie, byte[] key)
-// {
-// boolean b2 = ( trie.find(key) != null ) ;
-// boolean b = trie.delete(key) ;
-// System.out.flush() ;
-// if ( b != b2 )
-// System.err.println("Inconsistent (delete)") ;
-// trie.check() ;
-// }
+ private static void insert(RadixTree t, byte[] key, byte[] value)
+ {
+ t.insert(key, value) ;
+ t.check();
+ assertTrue(t.contains(key)) ;
+ RadixNode n = t.find(key) ;
+ assertNotNull(n) ;
+ assertEquals(key.length, n.lenFinish) ;
+ }
+
+ private static void delete(RadixTree trie, byte[] key)
+ {
+ boolean b2 = ( trie.find(key) != null ) ;
+ boolean b = trie.delete(key) ;
+ try {
+ trie.check() ;
+ } catch (AtlasException ex)
+ {
+ trie.print() ;
+ throw ex ;
+ }
+
+ assertFalse(trie.contains(key)) ;
+ RadixNode n = trie.find(key) ;
+ assertNull(n) ;
+ }
static void count(RadixTree t, int size)
{

0 comments on commit 95a1f0f

Please sign in to comment.