Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
ad326cb0
Commit
ad326cb0
authored
Dec 19, 2012
by
Eric Christiansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds desktop java junit tests
parent
3de6846d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
201 additions
and
1 deletion
+201
-1
CMakeLists.txt
modules/java/CMakeLists.txt
+6
-1
CMakeLists.txt
modules/java/java_test/CMakeLists.txt
+80
-0
build.xml
modules/java/java_test/build.xml
+71
-0
junit-4.11.jar
modules/java/java_test/lib/junit-4.11.jar
+0
-0
OpenCVTestCase.java
...es/java/java_test/src/org/opencv/test/OpenCVTestCase.java
+0
-0
OpenCVTestRunner.java
.../java/java_test/src/org/opencv/test/OpenCVTestRunner.java
+44
-0
No files found.
modules/java/CMakeLists.txt
View file @
ad326cb0
...
...
@@ -295,7 +295,12 @@ endif(ANDROID)
add_dependencies
(
${
lib_target
}
${
api_target
}
)
add_dependencies
(
${
the_module
}
${
lib_target
}
)
#android test project
#
android test project
if
(
ANDROID AND BUILD_TESTS
)
add_subdirectory
(
android_test
)
endif
()
# Desktop Java test project.
if
((
NOT ANDROID
)
AND BUILD_TESTS
)
add_subdirectory
(
java_test
)
endif
()
modules/java/java_test/CMakeLists.txt
0 → 100644
View file @
ad326cb0
ocv_check_dependencies
(
opencv_java
${
OPENCV_MODULE_opencv_java_OPT_DEPS
}
${
OPENCV_MODULE_opencv_java_REQ_DEPS
}
)
if
(
NOT OCV_DEPENDENCIES_FOUND OR NOT ANT_EXECUTABLE
)
return
()
endif
()
# TODO: This has the same name as the Android test project. That project should
# probably be renamed.
project
(
opencv_test_java
)
set
(
opencv_test_java_bin_dir
"
${
CMAKE_CURRENT_BINARY_DIR
}
/.build"
)
set
(
android_source_dir
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../android_test"
)
set
(
java_source_dir
${
CMAKE_CURRENT_SOURCE_DIR
}
)
# get project sources
file
(
GLOB_RECURSE opencv_test_java_files RELATIVE
"
${
android_source_dir
}
"
"
${
android_source_dir
}
/res/*"
"
${
android_source_dir
}
/src/*"
)
ocv_list_filterout
(
opencv_test_java_files
".svn"
)
ocv_list_filterout
(
opencv_test_java_files
".*#.*"
)
# These are the files that need to be updated for pure Java.
ocv_list_filterout
(
opencv_test_java_files
".*OpenCVTestCase.*"
)
ocv_list_filterout
(
opencv_test_java_files
".*OpenCVTestRunner.*"
)
# These files aren't for desktop Java.
ocv_list_filterout
(
opencv_test_java_files
".*android.*"
)
# These are files updated for pure Java.
file
(
GLOB_RECURSE modified_files RELATIVE
"
${
java_source_dir
}
"
"
${
java_source_dir
}
/src/*"
)
ocv_list_filterout
(
modified_files
".svn"
)
ocv_list_filterout
(
modified_files
".*#.*"
)
# These are extra jars needed to run the tests.
file
(
GLOB_RECURSE lib_files RELATIVE
"
${
java_source_dir
}
"
"
${
java_source_dir
}
/lib/*"
)
ocv_list_filterout
(
lib_files
".svn"
)
ocv_list_filterout
(
lib_files
".*#.*"
)
# copy sources out from the build tree
set
(
opencv_test_java_file_deps
""
)
foreach
(
f
${
opencv_test_java_files
}
)
add_custom_command
(
OUTPUT
"
${
opencv_test_java_bin_dir
}
/
${
f
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
android_source_dir
}
/
${
f
}
"
"
${
opencv_test_java_bin_dir
}
/
${
f
}
"
MAIN_DEPENDENCY
"
${
android_source_dir
}
/
${
f
}
"
COMMENT
"Copying
${
f
}
"
)
list
(
APPEND opencv_test_java_file_deps
"
${
android_source_dir
}
/
${
f
}
"
"
${
opencv_test_java_bin_dir
}
/
${
f
}
"
)
endforeach
()
# Overwrite select Android sources with Java-specific sources.
# Also, copy over the libs we'll need for testing.
foreach
(
f
${
modified_files
}
${
lib_files
}
)
add_custom_command
(
OUTPUT
"
${
opencv_test_java_bin_dir
}
/
${
f
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
java_source_dir
}
/
${
f
}
"
"
${
opencv_test_java_bin_dir
}
/
${
f
}
"
MAIN_DEPENDENCY
"
${
java_source_dir
}
/
${
f
}
"
COMMENT
"Copying
${
f
}
"
)
list
(
APPEND opencv_test_java_file_deps
"
${
java_source_dir
}
/
${
f
}
"
)
endforeach
()
# Copy the OpenCV jar after it has been generated.
add_custom_command
(
OUTPUT
"
${
opencv_test_java_bin_dir
}
/bin/
${
JAR_NAME
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
CMAKE_BINARY_DIR
}
/bin/
${
JAR_NAME
}
"
"
${
opencv_test_java_bin_dir
}
/bin/
${
JAR_NAME
}
"
COMMENT
"Copying the OpenCV jar"
)
add_custom_target
(
copy_opencv_jar ALL SOURCES
"
${
opencv_test_java_bin_dir
}
/bin/
${
JAR_NAME
}
"
)
# ${the_module} is the target for the Java jar.
add_dependencies
(
copy_opencv_jar
${
the_module
}
)
# Copy the ant build file.
file
(
COPY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/build.xml"
DESTINATION
"
${
opencv_test_java_bin_dir
}
"
)
# Create a script for running the Java tests and place it in build/bin.
if
(
WIN32
)
file
(
WRITE
"
${
CMAKE_BINARY_DIR
}
/bin/opencv_test_java.cmd"
"cd
${
opencv_test_java_bin_dir
}
\n
set path=
${
EXECUTABLE_OUTPUT_PATH
}
;%path%
\n
ant -DjavaLibraryPath=
${
EXECUTABLE_OUTPUT_PATH
}
/Release buildAndTest"
)
file
(
WRITE
"
${
CMAKE_BINARY_DIR
}
/bin/opencv_test_java_D.cmd"
"cd
${
opencv_test_java_bin_dir
}
\n
set path=
${
EXECUTABLE_OUTPUT_PATH
}
;%path%
\n
ant -DjavaLibraryPath=
${
EXECUTABLE_OUTPUT_PATH
}
/Debug buildAndTest"
)
else
()
file
(
WRITE
"
${
CMAKE_BINARY_DIR
}
/bin/opencv_test_java.sh"
"cd
${
opencv_test_java_bin_dir
}
;
\n
ant -DjavaLibraryPath=
${
LIBRARY_OUTPUT_PATH
}
buildAndTest;
\n
cd -"
)
endif
()
add_custom_target
(
${
PROJECT_NAME
}
ALL SOURCES
${
opencv_test_java_file_deps
}
)
add_dependencies
(
opencv_tests
${
PROJECT_NAME
}
)
modules/java/java_test/build.xml
0 → 100644
View file @
ad326cb0
<project>
<path
id=
"master-classpath"
>
<fileset
dir=
"lib"
>
<include
name=
"*.jar"
/>
</fileset>
<fileset
dir=
"bin"
>
<include
name=
"*.jar"
/>
</fileset>
</path>
<target
name=
"clean"
>
<delete
dir=
"build"
/>
<delete
dir=
"testResults"
/>
</target>
<target
name=
"compile"
>
<mkdir
dir=
"build/classes"
/>
<javac
sourcepath=
""
srcdir=
"src"
destdir=
"build/classes"
>
<include
name=
"**/*.java"
/>
<classpath
refid=
"master-classpath"
/>
</javac>
</target>
<target
name=
"jar"
>
<mkdir
dir=
"build/jar"
/>
<jar
destfile=
"build/jar/opencv-test.jar"
basedir=
"build/classes"
>
<manifest>
<attribute
name=
"Main-Class"
value=
"org.opencv.test.OpenCVTestRunner"
/>
</manifest>
</jar>
</target>
<!-- <target name="run" > -->
<!-- <java fork="true" classname="org.opencv.test.OpenCVTestRunner"> -->
<!-- <sysproperty key="java.library.path" path="${javaLibraryPath}"/> -->
<!-- <classpath refid="master-classpath"/> -->
<!-- <classpath> -->
<!-- <fileset dir="build/jar"> -->
<!-- <include name="*.jar"/> -->
<!-- </fileset> -->
<!-- </classpath> -->
<!-- </java> -->
<!-- </target> -->
<target
name=
"test"
>
<mkdir
dir=
"testResults"
/>
<junit
printsummary=
"yes"
haltonfailure=
"false"
>
<sysproperty
key=
"java.library.path"
path=
"${javaLibraryPath}"
/>
<classpath
refid=
"master-classpath"
/>
<classpath>
<pathelement
location=
"build/classes"
/>
</classpath>
<formatter
type=
"xml"
/>
<batchtest
fork=
"yes"
todir=
"testResults"
>
<zipfileset
src=
"build/jar/opencv-test.jar"
includes=
"**/*.class"
excludes=
"**/OpenCVTest*"
>
<exclude
name=
"**/*$*.class"
/>
</zipfileset>
</batchtest>
</junit>
</target>
<target
name=
"buildAndTest"
>
<antcall
target=
"compile"
/>
<antcall
target=
"jar"
/>
<antcall
target=
"test"
/>
</target>
</project>
\ No newline at end of file
modules/java/java_test/lib/junit-4.11.jar
0 → 100644
View file @
ad326cb0
File added
modules/java/java_test/src/org/opencv/test/OpenCVTestCase.java
0 → 100644
View file @
ad326cb0
This diff is collapsed.
Click to expand it.
modules/java/java_test/src/org/opencv/test/OpenCVTestRunner.java
0 → 100644
View file @
ad326cb0
package
org
.
opencv
.
test
;
import
java.io.File
;
import
java.io.IOException
;
import
junit.framework.Assert
;
import
org.opencv.core.Mat
;
public
class
OpenCVTestRunner
{
public
static
String
LENA_PATH
=
""
;
public
static
String
CHESS_PATH
=
""
;
public
static
String
LBPCASCADE_FRONTALFACE_PATH
=
""
;
private
static
String
TAG
=
"opencv_test_java"
;
public
static
String
getTempFileName
(
String
extension
)
{
if
(!
extension
.
startsWith
(
"."
))
extension
=
"."
+
extension
;
try
{
File
tmp
=
File
.
createTempFile
(
"OpenCV"
,
extension
);
String
path
=
tmp
.
getAbsolutePath
();
tmp
.
delete
();
return
path
;
}
catch
(
IOException
e
)
{
Log
(
"Failed to get temp file name. Exception is thrown: "
+
e
);
}
return
null
;
}
static
public
void
Log
(
String
message
)
{
System
.
out
.
println
(
TAG
+
" :: "
+
message
);
}
static
public
void
Log
(
Mat
m
)
{
System
.
out
.
println
(
TAG
+
" :: "
+
m
+
"\n "
+
m
.
dump
());
}
public
static
String
getOutputFileName
(
String
name
)
{
return
getTempFileName
(
name
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment