Skip to content

Commit 0999cf8

Browse files
author
Thomas Weise
committed
Added JUnit Tests and Build Definition Files
1 parent ef1dfa6 commit 0999cf8

15 files changed

+330
-0
lines changed

.travis.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
##
2+
## Build with Travis.CI
3+
##
4+
## https://travis-ci.org/optimizationBenchmarking/documentation-examples-loader
5+
#
6+
language: java
7+
8+
# By default, it runs under Java 7
9+
jdk:
10+
- oraclejdk7
11+
- openjdk7
12+
- oraclejdk8
13+
14+
# Cache Maven dependencies to speed up builds.
15+
cache:
16+
directories:
17+
- $HOME/.m2
18+
19+
# custom build step
20+
script: ant
21+
22+
before_install:
23+
- sudo apt-get -q -y -f update
24+
# Install the required Ant version
25+
- wget "https://raw.githubusercontent.com/optimizationBenchmarking/utils-build/master/antWebInstallerLinux.sh"
26+
- chmod 755 antWebInstallerLinux.sh
27+
- sudo ./antWebInstallerLinux.sh
28+
# fix for buffer overflows in getLocalHostName
29+
# https://github.com/travis-ci/travis-ci/issues/5227
30+
- cat /etc/hosts # optionally check the content *before*
31+
- sudo hostname "$(hostname | cut -c1-63)"
32+
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts
33+
- cat /etc/hosts # optionally check the content *after*
34+
35+
# prevent Maven from running
36+
install:
37+
- echo "Nothing."

