@Test public void testResourceRetriever() throws RetrieverException, IOException { final String imageResource = "parser-input/masks/green.png"; BufferedImage retrievedImage = resourceRetriever.retrieve(imageResource, new Properties()); BufferedImage loadedImage = ImageIO.read(this.getClass().getClassLoader().getResourceAsStream(imageResource)); ConfigurationCompiler configurationCompiler = new ConfigurationCompiler(); ImageComparator imageComparator = new DefaultImageComparator(); ComparisonResult comparisonResult = imageComparator.compare(retrievedImage, loadedImage, configurationCompiler.getPerception(), new HashSet<Mask>()); Assert.assertTrue(comparisonResult.isEqualsImages()); }
@Override public BufferedImage retrieve(String source, Properties localProperties) throws RetrieverException { URL resourceURL = this.getClass().getClassLoader().getResource(source); if (resourceURL == null) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' - given source doesn't exist"); } BufferedImage bufferedImage; try { bufferedImage = ImageIO.read(resourceURL); } catch (IOException e) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' from resourceURL '" + resourceURL + "'", e); } return bufferedImage; }
ResourceRetriever extends AbstractRetriever implements PatternRetriever, MaskRetriever { @Override public BufferedImage retrieve(String source, Properties localProperties) throws RetrieverException { URL resourceURL = this.getClass().getClassLoader().getResource(source); if (resourceURL == null) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' - given source doesn't exist"); } BufferedImage bufferedImage; try { bufferedImage = ImageIO.read(resourceURL); } catch (IOException e) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' from resourceURL '" + resourceURL + "'", e); } return bufferedImage; } }
ResourceRetriever extends AbstractRetriever implements PatternRetriever, MaskRetriever { @Override public BufferedImage retrieve(String source, Properties localProperties) throws RetrieverException { URL resourceURL = this.getClass().getClassLoader().getResource(source); if (resourceURL == null) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' - given source doesn't exist"); } BufferedImage bufferedImage; try { bufferedImage = ImageIO.read(resourceURL); } catch (IOException e) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' from resourceURL '" + resourceURL + "'", e); } return bufferedImage; }  }
ResourceRetriever extends AbstractRetriever implements PatternRetriever, MaskRetriever { @Override public BufferedImage retrieve(String source, Properties localProperties) throws RetrieverException { URL resourceURL = this.getClass().getClassLoader().getResource(source); if (resourceURL == null) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' - given source doesn't exist"); } BufferedImage bufferedImage; try { bufferedImage = ImageIO.read(resourceURL); } catch (IOException e) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' from resourceURL '" + resourceURL + "'", e); } return bufferedImage; }  @Override BufferedImage retrieve(String source, Properties localProperties); }
ResourceRetriever extends AbstractRetriever implements PatternRetriever, MaskRetriever { @Override public BufferedImage retrieve(String source, Properties localProperties) throws RetrieverException { URL resourceURL = this.getClass().getClassLoader().getResource(source); if (resourceURL == null) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' - given source doesn't exist"); } BufferedImage bufferedImage; try { bufferedImage = ImageIO.read(resourceURL); } catch (IOException e) { throw new RetrieverException(this.getClass().getSimpleName() + " wasn't able to retrieve image source '" + source + "' from resourceURL '" + resourceURL + "'", e); } return bufferedImage; }  @Override BufferedImage retrieve(String source, Properties localProperties);  }