1 4 package com.openedit.store.images; 5 6 import java.awt.Dimension ; 7 import java.awt.image.BufferedImage ; 8 import java.io.File ; 9 10 import javax.imageio.ImageIO ; 11 12 import com.openedit.modules.image.ImageResizer; 13 import com.openedit.store.StoreTestCase; 14 15 19 public class ImageResizerTest extends StoreTestCase 20 { 21 public ImageResizerTest( String inName ) 22 { 23 super( inName ); 24 } 25 26 public void testResizeImage() throws Exception 27 { 28 final int MAX_WIDTH = 150; 29 ImageResizer resizer = new ImageResizer(); 30 resizer.setMaxScaledSize( new Dimension ( MAX_WIDTH, Integer.MAX_VALUE ) ); 31 32 File imageDir = new File ( "store" + File.separatorChar + "images" ); 33 File inputFile = new File ( imageDir, "testImage.jpg" ); 35 if ( inputFile.exists()) { 37 File outputFile = new File ( imageDir, "scaledTestImage.jpg" ); 38 outputFile.delete(); 39 40 resizer.resizeImage( inputFile, outputFile ); 41 42 BufferedImage scaledImage = ImageIO.read( outputFile ); 43 assertTrue( scaledImage.getWidth() <= MAX_WIDTH ); 44 } 45 } 46 } 47 | Popular Tags |