appveyor.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
##
2+
## Build with appveyor
3+
##
4+
## https://ci.appveyor.com/project/thomasWeise/documentation-examples-loader
5+
#
6+
environment:
7+
matrix:
8+
- JAVA_HOME: C:\Program Files\Java\jdk1.7.0
9+
- JAVA_HOME: C:\Program Files\Java\jdk1.8.0
10+
11+
install:
12+
- ps: if(!(Test-Path -Path 'C:\bin\apache-maven-3.2.5\' )){ cinst maven -Version 3.2.5 }
13+
- ps: if(!(Test-Path -Path 'C:\ProgramData\chocolatey\lib\ant\apache-ant-1.9.6\' )){ cinst ant -i -Version 1.9.6 }
14+
# choco does not set the PATH environment variable correctly
15+
# so we do it manually, like
16+
# https://github.com/abelsromero/asciidoctor-maven-plugin/blob/master/appveyor.yml
17+
- cmd: SET PATH=C:\ProgramData\chocolatey\lib\ant\apache-ant-1.9.6\bin;C:\bin\apache-maven-3.2.5\bin;%JAVA_HOME%\bin;%PATH%
18+
19+
cache:
20+
- C:\bin\apache-maven-3.2.5\
21+
- C:\ProgramData\chocolatey\lib\ant\apache-ant-1.9.6
22+
23+
platform:
24+
- x86
25+
- x64
26+
27+
configuration:
28+
- Release
29+
30+
build_script:
31+
- ant
32+
33+
test_script:
34+
- echo "Nothing."

circle.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
##
2+
## Build with CircleCI
3+
##
4+
## https://circleci.com/gh/optimizationBenchmarking/documentation-examples-loader
5+
#
6+
machine:
7+
# Install the newest version of ant.
8+
pre:
9+
# Install the required Ant version
10+
- sudo apt-get -q -y -f update
11+
- wget "https://raw.githubusercontent.com/optimizationBenchmarking/utils-build/master/antWebInstallerLinux.sh"
12+
- chmod 755 antWebInstallerLinux.sh
13+
- sudo ./antWebInstallerLinux.sh
14+
environment:
15+
# We set the environment variable JAVA_OPTS to reduce
16+
# the memory footprint in order to prevent unexpected
17+
# test termination.
18+
JAVA_OPTS: -Xms1536m -Xmx1536m
19+
MAVEN_OPTS: -Xms1536m -Xmx1536m
20+
_JAVA_OPTIONS: -Xms1536m -Xmx1536m
21+
22+
23+
# We do nothing here.
24+
dependencies:
25+
override:
26+
- echo "Nothing"
27+
28+
# We set a high timeout to prevent the test from being
29+
# terminated unexpectedly.
30+
test:
31+
override:
32+
- ant:
33+
timeout: 10000
34+
35+
# The branches to be ignored
36+
general:
37+
branches:
38+
ignore:
39+
- gh-pages
40+
- documentation

shippable.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
##
2+
## Build with Shippable
3+
##
4+
## https://app.shippable.com/projects/ TODO
5+
#
6+
#
7+
language: java
8+
#
9+
jdk:
10+
- openjdk7
11+
- oraclejdk7
12+
- oraclejdk8
13+
#
14+
# install maven
15+
before_install:
16+
- if [[ $SHIPPABLE_JDK_VERSION == "openjdk7" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"; export PATH="$PATH:/usr/lib/jvm/java-7-openjdk-amd64/bin"; export java_path="/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java"; fi
17+
- if [[ $SHIPPABLE_JDK_VERSION == "oraclejdk7" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-7-oracle"; export PATH="$PATH:/usr/lib/jvm/java-7-oracle/bin"; export java_path="/usr/lib/jvm/java-7-oracle/jre/bin/java"; fi
18+
- if [[ $SHIPPABLE_JDK_VERSION == "openjdk6" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-6-openjdk-amd64"; export PATH="$PATH:/usr/lib/jvm/java-6-openjdk-amd64/bin"; export java_path="/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java"; fi
19+
- if [[ $SHIPPABLE_JDK_VERSION == "oraclejdk8" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-8-oracle"; export PATH="$PATH:/usr/lib/jvm/java-8-oracle/bin"; export java_path="/usr/lib/jvm/java-8-oracle/jre/bin/java"; fi
20+
- update-alternatives --set java $java_path
21+
- java -version
22+
# Install the required Ant and Maven version
23+
- shippable_retry sudo apt-get -q -y update
24+
- shippable_retry sudo apt-get -y install maven
25+
- shippable_retry wget "https://raw.githubusercontent.com/optimizationBenchmarking/utils-build/master/antWebInstallerLinux.sh"
26+
- chmod 755 antWebInstallerLinux.sh
27+
- shippable_retry sudo ./antWebInstallerLinux.sh --purgeAnt=false
28+
29+
# install override
30+
install:
31+
- echo "Nothing to do here."
32+
#
33+
script:
34+
- if [[ $SHIPPABLE_JDK_VERSION == "openjdk7" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"; export PATH="$PATH:/usr/lib/jvm/java-7-openjdk-amd64/bin"; export java_path="/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java"; fi
35+
- if [[ $SHIPPABLE_JDK_VERSION == "oraclejdk7" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-7-oracle"; export PATH="$PATH:/usr/lib/jvm/java-7-oracle/bin"; export java_path="/usr/lib/jvm/java-7-oracle/jre/bin/java"; fi
36+
- if [[ $SHIPPABLE_JDK_VERSION == "openjdk6" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-6-openjdk-amd64"; export PATH="$PATH:/usr/lib/jvm/java-6-openjdk-amd64/bin"; export java_path="/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java"; fi
37+
- if [[ $SHIPPABLE_JDK_VERSION == "oraclejdk8" ]] ; then export JAVA_HOME="/usr/lib/jvm/java-8-oracle"; export PATH="$PATH:/usr/lib/jvm/java-8-oracle/bin"; export java_path="/usr/lib/jvm/java-8-oracle/jre/bin/java"; fi
38+
- update-alternatives --set java $java_path
39+
- java -version
40+
- ant
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package test.junit.org.optimizationBenchmarking.documentation.examples;
2+
3+
import org.junit.experimental.categories.Category;
4+
import org.optimizationBenchmarking.documentation.examples.ExampleDownloadJobBuilder;
5+
6+
import shared.junit.CategorySlowTests;
7+
8+
/**
9+
* The test of downloading and installing the BBOB example
10+
*/
11+
@Category(CategorySlowTests.class)
12+
public final class BBOBExampleTest extends SingleExampleTest {
13+
14+
/** create */
15+
public BBOBExampleTest() {
16+
super();
17+
}
18+
19+
/** {@inheritDoc} */
20+
@Override
21+
protected final void setup(final ExampleDownloadJobBuilder builder) {
22+
builder.setExampleId("bbob"); //$NON-NLS-1$
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package test.junit.org.optimizationBenchmarking.documentation.examples;
2+
3+
import org.optimizationBenchmarking.documentation.examples.ExampleDownloadTool;
4+
5+
import shared.junit.org.optimizationBenchmarking.utils.tools.ToolTest;
6+
7+
/** the test of the example download tool */
8+
public class ExampleDownloadToolTest
9+
extends ToolTest<ExampleDownloadTool> {
10+
11+
/** create the test */
12+
public ExampleDownloadToolTest() {
13+
super(ExampleDownloadTool.getInstance());
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package test.junit.org.optimizationBenchmarking.documentation.examples;
2+
3+
import org.optimizationBenchmarking.documentation.examples.ExampleDownloadJobBuilder;
4+
5+
/**
6+
* The test of downloading and installing the maximum satisfiability
7+
* example
8+
*/
9+
public final class MaxSatExampleTest extends SingleExampleTest {
10+
11+
/** create */
12+
public MaxSatExampleTest() {
13+
super();
14+
}
15+
16+
/** {@inheritDoc} */
17+
@Override
18+
protected final void setup(final ExampleDownloadJobBuilder builder) {
19+
builder.setExampleId("maxSat"); //$NON-NLS-1$
20+
}
21+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package test.junit.org.optimizationBenchmarking.documentation.examples;
2+
3+
import org.junit.Assert;
4+
import org.junit.Ignore;
5+
import org.junit.Test;
6+
import org.optimizationBenchmarking.documentation.examples.ExampleDownloadJobBuilder;
7+
import org.optimizationBenchmarking.documentation.examples.ExampleDownloadTool;
8+
import org.optimizationBenchmarking.utils.io.paths.TempDir;
9+
10+
import shared.junit.TestBase;
11+
12+
/** A base class for testing example installations. */
13+
@Ignore
14+
public abstract class SingleExampleTest {
15+
16+
/** create the installer test */
17+
protected SingleExampleTest() {
18+
super();
19+
}
20+
21+
/**
22+
* setup the job builder
23+
*
24+
* @param builder
25+
* the job builder
26+
*/
27+
protected abstract void setup(final ExampleDownloadJobBuilder builder);
28+
29+
/**
30+
* test the example download
31+
*
32+
* @throws Exception
33+
* if I/O fails
34+
*/
35+
@Test(timeout = 3600000)
36+
public void testExampleDownload() throws Exception {
37+
ExampleDownloadJobBuilder builder;
38+
39+
builder = ExampleDownloadTool.getInstance().use();
40+
this.setup(builder);
41+
builder.setLogger(TestBase.getNullLogger());
42+
43+
try (final TempDir temp = new TempDir()) {
44+
builder.setDestinationPath(temp.getPath());
45+
Assert.assertNotNull(builder.create().call());
46+
}
47+
}
48+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* The the tests of the example downloader package.
3+
*/
4+
package test.junit.org.optimizationBenchmarking.documentation.examples;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* In this package, we provide the tests of the documentation classes that
3+
* are used in many <a href="http://www.optimizationBenchmarking.org/">
4+
* optimizationBenchmarking.org</a> tools.
5+
*/
6+
package test.junit.org.optimizationBenchmarking.documentation;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* In this package, we provide the tests of the
3+
* <a href="http://www.optimizationBenchmarking.org/">
4+
* optimizationBenchmarking.org</a> tools.
5+
*/
6+
package test.junit.org.optimizationBenchmarking;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* <p>
3+
* A package that holds other packages with
4+
* <a href="http://junit.org/">JUnit</a> tests but itself is empty (as
5+
* there are no classes that could be tested at the {@code org} level).
6+
* </p>
7+
*/
8+
package test.junit.org;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* In this package we keep all the <a href="http://junit.org/">JUnit</a>
3+
* tests for our source codes.
4+
* </p>
5+
* <p>
6+
* Unit tests are classes that can automatically be executed by a testing
7+
* framework. Each unit test class can have multiple test cases and each
8+
* such test case checks whether one particular method or interaction of a
9+
* tested class behaves as it should behave. For example, one could test
10+
* the {@link java.lang.String#concat(java.lang.String)} method by creating
11+
* two strings {@code a} and {@code b} and checking whether a
12+
* <code>a.concat(b).equals(a + b)</code>. Unit testing frameworks are able
13+
* to run many such tests and to create reports. If a test fails, it means
14+
* that there is an error. If no test fails, it does not mean that there is
15+
* no error. Still, having many test cases and having them succeed is a
16+
* good indicator for a healthy project. The more aspects and classes of a
17+
* project are covered with tests, the better.
18+
* </p>
19+
* <p>
20+
* The hierarchy of the sub-packages within this package reflects the
21+
* source package hierarchy, i.e., package
22+
* {@link test.junit.org.optimizationBenchmarking.utils.text.transformations}
23+
* contains the tests for the classes in package
24+
* {@link org.optimizationBenchmarking.utils.text.transformations}.
25+
* </p>
26+
*/
27+
package test.junit;

src/test/java/test/package-info.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* In this package we keep all test code for our sources. Test classes are
3+
* in package names corresponding to the packages they test. For example,
4+
* in package {@code test.junit.org.optimizationBenchmarking.utils} you
5+
* will find all tests for the classes from package
6+
* {@code org.optimizationBenchmarking.utils}.
7+
*/
8+
package test;

wercker.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
##
2+
## Build with Wercker
3+
##
4+
## https://app.wercker.com/#applications/ TODO
5+
#
6+
box: optimizationbenchmarking/linux-evaluator-build
7+
#
8+
build:
9+
steps:
10+
- script:
11+
name: Ant-based Maven Build
12+
code: ant

0 commit comments

Comments
 (0)