Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for paper #378

Draft
wants to merge 48 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5527653
SciViewTests: added 3 new tests.
Domino2357 Mar 31, 2021
8029c90
SciViewTest: added a new test.
Domino2357 Apr 12, 2021
e92e423
SciViewTests: added a new test alongside a corresponding mock file.
Domino2357 Apr 12, 2021
fdfb529
SciViewTests: added test for a trahsed volume file, doesn't work so far.
Domino2357 Apr 12, 2021
b6e1ab4
SciViewTests: added a new test.
Domino2357 Apr 13, 2021
e7b543a
SviView: added Null-safety for centerOnPosition.
Domino2357 Apr 13, 2021
0eec0d7
Added small volume data set for testing purposes
Domino2357 Apr 13, 2021
68836de
LineTests: created new testclass for the 3D line.
Domino2357 Apr 20, 2021
62930e0
LineTests: renamed to Line3DTests
Domino2357 Apr 20, 2021
8be9517
SciViewTest: added some new tests, still need revision, though.
Domino2357 Apr 20, 2021
3f2937a
SciViewTests: added 3 new tests.
Domino2357 Mar 31, 2021
0a24fbc
SciViewTest: added a new test.
Domino2357 Apr 12, 2021
00d9e78
SciViewTests: added a new test alongside a corresponding mock file.
Domino2357 Apr 12, 2021
3421740
SciViewTests: added test for a trahsed volume file, doesn't work so far.
Domino2357 Apr 12, 2021
d690f9a
SciViewTests: added a new test.
Domino2357 Apr 13, 2021
c60970a
SviView: added Null-safety for centerOnPosition.
Domino2357 Apr 13, 2021
d18edcb
Added small volume data set for testing purposes
Domino2357 Apr 13, 2021
ae4bc7e
LineTests: created new testclass for the 3D line.
Domino2357 Apr 20, 2021
8aa25e1
LineTests: renamed to Line3DTests
Domino2357 Apr 20, 2021
e1188c0
SciViewTest: added some new tests, still need revision, though.
Domino2357 Apr 20, 2021
05d95cf
SciViewTest: removed non-applicable test
Domino2357 Apr 24, 2021
b880f74
Added MeshConverterTests.kt
Domino2357 Apr 24, 2021
b34fce0
Line3DTests: made a new one in another directory.
Domino2357 Apr 24, 2021
c5f4814
SciViewTests: converted the SciViewTest class to Kotlin, can not test…
Domino2357 Apr 24, 2021
4201b1d
SviViewTests: deleted comments.
Domino2357 Apr 26, 2021
c73eee1
Line3D: corrected test.
Domino2357 Apr 27, 2021
4b8d3ab
MeshConverterTests: finished test
Domino2357 Apr 27, 2021
fd956e5
Added new test for DisplayWindow
Domino2357 Apr 27, 2021
e1a230a
Added test for SwingMainWindow
Domino2357 Apr 27, 2021
27bee25
Added a new test for SwingNodePropertyEditor
Domino2357 Apr 27, 2021
968c04e
Added TaskManagerTests
Domino2357 Apr 28, 2021
f811800
added ControlPointTests
Domino2357 Apr 28, 2021
54777da
ControlPointTests: added new tests
Domino2357 Apr 28, 2021
ad5ee85
Added new test.
Domino2357 Apr 28, 2021
d77baa4
Added new test for Ruler
Domino2357 Apr 28, 2021
83d608a
Deleted deprecated files and added some blank lines
Domino2357 Apr 29, 2021
9329d34
Wrote a new test for SciView.
Domino2357 Apr 29, 2021
e90bd08
Deleted SciViewTest.java as a new version with kotlin exists.
Domino2357 Apr 29, 2021
87aec7f
Added 'System.setProperty('java.awt.headless', 'false')' to hopefully…
Domino2357 Apr 30, 2021
154b81b
up
Domino2357 Apr 30, 2021
513a219
up
Domino2357 Apr 30, 2021
0e6f7b7
up
Domino2357 Apr 30, 2021
0ef0e16
up
Domino2357 Apr 30, 2021
4fdcf66
Merge branch 'master' into unitTestsForPaper
Domino2357 Apr 30, 2021
08c5b0a
Test CI
elect86 May 4, 2021
b801e7f
Merge remote-tracking branch 'origin/unitTestsForPaper' into unitTest…
elect86 May 4, 2021
98bd723
Gradle 7.0
elect86 May 4, 2021
06f8893
Merge branch 'master' into unitTestsForPaper
Domino2357 Jun 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
cache:
paths:
- maven.repository/
- models/
- pdb-store/
- .gradle-user-home/

