TMI-64: Test case clean-up

This commit is contained in:
Harald Kuhr
2015-04-10 11:06:50 +02:00
parent 0232b63ed8
commit e603ae260d
20 changed files with 171 additions and 131 deletions

View File

@@ -1,34 +1,47 @@
package com.twelvemonkeys.imageio.reference;
import com.sun.imageio.plugins.jpeg.JPEGImageReader;
import com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
import com.twelvemonkeys.lang.SystemUtil;
import org.junit.Ignore;
import org.junit.Test;
import javax.imageio.IIOException;
import javax.imageio.ImageReader;
import javax.imageio.spi.ImageReaderSpi;
import java.awt.*;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.Assume.assumeNoException;
/**
* JPEGImageReaderTestCase
* JPEGImageReaderTest
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: JPEGImageReaderTestCase.java,v 1.0 Oct 9, 2009 3:37:25 PM haraldk Exp$
* @version $Id: JPEGImageReaderTest.java,v 1.0 Oct 9, 2009 3:37:25 PM haraldk Exp$
*/
public class JPEGImageReaderTestCase extends ImageReaderAbstractTestCase<JPEGImageReader> {
public class JPEGImageReaderTest extends ImageReaderAbstractTest {
private static final boolean IS_JAVA_6 = SystemUtil.isClassAvailable("java.util.Deque");
protected JPEGImageReaderSpi provider = new JPEGImageReaderSpi();
protected final ImageReaderSpi provider = lookupSpi();
private ImageReaderSpi lookupSpi() {
try {
return (ImageReaderSpi) Class.forName("com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi").newInstance();
}
catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
assumeNoException(e);
}
return null;
}
@Override
protected List<TestData> getTestData() {
return Arrays.asList(
return Collections.singletonList(
new TestData(getClassLoaderResource("/jpeg/R-7439-1151526181.jpeg"), new Dimension(386, 396))
);
}
@@ -39,14 +52,21 @@ public class JPEGImageReaderTestCase extends ImageReaderAbstractTestCase<JPEGIma
}
@Override
protected Class<JPEGImageReader> getReaderClass() {
return JPEGImageReader.class;
protected Class getReaderClass() {
try {
return Class.forName("com.sun.imageio.plugins.jpeg.JPEGImageReader");
}
catch (ClassNotFoundException e) {
assumeNoException(e);
}
return null;
}
@Override
protected JPEGImageReader createReader() {
protected ImageReader createReader() {
try {
return (JPEGImageReader) provider.createReaderInstance();
return provider.createReaderInstance();
}
catch (IOException e) {
throw new RuntimeException(e);

View File

@@ -1,30 +1,43 @@
package com.twelvemonkeys.imageio.reference;
import com.sun.imageio.plugins.png.PNGImageReader;
import com.sun.imageio.plugins.png.PNGImageReaderSpi;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTestCase;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
import org.junit.Test;
import javax.imageio.IIOException;
import javax.imageio.ImageReader;
import javax.imageio.spi.ImageReaderSpi;
import java.awt.*;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.junit.Assume.assumeNoException;
/**
* PNGImageReaderTestCase
* PNGImageReaderTest
*
* @author <a href="mailto:harald.kuhr@gmail.com">Harald Kuhr</a>
* @author last modified by $Author: haraldk$
* @version $Id: PNGImageReaderTestCase.java,v 1.0 Oct 9, 2009 3:37:25 PM haraldk Exp$
* @version $Id: PNGImageReaderTest.java,v 1.0 Oct 9, 2009 3:37:25 PM haraldk Exp$
*/
public class PNGImageReaderTestCase extends ImageReaderAbstractTestCase<PNGImageReader> {
protected PNGImageReaderSpi provider = new PNGImageReaderSpi();
public class PNGImageReaderTest extends ImageReaderAbstractTest {
protected final ImageReaderSpi provider = lookupSpi();
private ImageReaderSpi lookupSpi() {
try {
return (ImageReaderSpi) Class.forName("com.sun.imageio.plugins.png.PNGImageReaderSpi").newInstance();
}
catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
assumeNoException(e);
}
return null;
}
@Override
protected List<TestData> getTestData() {
return Arrays.asList(
return Collections.singletonList(
new TestData(getClassLoaderResource("/png/12monkeys-splash.png"), new Dimension(300, 410))
);
}
@@ -35,14 +48,21 @@ public class PNGImageReaderTestCase extends ImageReaderAbstractTestCase<PNGImage
}
@Override
protected Class<PNGImageReader> getReaderClass() {
return PNGImageReader.class;
protected Class getReaderClass() {
try {
return Class.forName("com.sun.imageio.plugins.png.PNGImageReader");
}
catch (ClassNotFoundException e) {
assumeNoException(e);
}
return null;
}
@Override
protected PNGImageReader createReader() {
protected ImageReader createReader() {
try {
return (PNGImageReader) provider.createReaderInstance();
return provider.createReaderInstance();
}
catch (IOException e) {
throw new RuntimeException(e);