Skip to content

Commit

Permalink
Move tests from elk-cli to elk-reasoner
Browse files Browse the repository at this point in the history
Also add realization tests with interrupts.
  • Loading branch information
Peter Skocovsky committed Jan 17, 2017
1 parent 58c7f3f commit 4ca2ff3
Show file tree
Hide file tree
Showing 26 changed files with 127 additions and 214 deletions.
23 changes: 0 additions & 23 deletions elk-cli/pom.xml
Expand Up @@ -26,16 +26,6 @@
<artifactId>elk-util-io</artifactId> <artifactId>elk-util-io</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elk-util-hashing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elk-util-collections</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>elk-util-common</artifactId> <artifactId>elk-util-common</artifactId>
Expand Down Expand Up @@ -70,19 +60,6 @@
<type>test-jar</type> <type>test-jar</type>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elk-util-testing</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>elk-util-concurrent</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
Expand Down
Expand Up @@ -38,13 +38,13 @@
@RunWith(PolySuite.class) @RunWith(PolySuite.class)
public abstract class BaseRealizationCorrectnessTest<EO extends TestOutput> public abstract class BaseRealizationCorrectnessTest<EO extends TestOutput>
extends extends
ReasoningCorrectnessTestWithOutput<UrlTestInput, EO, InstanceTaxonomyTestOutput<?>, ReasoningTestManifest<EO, InstanceTaxonomyTestOutput<?>>, ReasoningTestWithOutputDelegate<InstanceTaxonomyTestOutput<?>>> { ReasoningCorrectnessTestWithInterrupts<UrlTestInput, EO, InstanceTaxonomyTestOutput<?>, ReasoningTestManifest<EO, InstanceTaxonomyTestOutput<?>>, ReasoningTestWithOutputAndInterruptsDelegate<InstanceTaxonomyTestOutput<?>>> {


final static String INPUT_DATA_LOCATION = "realization_test_input"; final static String INPUT_DATA_LOCATION = "realization_test_input";


public BaseRealizationCorrectnessTest( public BaseRealizationCorrectnessTest(
final ReasoningTestManifest<EO, InstanceTaxonomyTestOutput<?>> testManifest, final ReasoningTestManifest<EO, InstanceTaxonomyTestOutput<?>> testManifest,
final ReasoningTestWithOutputDelegate<InstanceTaxonomyTestOutput<?>> testDelegate) { final ReasoningTestWithOutputAndInterruptsDelegate<InstanceTaxonomyTestOutput<?>> testDelegate) {
super(testManifest, testDelegate); super(testManifest, testDelegate);
} }


Expand Down
Expand Up @@ -53,7 +53,7 @@ public abstract class DiffRealizationCorrectnessTest extends


public DiffRealizationCorrectnessTest( public DiffRealizationCorrectnessTest(
final ReasoningTestManifest<InstanceTaxonomyTestOutput<?>, InstanceTaxonomyTestOutput<?>> testManifest, final ReasoningTestManifest<InstanceTaxonomyTestOutput<?>, InstanceTaxonomyTestOutput<?>> testManifest,
final ReasoningTestWithOutputDelegate<InstanceTaxonomyTestOutput<?>> testDelegate) { final ReasoningTestWithOutputAndInterruptsDelegate<InstanceTaxonomyTestOutput<?>> testDelegate) {
super(testManifest, testDelegate); super(testManifest, testDelegate);
} }


Expand Down
Expand Up @@ -20,14 +20,11 @@
* limitations under the License. * limitations under the License.
* #L% * #L%
*/ */
package org.semanticweb.elk.cli; package org.semanticweb.elk.reasoner;


import java.util.Arrays; import java.util.Arrays;


import org.semanticweb.elk.owl.interfaces.ElkClass; import org.semanticweb.elk.owl.interfaces.ElkClass;
import org.semanticweb.elk.reasoner.DiffClassificationCorrectnessTest;
import org.semanticweb.elk.reasoner.ReasoningTestManifest;
import org.semanticweb.elk.reasoner.TaxonomyTestOutput;
import org.semanticweb.elk.reasoner.taxonomy.model.Taxonomy; import org.semanticweb.elk.reasoner.taxonomy.model.Taxonomy;
import org.semanticweb.elk.testing.TestInput; import org.semanticweb.elk.testing.TestInput;


Expand All @@ -36,7 +33,7 @@
* *
* pavel.klinov@uni-ulm.de * pavel.klinov@uni-ulm.de
*/ */
public class CLIDiffClassificationCorrectnessTest public class ElkDiffClassificationCorrectnessTest
extends DiffClassificationCorrectnessTest { extends DiffClassificationCorrectnessTest {


static final String[] IGNORE_LIST = {}; static final String[] IGNORE_LIST = {};
Expand All @@ -45,9 +42,9 @@ public class CLIDiffClassificationCorrectnessTest
Arrays.sort(IGNORE_LIST); Arrays.sort(IGNORE_LIST);
} }


public CLIDiffClassificationCorrectnessTest( public ElkDiffClassificationCorrectnessTest(
final ReasoningTestManifest<TaxonomyTestOutput<?>, TaxonomyTestOutput<?>> testManifest) { final ReasoningTestManifest<TaxonomyTestOutput<?>, TaxonomyTestOutput<?>> testManifest) {
super(testManifest, new CliReasoningTestDelegate<TaxonomyTestOutput<?>>( super(testManifest, new ElkReasoningTestDelegate<TaxonomyTestOutput<?>>(
testManifest) { testManifest) {


@Override @Override
Expand Down
Expand Up @@ -20,21 +20,18 @@
* limitations under the License. * limitations under the License.
* #L% * #L%
*/ */
package org.semanticweb.elk.cli; package org.semanticweb.elk.reasoner;


import java.util.Arrays; import java.util.Arrays;


import org.semanticweb.elk.owl.interfaces.ElkObjectProperty; import org.semanticweb.elk.owl.interfaces.ElkObjectProperty;
import org.semanticweb.elk.reasoner.DiffObjectPropertyClassificationCorrectnessTest;
import org.semanticweb.elk.reasoner.ReasoningTestManifest;
import org.semanticweb.elk.reasoner.TaxonomyTestOutput;
import org.semanticweb.elk.reasoner.taxonomy.model.Taxonomy; import org.semanticweb.elk.reasoner.taxonomy.model.Taxonomy;
import org.semanticweb.elk.testing.TestInput; import org.semanticweb.elk.testing.TestInput;


/** /**
* @author Peter Skocovsky * @author Peter Skocovsky
*/ */
public class CLIDiffObjectPropertyClassificationCorrectnessTest public class ElkDiffObjectPropertyClassificationCorrectnessTest
extends DiffObjectPropertyClassificationCorrectnessTest { extends DiffObjectPropertyClassificationCorrectnessTest {


static final String[] IGNORE_LIST = {}; static final String[] IGNORE_LIST = {};
Expand All @@ -43,9 +40,9 @@ public class CLIDiffObjectPropertyClassificationCorrectnessTest
Arrays.sort(IGNORE_LIST); Arrays.sort(IGNORE_LIST);
} }


public CLIDiffObjectPropertyClassificationCorrectnessTest( public ElkDiffObjectPropertyClassificationCorrectnessTest(
final ReasoningTestManifest<TaxonomyTestOutput<?>, TaxonomyTestOutput<?>> testManifest) { final ReasoningTestManifest<TaxonomyTestOutput<?>, TaxonomyTestOutput<?>> testManifest) {
super(testManifest, new CliReasoningTestDelegate<TaxonomyTestOutput<?>>( super(testManifest, new ElkReasoningTestDelegate<TaxonomyTestOutput<?>>(
testManifest) { testManifest) {


@Override @Override
Expand Down
Expand Up @@ -20,15 +20,12 @@
* limitations under the License. * limitations under the License.
* #L% * #L%
*/ */
package org.semanticweb.elk.cli; package org.semanticweb.elk.reasoner;


import java.util.Arrays; import java.util.Arrays;


import org.semanticweb.elk.owl.interfaces.ElkClass; import org.semanticweb.elk.owl.interfaces.ElkClass;
import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual; import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual;
import org.semanticweb.elk.reasoner.DiffRealizationCorrectnessTest;
import org.semanticweb.elk.reasoner.InstanceTaxonomyTestOutput;
import org.semanticweb.elk.reasoner.ReasoningTestManifest;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy; import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy;
import org.semanticweb.elk.testing.TestInput; import org.semanticweb.elk.testing.TestInput;


Expand All @@ -37,7 +34,7 @@
* *
* pavel.klinov@uni-ulm.de * pavel.klinov@uni-ulm.de
*/ */
public class CLIDiffRealizationCorrectnessTest extends public class ElkDiffRealizationCorrectnessTest extends
DiffRealizationCorrectnessTest { DiffRealizationCorrectnessTest {


static final String[] IGNORE_LIST = { static final String[] IGNORE_LIST = {
Expand All @@ -49,10 +46,10 @@ public class CLIDiffRealizationCorrectnessTest extends
Arrays.sort(IGNORE_LIST); Arrays.sort(IGNORE_LIST);
} }


public CLIDiffRealizationCorrectnessTest( public ElkDiffRealizationCorrectnessTest(
final ReasoningTestManifest<InstanceTaxonomyTestOutput<?>, InstanceTaxonomyTestOutput<?>> testManifest) { final ReasoningTestManifest<InstanceTaxonomyTestOutput<?>, InstanceTaxonomyTestOutput<?>> testManifest) {
super(testManifest, super(testManifest,
new CliReasoningTestDelegate<InstanceTaxonomyTestOutput<?>>( new ElkReasoningTestDelegate<InstanceTaxonomyTestOutput<?>>(
testManifest) { testManifest) {


@Override @Override
Expand Down
Expand Up @@ -23,13 +23,10 @@
/** /**
* *
*/ */
package org.semanticweb.elk.cli; package org.semanticweb.elk.reasoner;


import org.semanticweb.elk.owl.interfaces.ElkClass; import org.semanticweb.elk.owl.interfaces.ElkClass;
import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual; import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual;
import org.semanticweb.elk.reasoner.HashRealizationCorrectnessTest;
import org.semanticweb.elk.reasoner.InstanceTaxonomyTestOutput;
import org.semanticweb.elk.reasoner.ReasoningTestManifest;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy; import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy;
import org.semanticweb.elk.testing.HashTestOutput; import org.semanticweb.elk.testing.HashTestOutput;


Expand All @@ -41,13 +38,13 @@
* pavel.klinov@uni-ulm.de * pavel.klinov@uni-ulm.de
*/ */


public class CLIHashRealizationCorrectnessTest public class ElkHashRealizationCorrectnessTest
extends HashRealizationCorrectnessTest { extends HashRealizationCorrectnessTest {


public CLIHashRealizationCorrectnessTest( public ElkHashRealizationCorrectnessTest(
final ReasoningTestManifest<HashTestOutput, InstanceTaxonomyTestOutput<?>> testManifest) { final ReasoningTestManifest<HashTestOutput, InstanceTaxonomyTestOutput<?>> testManifest) {
super(testManifest, super(testManifest,
new CliReasoningTestDelegate<InstanceTaxonomyTestOutput<?>>( new ElkReasoningTestDelegate<InstanceTaxonomyTestOutput<?>>(
testManifest) { testManifest) {


@Override @Override
Expand Down
Expand Up @@ -19,24 +19,21 @@
* limitations under the License. * limitations under the License.
* #L% * #L%
*/ */
package org.semanticweb.elk.cli; package org.semanticweb.elk.reasoner;


import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;


import java.util.Random; import java.util.Random;


import org.semanticweb.elk.RandomSeedProvider; import org.semanticweb.elk.RandomSeedProvider;
import org.semanticweb.elk.reasoner.RandomReasonerInterrupter;
import org.semanticweb.elk.reasoner.Reasoner; import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.ReasoningTestWithOutputAndInterruptsDelegate;
import org.semanticweb.elk.reasoner.TestReasonerUtils;
import org.semanticweb.elk.reasoner.stages.ElkInterruptedException; import org.semanticweb.elk.reasoner.stages.ElkInterruptedException;
import org.semanticweb.elk.testing.TestManifest; import org.semanticweb.elk.testing.TestManifest;
import org.semanticweb.elk.testing.TestOutput; import org.semanticweb.elk.testing.TestOutput;
import org.semanticweb.elk.testing.UrlTestInput; import org.semanticweb.elk.testing.UrlTestInput;


public abstract class CliReasoningTestDelegate<AO extends TestOutput> public abstract class ElkReasoningTestDelegate<AO extends TestOutput>
implements ReasoningTestWithOutputAndInterruptsDelegate<AO> { implements ReasoningTestWithOutputAndInterruptsDelegate<AO> {


public static final double INTERRUPTION_CHANCE = 0.3; public static final double INTERRUPTION_CHANCE = 0.3;
Expand All @@ -45,7 +42,7 @@ public abstract class CliReasoningTestDelegate<AO extends TestOutput>


private Reasoner reasoner_; private Reasoner reasoner_;


public CliReasoningTestDelegate( public ElkReasoningTestDelegate(
final TestManifest<? extends UrlTestInput> manifest) { final TestManifest<? extends UrlTestInput> manifest) {
this.manifest_ = manifest; this.manifest_ = manifest;
} }
Expand Down
Expand Up @@ -45,7 +45,7 @@ public abstract class HashRealizationCorrectnessTest extends


public HashRealizationCorrectnessTest( public HashRealizationCorrectnessTest(
final ReasoningTestManifest<HashTestOutput, InstanceTaxonomyTestOutput<?>> testManifest, final ReasoningTestManifest<HashTestOutput, InstanceTaxonomyTestOutput<?>> testManifest,
final ReasoningTestWithOutputDelegate<InstanceTaxonomyTestOutput<?>> testDelegate) { final ReasoningTestWithOutputAndInterruptsDelegate<InstanceTaxonomyTestOutput<?>> testDelegate) {
super(testManifest, testDelegate); super(testManifest, testDelegate);
} }


Expand Down
Expand Up @@ -19,7 +19,7 @@
* limitations under the License. * limitations under the License.
* #L% * #L%
*/ */
package org.semanticweb.elk.cli.query; package org.semanticweb.elk.reasoner.query;


import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
Expand All @@ -28,13 +28,10 @@
import java.util.Collection; import java.util.Collection;


import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.semanticweb.elk.cli.CliReasoningTestDelegate;
import org.semanticweb.elk.io.IOUtils; import org.semanticweb.elk.io.IOUtils;
import org.semanticweb.elk.owl.interfaces.ElkClass; import org.semanticweb.elk.owl.interfaces.ElkClass;
import org.semanticweb.elk.owl.interfaces.ElkClassExpression; import org.semanticweb.elk.owl.interfaces.ElkClassExpression;
import org.semanticweb.elk.reasoner.query.BaseQueryTest; import org.semanticweb.elk.reasoner.ElkReasoningTestDelegate;
import org.semanticweb.elk.reasoner.query.QueryTestInput;
import org.semanticweb.elk.reasoner.query.EquivalentEntitiesTestOutput;
import org.semanticweb.elk.reasoner.taxonomy.model.Node; import org.semanticweb.elk.reasoner.taxonomy.model.Node;
import org.semanticweb.elk.testing.ConfigurationUtils; import org.semanticweb.elk.testing.ConfigurationUtils;
import org.semanticweb.elk.testing.ConfigurationUtils.MultiManifestCreator; import org.semanticweb.elk.testing.ConfigurationUtils.MultiManifestCreator;
Expand All @@ -44,13 +41,13 @@
import org.semanticweb.elk.testing.TestManifestWithOutput; import org.semanticweb.elk.testing.TestManifestWithOutput;


@RunWith(PolySuite.class) @RunWith(PolySuite.class)
public class CliClassExpressionEquivalentClassesQueryTest extends public class ElkClassExpressionEquivalentClassesQueryTest extends
BaseQueryTest<ElkClassExpression, EquivalentEntitiesTestOutput<ElkClass>> { BaseQueryTest<ElkClassExpression, EquivalentEntitiesTestOutput<ElkClass>> {


public CliClassExpressionEquivalentClassesQueryTest( public ElkClassExpressionEquivalentClassesQueryTest(
final TestManifestWithOutput<QueryTestInput<ElkClassExpression>, EquivalentEntitiesTestOutput<ElkClass>, EquivalentEntitiesTestOutput<ElkClass>> manifest) { final TestManifestWithOutput<QueryTestInput<ElkClassExpression>, EquivalentEntitiesTestOutput<ElkClass>, EquivalentEntitiesTestOutput<ElkClass>> manifest) {
super(manifest, super(manifest,
new CliReasoningTestDelegate<EquivalentEntitiesTestOutput<ElkClass>>( new ElkReasoningTestDelegate<EquivalentEntitiesTestOutput<ElkClass>>(
manifest) { manifest) {


@Override @Override
Expand All @@ -59,7 +56,7 @@ public EquivalentEntitiesTestOutput<ElkClass> getActualOutput()
final Node<ElkClass> equivalent = getReasoner() final Node<ElkClass> equivalent = getReasoner()
.getEquivalentClassesQuietly( .getEquivalentClassesQuietly(
manifest.getInput().getQuery()); manifest.getInput().getQuery());
return new CliEquivalentEntitiesTestOutput(equivalent); return new ElkEquivalentEntitiesTestOutput(equivalent);
} }


}); });
Expand All @@ -83,7 +80,7 @@ public Collection<? extends TestManifestWithOutput<QueryTestInput<ElkClassExpres
try { try {
outputIS = output.openStream(); outputIS = output.openStream();


return CliExpectedTestOutputLoader.load(outputIS) return ElkExpectedTestOutputLoader.load(outputIS)
.getEquivalentEntitiesManifests(input); .getEquivalentEntitiesManifests(input);


} finally { } finally {
Expand Down
Expand Up @@ -19,7 +19,7 @@
* limitations under the License. * limitations under the License.
* #L% * #L%
*/ */
package org.semanticweb.elk.cli.query; package org.semanticweb.elk.reasoner.query;


import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
Expand All @@ -29,13 +29,10 @@
import java.util.Set; import java.util.Set;


import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.semanticweb.elk.cli.CliReasoningTestDelegate;
import org.semanticweb.elk.io.IOUtils; import org.semanticweb.elk.io.IOUtils;
import org.semanticweb.elk.owl.interfaces.ElkClassExpression; import org.semanticweb.elk.owl.interfaces.ElkClassExpression;
import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual; import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual;
import org.semanticweb.elk.reasoner.query.BaseQueryTest; import org.semanticweb.elk.reasoner.ElkReasoningTestDelegate;
import org.semanticweb.elk.reasoner.query.QueryTestInput;
import org.semanticweb.elk.reasoner.query.RelatedEntitiesTestOutput;
import org.semanticweb.elk.reasoner.taxonomy.ElkIndividualKeyProvider; import org.semanticweb.elk.reasoner.taxonomy.ElkIndividualKeyProvider;
import org.semanticweb.elk.reasoner.taxonomy.model.Node; import org.semanticweb.elk.reasoner.taxonomy.model.Node;
import org.semanticweb.elk.testing.ConfigurationUtils; import org.semanticweb.elk.testing.ConfigurationUtils;
Expand All @@ -46,13 +43,13 @@
import org.semanticweb.elk.testing.TestManifestWithOutput; import org.semanticweb.elk.testing.TestManifestWithOutput;


@RunWith(PolySuite.class) @RunWith(PolySuite.class)
public class CliClassExpressionInstancesQueryTest extends public class ElkClassExpressionInstancesQueryTest extends
BaseQueryTest<ElkClassExpression, RelatedEntitiesTestOutput<ElkNamedIndividual>> { BaseQueryTest<ElkClassExpression, RelatedEntitiesTestOutput<ElkNamedIndividual>> {


public CliClassExpressionInstancesQueryTest( public ElkClassExpressionInstancesQueryTest(
final TestManifestWithOutput<QueryTestInput<ElkClassExpression>, RelatedEntitiesTestOutput<ElkNamedIndividual>, RelatedEntitiesTestOutput<ElkNamedIndividual>> manifest) { final TestManifestWithOutput<QueryTestInput<ElkClassExpression>, RelatedEntitiesTestOutput<ElkNamedIndividual>, RelatedEntitiesTestOutput<ElkNamedIndividual>> manifest) {
super(manifest, super(manifest,
new CliReasoningTestDelegate<RelatedEntitiesTestOutput<ElkNamedIndividual>>( new ElkReasoningTestDelegate<RelatedEntitiesTestOutput<ElkNamedIndividual>>(
manifest) { manifest) {


@Override @Override
Expand All @@ -62,7 +59,7 @@ public RelatedEntitiesTestOutput<ElkNamedIndividual> getActualOutput()
.getInstancesQuietly( .getInstancesQuietly(
manifest.getInput().getQuery(), manifest.getInput().getQuery(),
true); true);
return new CliRelatedEntitiesTestOutput<ElkNamedIndividual>( return new ElkRelatedEntitiesTestOutput<ElkNamedIndividual>(
subNodes, ElkIndividualKeyProvider.INSTANCE); subNodes, ElkIndividualKeyProvider.INSTANCE);
} }


Expand All @@ -87,7 +84,7 @@ public Collection<? extends TestManifestWithOutput<QueryTestInput<ElkClassExpres
try { try {
outputIS = output.openStream(); outputIS = output.openStream();


return CliExpectedTestOutputLoader.load(outputIS) return ElkExpectedTestOutputLoader.load(outputIS)
.getInstancesManifests(input); .getInstancesManifests(input);


} finally { } finally {
Expand Down

0 comments on commit 4ca2ff3

Please sign in to comment.