[MediaWiki-commits] [Gerrit] wikidata...rdf[master]: Extract RdfRepositoryForTesting to a JUnit @Rule

2017-12-11 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/396380 )

Change subject: Extract RdfRepositoryForTesting to a JUnit @Rule
..


Extract RdfRepositoryForTesting to a JUnit @Rule

Rules allow better composition of test infrastructure than abstract classes.
In this case, it opens the way to better test the RdfRepositoryForTesting
itself as well.

Bug: T178721
Change-Id: I77139a6d64b3610c2621676c9b686dfbfd22b260
---
D 
tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/AbstractUpdaterIntegrationTestBase.java
M tools/src/test/java/org/wikidata/query/rdf/tool/IOBlastingIntegrationTest.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/MultipleResultsQueryIntegrationTest.java
M tools/src/test/java/org/wikidata/query/rdf/tool/MungeIntegrationTest.java
A tools/src/test/java/org/wikidata/query/rdf/tool/RdfRepositoryForTesting.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseDateExtensionIntegrationTest.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseGeoExtensionIntegrationTest.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/rdf/RdfRepositoryIntegrationTest.java
9 files changed, 370 insertions(+), 373 deletions(-)

Approvals:
  Smalyshev: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
 
b/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
deleted file mode 100644
index 5f439a3..000
--- 
a/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.wikidata.query.rdf.tool;
-
-import java.net.URI;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.wikidata.query.rdf.common.uri.WikibaseUris;
-import org.wikidata.query.rdf.tool.rdf.RdfRepository;
-
-import com.carrotsearch.randomizedtesting.RandomizedRunner;
-import com.carrotsearch.randomizedtesting.RandomizedTest;
-
-/**
- * Superclass of integration tests that an RDF repository and clear it between
- * test methods.
- */
-@RunWith(RandomizedRunner.class)
-public abstract class AbstractRdfRepositoryIntegrationTestBase extends 
RandomizedTest {
-
-/**
- * Take a relative path and create a URL with the full path to Blazegraph 
on
- * localhost.
- */
-private static URI url(String path) {
-return URI.create("http://localhost:/bigdata; + path);
-}
-
-/**
- * Wikibase uris to test with.
- */
-private final WikibaseUris uris;
-/**
- * Repository to test with.
- */
-private RdfRepositoryForTesting rdfRepository;
-
-/**
- * Build the test against prod wikidata.
- */
-public AbstractRdfRepositoryIntegrationTestBase() {
-this(WikibaseUris.getURISystem());
-}
-
-public AbstractRdfRepositoryIntegrationTestBase(WikibaseUris uris) {
-this.uris = uris;
-}
-
-/**
- * Initializes the {@link RdfRepository} before each test.
- *
- * Since randomized testing ThreadLeakControl checks for leaked thread, not
- * closing properly the RdfRepository after each test causes random false
- * negative in the test results. Initializing the RdfRepository for each
- * test might be slightly less performant, but at least it ensures
- * reproducible tests.
- */
-@Before
-public void initRdfRepository() {
-rdfRepository = new RdfRepositoryForTesting("wdq");
-rdfRepository.clear();
-}
-
-/**
- * Closes the {@link RdfRepository} after each test.
- *
- * @throws Exception on error
- */
-@After
-public void clearAndShutdownRdfRepository() throws Exception {
-if (rdfRepository != null) {
-rdfRepository.clear();
-rdfRepository.close();
-}
-}
-
-/**
- * Uris to test with.
- */
-public WikibaseUris uris() {
-return uris;
-}
-
-/**
- * Repository to test against.
- */
-public RdfRepositoryForTesting rdfRepository() {
-return rdfRepository;
-}
-
-/**
- * RdfRepository extension used for testing. We don't want to anyone to
- * accidentally use clear() so we don't put it in the repository.
- */
-public static class RdfRepositoryForTesting extends RdfRepository {
-
-/**
- * The namespace of the local RDF repository, e.g. "kb" or "wdq".
- */
-private final String namespace;
-
-public RdfRepositoryForTesting(String namespace) {
-super(url("/namespace/" + namespace + "/sparql"), 
WikibaseUris.WIKIDATA);
-this.namespace = namespace;
-}
-
-/**
- * Clear's the whole repository.
- */

[MediaWiki-commits] [Gerrit] wikidata...rdf[master]: Extract RdfRepositoryForTesting to a JUnit @Rule

2017-12-08 Thread Gehel (Code Review)
Gehel has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/396380 )

Change subject: Extract RdfRepositoryForTesting to a JUnit @Rule
..

Extract RdfRepositoryForTesting to a JUnit @Rule

Rules allow better composition of test infrastructure than abstract classes.
In this case, it opens the way to better test the RdfRepositoryForTesting
itself as well.

Bug: T178721
Change-Id: I77139a6d64b3610c2621676c9b686dfbfd22b260
---
D 
tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/AbstractUpdaterIntegrationTestBase.java
M tools/src/test/java/org/wikidata/query/rdf/tool/IOBlastingIntegrationTest.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/MultipleResultsQueryIntegrationTest.java
M tools/src/test/java/org/wikidata/query/rdf/tool/MungeIntegrationTest.java
A tools/src/test/java/org/wikidata/query/rdf/tool/RdfRepositoryForTesting.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseDateExtensionIntegrationTest.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/WikibaseGeoExtensionIntegrationTest.java
M 
tools/src/test/java/org/wikidata/query/rdf/tool/rdf/RdfRepositoryIntegrationTest.java
9 files changed, 364 insertions(+), 373 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/rdf 
refs/changes/80/396380/1

diff --git 
a/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
 
b/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
deleted file mode 100644
index 5f439a3..000
--- 
a/tools/src/test/java/org/wikidata/query/rdf/tool/AbstractRdfRepositoryIntegrationTestBase.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.wikidata.query.rdf.tool;
-
-import java.net.URI;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.wikidata.query.rdf.common.uri.WikibaseUris;
-import org.wikidata.query.rdf.tool.rdf.RdfRepository;
-
-import com.carrotsearch.randomizedtesting.RandomizedRunner;
-import com.carrotsearch.randomizedtesting.RandomizedTest;
-
-/**
- * Superclass of integration tests that an RDF repository and clear it between
- * test methods.
- */
-@RunWith(RandomizedRunner.class)
-public abstract class AbstractRdfRepositoryIntegrationTestBase extends 
RandomizedTest {
-
-/**
- * Take a relative path and create a URL with the full path to Blazegraph 
on
- * localhost.
- */
-private static URI url(String path) {
-return URI.create("http://localhost:/bigdata; + path);
-}
-
-/**
- * Wikibase uris to test with.
- */
-private final WikibaseUris uris;
-/**
- * Repository to test with.
- */
-private RdfRepositoryForTesting rdfRepository;
-
-/**
- * Build the test against prod wikidata.
- */
-public AbstractRdfRepositoryIntegrationTestBase() {
-this(WikibaseUris.getURISystem());
-}
-
-public AbstractRdfRepositoryIntegrationTestBase(WikibaseUris uris) {
-this.uris = uris;
-}
-
-/**
- * Initializes the {@link RdfRepository} before each test.
- *
- * Since randomized testing ThreadLeakControl checks for leaked thread, not
- * closing properly the RdfRepository after each test causes random false
- * negative in the test results. Initializing the RdfRepository for each
- * test might be slightly less performant, but at least it ensures
- * reproducible tests.
- */
-@Before
-public void initRdfRepository() {
-rdfRepository = new RdfRepositoryForTesting("wdq");
-rdfRepository.clear();
-}
-
-/**
- * Closes the {@link RdfRepository} after each test.
- *
- * @throws Exception on error
- */
-@After
-public void clearAndShutdownRdfRepository() throws Exception {
-if (rdfRepository != null) {
-rdfRepository.clear();
-rdfRepository.close();
-}
-}
-
-/**
- * Uris to test with.
- */
-public WikibaseUris uris() {
-return uris;
-}
-
-/**
- * Repository to test against.
- */
-public RdfRepositoryForTesting rdfRepository() {
-return rdfRepository;
-}
-
-/**
- * RdfRepository extension used for testing. We don't want to anyone to
- * accidentally use clear() so we don't put it in the repository.
- */
-public static class RdfRepositoryForTesting extends RdfRepository {
-
-/**
- * The namespace of the local RDF repository, e.g. "kb" or "wdq".
- */
-private final String namespace;
-
-public RdfRepositoryForTesting(String namespace) {
-super(url("/namespace/" + namespace + "/sparql"), 
WikibaseUris.WIKIDATA);
-this.namespace = namespace;
-}
-
-/**
- * Clear's the whole repository.
- */