Skip to content

Commit

Permalink
Added turtle test annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
oskopek committed Aug 27, 2015
1 parent c1281d8 commit b35f666
Show file tree
Hide file tree
Showing 26 changed files with 245 additions and 83 deletions.
14 changes: 11 additions & 3 deletions pom.xml
Expand Up @@ -58,11 +58,11 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<version>2.7</version>
<configuration>
<format>xml</format>
<maxmem>256m</maxmem>
<aggregate>true</aggregate>
<quiet>true</quiet>
<check>
<branchRate>85</branchRate>
<lineRate>85</lineRate>
Expand Down Expand Up @@ -161,6 +161,14 @@
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<forkCount>0.5C</forkCount>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Expand Down Expand Up @@ -190,7 +198,7 @@
<configuration>
<checkstyleRules>
<module name="Checker">
<!--<property name="severity" value="warning" default="warning"/>-->
<property name="severity" value="warning" default="warning"/>
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile">
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/sk/gymy/seminar/app/SeminarBenchmarkApp.java
Expand Up @@ -20,14 +20,14 @@

public class SeminarBenchmarkApp extends CommonBenchmarkApp {

public static final String SOLVER_BENCHMARK_CONFIG = "sk/gymy/seminar/benchmark/seminarBenchmarkConfig.xml";

public static void main(String[] args) {
new SeminarBenchmarkApp().buildAndBenchmark(args);
}

public SeminarBenchmarkApp() {
super(new ArgOption("default", "sk/gymy/seminar/benchmark/seminarBenchmarkConfig.xml"),
new ArgOption("stepLimit", "sk/gymy/seminar/benchmark/seminarStepLimitBenchmarkConfig.xml"),
new ArgOption("scoreDirector", "sk/gymy/seminar/benchmark/seminarScoreDirectorBenchmarkConfig.xml"));
super(new ArgOption("default", SeminarBenchmarkApp.SOLVER_BENCHMARK_CONFIG));
}

}
2 changes: 1 addition & 1 deletion src/main/java/sk/gymy/seminar/app/SeminarHelloWorld.java
Expand Up @@ -39,7 +39,7 @@ public static void main(String[] args) {
public static String solveHelloWorld() {
// Build the Solver
SolverFactory solverFactory =
SolverFactory.createFromXmlResource("sk/gymy/seminar/solver/seminarSolverConfig.xml");
SolverFactory.createFromXmlResource(SeminarApp.SOLVER_CONFIG);

String unsolved5SeminarPath = "data/seminar/import/simple5.sem";
Solver solver = solverFactory.buildSolver();
Expand Down

This file was deleted.

7 changes: 5 additions & 2 deletions src/test/java/sk/gymy/seminar/app/SeminarAppTest.java
Expand Up @@ -32,8 +32,10 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import sk.gymy.seminar.common.AbstractTest;
import sk.gymy.seminar.common.DisplayTest;

public class SeminarAppTest {
public class SeminarAppTest extends AbstractTest {

private SeminarApp seminarApp;

Expand All @@ -43,7 +45,8 @@ public void setUp() {
}

@Test
@Ignore("No X11 DISPLAY variable was set, but this program performed an operation which requires it.")
@DisplayTest
@Ignore("Unreliable test and pollutes UI")
public void testSwingUI() throws IOException {
SeminarApp.prepareSwingEnvironment();
SeminarApp.prepareDataDirStructure(Files.createTempDir());
Expand Down
Expand Up @@ -20,18 +20,20 @@

import org.junit.Ignore;
import org.junit.Test;
import sk.gymy.seminar.common.AbstractTest;
import sk.gymy.seminar.common.TurtleTest;

public class SeminarBenchmarkAppTest {
public class SeminarBenchmarkAppTest extends AbstractTest {

@Test
public void testSeminarBenchmarkApp() {
SeminarBenchmarkApp sba = new SeminarBenchmarkApp();
assertNotNull(sba);
//sba.buildAndBenchmark(new String[0]);
}

@Test
@Ignore
@TurtleTest
@Ignore("Ign")
public void testBuildAndBenchmark() {
SeminarBenchmarkApp sba = new SeminarBenchmarkApp();
assertNotNull(sba);
Expand Down
14 changes: 12 additions & 2 deletions src/test/java/sk/gymy/seminar/app/SeminarBenchmarkTest.java
Expand Up @@ -16,23 +16,33 @@

package sk.gymy.seminar.app;

import org.junit.Rule;
import org.junit.Test;
import org.optaplanner.examples.common.app.PlannerBenchmarkTest;
import sk.gymy.seminar.common.DisplayTestRule;
import sk.gymy.seminar.common.TurtleTestRule;

import java.io.File;

public class SeminarBenchmarkTest extends PlannerBenchmarkTest {

// TODO figure out how to inherit from AbstractTest
@Rule
public final TurtleTestRule turtleTestRule = new TurtleTestRule();

@Rule
public final DisplayTestRule displayTestRule = new DisplayTestRule();

@Override
protected String createBenchmarkConfigResource() {
return "sk/gymy/seminar/benchmark/seminarBenchmarkConfig.xml";
return SeminarBenchmarkApp.SOLVER_BENCHMARK_CONFIG;
}

// ************************************************************************
// Tests
// ************************************************************************

@Test(timeout = 600000)
@Test(timeout = 60000)
public void benchmarkSimple5() {
runBenchmarkTest(new File("data/seminar/unsolved/simple5.xml"));
}
Expand Down
15 changes: 13 additions & 2 deletions src/test/java/sk/gymy/seminar/app/SeminarBranchAndBoundTest.java
Expand Up @@ -16,6 +16,7 @@

package sk.gymy.seminar.app;

import org.junit.Rule;
import org.junit.Test;
import org.optaplanner.core.api.solver.SolverFactory;
import org.optaplanner.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig;
Expand All @@ -24,16 +25,25 @@
import org.optaplanner.core.config.solver.EnvironmentMode;
import org.optaplanner.examples.common.app.SolverPerformanceTest;
import org.optaplanner.examples.common.persistence.SolutionDao;
import sk.gymy.seminar.common.DisplayTestRule;
import sk.gymy.seminar.common.TurtleTestRule;
import sk.gymy.seminar.persistence.SeminarDao;

import java.io.File;
import java.util.Collections;

public class SeminarBranchAndBoundTest extends SolverPerformanceTest {

// TODO figure out how to inherit from AbstractTest
@Rule
public final TurtleTestRule turtleTestRule = new TurtleTestRule();

@Rule
public final DisplayTestRule displayTestRule = new DisplayTestRule();

@Override
protected String createSolverConfigResource() {
return "sk/gymy/seminar/solver/seminarSolverConfig.xml";
return SeminarApp.SOLVER_CONFIG;
}

@Override
Expand Down Expand Up @@ -71,7 +81,8 @@ public void solveModel_gymy2014_2() {
}

@Test(timeout = 60000)
public void solveModel_gymy2014_4() { // TODO BranchAndBound can't solve to the best score, which is "-8hard/-3soft"
public void solveModel_gymy2014_4() {
// TODO BranchAndBound can't solve to the best score, which is "-8hard/-3soft"
runSpeedTest(new File("data/seminar/unsolved/gymy2014-4.xml"), "-8hard/-4soft", EnvironmentMode.PRODUCTION);
}

Expand Down
22 changes: 16 additions & 6 deletions src/test/java/sk/gymy/seminar/app/SeminarBruteForceTest.java
Expand Up @@ -16,7 +16,7 @@

package sk.gymy.seminar.app;

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.optaplanner.core.api.solver.SolverFactory;
import org.optaplanner.core.config.exhaustivesearch.ExhaustiveSearchPhaseConfig;
Expand All @@ -25,16 +25,26 @@
import org.optaplanner.core.config.solver.EnvironmentMode;
import org.optaplanner.examples.common.app.SolverPerformanceTest;
import org.optaplanner.examples.common.persistence.SolutionDao;
import sk.gymy.seminar.common.DisplayTestRule;
import sk.gymy.seminar.common.TurtleTest;
import sk.gymy.seminar.common.TurtleTestRule;
import sk.gymy.seminar.persistence.SeminarDao;

import java.io.File;
import java.util.Collections;

public class SeminarBruteForceTest extends SolverPerformanceTest {

// TODO figure out how to inherit from AbstractTest
@Rule
public final TurtleTestRule turtleTestRule = new TurtleTestRule();

@Rule
public final DisplayTestRule displayTestRule = new DisplayTestRule();

@Override
protected String createSolverConfigResource() {
return "sk/gymy/seminar/solver/seminarSolverConfig.xml";
return SeminarApp.SOLVER_CONFIG;
}

@Override
Expand Down Expand Up @@ -65,14 +75,14 @@ public void solveModel_unsolvable5() {
runSpeedTest(new File("data/seminar/unsolved/unsolvable5.xml"), "0hard/-1soft", EnvironmentMode.REPRODUCIBLE);
}

@Test(timeout = 60000)
@Ignore("Test takes too long.")
@Test(timeout = 600000)
@TurtleTest
public void solveModel_gymy2014_2() {
runSpeedTest(new File("data/seminar/unsolved/gymy2014-2.xml"), "-22hard/-10soft", EnvironmentMode.REPRODUCIBLE);
}

@Test(timeout = 60000)
@Ignore("Test takes too long.")
@Test(timeout = 600000)
@TurtleTest
public void solveModel_gymy2014_4() {
runSpeedTest(new File("data/seminar/unsolved/gymy2014-4.xml"), "-8hard/-3soft", EnvironmentMode.REPRODUCIBLE);
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/sk/gymy/seminar/app/SeminarHelloWorldTest.java
Expand Up @@ -19,8 +19,9 @@
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import sk.gymy.seminar.common.AbstractTest;

public class SeminarHelloWorldTest {
public class SeminarHelloWorldTest extends AbstractTest {

@Test
public void testHelloWorldMain() {
Expand Down
12 changes: 11 additions & 1 deletion src/test/java/sk/gymy/seminar/app/SeminarPerformanceTest.java
Expand Up @@ -16,19 +16,29 @@

package sk.gymy.seminar.app;

import org.junit.Rule;
import org.junit.Test;
import org.optaplanner.core.config.solver.EnvironmentMode;
import org.optaplanner.examples.common.app.SolverPerformanceTest;
import org.optaplanner.examples.common.persistence.SolutionDao;
import sk.gymy.seminar.common.DisplayTestRule;
import sk.gymy.seminar.common.TurtleTestRule;
import sk.gymy.seminar.persistence.SeminarDao;

import java.io.File;

public class SeminarPerformanceTest extends SolverPerformanceTest {

// TODO figure out how to inherit from AbstractTest
@Rule
public final TurtleTestRule turtleTestRule = new TurtleTestRule();

@Rule
public final DisplayTestRule displayTestRule = new DisplayTestRule();

@Override
protected String createSolverConfigResource() {
return "sk/gymy/seminar/solver/seminarSolverConfig.xml";
return SeminarApp.SOLVER_CONFIG;
}

@Override
Expand Down
14 changes: 13 additions & 1 deletion src/test/java/sk/gymy/seminar/app/SeminarSolveAllTurtleTest.java
Expand Up @@ -16,16 +16,28 @@

package sk.gymy.seminar.app;

import org.junit.Rule;
import org.junit.runners.Parameterized;
import org.optaplanner.examples.common.app.UnsolvedDirSolveAllTurtleTest;
import org.optaplanner.examples.common.persistence.SolutionDao;
import sk.gymy.seminar.common.DisplayTestRule;
import sk.gymy.seminar.common.TurtleTest;
import sk.gymy.seminar.common.TurtleTestRule;
import sk.gymy.seminar.persistence.SeminarDao;

import java.io.File;
import java.util.Collection;

@TurtleTest
public class SeminarSolveAllTurtleTest extends UnsolvedDirSolveAllTurtleTest {

// TODO figure out how to inherit from AbstractTest
@Rule
public final TurtleTestRule turtleTestRule = new TurtleTestRule();

@Rule
public final DisplayTestRule displayTestRule = new DisplayTestRule();

@Parameterized.Parameters(name = "{index}: {0}")
public static Collection<Object[]> getSolutionFilesAsParameters() {
return getUnsolvedDirFilesAsParameters(new SeminarDao());
Expand All @@ -37,7 +49,7 @@ public SeminarSolveAllTurtleTest(File unsolvedDataFile) {

@Override
protected String createSolverConfigResource() {
return "/sk/gymy/seminar/solver/seminarSolverConfig.xml";
return SeminarApp.SOLVER_CONFIG;
}

@Override
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/sk/gymy/seminar/common/AbstractTest.java
@@ -0,0 +1,14 @@
package sk.gymy.seminar.common;

import org.junit.Rule;
import org.optaplanner.examples.common.app.LoggingMain;

public abstract class AbstractTest extends LoggingMain {

@Rule
public final TurtleTestRule turtleTestRule = new TurtleTestRule();

@Rule
public final DisplayTestRule displayTestRule = new DisplayTestRule();

}

0 comments on commit b35f666

Please sign in to comment.