Icon implements Serializable { public BufferedImage getImage() { if (this.image == null) { this.buildImageFromData(); } return this.image; } Icon();  Icon(byte[] data, String imageType);  Icon(Image image, String imageType); byte[] getData(); BufferedImage getImage(); String getImageType(); void setImageType(String imageType); void setData(byte[] data, String imageType); final void setImage(Image image, String imageType); void setImage(String imagePath);  }
@Test public void testGetImage_blankConstructor() { System.out.println("getImage"); testSetImage_String(); BufferedImage actualImg = icon.getImage(); assertTrue("Height of img must be 64 due to fixed size resizing", actualImg.getHeight() == 64); }
@Test public void testGetImage_byteArrayConstructor(){ try { BufferedImage inputImg = ImageIO.read(new File(this.location)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(inputImg, "png", baos); byte[] inputImageBytes = baos.toByteArray(); icon = new Icon(inputImageBytes,"png"); BufferedImage actualImg = icon.getImage(); assertTrue("Height of img must be 64 due to fixed size resizing", actualImg.getHeight() == 64); } catch (IOException ex) { fail("Could not locate image"); } }
@Test public void testGetImage_imageConstructor() { System.out.println("getImage"); try { BufferedImage inputImg = ImageIO.read(new File(this.location)); icon = new Icon(inputImg,"png"); BufferedImage actualImg = icon.getImage(); assertTrue("Height of img must be 64 due to fixed size resizing", actualImg.getHeight() == 64); } catch (IOException ex) { Exceptions.printStackTrace(ex); fail(""); } }