variables:
# MAVEN_OPTS: "-Dmaven.repo.local=maven.repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Xmx4g"
JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"
PDB_CACHE_DIR: "./pdb-store/cache"
PDB_DIR: "./pdb-store"
MODEL_DIR: "./models"
GRADLE_USER_HOME: "./.gradle-user-home"

# simple unit tests without requiring GPUs
unit-tests-no-gpu:
image: ubuntu:bionic
before_script:
- mkdir -p ./pdb-store/cache
- apt-get update -qq --force-yes > /dev/null
- apt-get install -qq -y --allow-downgrades --allow-remove-essential --allow-change-held-packages unzip wget git openjdk-8-jdk-headless curl libgl1-mesa-glx sudo sed > /dev/null
- if [ ! -d "$MODEL_DIR" ]; then wget -q https://ulrik.is/scenery-demo-models.zip && unzip -q scenery-demo-models.zip; fi
- sudo sed -i -e '/^assistive_technologies=/s/^/#/' /etc/java-*-openjdk/accessibility.properties
- chmod +x gradlew
script:
- ./gradlew build -x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar -PjvmTarget=1.8 -PsourceCompatibility=1.8

# base job for running with GPUs
.base-job-gpu: &base-job-gpu
before_script:
- mkdir -p ./pdb-store/cache
# Installs Maven, Vulkan development libraries, etc.
- apt-get update -qq --force-yes > /dev/null
- apt-get install -qq -y --allow-downgrades --allow-remove-essential --allow-change-held-packages unzip wget git openjdk-8-jdk-headless libvulkan1 libvulkan-dev vulkan-utils ocl-icd-opencl-dev clinfo curl > /dev/null
- curl -sL https://deb.nodesource.com/setup_14.x | bash -
- apt-get install -qq --force-yes nodejs
- npm install --save argos-cli
- mkdir -p /etc/OpenCL/vendors && echo "libnvidia-opencl.so.1" > /etc/OpenCL/vendors/nvidia.icd
# Output Vulkan driver information, but do not fail in case of non-zero
# return (happens e.g. if $DISPLAY is not set)
- vulkaninfo || true
- clinfo || true
- if [ ! -d "$MODEL_DIR" ]; then wget -q https://ulrik.is/scenery-demo-models.zip && unzip -q scenery-demo-models.zip; fi
- chmod +x gradlew
- ./gradlew --stop # stop any deamon https://stackoverflow.com/a/58397542/1047713
script:
- ./gradlew build -S -x dokkaHtml -x dokkaHtmlJar -x javadoc -x dokkaJavadocJar -PjvmTarget=1.8 -PsourceCompatibility=1.8 -Pgpu=true -i
artifacts:
when: always
expire_in: 48h
paths:
- results.tar.bz2

scenery-nvidia:
image: nvidia/vulkan:1.1.121-cuda-10.1-alpha
<<: *base-job-gpu
after_script:
- nvidia-smi
- tar cvjf results.tar.bz2 screenshots/
- ARGOS_COMMIT=$CI_COMMIT_SHA ARGOS_BRANCH=$CI_COMMIT_REF_NAME ./node_modules/argos-cli/bin/argos upload screenshots/ --token $ARGOS_TOKEN || true
tags:
- cuda
- intel

