Skip to content

Commit

Permalink
[Refactoring] Transition integration tests to JUnit 5, test code impr…
Browse files Browse the repository at this point in the history
…ovements.
  • Loading branch information
ledsoft committed Jul 15, 2019
1 parent 520bf96 commit 1ed698b
Show file tree
Hide file tree
Showing 30 changed files with 905 additions and 1,147 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) 2019 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.test.query.jena;

Expand All @@ -19,8 +17,8 @@
import cz.cvut.kbss.jopa.test.query.QueryTestEnvironment;
import cz.cvut.kbss.jopa.test.query.runner.PolymorphicSelectQueryRunner;
import cz.cvut.kbss.ontodriver.jena.config.JenaOntoDriverProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,12 +31,12 @@ public class PolymorphicSelectQueryTest extends PolymorphicSelectQueryRunner {

private static EntityManager em;

public PolymorphicSelectQueryTest() {
PolymorphicSelectQueryTest() {
super(LOG);
}

@Before
public void setUp() {
@BeforeEach
void setUp() {
final JenaPersistenceFactory persistenceFactory = new JenaPersistenceFactory();
final Map<String, String> properties = new HashMap<>();
properties.put(JenaOntoDriverProperties.JENA_STORAGE_TYPE, JenaOntoDriverProperties.IN_MEMORY);
Expand All @@ -49,7 +47,7 @@ public void setUp() {
em.getEntityManagerFactory().getCache().evictAll();
}

@After
@AfterEach
public void tearDown() {
em.close();
em.getEntityManagerFactory().close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) 2019 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.test.query.jena;

Expand All @@ -19,8 +17,8 @@
import cz.cvut.kbss.jopa.test.query.QueryTestEnvironment;
import cz.cvut.kbss.jopa.test.query.runner.QueryRunner;
import cz.cvut.kbss.ontodriver.jena.config.JenaOntoDriverProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,12 +31,12 @@ public class QueryTest extends QueryRunner {

private static EntityManager em;

public QueryTest() {
QueryTest() {
super(LOG);
}

@Before
public void setUp() {
@BeforeEach
void setUp() {
final JenaPersistenceFactory persistenceFactory = new JenaPersistenceFactory();
final Map<String, String> properties = new HashMap<>();
properties.put(JenaOntoDriverProperties.JENA_STORAGE_TYPE, JenaOntoDriverProperties.IN_MEMORY);
Expand All @@ -49,8 +47,8 @@ public void setUp() {
em.getEntityManagerFactory().getCache().evictAll();
}

@After
public void tearDown() {
@AfterEach
void tearDown() {
em.close();
em.getEntityManagerFactory().close();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/**
* Copyright (C) 2019 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.test.query.jena;

Expand All @@ -19,8 +17,8 @@
import cz.cvut.kbss.jopa.test.query.QueryTestEnvironment;
import cz.cvut.kbss.jopa.test.query.runner.TypedQueryRunner;
import cz.cvut.kbss.ontodriver.jena.config.JenaOntoDriverProperties;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,12 +31,12 @@ public class TypedQueryTest extends TypedQueryRunner {

private static EntityManager em;

public TypedQueryTest() {
TypedQueryTest() {
super(LOG);
}

@Before
public void setUp() {
@BeforeEach
void setUp() {
final JenaPersistenceFactory persistenceFactory = new JenaPersistenceFactory();
final Map<String, String> properties = new HashMap<>();
properties.put(JenaOntoDriverProperties.JENA_STORAGE_TYPE, JenaOntoDriverProperties.IN_MEMORY);
Expand All @@ -49,8 +47,8 @@ public void setUp() {
em.getEntityManagerFactory().getCache().evictAll();
}

@After
public void tearDown() {
@AfterEach
void tearDown() {
em.close();
em.getEntityManagerFactory().close();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
/**
* Copyright (C) 2019 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.test.query.owlapi;

import cz.cvut.kbss.jopa.model.EntityManager;
import cz.cvut.kbss.jopa.test.environment.OwlapiPersistenceFactory;
import cz.cvut.kbss.jopa.test.query.QueryTestEnvironment;
import cz.cvut.kbss.jopa.test.query.runner.PolymorphicSelectQueryRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,21 +31,21 @@ public class PolymorphicSelectQueryTest extends PolymorphicSelectQueryRunner {

private static EntityManager em;

public PolymorphicSelectQueryTest() {
PolymorphicSelectQueryTest() {
super(LOG);
}

@BeforeClass
public static void setUpBeforeClass() {
@BeforeAll
static void setUpBeforeClass() {
final OwlapiPersistenceFactory persistenceFactory = new OwlapiPersistenceFactory();
em = persistenceFactory.getEntityManager("PolymorphicSelectQueryTests", false, Collections.emptyMap());
QueryTestEnvironment.generateTestData(em);
em.clear();
em.getEntityManagerFactory().getCache().evictAll();
}

@AfterClass
public static void tearDownAfterClass() {
@AfterAll
static void tearDownAfterClass() {
em.close();
em.getEntityManagerFactory().close();
}
Expand All @@ -57,14 +55,14 @@ protected EntityManager getEntityManager() {
return em;
}

@Ignore
@Disabled
@Test
public void selectLoadsInstanceOfMostConcreteSubclassOfAbstractEntity() {
// Another possible bug in OWL2Query - This query returns no results and there is a warning:
// cz.cvut.kbss.owl2query.engine.QueryImpl checkType WARNING: 'rdfs:label' is not an object of type 'DATA_PROPERTY'.
}

@Ignore
@Disabled
@Test
public void selectLoadsInstanceOfMostConcreteSubclassOfConcreteEntity() {
// Same as above
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
/**
* Copyright (C) 2019 Czech Technical University in Prague
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.test.query.owlapi;

import cz.cvut.kbss.jopa.model.EntityManager;
import cz.cvut.kbss.jopa.test.environment.OwlapiPersistenceFactory;
import cz.cvut.kbss.jopa.test.query.QueryTestEnvironment;
import cz.cvut.kbss.jopa.test.query.runner.QueryRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -33,21 +31,21 @@ public class QueryTest extends QueryRunner {

private static EntityManager em;

public QueryTest() {
QueryTest() {
super(LOG);
}

@BeforeClass
public static void setUpBeforeClass() {
@BeforeAll
static void setUpBeforeClass() {
final OwlapiPersistenceFactory persistenceFactory = new OwlapiPersistenceFactory();
em = persistenceFactory.getEntityManager("SPARQLQueryTests", false, Collections.emptyMap());
QueryTestEnvironment.generateTestData(em);
em.clear();
em.getEntityManagerFactory().getCache().evictAll();
}

@AfterClass
public static void tearDownAfterClass() {
@AfterAll
static void tearDownAfterClass() {
em.close();
em.getEntityManagerFactory().close();
}
Expand All @@ -57,31 +55,31 @@ protected EntityManager getEntityManager() {
return em;
}

@Ignore
@Disabled
@Override
public void selectWithOptionalReturnsNullInUnfilledColumns() {
// OWL2Query does not support OPTIONAL pattern
}

@Ignore
@Disabled
@Override
public void queryWithEntityMappingLoadsReferencedEntityAndInheritedAttributes() {
// OWL2Query does not return any results for the test query
}

@Ignore
@Disabled
@Test
public void executeUpdateRunsUpdateOnRepository() {
// No updates in OWL2Query
}

@Ignore
@Disabled
@Test
public void executeUpdateRunsDeleteOnRepository() {
// No updates in OWL2Query
}

@Ignore
@Disabled
@Test
public void executeUpdateRunsInsertOnRepository() {
// No updates in OWL2Query
Expand Down
Loading

0 comments on commit 1ed698b

Please sign in to comment.