mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-04-24 00:00:04 -04:00
Fix flaky old test.
This commit is contained in:
+22
-17
@@ -34,14 +34,14 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.color.ColorSpace;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.IndexColorModel;
|
||||
import java.awt.color.*;
|
||||
import java.awt.image.*;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* BufferedImageFactoryTestCase
|
||||
@@ -89,12 +89,17 @@ public class BufferedImageFactoryTest {
|
||||
|
||||
// This is a little random, and it would be nicer if we could throw an IllegalArgumentException on create.
|
||||
// Unfortunately, the API doesn't allow this...
|
||||
@Test(timeout = 1000, expected = ImageConversionException.class)
|
||||
@Test(timeout = 1000)
|
||||
public void testGetBufferedImageErrorSourceURL() {
|
||||
Image source = Toolkit.getDefaultToolkit().createImage(getClass().getResource("/META-INF/MANIFEST.MF"));
|
||||
|
||||
BufferedImageFactory factory = new BufferedImageFactory(source);
|
||||
factory.getBufferedImage();
|
||||
try {
|
||||
BufferedImageFactory factory = new BufferedImageFactory(source);
|
||||
assertNull(factory.getBufferedImage()); // Should normally not be reached
|
||||
}
|
||||
catch (ImageConversionException ignore) {
|
||||
// This exception is allowed and *expected*, however this behavior is flaky in some environments...
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -260,9 +265,9 @@ public class BufferedImageFactoryTest {
|
||||
|
||||
// Listener should abort ASAP
|
||||
factory.addProgressListener(new BufferedImageFactory.ProgressListener() {
|
||||
public void progress(BufferedImageFactory pFactory, float pPercentage) {
|
||||
if (pPercentage > 5) {
|
||||
pFactory.abort();
|
||||
public void progress(BufferedImageFactory factory, float percentage) {
|
||||
if (percentage > 5) {
|
||||
factory.abort();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -343,7 +348,7 @@ public class BufferedImageFactoryTest {
|
||||
VerifyingListener listener = new VerifyingListener(factory);
|
||||
factory.addProgressListener(listener);
|
||||
factory.removeProgressListener(new BufferedImageFactory.ProgressListener() {
|
||||
public void progress(BufferedImageFactory pFactory, float pPercentage) {
|
||||
public void progress(BufferedImageFactory factory, float percentage) {
|
||||
}
|
||||
});
|
||||
factory.getBufferedImage();
|
||||
@@ -380,11 +385,11 @@ public class BufferedImageFactoryTest {
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
public void progress(BufferedImageFactory pFactory, float pPercentage) {
|
||||
assertEquals(factory, pFactory);
|
||||
assertTrue(pPercentage >= progress && pPercentage <= 100f);
|
||||
public void progress(BufferedImageFactory factory, float percentage) {
|
||||
assertEquals(this.factory, factory);
|
||||
assertTrue(percentage >= progress && percentage <= 100f);
|
||||
|
||||
progress = pPercentage;
|
||||
progress = percentage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user