#scenery-amd:
# image: rocm/rocm-terminal
# <<: *base-job
# variables:
# SUDO: "sudo"
# GPURUN: "sudo su -m - rocm-user -c"
# before_script:
# # The rocm docker container requires the user to be in the video group which
# # can usually be set via docker's --group-add option. GitLab-Runner currently
# # has no known option for doing that. Therefore, it manually has to happen in
# # the job description.
# - $SUDO usermod -a -G video rocm-user
# # Installs Maven, Vulkan development libraries, etc.
# - $SUDO apt-get -qq --force-yes update > /dev/null
# - $SUDO apt-get install -qq --force-yes unzip kmod wget git maven openjdk-8-jdk libvulkan1 libvulkan-dev vulkan-utils > /dev/null
# # Installs the AMD GPUopen Vulkan driver
# - wget https://github.com/GPUOpen-Drivers/AMDVLK/releases/download/v-2019.Q3.6/amdvlk_2019.Q3.6_amd64.deb
# - $SUDO dpkg -i amdvlk_2019.Q3.6_amd64.deb
# - $SUDO apt-get -f install
# - $SUDO lsmod
# # Output Vulkan driver information, but do not fail in case of non-zero
# # return (happens e.g. if $DISPLAY is not set)
# - vulkaninfo || true
# - wget -q https://ulrik.is/scenery-demo-models.zip
# - unzip -q scenery-demo-models.zip
# after_script:
# - rocm-smi
# tags:
# - amd
# - rocm
#
#
17 changes: 17 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.kotlin.dsl.implementation
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import sciview.implementation
Expand Down Expand Up @@ -125,6 +126,22 @@ tasks {
}
test {
finalizedBy(jacocoTestReport) // report is always generated after tests run
testLogging {
// set options for log level LIFECYCLE
// events "failed"
// exceptionFormat "short"

// set options for log level DEBUG
debug {
// events "started", "skipped", "failed"
exceptionFormat = TestExceptionFormat.FULL
}

// remove standard output/error logging from --info builds
// by assigning only 'failed' and 'skipped' events
// info.events = ["failed", "skipped"]
showStandardStreams = true
}
}
jar {
archiveVersion.set(rootProject.version.toString())
Expand Down
62 changes: 43 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
<imagej-mesh.version>0.8.1</imagej-mesh.version>
<bigdataviewer-vistools.version>1.0.0-beta-21</bigdataviewer-vistools.version>

<kotlin.version>1.4.20</kotlin.version>
<kotlin.version>1.4.32-release-371</kotlin.version>
<kotlinx-coroutines-core.version>1.3.9</kotlinx-coroutines-core.version>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
</properties>
Expand Down Expand Up @@ -350,11 +350,27 @@
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>

</dependencies>
</dependencies>

<build>
<testSourceDirectory>src/test/tests</testSourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -390,34 +406,34 @@
</execution>
<execution>
<id>compile</id>
<phase>validate</phase>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
<source>target/generated-sources/kapt</source>
<source>target/generated-sources/kaptKotlin</source>
</sourceDirs>
<jvmTarget>${kotlin.compiler.jvmTarget}</jvmTarget>
<jvmTarget>${kotlin.compiler.jvmTarget}</jvmTarget>
<args>
<arg>-Werror</arg>
<arg>-Xopt-in=kotlin.RequiresOptIn</arg>
</args>
</configuration>
<sourceDirs>
<source>src/main/java</source>
<source>src/main/kotlin</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals> <goal>test-compile</goal> </goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/tests</sourceDir>
</sourceDirs>
</configuration>
</execution>
<configuration>
<sourceDirs>
<source>src/test/java</source>
<source>src/test/kotlin</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<jvmTarget>${kotlin.compiler.jvmTarget}</jvmTarget>
<jvmTarget>1.8</jvmTarget>
<args>
<arg>-Werror</arg>
<arg>-Xopt-in=kotlin.RequiresOptIn</arg>
Expand All @@ -442,7 +458,15 @@
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/sc/iview/SciView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ class SciView : SceneryBase, CalibratedRealInterval<CalibratedAxis> {
* Center the camera on the specified Node
*/
fun centerOnPosition(currentPos: Vector3f?) {
controls.centerOnPosition(currentPos)
if(currentPos != null) {
controls.centerOnPosition(currentPos)
}
else { logger.info("The current position is null.") }
}

/**
Expand Down
102 changes: 0 additions & 102 deletions src/test/java/sc/iview/SciViewTest.java

This file was deleted.

35 changes: 35 additions & 0 deletions src/test/kotlin/sc/iview/ControlPointTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package sc.iview

import graphics.scenery.Node
import org.joml.Vector3f
import org.junit.Test
import sc.iview.process.ControlPoints
import kotlin.test.assertTrue

class ControlPointTests {

@Test
fun testAddPoint() {
val controlPoints = ControlPoints()
val node = Node("testMe")
controlPoints.addPoint(node)
assertTrue(controlPoints.getNodes().contains(node))
}

@Test
fun testSetPoints() {
val controlPoints = ControlPoints()
val nodeList = arrayOf(Vector3f(1f, 2f, 3f), Vector3f(4f, 5f, 6f))
controlPoints.setPoints(nodeList)
assertTrue { controlPoints.getNodes()[0].position == Vector3f(1f, 2f, 3f) }
}

@Test
fun testInitializeSciView() {
val controlPoints = ControlPoints()
val sv = SciView.create()
val numberOfNodes = sv.allSceneNodes.size
controlPoints.initializeSciView(sv, 0f)
assertTrue { sv.allSceneNodes.size == numberOfNodes+1 }
}
}
15 changes: 15 additions & 0 deletions src/test/kotlin/sc/iview/Line3DTests.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package sc.iview

import junit.framework.Assert.assertNotNull
import org.junit.Test
import sc.iview.node.Line3D

class Line3DTests {

//tests if a bounding box becomes null when Line does not implement HasGeometry
@Test
fun testBoundingBox() {
val line = Line3D()
assertNotNull(line.generateBoundingBox())
}
}
Loading