Skip to content

Commit

Permalink
Fix test ClassPath dependencies (frankframework#2366)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsm5 authored Oct 20, 2021
1 parent ace3cbf commit 932fb7c
Show file tree
Hide file tree
Showing 18 changed files with 762 additions and 163 deletions.
1 change: 0 additions & 1 deletion akamai/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.24.5</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
23 changes: 11 additions & 12 deletions aspose/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@
<version>18.11</version>
</dependency>

<dependency>
<groupId>org.ibissource</groupId>
<artifactId>ibis-adapterframework-core</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<scope>test</scope>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -264,22 +272,13 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.testautomationguru.pdfutil</groupId>
<artifactId>pdf-util</artifactId>
<version>0.0.3</version>
</dependency>

<dependency>
<groupId>org.ibissource</groupId>
<artifactId>ibis-adapterframework-core</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.8</version>
<scope>test</scope>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.testautomationguru.utility;

public enum CompareMode {
TEXT_MODE,
VISUAL_MODE
}
46 changes: 46 additions & 0 deletions aspose/src/test/java/com/testautomationguru/utility/ImageUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.testautomationguru.utility;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;

import javax.imageio.ImageIO;

class ImageUtil {

static Logger logger = Logger.getLogger(ImageUtil.class.getName());

static boolean compareAndHighlight(final BufferedImage img1, final BufferedImage img2, String fileName, boolean highlight, int colorCode) throws IOException {

final int w = img1.getWidth();
final int h = img1.getHeight();
final int[] p1 = img1.getRGB(0, 0, w, h, null, 0, w);
final int[] p2 = img2.getRGB(0, 0, w, h, null, 0, w);

if(!(java.util.Arrays.equals(p1, p2))) {
logger.warning("Image compared - does not match");
if(highlight) {
for(int i = 0; i < p1.length; i++) {
if(p1[i] != p2[i]) {
p1[i] = colorCode;
}
}
final BufferedImage out = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
out.setRGB(0, 0, w, h, p1, 0, w);
saveImage(out, fileName);
}
return false;
}
return true;
}

static void saveImage(BufferedImage image, String file) {
try {
File outputfile = new File(file);
ImageIO.write(image, "png", outputfile);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading

0 comments on commit 932fb7c

Please sign in to comment.