/*
* SunJDKParserTest.java
*
* 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: SunJDKParserTest.java,v 1.9 2008-11-21 09:20:19 irockel Exp $
*/
package com.pironet.tda;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import junit.framework.*;
import java.util.Map;
import java.util.Vector;
import com.pironet.tda.parser.DumpParser;
import com.pironet.tda.parser.DumpParserFactory;
import com.pironet.tda.parser.impl.SunJDKParser;
/**
* test parsing of log files from sun vms.
* @author irockel
*/
public class SunJDKParserTest extends TestCase {
public SunJDKParserTest(String testName) {
super(testName);
}
protected void setUp() throws Exception {
}
protected void tearDown() throws Exception {
}
public static Test suite() {
TestSuite suite = new TestSuite(SunJDKParserTest.class);
return suite;
}
/**
* Test of hasMoreDumps method, of class com.pironet.tda.SunJDKParser.
*/
public void testDumpLoad() throws FileNotFoundException, IOException {
System.out.println("dumpLoad");
FileInputStream fis = null;
DumpParser instance = null;
try {
fis = new FileInputStream("test/none/test.log");
Map dumpMap = new HashMap();
Vector topNodes = new Vector();
instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);
assertTrue(instance instanceof SunJDKParser);
while (instance.hasMoreDumps()) {
topNodes.add(instance.parseNext());
}
// check if three dumps are in it.
assertEquals(3, topNodes.size());
} finally {
if(instance != null) {
instance.close();
}
if(fis != null) {
fis.close();
}
}
}
/**
* Test of isFoundClassHistograms method, of class com.pironet.tda.SunJDKParser.
*/
public void testIsFoundClassHistograms() throws FileNotFoundException, IOException {
System.out.println("isFoundClassHistograms");
DumpParser instance = null;
FileInputStream fis = null;
try {
fis = new FileInputStream("test/none/testwithhistogram.log");
Map dumpMap = new HashMap();
instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);
Vector topNodes = new Vector();
while (instance.hasMoreDumps()) {
topNodes.add(instance.parseNext());
}
boolean expResult = true;
boolean result = instance.isFoundClassHistograms();
assertEquals(expResult, result);
} finally {
if(instance != null) {
instance.close();
}
if(fis != null) {
fis.close();
}
}
}
public void test64BitDumpLoad() throws FileNotFoundException, IOException {
System.out.println("64BitDumpLoad");
FileInputStream fis = null;
DumpParser instance = null;
try {
fis = new FileInputStream("test/none/test64bit.log");
Map dumpMap = new HashMap();
Vector topNodes = new Vector();
instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);
assertTrue(instance instanceof SunJDKParser);
while (instance.hasMoreDumps()) {
topNodes.add(instance.parseNext());
}
// check if one dump was found.
assertEquals(1, topNodes.size());
} finally {
if(instance != null) {
instance.close();
}
if(fis != null) {
fis.close();
}
}
}
public void testSAPDumps() throws FileNotFoundException, IOException {
System.out.println("SAPDumpLoad");
FileInputStream fis = null;
DumpParser instance = null;
try {
fis = new FileInputStream("test/none/sapdump.log");
Map dumpMap = new HashMap();
Vector topNodes = new Vector();
instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);
assertTrue(instance instanceof SunJDKParser);
while (instance.hasMoreDumps()) {
topNodes.add(instance.parseNext());
}
// check if two dump were found.
assertEquals(2, topNodes.size());
} finally {
if(instance != null) {
instance.close();
}
if(fis != null) {
fis.close();
}
}
}
public void testHPDumps() throws FileNotFoundException, IOException {
System.out.println("HPDumpLoad");
FileInputStream fis = null;
DumpParser instance = null;
try {
fis = new FileInputStream("test/none/hpdump.log");
Map dumpMap = new HashMap();
Vector topNodes = new Vector();
instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);
assertTrue(instance instanceof SunJDKParser);
while (instance.hasMoreDumps()) {
topNodes.add(instance.parseNext());
}
// check if two dump were found.
assertEquals(2, topNodes.size());
} finally {
if(instance != null) {
instance.close();
}
if(fis != null) {
fis.close();
}
}
}
public void testRemoteVisualVMDumps() throws FileNotFoundException, IOException {
System.out.println("VisualVMDumpLoad");
FileInputStream fis = null;
DumpParser instance = null;
try {
fis = new FileInputStream("test/none/visualvmremote.log");
Map dumpMap = new HashMap();
Vector topNodes = new Vector();
instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);
assertTrue(instance instanceof SunJDKParser);
while (instance.hasMoreDumps()) {
topNodes.add(instance.parseNext());
}
// check if two dump were found.
assertEquals(1, topNodes.size());
} finally {
if(instance != null) {
instance.close();
}
if(fis != null) {
fis.close();
}
}
}
public void testURLThreadNameDumps() throws FileNotFoundException, IOException {
System.out.println("URLThreadNameDumpLoad");
FileInputStream fis = null;
DumpParser instance = null;
try {
fis = new FileInputStream("test/none/urlthread.log");
Map dumpMap = new HashMap();
Vector topNodes = new Vector();
instance = DumpParserFactory.get().getDumpParserForLogfile(fis, dumpMap, false, 0);
assertTrue(instance instanceof SunJDKParser);
while (instance.hasMoreDumps()) {
topNodes.add(instance.parseNext());
}
// check if two dump were found.
assertEquals(1, topNodes.size());
} finally {
if(instance != null) {
instance.close();
}
if(fis != null) {
fis.close();
}
}
}
}