Classes for creating images on the fly for testing purpose.
The classes in this package provide a builder pattern with fluent interface to create images for your tests in several dimensions and in different types.
The classes are either available as Spring beans or might be instantiated directly.
Spring Usage
The recommended usage for the image builders is using Spring. To do so it is recommended to import the provided Spring context file:
{@code}
Then use the {@code SpringJUnit4ClassRunner} to run your tests:
@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:my-test-context.xml") public class MyTest { @Inject private BufferedImageBuilderProvider imageBuilderProvider; @Test public void myTest() throws Exception { BufferedImageBuilder bufferedImageBuilder = imageBuilderProvider.get(); BufferedImage image = bufferedImageBuilder.build(); ... } }
Using the provided Spring context you could easily adjust default values at command line. The properties provided in {@code data-context.xml} are:
Property | Default | Comment |
---|---|---|
{@code data.image.width.default} | 256 | the default width in pixels |
{@code data.image.height.default} | 256 | the default height in pixels |
{@code data.image.color.model.type.default} | {@code typeIntRGB} | bean-name referring to ImageType-enum |
{@code data.image.mimetype.default} | {@code image/png} | Mime-Type used for image output |
Plain/Direct Usage
public class MyTest { @Test public void myTest() throws Exception { BufferedImageBuilder bufferedImageBuilder = new DefaultBufferedImageBuilder(); BufferedImage image = bufferedImageBuilder.build(); ... } }