@Test public void testBadMarkers() throws IOException { BufferedReader r = utf8Reader(TEST_DIR + File.separator + "bad-markers.txt"); String l; int n = 0; while ((l = r.readLine()) != null) { OpenstatMarker m = OpenstatMarker.parseURL(l); assertNull("Marker found in line #" + n, m); n++; } }
@Test public void testParseRawMarker() throws IOException { BufferedReader r = utf8Reader(TEST_FILE); String l; int n = 0; while ((l = r.readLine()) != null) { String[] col = l.split("\t", -1); OpenstatMarker m = OpenstatMarker.parseRawMarker(col[COL_RAWMARKER]); assertEquals("Mismatch at service in line #" + n, col[COL_SERVICE], m.getService()); assertEquals("Mismatch at campaign in line #" + n, col[COL_CAMPAIGN], m.getCampaign()); assertEquals("Mismatch at ad in line #" + n, col[COL_AD], m.getAd()); assertEquals("Mismatch at source in line #" + n, col[COL_SOURCE], m.getSource()); assertEquals(col[COL_RAWMARKER], m.toString()); n++; } }
@Test public void testParseURL() throws IOException { BufferedReader r = utf8Reader(TEST_FILE); String l; int n = 0; while ((l = r.readLine()) != null) { String[] col = l.split("\t", -1); OpenstatMarker m = OpenstatMarker.parseURL(col[COL_URL]); assertNotNull("No marker found in line #" + n, m); assertEquals("Mismatch at service in line #" + n, col[COL_SERVICE], m.getService()); assertEquals("Mismatch at campaign in line #" + n, col[COL_CAMPAIGN], m.getCampaign()); assertEquals("Mismatch at ad in line #" + n, col[COL_AD], m.getAd()); assertEquals("Mismatch at source in line #" + n, col[COL_SOURCE], m.getSource()); assertEquals(col[COL_RAWMARKER], m.toString()); String re1 = m.encodedMarker(false); assertEquals( "Raw reencoding error (got \"" + re1 + "\") in line #" + n, m, OpenstatMarker.parseMarker(re1)); String re2 = m.encodedMarker(true); assertEquals( "Base64 reencoding error (got \"" + re2 + "\") in line #" + n, m, OpenstatMarker.parseMarker(re2)); n++; } }