-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09151d3
commit 8a514f0
Showing
2 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
barcode4j-xgc/src/test/java/org/krysalis/barcode4j/image/loader/ImageLoaderBarcodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.krysalis.barcode4j.image.loader; | ||
|
||
import org.apache.xmlgraphics.image.loader.Image; | ||
import org.apache.xmlgraphics.image.loader.ImageException; | ||
import org.apache.xmlgraphics.image.loader.ImageFlavor; | ||
import org.apache.xmlgraphics.image.loader.ImageInfo; | ||
import org.apache.xmlgraphics.image.loader.spi.ImageLoader; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class ImageLoaderBarcodeTest { | ||
|
||
@Test | ||
@DisplayName("Should load original ImageBarcode when instantiated with BARCODE_IMAGE_FLAVOR target") | ||
void testSupportedTargetFlavor_Barcode4jImageFlavor() throws ImageException, IOException { | ||
final ImageBarcode originalImage = mock(ImageBarcode.class); | ||
|
||
final ImageInfo info = mock(ImageInfo.class); | ||
when(info.getOriginalImage()).thenReturn(originalImage); | ||
|
||
final ImageLoader loader = new ImageLoaderBarcode(ImageBarcode.BARCODE_IMAGE_FLAVOR); | ||
|
||
final Image result = loader.loadImage(info, null, null); | ||
|
||
assertNotNull(result); | ||
assertEquals(originalImage, result); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should throw IllegalArgumentException with target flavor: BUFFERED_IMAGE") | ||
void testUnsupportedTargetFlavor_BufferedImage() { | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
new ImageLoaderBarcode(ImageFlavor.BUFFERED_IMAGE); | ||
}); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should throw IllegalArgumentException with target flavor: RENDERED_IMAGE") | ||
void testUnsupportedTargetFlavor_RenderedImage() { | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
new ImageLoaderBarcode(ImageFlavor.RENDERED_IMAGE); | ||
}); | ||
} | ||
} |