Package test.apache.kato.hprof.image

Source Code of test.apache.kato.hprof.image.TestImageFactory

/*******************************************************************************
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package test.apache.kato.hprof.image;

import java.io.File;
import java.io.IOException;

import javax.tools.diagnostics.image.Image;
import javax.tools.diagnostics.image.ImageFactory;

import org.apache.kato.common.InvalidFileFormat;
import org.apache.kato.hprof.image.ImageFactoryImpl;

public class TestImageFactory extends AbstractHProfTestCase {

 
  public void testConstructor() {
   
    new ImageFactoryImpl();
   
  }
  public void testMajorVersion() {
   
    ImageFactory factory=new ImageFactoryImpl();
    assertEquals("major version mismatch",0,factory.getMajorVersion());
  }
  public void testMinorVersion() {
   
    ImageFactory factory=new ImageFactoryImpl();
    assertEquals("minor version mismatch",1,factory.getMinorVersion());
  }
 
  public void testModVersion() {
   
    ImageFactory factory=new ImageFactoryImpl();
    assertEquals("modification version mismatch",0,factory.getModificationLevel());
  }
 
  public void testGetImageFromNull1() throws IOException {
   
    ImageFactory factory=new ImageFactoryImpl();
    try {
    factory.getImage(null);
    fail("Expected illegal argument exception");
    }
    catch(IllegalArgumentException iae) {
     
    }
  }
 
  public void testGetImageFromNull2() throws IOException {
   
    ImageFactory factory=new ImageFactoryImpl();
    try {
    factory.getImage(null,null);
    fail("Expected illegal argument exception");
    }
    catch(IllegalArgumentException iae) {
     
    }
  }
 
  public void testGetImageFromEmptyFile() throws IOException {
   
    ImageFactory factory=new ImageFactoryImpl();
    File realFile = getEmptyHProfFile();
    try {
    factory.getImage(realFile);
    fail("Expecting InvalidFileFormat exception");
    } catch(InvalidFileFormat iff) {
     
    }
   
  }
  public void testGetImageFromheaderOnlyFile() throws IOException {
   
    ImageFactory factory=new ImageFactoryImpl();
    File realFile = getHeaderOnlyHProfFile();
    try {
    factory.getImage(realFile);
    fail("Expecting InvalidFileFormat exception");
    } catch(InvalidFileFormat iff) {
     
    }
   
  }
public void testGetImageFromMinimalFile() throws IOException {
 
  ImageFactory factory=new ImageFactoryImpl();
  File realFile = getMinimalHProfFile();
  Image image=factory.getImage(realFile);
 
 
}
}
TOP

Related Classes of test.apache.kato.hprof.image.TestImageFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.