com.pironet.tda.BeaJDKParserTest.java Source code

Java tutorial

Introduction

Here is the source code for com.pironet.tda.BeaJDKParserTest.java

Source

/*
 * This file is part of TDA - Thread Dump Analysis Tool.
 *
 * Foobar is free software; you can redistribute it and/or modify
 * it under the terms of the Lesser GNU General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * Foobar is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Lesser GNU General Public License for more details.
 *
 * You should have received a copy of the Lesser GNU General Public License
 * along with Foobar; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * $Id: BeaJDKParserTest.java,v 1.4 2010-04-01 08:58:58 irockel Exp $
 */

package com.pironet.tda;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import javax.swing.tree.MutableTreeNode;

import org.apache.commons.io.IOUtils;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

/**
 * @author irockel
 */
public class BeaJDKParserTest extends TestCase {

    public BeaJDKParserTest(String testName) {
        super(testName);
    }

    protected void setUp() throws Exception {
        super.setUp();
    }

    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public static Test suite() {

        return new TestSuite(BeaJDKParserTest.class);
    }

    /**
     * Test of hasMoreDumps method, of class com.pironet.tda.SunJDKParser.
     */
    public void testDumpLoad() throws IOException {
        System.out.println("dumpLoad");
        InputStream fis = null;
        DumpParser instance = null;

        try {
            fis = getClass().getResourceAsStream("/data/jrockit_15_dump.txt");
            Map<String, Map<String, String>> dumpMap = new HashMap<>();
            Vector<MutableTreeNode> topNodes = new Vector<>();
            instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);

            assertTrue(instance instanceof BeaJDKParser);

            while (instance.hasMoreDumps()) {
                topNodes.add(instance.parseNext());
            }

            // check if three dumps are in it.
            //assertEquals(3, topNodes.size());
        } finally {
            IOUtils.closeQuietly(instance);
            IOUtils.closeQuietly(fis);
        }
    }

}