mirror of
https://github.com/opencv/opencv.git
synced 2025-07-31 09:57:28 +08:00
java: skip test in case of missed classes from opencv_contrib
This commit is contained in:
parent
8d662a1a28
commit
fe29080d59
@ -29,6 +29,11 @@ import static junit.framework.Assert.assertFalse;
|
|||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
|
||||||
public class OpenCVTestCase extends TestCase {
|
public class OpenCVTestCase extends TestCase {
|
||||||
|
|
||||||
|
public static class TestSkipException extends RuntimeException {
|
||||||
|
public TestSkipException() {}
|
||||||
|
}
|
||||||
|
|
||||||
//change to 'true' to unblock fail on fail("Not yet implemented")
|
//change to 'true' to unblock fail on fail("Not yet implemented")
|
||||||
public static final boolean passNYI = true;
|
public static final boolean passNYI = true;
|
||||||
|
|
||||||
@ -188,12 +193,40 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
protected void runTest() throws Throwable {
|
protected void runTest() throws Throwable {
|
||||||
// Do nothing if the precondition does not hold.
|
// Do nothing if the precondition does not hold.
|
||||||
if (isTestCaseEnabled) {
|
if (isTestCaseEnabled) {
|
||||||
super.runTest();
|
try {
|
||||||
|
super.runTest();
|
||||||
|
} catch (TestSkipException ex) {
|
||||||
|
Log.w(TAG, "Test case \"" + this.getClass().getName() + "\" skipped!");
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Test case \"" + this.getClass().getName() + "\" disabled!");
|
Log.e(TAG, "Test case \"" + this.getClass().getName() + "\" disabled!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runBare() throws Throwable {
|
||||||
|
Throwable exception = null;
|
||||||
|
try {
|
||||||
|
setUp();
|
||||||
|
} catch (TestSkipException ex) {
|
||||||
|
Log.w(TAG, "Test case \"" + this.getClass().getName() + "\" skipped!");
|
||||||
|
assertTrue(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
runTest();
|
||||||
|
} catch (Throwable running) {
|
||||||
|
exception = running;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
tearDown();
|
||||||
|
} catch (Throwable tearingDown) {
|
||||||
|
if (exception == null) exception = tearingDown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exception != null) throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
protected Mat getMat(int type, double... vals)
|
protected Mat getMat(int type, double... vals)
|
||||||
{
|
{
|
||||||
return new Mat(matSize, matSize, type, new Scalar(vals));
|
return new Mat(matSize, matSize, type, new Scalar(vals));
|
||||||
@ -497,6 +530,10 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
catch(Exception ex) {
|
||||||
|
if (cname.startsWith(XFEATURES2D))
|
||||||
|
{
|
||||||
|
throw new TestSkipException();
|
||||||
|
}
|
||||||
message = TAG + " :: " + "could not instantiate " + cname + "! Exception: " + ex.getMessage();
|
message = TAG + " :: " + "could not instantiate " + cname + "! Exception: " + ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
<target name="test">
|
<target name="test">
|
||||||
<mkdir dir="${test.dir}"/>
|
<mkdir dir="${test.dir}"/>
|
||||||
<junit printsummary="true" haltonfailure="false" haltonerror="false" showoutput="false" logfailedtests="true" maxmemory="256m">
|
<junit printsummary="true" haltonfailure="false" haltonerror="false" showoutput="true" logfailedtests="true" maxmemory="256m">
|
||||||
<sysproperty key="java.library.path" path="${opencv.lib.path}"/>
|
<sysproperty key="java.library.path" path="${opencv.lib.path}"/>
|
||||||
<env key="PATH" path="${opencv.lib.path}"/>
|
<env key="PATH" path="${opencv.lib.path}"/>
|
||||||
<classpath refid="master-classpath"/>
|
<classpath refid="master-classpath"/>
|
||||||
|
@ -27,6 +27,11 @@ import org.opencv.core.KeyPoint;
|
|||||||
import org.opencv.imgcodecs.Imgcodecs;
|
import org.opencv.imgcodecs.Imgcodecs;
|
||||||
|
|
||||||
public class OpenCVTestCase extends TestCase {
|
public class OpenCVTestCase extends TestCase {
|
||||||
|
|
||||||
|
public static class TestSkipException extends RuntimeException {
|
||||||
|
public TestSkipException() {}
|
||||||
|
}
|
||||||
|
|
||||||
//change to 'true' to unblock fail on fail("Not yet implemented")
|
//change to 'true' to unblock fail on fail("Not yet implemented")
|
||||||
public static final boolean passNYI = true;
|
public static final boolean passNYI = true;
|
||||||
|
|
||||||
@ -214,12 +219,40 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
protected void runTest() throws Throwable {
|
protected void runTest() throws Throwable {
|
||||||
// Do nothing if the precondition does not hold.
|
// Do nothing if the precondition does not hold.
|
||||||
if (isTestCaseEnabled) {
|
if (isTestCaseEnabled) {
|
||||||
super.runTest();
|
try {
|
||||||
|
super.runTest();
|
||||||
|
} catch (TestSkipException ex) {
|
||||||
|
OpenCVTestRunner.Log(TAG + " :: " + "Test case \"" + this.getClass().getName() + "\" skipped!");
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
OpenCVTestRunner.Log(TAG + " :: " + "Test case \"" + this.getClass().getName() + "\" disabled!");
|
OpenCVTestRunner.Log(TAG + " :: " + "Test case \"" + this.getClass().getName() + "\" disabled!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runBare() throws Throwable {
|
||||||
|
Throwable exception = null;
|
||||||
|
try {
|
||||||
|
setUp();
|
||||||
|
} catch (TestSkipException ex) {
|
||||||
|
OpenCVTestRunner.Log(TAG + " :: " + "Test case \"" + this.getClass().getName() + "\" skipped!");
|
||||||
|
assertTrue(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
runTest();
|
||||||
|
} catch (Throwable running) {
|
||||||
|
exception = running;
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
tearDown();
|
||||||
|
} catch (Throwable tearingDown) {
|
||||||
|
if (exception == null) exception = tearingDown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (exception != null) throw exception;
|
||||||
|
}
|
||||||
|
|
||||||
protected Mat getMat(int type, double... vals)
|
protected Mat getMat(int type, double... vals)
|
||||||
{
|
{
|
||||||
return new Mat(matSize, matSize, type, new Scalar(vals));
|
return new Mat(matSize, matSize, type, new Scalar(vals));
|
||||||
@ -523,6 +556,10 @@ public class OpenCVTestCase extends TestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
catch(Exception ex) {
|
||||||
|
if (cname.startsWith(XFEATURES2D))
|
||||||
|
{
|
||||||
|
throw new TestSkipException();
|
||||||
|
}
|
||||||
message = TAG + " :: " + "could not instantiate " + cname + "! Exception: " + ex.getMessage();
|
message = TAG + " :: " + "could not instantiate " + cname + "! Exception: " + ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user