You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by bd...@apache.org on 2013/11/07 20:52:06 UTC

svn commit: r1539782 - /incubator/devicemap/trunk/devicemapjava/src/test/java/org/apache/devicemap/client/RefDataTest.java

Author: bdelacretaz
Date: Thu Nov  7 19:52:05 2013
New Revision: 1539782

URL: http://svn.apache.org/r1539782
Log:
DMAP-29 - add devicemap.output.actual.data.except option

Modified:
    incubator/devicemap/trunk/devicemapjava/src/test/java/org/apache/devicemap/client/RefDataTest.java

Modified: incubator/devicemap/trunk/devicemapjava/src/test/java/org/apache/devicemap/client/RefDataTest.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapjava/src/test/java/org/apache/devicemap/client/RefDataTest.java?rev=1539782&r1=1539781&r2=1539782&view=diff
==============================================================================
--- incubator/devicemap/trunk/devicemapjava/src/test/java/org/apache/devicemap/client/RefDataTest.java (original)
+++ incubator/devicemap/trunk/devicemapjava/src/test/java/org/apache/devicemap/client/RefDataTest.java Thu Nov  7 19:52:05 2013
@@ -57,6 +57,8 @@ public class RefDataTest {
     private static Set<String> successful = new HashSet<String>();
     private static int totalTests;
     
+    private static final String outputActualDataExcept = System.getProperty("devicemap.output.actual.data.except");
+    
     static {
         DeviceMapClient c = null;
         try {
@@ -177,12 +179,28 @@ public class RefDataTest {
         }
     }
     
+    /** If the corresponding option is set, output to stderr the results that
+     *  we get, in the same format as our test file, so that we can see 
+     *  the diffs with it. 
+     * @param actualId if null, the value from our TestEntry is used.
+     */
+    private void outputActualData(String actualId) {
+        if(outputActualDataExcept != null) {
+            String newId = entry.id;
+            if(actualId != null && !outputActualDataExcept.equals(actualId)) {
+                newId = actualId;
+            }
+            System.err.println(String.format("%s DMAP_EXPECT id:%s", entry.userAgent, newId));
+        }
+    }
+    
     @Test
     public void testId() {
         final Map<String, String> props = deviceMapClient.classify(entry.userAgent);
         if(props == null) {
             // TODO this should be a test failure
             ignoredNoEntry.add(entry.toString());
+            outputActualData(null);
             return;
         }
         
@@ -191,9 +209,11 @@ public class RefDataTest {
         if(!entry.id.equals(actual)) {
             // TODO this should be a test failure
             ignoredNoMatch.add(entry.toString());
+            outputActualData(actual);
             return;
         }
         
         successful.add(entry.toString());
+        outputActualData(null);
     }
 }
\ No newline at end of file