Icon implements Serializable { public void setData(byte[] data, String imageType) { this.data = data; this.imageType = imageType; this.buildImageFromData(); } 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 testSetData() { System.out.println("setData"); try { BufferedImage inputImg = ImageIO.read(new File(this.location)); assertTrue("Input img must have height>0 but has not", inputImg.getHeight() > 0); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(inputImg, "png", baos); byte[] inputImageBytes = baos.toByteArray(); icon.setData(inputImageBytes, "png"); BufferedImage outputImg = icon.getImage(); assertTrue(outputImg.getHeight() == 64); } catch (IOException ex) { fail("Could not locate image"); } }