@Test
    public void testLogging() throws java.io.IOException, InvalidLogFormatException {
        File tmpDir = temporaryFolder.newFolder();

        ArchiverHandler a = new ArchiverHandler(tmpDir.getAbsolutePath(),
                                                1024, "gzip");

        for (int i = 0; i < msg.length; i++) {
            a.handle(msg[i]);
        }
        a.close();


        // make sure all the log files are there, that all log entries
        // are accounted for and that they match what we logged.
        int messageCount = 0;

        // map of files we've already inspected.  this we need to ensure
        // that we are not inspecting the same files over and over again
        // so the counts get messed up
        Set<String> inspectedFiles = new HashSet<String>();

        for (int i = 0; i < msg.length; i++) {
            String name = a.getPrefix(msg[i]) + "-0";

            // have we inspected this file before?
            if (! inspectedFiles.add(name)) {
                continue;
            }


            File f = new File(name);
            assertTrue(f.exists());

            BufferedReader br = new BufferedReader(new FileReader(f));
            for (String line = br.readLine();
                 line != null;
                 line = br.readLine()) {
                // primitive check if the messages match
                boolean foundMatch = false;
                for (int k = 0; k < mStrings.length; k++) {
                    if (mStrings[k].equals(line)) {
                        foundMatch = true;
                        break;
                    }
                }
                assertTrue(foundMatch);

                // try to instantiate messages to ensure that they
                // are parseable
                @SuppressWarnings("unused")
                    LogMessage m = LogMessage.parseNativeFormat(line);
                messageCount++;
            }
            br.close();
        }

        // verify that the number of log messages written equals
        // the number of log messages we have in our test
        assertEquals(mStrings.length, messageCount);
    }
Log some messages to the handler and verify that they are
written.
logserver/src/test/java/com/yahoo/logserver/handlers/archive/ArchiverHandlerTestCase.java