From 15280e46bb8ad52cc07e58bf972a161edcf80f48 Mon Sep 17 00:00:00 2001 From: Richard Richter Date: Wed, 18 Mar 2020 17:16:34 +0100 Subject: [PATCH] repo-sql-impl-test experiment with DB cleanup instead of dirty context This speeds up the tests significantly, but currently there are couple of problems with it: - H2 server is sometimes started repeatedly (port binding fails). - Seems that some objects are missing for some tests. This may be caused by: - Various Spring contexts are used, this is definitely a problem, it should be unified on BaseSQLRepoTest level to avoid context refresh. - Some data are probably initialized during Spring setup and missing after they are deleted. We either have to add WHERE to DELETE if these objects are always to be preserved, or (more systemic?) to initialize these objects after the DB cleanup. --- .../evolveum/midpoint/test/util/TestUtil.java | 9 - repo/repo-sql-impl-test/pom.xml | 4 + .../midpoint/repo/sql/testing/DbDeleter.java | 154 ++++++++++++++++++ .../midpoint/repo/sql/AbstractPhotoTest.java | 23 ++- .../midpoint/repo/sql/AddGetObjectTest.java | 65 ++++---- .../midpoint/repo/sql/AddOverwriteTest.java | 43 ++--- .../repo/sql/AuditCleanupPerformanceTest.java | 8 +- .../evolveum/midpoint/repo/sql/AuditTest.java | 5 - .../midpoint/repo/sql/BaseSQLRepoTest.java | 17 +- .../midpoint/repo/sql/CertificationTest.java | 2 - .../repo/sql/CertificationTestReindex.java | 3 - .../midpoint/repo/sql/CleanupTest.java | 107 ++++++------ .../midpoint/repo/sql/ConcurrencyTest.java | 6 - .../midpoint/repo/sql/DataSourceTest.java | 8 +- .../midpoint/repo/sql/DeleteTest.java | 31 ++-- .../midpoint/repo/sql/DeleteTestSimple.java | 13 +- .../repo/sql/EmbeddedServerModeTest.java | 10 +- .../midpoint/repo/sql/EncodingTest.java | 2 - .../sql/ExtDictionaryConcurrencyTest.java | 5 - .../midpoint/repo/sql/ExtDictionaryTest.java | 6 +- .../midpoint/repo/sql/ExtensionTest.java | 73 ++++----- .../repo/sql/ListAccountShadowOwnerTest.java | 7 +- .../midpoint/repo/sql/LookupTableTest.java | 5 - .../repo/sql/LookupTableTestReindex.java | 8 +- .../repo/sql/ModifyAssignmentTest.java | 5 - .../midpoint/repo/sql/ModifyTest.java | 5 - .../midpoint/repo/sql/ModifyTestReindex.java | 31 ++-- .../midpoint/repo/sql/ModifyUser.java | 22 ++- .../repo/sql/ObjectDeltaUpdaterTest.java | 108 ++++++------ .../midpoint/repo/sql/OrgPhotoTest.java | 20 +-- .../midpoint/repo/sql/OrgStructTest.java | 17 +- .../midpoint/repo/sql/PerformanceTest.java | 41 ++--- .../repo/sql/QueryInterpreter2Test.java | 6 - .../repo/sql/RAnyConverterStaticTest.java | 2 - .../evolveum/midpoint/repo/sql/RUtilTest.java | 5 - .../midpoint/repo/sql/ResourceModifyTest.java | 5 - .../repo/sql/SearchIterativeTest.java | 2 - .../repo/sql/SearchShadowOwnerTest.java | 29 ++-- .../midpoint/repo/sql/SearchTest.java | 2 - .../midpoint/repo/sql/SequenceTest.java | 41 ++--- .../sql/SpringApplicationContextTest.java | 11 +- .../midpoint/repo/sql/UserPhotoTest.java | 20 +-- .../closure/OrgClosureConcurrencyTest.java | 13 -- .../closure/OrgClosureCorrectnessTest.java | 59 ++++--- .../closure/OrgClosureOverwriteAddTest.java | 17 +- .../closure/OrgClosurePerformanceTest1.java | 44 +++-- .../closure/OrgClosurePerformanceTest2.java | 44 +++-- .../repo/sql/util/OrgStructGenerator.java | 29 ++-- 48 files changed, 608 insertions(+), 584 deletions(-) create mode 100644 repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/DbDeleter.java diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java index e69df1ea4bc..673fefc352c 100644 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/util/TestUtil.java @@ -145,15 +145,6 @@ public static void assertElement(List elements, QName elementQName, Stri AssertJUnit.fail("No element with name " + elementQName); } - public static void assertExceptionSanity(ObjectAlreadyExistsException e) { - LOGGER.debug("Exception (expected) {}", e, e); - System.out.println("Exception (expected)"); - System.out.println(ExceptionUtils.getFullStackTrace(e)); - assert !e.getMessage().isEmpty() : "Empty exception message"; - assert e.getMessage().length() < MAX_EXCEPTION_MESSAGE_LENGTH : "Exception message too long (" - + e.getMessage().length() + " characters): " + e.getMessage(); - } - public static void displayCleanup(String testName) { System.out.println(TEST_OUT_SECTION_PREFIX + " CLEANUP " + testName + TEST_OUT_SECTION_SUFFIX); LOGGER.info(TEST_LOG_SECTION_PREFIX + " CLEANUP " + testName + TEST_LOG_SECTION_SUFFIX); diff --git a/repo/repo-sql-impl-test/pom.xml b/repo/repo-sql-impl-test/pom.xml index 79965ac6f27..b78bb3c26ae 100644 --- a/repo/repo-sql-impl-test/pom.xml +++ b/repo/repo-sql-impl-test/pom.xml @@ -109,6 +109,10 @@ org.hibernate hibernate-core + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + org.jetbrains annotations diff --git a/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/DbDeleter.java b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/DbDeleter.java new file mode 100644 index 00000000000..e9894170029 --- /dev/null +++ b/repo/repo-sql-impl-test/src/main/java/com/evolveum/midpoint/repo/sql/testing/DbDeleter.java @@ -0,0 +1,154 @@ +package com.evolveum.midpoint.repo.sql.testing; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.PersistenceUnit; +import javax.persistence.Query; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.evolveum.midpoint.repo.sql.SqlRepositoryConfiguration; +import com.evolveum.midpoint.util.logging.Trace; +import com.evolveum.midpoint.util.logging.TraceManager; + +/** + * Class for DB cleanup before the test class is run. + * Partially duplicates {@link TestSqlRepositoryBeanPostProcessor} - if this is successful + * we should somehow consolidate/merge these. + */ +@Component +public class DbDeleter { + + private static final Trace LOGGER = TraceManager.getTrace(DbDeleter.class); + + private static final String TRUNCATE_FUNCTION = "cleanupTestDatabase"; + private static final String TRUNCATE_PROCEDURE = "cleanupTestDatabaseProc"; + + @PersistenceUnit + private EntityManagerFactory entityManagerFactory; + + @Autowired + private TestSqlRepositoryFactory testSqlRepositoryFactory; + + public void cleanupTestDatabase() { + SqlRepositoryConfiguration config = testSqlRepositoryFactory.getSqlConfiguration(); + if (!config.isDropIfExists()) { + LOGGER.info("We're not deleting objects from DB if drop-if-exists=false."); + return; + } + + System.out.println("\n!!! DELETING objects from database."); + LOGGER.info("Deleting objects from database."); + + long startMs = System.currentTimeMillis(); + EntityManager entityManager = entityManagerFactory.createEntityManager(); + try { + entityManager.getTransaction().begin(); + + Query query; + if (config.isUsingH2()) { + LOGGER.info("Using bunch of deletes for H2."); + deleteAllTables(entityManager); + } else if (config.isUsingOracle() || config.isUsingSQLServer()) { + LOGGER.info("Using truncate procedure."); + query = entityManager.createNativeQuery("{ call " + TRUNCATE_PROCEDURE + "() }"); + query.executeUpdate(); + } else { + LOGGER.info("Using truncate function."); + query = entityManager.createNativeQuery("select " + TRUNCATE_FUNCTION + "();"); + query.getSingleResult(); + } + + entityManager.getTransaction().commit(); + } catch (Exception ex) { + LOGGER.error("Couldn't cleanup database, reason:", ex); + entityManager.getTransaction().rollback(); + throw ex; + } finally { + entityManager.close(); + } + LOGGER.info("DB cleaned up in {} ms", System.currentTimeMillis() - startMs); + } + + private void deleteAllTables(EntityManager entityManager) { + deleteTable(entityManager, "m_object_text_info"); + deleteTable(entityManager, "m_operation_execution"); + deleteTable(entityManager, "m_sequence"); + deleteTable(entityManager, "m_acc_cert_wi_reference"); + deleteTable(entityManager, "m_acc_cert_wi"); + deleteTable(entityManager, "m_acc_cert_case"); + deleteTable(entityManager, "m_acc_cert_campaign"); + deleteTable(entityManager, "m_acc_cert_definition"); + deleteTable(entityManager, "m_audit_resource"); + deleteTable(entityManager, "m_audit_ref_value"); + deleteTable(entityManager, "m_audit_prop_value"); + deleteTable(entityManager, "m_audit_delta"); + deleteTable(entityManager, "m_audit_item"); + deleteTable(entityManager, "m_audit_event"); + deleteTable(entityManager, "m_object_ext_date"); + deleteTable(entityManager, "m_object_ext_long"); + deleteTable(entityManager, "m_object_ext_string"); + deleteTable(entityManager, "m_object_ext_poly"); + deleteTable(entityManager, "m_object_ext_reference"); + deleteTable(entityManager, "m_object_ext_boolean"); + deleteTable(entityManager, "m_reference"); + deleteTable(entityManager, "m_assignment_ext_date"); + deleteTable(entityManager, "m_assignment_ext_long"); + deleteTable(entityManager, "m_assignment_ext_poly"); + deleteTable(entityManager, "m_assignment_ext_reference"); + deleteTable(entityManager, "m_assignment_ext_string"); + deleteTable(entityManager, "m_assignment_ext_boolean"); + deleteTable(entityManager, "m_assignment_extension"); + deleteTable(entityManager, "m_assignment_reference"); + deleteTable(entityManager, "m_assignment_policy_situation"); + deleteTable(entityManager, "m_assignment"); + deleteTable(entityManager, "m_connector_target_system"); + deleteTable(entityManager, "m_connector"); + deleteTable(entityManager, "m_connector_host"); + deleteTable(entityManager, "m_lookup_table_row"); + deleteTable(entityManager, "m_lookup_table"); + deleteTable(entityManager, "m_node"); + deleteTable(entityManager, "m_shadow"); + deleteTable(entityManager, "m_task_dependent"); + deleteTable(entityManager, "m_task"); + deleteTable(entityManager, "m_object_template"); + deleteTable(entityManager, "m_value_policy"); + deleteTable(entityManager, "m_resource"); + deleteTable(entityManager, "m_user_employee_type"); + deleteTable(entityManager, "m_user_organization"); + deleteTable(entityManager, "m_user_organizational_unit"); + deleteTable(entityManager, "m_focus_photo"); + deleteTable(entityManager, "m_focus_policy_situation"); + deleteTable(entityManager, "m_user"); + deleteTable(entityManager, "m_report"); + deleteTable(entityManager, "m_report_output"); + deleteTable(entityManager, "m_org_org_type"); + deleteTable(entityManager, "m_org_closure"); + deleteTable(entityManager, "m_org"); + deleteTable(entityManager, "m_role"); + deleteTable(entityManager, "m_service_type"); + deleteTable(entityManager, "m_service"); + deleteTable(entityManager, "m_archetype"); + deleteTable(entityManager, "m_abstract_role"); + deleteTable(entityManager, "m_system_configuration"); + deleteTable(entityManager, "m_generic_object"); + deleteTable(entityManager, "m_trigger"); + deleteTable(entityManager, "m_focus"); + deleteTable(entityManager, "m_security_policy"); + deleteTable(entityManager, "m_form"); + deleteTable(entityManager, "m_case_wi_reference"); + deleteTable(entityManager, "m_case_wi"); + deleteTable(entityManager, "m_case"); + deleteTable(entityManager, "m_function_library"); + deleteTable(entityManager, "m_ext_item"); + deleteTable(entityManager, "m_object_subtype"); + deleteTable(entityManager, "m_object_collection"); + deleteTable(entityManager, "m_dashboard"); + deleteTable(entityManager, "m_object"); + } + + private void deleteTable(EntityManager entityManager, String tableName) { + entityManager.createNativeQuery("DELETE FROM " + tableName).executeUpdate(); + } +} diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AbstractPhotoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AbstractPhotoTest.java index f83ef022b51..8187c4e4897 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AbstractPhotoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AbstractPhotoTest.java @@ -7,28 +7,27 @@ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.*; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.schema.*; +import com.evolveum.midpoint.schema.DeltaConvertor; +import com.evolveum.midpoint.schema.GetOperationOptions; +import com.evolveum.midpoint.schema.RetrieveOption; +import com.evolveum.midpoint.schema.SelectorOptions; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType; -import org.testng.annotations.BeforeClass; - -import java.io.File; -import java.io.IOException; -import java.util.Collection; -import java.util.Collections; -import static org.testng.AssertJUnit.*; - -/** - * - */ public abstract class AbstractPhotoTest extends BaseSQLRepoTest { static final File TEST_DIR = new File("src/test/resources/photo"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java index 5b7f35f8d5f..6aa5e2abcda 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddGetObjectTest.java @@ -7,6 +7,21 @@ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.*; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.File; +import java.util.*; +import javax.xml.namespace.QName; + +import org.hibernate.Session; +import org.hibernate.query.Query; +import org.hibernate.stat.Statistics; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.delta.ItemDelta; @@ -20,7 +35,8 @@ import com.evolveum.midpoint.repo.sql.data.common.enums.ROperationResultStatus; import com.evolveum.midpoint.repo.sql.type.XMLGregorianCalendarType; import com.evolveum.midpoint.repo.sql.util.RUtil; -import com.evolveum.midpoint.schema.*; +import com.evolveum.midpoint.schema.GetOperationOptionsBuilder; +import com.evolveum.midpoint.schema.ResultHandler; import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; @@ -30,26 +46,8 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.hibernate.query.Query; -import org.hibernate.Session; -import org.hibernate.stat.Statistics; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; -import javax.xml.namespace.QName; -import java.io.File; -import java.util.*; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.*; - -/** - * @author lazyman - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class AddGetObjectTest extends BaseSQLRepoTest { @Test(enabled = false) @@ -64,8 +62,8 @@ public void perfTest() throws Exception { long time = System.currentTimeMillis(); for (int i = 0; i < elements.size(); i++) { if (i % 500 == 0) { - logger.info("Previous cycle time {}. Next cycle: {}", new Object[]{ - (System.currentTimeMillis() - time - previousCycle), i}); + logger.info("Previous cycle time {}. Next cycle: {}", new Object[] { + (System.currentTimeMillis() - time - previousCycle), i }); previousCycle = System.currentTimeMillis() - time; } @@ -73,7 +71,7 @@ public void perfTest() throws Exception { repositoryService.addObject(object, null, new OperationResult("add performance test")); } logger.info("Time to add objects ({}): {}", - new Object[]{elements.size(), (System.currentTimeMillis() - time)}); + new Object[] { elements.size(), (System.currentTimeMillis() - time) }); stats.logSummary(); } @@ -88,7 +86,7 @@ public void addSameName() throws Exception { assert false : "Unexpected success"; } catch (ObjectAlreadyExistsException e) { - TestUtil.assertExceptionSanity(e); + displayExpectedException(e); } } @@ -97,7 +95,7 @@ public void addGetDSEESyncDoubleTest() throws Exception { final File OBJECTS_FILE = new File("./../../samples/dsee/odsee-localhost-advanced-sync.xml"); if (!OBJECTS_FILE.exists()) { logger.warn("skipping addGetDSEESyncDoubleTest, file {} not found.", - new Object[]{OBJECTS_FILE.getPath()}); + new Object[] { OBJECTS_FILE.getPath() }); return; } addGetCompare(OBJECTS_FILE); @@ -107,7 +105,7 @@ public void addGetDSEESyncDoubleTest() throws Exception { assert false : "Unexpected success"; } catch (ObjectAlreadyExistsException e) { - TestUtil.assertExceptionSanity(e); + displayExpectedException(e); } } @@ -192,7 +190,7 @@ private List> addGetCompare(File file) throws Exception { } } catch (Throwable ex) { logger.error("Exception occurred for {}", object, ex); - throw new RuntimeException("Exception during processing of "+object+": "+ex.getMessage(), ex); + throw new RuntimeException("Exception during processing of " + object + ": " + ex.getMessage(), ex); } } AssertJUnit.assertEquals("Found changes during add/get test " + count, 0, count); @@ -209,7 +207,7 @@ private Integer size(PrismContainerValue value) { private void checkContainerValuesSize(QName parentName, PrismContainerValue newValue, PrismContainerValue oldValue) { logger.info("Checking: " + parentName); - AssertJUnit.assertEquals("Count doesn't match for '" + parentName + "' id="+newValue.getId(), size(oldValue), size(newValue)); + AssertJUnit.assertEquals("Count doesn't match for '" + parentName + "' id=" + newValue.getId(), size(oldValue), size(newValue)); List checked = new ArrayList<>(); @@ -309,7 +307,7 @@ public void addGetFullAccount() throws Exception { ObjectDelta delta = fileAccount.diff(repoAccount); AssertJUnit.assertNotNull(delta); - logger.info("delta\n{}", new Object[]{delta.debugDump(3)}); + logger.info("delta\n{}", new Object[] { delta.debugDump(3) }); if (!delta.isEmpty()) { fail("delta is not empty: " + delta.debugDump()); } @@ -385,7 +383,7 @@ public void testAddGetSyncDescription() throws Exception { } @Test - public void addGetRoleWithResourceRefFilter() throws Exception{ + public void addGetRoleWithResourceRefFilter() throws Exception { PrismObject role = prismContext.parseObject(new File("src/test/resources/basic/role-resource-filter.xml")); System.out.println("role: " + role.debugDump()); @@ -482,7 +480,6 @@ private String testIterationToken(String token) throws Exception { // System.out.println(">>> " + time); // } - @Test public void test() throws Exception { OperationResult result = new OperationResult("asdf"); @@ -563,7 +560,7 @@ public void test100AddUserWithoutAssignmentIds() throws Exception { } Collections.sort(dbShorts); - logger.info("assigments ids: expected {} db {}", Arrays.toString(xmlShorts.toArray()), + logger.info("assignments ids: expected {} db {}", Arrays.toString(xmlShorts.toArray()), Arrays.toString(dbShorts.toArray())); AssertJUnit.assertArrayEquals(xmlShorts.toArray(), dbShorts.toArray()); } finally { @@ -737,10 +734,10 @@ public void test300ContainerIds() throws Exception { UserType user = new UserType(prismContext) .name("t300") .beginAssignment() - .description("a1") + .description("a1") .end() .beginAssignment() - .description("a2") + .description("a2") .end(); // WHEN diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddOverwriteTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddOverwriteTest.java index 58970525274..dcfc7f840a7 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddOverwriteTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AddOverwriteTest.java @@ -10,6 +10,15 @@ import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismObjectDefinition; import com.evolveum.midpoint.prism.PrismPropertyDefinition; @@ -18,40 +27,15 @@ import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.repo.api.RepoAddOptions; -import com.evolveum.midpoint.schema.MidPointPrismContextFactory; -import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.test.util.MidPointAsserts; -import com.evolveum.midpoint.util.PrettyPrinter; import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; -import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; - -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Test; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import com.evolveum.midpoint.xml.ns._public.common.common_3.*; /** * @author lazyman */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class AddOverwriteTest extends BaseSQLRepoTest { private static final String ORG_STRUCT_OBJECTS = "src/test/resources/orgstruct/org-monkey-island.xml"; @@ -65,7 +49,6 @@ public class AddOverwriteTest extends BaseSQLRepoTest { public void addWithOverwrite() throws Exception { List> objects = prismContext.parserFor(new File(ORG_STRUCT_OBJECTS)).parseObjects(); - OperationResult opResult = new OperationResult("Import file"); for (PrismObject o : objects) { repositoryService.addObject(o, null, opResult); @@ -91,7 +74,6 @@ public void addWithOverwrite() throws Exception { String newOid = repositoryService.addObject(newCarla, RepoAddOptions.createOverwrite(), opResult); AssertJUnit.assertEquals(oid, newOid); - carla = getCarla(opResult); PrismAsserts.assertPropertyValue(carla, ObjectType.F_NAME, PrismTestUtil.createPolyString("carla")); PrismAsserts.assertPropertyValue(carla, UserType.F_GIVEN_NAME, PrismTestUtil.createPolyString("Carla imported")); @@ -110,7 +92,6 @@ private PrismObject getCarla(OperationResult opResult) throws Exception { return users.get(0); } - @Test(expectedExceptions = ObjectNotFoundException.class) public void test090GetVersionNonExisting() throws Exception { OperationResult result = new OperationResult("get version"); @@ -146,7 +127,7 @@ public void test091GetVersion() throws Exception { public void addWithOverwriteResource() throws Exception { // GIVEN - SchemaRegistry reg= prismContext.getSchemaRegistry(); + SchemaRegistry reg = prismContext.getSchemaRegistry(); PrismPropertyDefinition def = reg.findPropertyDefinitionByElementName(CapabilitiesType.F_NATIVE); PrismObject resource = prismContext.parseObject(RESOURCE_OPENDJ_FILE); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditCleanupPerformanceTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditCleanupPerformanceTest.java index 12bab80ae4f..12ba4c144b9 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditCleanupPerformanceTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditCleanupPerformanceTest.java @@ -11,7 +11,6 @@ import org.hibernate.Session; import org.hibernate.query.Query; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -31,8 +30,7 @@ * @author lazyman * @author mederly */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class AuditCleanupPerformanceTest extends BaseSQLRepoTest { private static final int RECORDS = 50000; @@ -76,7 +74,7 @@ private void assertAuditEventRecord(OperationResult result) { private void prepareAuditEventRecords() throws Exception { long start = System.currentTimeMillis(); - for (int i = 0; i < RECORDS;) { + for (int i = 0; i < RECORDS; ) { AuditEventRecord record = new AuditEventRecord(); record.addDelta(createObjectDeltaOperation(i)); record.setTimestamp(System.currentTimeMillis()); @@ -84,7 +82,7 @@ private void prepareAuditEventRecords() throws Exception { record.addReferenceValue("ref1", ObjectTypeUtil.createObjectRef("oid1", ObjectTypes.USER).asReferenceValue()); auditService.audit(record, new NullTaskImpl()); i++; - if (i%1000 == 0 || i == RECORDS) { + if (i % 1000 == 0 || i == RECORDS) { long duration = System.currentTimeMillis() - start; System.out.println(i + " records created in " + duration + " ms (" + duration / i + " ms per record)"); } diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditTest.java index 1e42077b7dc..29d75250948 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/AuditTest.java @@ -16,7 +16,6 @@ import org.hibernate.Session; import org.hibernate.query.Query; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; @@ -31,11 +30,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -/** - * @author mederly - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class AuditTest extends BaseSQLRepoTest { @Test diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java index 8d49cda7f95..892bb60da03 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/BaseSQLRepoTest.java @@ -50,6 +50,7 @@ import com.evolveum.midpoint.repo.sql.data.common.dictionary.ExtItemDictionary; import com.evolveum.midpoint.repo.sql.data.common.embedded.REmbeddedReference; import com.evolveum.midpoint.repo.sql.helpers.BaseHelper; +import com.evolveum.midpoint.repo.sql.testing.DbDeleter; import com.evolveum.midpoint.repo.sql.testing.TestQueryListener; import com.evolveum.midpoint.repo.sql.util.HibernateToSqlTranslator; import com.evolveum.midpoint.repo.sql.util.RUtil; @@ -108,6 +109,8 @@ public class BaseSQLRepoTest extends AbstractSpringTest @Autowired protected Protector protector; @Autowired protected TestQueryListener queryListener; + @Autowired private DbDeleter dbDeleter; + protected boolean verbose = false; @BeforeSuite @@ -129,17 +132,23 @@ public void setFactory(SessionFactory factory) { private volatile boolean initSystemExecuted = false; @PostConstruct - public void beforeMethod() throws Exception { + public void initTestClass() throws Exception { if (initSystemExecuted) { logger.trace("initSystem: already called for class {} - IGNORING", getClass().getName()); return; } initSystemExecuted = true; + dbDeleter.cleanupTestDatabase(); + // delete must be first as initSystem can already prepare objects for the test class initSystem(); } + public void initSystem() throws Exception { + // can be overridden in subclasses for once-per-test-class initialization + } + @AfterMethod - public void afterMethod(Method method) { + public final void finalizePersistenceSession(Method method) { try { Session session = factory.getCurrentSession(); if (session != null) { @@ -156,10 +165,6 @@ protected boolean isH2() { return baseHelper.getConfiguration().isUsingH2(); } - public void initSystem() throws Exception { - - } - protected Session open() { Session session = getFactory().openSession(); session.beginTransaction(); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java index d2d55a2c2c0..b10b99eb711 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTest.java @@ -28,7 +28,6 @@ import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -55,7 +54,6 @@ import static org.testng.AssertJUnit.*; @ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class CertificationTest extends BaseSQLRepoTest { private static final File TEST_DIR = new File("src/test/resources/cert"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTestReindex.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTestReindex.java index 515964f4f7f..726b51d38b6 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTestReindex.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CertificationTestReindex.java @@ -8,7 +8,6 @@ package com.evolveum.midpoint.repo.sql; import com.evolveum.midpoint.repo.api.RepoModifyOptions; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; /** @@ -18,11 +17,9 @@ * @author mederly */ @ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class CertificationTestReindex extends CertificationTest { protected RepoModifyOptions getModifyOptions() { return RepoModifyOptions.createExecuteIfNoChanges(); } - } diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CleanupTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CleanupTest.java index 57da9ea54ce..7dd815ef2ac 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CleanupTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/CleanupTest.java @@ -7,6 +7,19 @@ package com.evolveum.midpoint.repo.sql; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.Duration; + +import org.hibernate.Session; +import org.hibernate.query.Query; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; + import com.evolveum.midpoint.audit.api.AuditEventRecord; import com.evolveum.midpoint.prism.delta.DeltaFactory; import com.evolveum.midpoint.repo.sql.data.audit.RAuditEventRecord; @@ -19,23 +32,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.hibernate.query.Query; -import org.hibernate.Session; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; - -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.Duration; - -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class CleanupTest extends BaseSQLRepoTest { private Calendar create_2013_07_12_12_00_Calendar() { @@ -140,51 +137,51 @@ public void testAuditCleanupMaxRecords() throws Exception { } private RAuditEventRecord assertAndReturnAuditEventRecord(OperationResult result) { - AssertJUnit.assertTrue(result.isSuccess()); + AssertJUnit.assertTrue(result.isSuccess()); - Session session = getFactory().openSession(); - try { - session.beginTransaction(); + Session session = getFactory().openSession(); + try { + session.beginTransaction(); - Query query = session.createQuery("from " + RAuditEventRecord.class.getSimpleName()); - List records = query.list(); + Query query = session.createQuery("from " + RAuditEventRecord.class.getSimpleName()); + List records = query.list(); - AssertJUnit.assertEquals(1, records.size()); - session.getTransaction().commit(); - return records.get(0); - } finally { - session.close(); - } + AssertJUnit.assertEquals(1, records.size()); + session.getTransaction().commit(); + return records.get(0); + } finally { + session.close(); + } } private void prepareAuditEventRecords() throws Exception { - Calendar calendar = create_2013_07_12_12_00_Calendar(); - for (int i = 0; i < 3; i++) { - long timestamp = calendar.getTimeInMillis(); - AuditEventRecord record = new AuditEventRecord(); - record.addDelta(createObjectDeltaOperation(i)); - record.setTimestamp(timestamp); - record.addPropertyValue("prop1", "val1"); - record.addReferenceValue("ref1", ObjectTypeUtil.createObjectRef("oid1", ObjectTypes.USER).asReferenceValue()); - logger.info("Adding audit record with timestamp {}", new Object[]{new Date(timestamp)}); - - auditService.audit(record, new NullTaskImpl()); - calendar.add(Calendar.HOUR_OF_DAY, 1); - } - - Session session = getFactory().openSession(); - try { - session.beginTransaction(); - - Query query = session.createQuery("select count(*) from " + RAuditEventRecord.class.getSimpleName()); - Long count = (Long) query.uniqueResult(); - - AssertJUnit.assertEquals(3L, (long) count); - session.getTransaction().commit(); - } finally { - session.close(); - } + Calendar calendar = create_2013_07_12_12_00_Calendar(); + for (int i = 0; i < 3; i++) { + long timestamp = calendar.getTimeInMillis(); + AuditEventRecord record = new AuditEventRecord(); + record.addDelta(createObjectDeltaOperation(i)); + record.setTimestamp(timestamp); + record.addPropertyValue("prop1", "val1"); + record.addReferenceValue("ref1", ObjectTypeUtil.createObjectRef("oid1", ObjectTypes.USER).asReferenceValue()); + logger.info("Adding audit record with timestamp {}", new Object[] { new Date(timestamp) }); + + auditService.audit(record, new NullTaskImpl()); + calendar.add(Calendar.HOUR_OF_DAY, 1); + } + + Session session = getFactory().openSession(); + try { + session.beginTransaction(); + + Query query = session.createQuery("select count(*) from " + RAuditEventRecord.class.getSimpleName()); + Long count = (Long) query.uniqueResult(); + + AssertJUnit.assertEquals(3L, (long) count); + session.getTransaction().commit(); + } finally { + session.close(); + } } private ObjectDeltaOperation createObjectDeltaOperation(int i) throws Exception { diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ConcurrencyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ConcurrencyTest.java index 6f816329a12..4aed197bd62 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ConcurrencyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ConcurrencyTest.java @@ -20,7 +20,6 @@ import javax.xml.namespace.QName; import org.hibernate.Session; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; @@ -40,12 +39,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -/** - * @author Pavol Mederly - */ - @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ConcurrencyTest extends BaseSQLRepoTest { private static final long WAIT_FOR_THREAD_NATURAL_STOP_TIME = 300000; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DataSourceTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DataSourceTest.java index 3ed9e5f1343..dc53e5efef9 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DataSourceTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DataSourceTest.java @@ -8,16 +8,10 @@ package com.evolveum.midpoint.repo.sql; import org.hibernate.Session; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; - -/** - * @author lazyman - */ -@ContextConfiguration(locations = {"../../../../../ctx-test-datasource.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test-datasource.xml" }) public class DataSourceTest extends BaseSQLRepoTest { @Test diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTest.java index 0bfda38a166..bf50fe8154b 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTest.java @@ -7,28 +7,23 @@ package com.evolveum.midpoint.repo.sql; -import com.evolveum.midpoint.prism.Objectable; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; +import java.io.File; +import java.util.ArrayList; +import java.util.List; import org.hibernate.Session; import org.hibernate.query.Query; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import java.io.File; -import java.util.ArrayList; -import java.util.List; +import com.evolveum.midpoint.prism.Objectable; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType; -/** - * @author lazyman - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class DeleteTest extends BaseSQLRepoTest { @Test @@ -36,7 +31,7 @@ public void delete001() throws Exception { final File file = new File("./../../samples/dsee/odsee-localhost-advanced-sync.xml"); if (!file.exists()) { logger.warn("skipping addGetDSEESyncDoubleTest, file {} not found.", - new Object[]{file.getPath()}); + new Object[] { file.getPath() }); return; } @@ -46,13 +41,13 @@ public void delete001() throws Exception { OperationResult result = new OperationResult("Delete Test"); for (int i = 0; i < elements.size(); i++) { PrismObject object = elements.get(i); - logger.info("Adding object {}, type {}", new Object[]{i, object.getCompileTimeClass().getSimpleName()}); + logger.info("Adding object {}, type {}", new Object[] { i, object.getCompileTimeClass().getSimpleName() }); oids.add(repositoryService.addObject(object, null, result)); } for (int i = 0; i < elements.size(); i++) { PrismObject object = elements.get(i); - logger.info("Deleting object {}, type {}", new Object[]{i, object.getCompileTimeClass().getSimpleName()}); + logger.info("Deleting object {}, type {}", new Object[] { i, object.getCompileTimeClass().getSimpleName() }); repositoryService.deleteObject(object.getCompileTimeClass(), oids.get(i), result); } @@ -108,7 +103,7 @@ public void test100DeleteObjects() throws Exception { result.recomputeStatus(); AssertJUnit.assertTrue(result.isSuccess()); - for (int i=0; i< objects.size(); i++ ){ + for (int i = 0; i < objects.size(); i++) { repositoryService.deleteObject((Class) objects.get(i).getCompileTimeClass(), oids.get(i), result); } diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTestSimple.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTestSimple.java index 77560669091..b22ca43fefc 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTestSimple.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/DeleteTestSimple.java @@ -7,17 +7,16 @@ package com.evolveum.midpoint.repo.sql; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.test.annotation.DirtiesContext; +import java.io.File; + import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import java.io.File; +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class DeleteTestSimple extends BaseSQLRepoTest { @Test diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EmbeddedServerModeTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EmbeddedServerModeTest.java index ca5be97f4d7..565e8a69493 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EmbeddedServerModeTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EmbeddedServerModeTest.java @@ -7,17 +7,15 @@ package com.evolveum.midpoint.repo.sql; +import java.sql.Connection; +import java.sql.DriverManager; + import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; -import java.sql.Connection; -import java.sql.DriverManager; - -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class EmbeddedServerModeTest extends BaseSQLRepoTest { @Autowired diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EncodingTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EncodingTest.java index 02f5cda8ad7..163e7eaea96 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EncodingTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/EncodingTest.java @@ -11,7 +11,6 @@ import java.util.List; import javax.xml.namespace.QName; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -33,7 +32,6 @@ import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class EncodingTest extends BaseSQLRepoTest { /** diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryConcurrencyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryConcurrencyTest.java index 246f86da0d3..31b3e8cb73f 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryConcurrencyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryConcurrencyTest.java @@ -14,7 +14,6 @@ import java.util.concurrent.Future; import javax.xml.namespace.QName; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -28,11 +27,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -/** - * Created by Viliam Repan (lazyman). - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ExtDictionaryConcurrencyTest extends BaseSQLRepoTest { private static final String NAMESPACE = "http://concurrency"; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryTest.java index 19d981d4b0b..ff061a2df48 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtDictionaryTest.java @@ -14,7 +14,6 @@ import javax.xml.namespace.QName; import org.hibernate.Session; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; @@ -26,8 +25,7 @@ import com.evolveum.midpoint.util.exception.SystemException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class ExtDictionaryTest extends BaseSQLRepoTest { private static final int ROUNDS = 50; @@ -36,9 +34,11 @@ public class ExtDictionaryTest extends BaseSQLRepoTest { static class TestingThread extends Thread { Throwable throwable; + TestingThread(Runnable target) { super(target); } + @Override public void run() { try { diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtensionTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtensionTest.java index ed4ccf29cf1..5a3b28ef7a7 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtensionTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ExtensionTest.java @@ -17,7 +17,6 @@ import javax.xml.namespace.QName; import org.hibernate.Session; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; @@ -49,8 +48,7 @@ * Introduced as part of providing "index-only" extension values (MID-5558) * and related refactoring of ObjectDeltaUpdater. */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class ExtensionTest extends BaseSQLRepoTest { private static final File TEST_DIR = new File("src/test/resources/extension"); @@ -247,7 +245,7 @@ public void test025AddVisibleUserExtensionValueDuplicate() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION, EXT_VISIBLE) - .add("v4") + .add("v4") .asObjectDelta(""); delta.applyTo(expectedUser); @@ -293,7 +291,7 @@ public void test026ReplaceVisibleExtensionValues() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION, EXT_WEAPON) - .replace("weapon1", "weapon2") + .replace("weapon1", "weapon2") .asObjectDelta(""); delta.applyTo(expectedUser); @@ -332,7 +330,7 @@ public void test027DeleteVisibleExtensionValues() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION, EXT_WEAPON) - .delete("weapon1", "weapon2") + .delete("weapon1", "weapon2") .asObjectDelta(""); delta.applyTo(expectedUser); @@ -384,9 +382,9 @@ public void test028DeleteAlreadyLoadedVisibleExtensionValue() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION, EXT_WEAPON) - .replace("w1") + .replace("w1") .item(UserType.F_EXTENSION, EXT_VISIBLE) - .delete("v4", "v5") + .delete("v4", "v5") .asObjectDelta(""); delta.applyTo(expectedUser); @@ -425,7 +423,7 @@ public void test029ReplaceNonIndexedExtensionProperty() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION, EXT_LOOT) - .replace(34) + .replace(34) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -757,7 +755,7 @@ public void test050DeleteWholeExtension() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION) - .delete(existingExtension) + .delete(existingExtension) .asObjectDelta(""); expectedUser.asObjectable().setExtension(null); // we cannot apply the delta here as expectedUser has hidden1 values in the extension @@ -803,7 +801,7 @@ public void test055AddWholeExtension() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION) - .add(extValue.clone()) + .add(extValue.clone()) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -851,7 +849,7 @@ public void test058AddWholeExtensionDifferentValue() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION) - .add(extValue.clone()) + .add(extValue.clone()) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -896,7 +894,7 @@ public void test060ReplaceWholeExtension() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION) - .replace(extValue.clone()) + .replace(extValue.clone()) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -939,7 +937,7 @@ public void test065ReplaceWholeExtensionToNull() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_EXTENSION) - .replace() + .replace() .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1066,7 +1064,7 @@ public void test125AddAssignmentExtensionValueDuplicate() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION, EXT_WEAPON) - .add("w4") + .add("w4") .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1102,7 +1100,7 @@ public void test126ReplaceAssignmentExtensionValues() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION, EXT_WEAPON) - .replace("w2", "w9") + .replace("w2", "w9") .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1143,7 +1141,7 @@ public void test127DeleteAssignmentExtensionValues() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION, EXT_WEAPON) - .delete("w2") + .delete("w2") .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1212,7 +1210,7 @@ public void test145ReplaceAssignmentValuesToNull() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION, EXT_WEAPON) - .replace() + .replace() .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1254,7 +1252,7 @@ public void test150DeleteWholeAssignmentExtension() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION) - .delete(existingExtension.clone()) + .delete(existingExtension.clone()) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1305,7 +1303,7 @@ public void test155AddWholeAssignmentExtension() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION) - .add(extValue.clone()) + .add(extValue.clone()) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1361,7 +1359,7 @@ public void test158AddWholeAssignmentExtensionDifferentValue() throws Exception ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 1, AssignmentType.F_EXTENSION) - .add(extValue.clone()) + .add(extValue.clone()) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1520,7 +1518,7 @@ public void test170AddAssignments() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) - .add(newAssignment, newAssignment2) + .add(newAssignment, newAssignment2) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1579,7 +1577,7 @@ public void test173DeleteAssignment() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) - .delete(new AssignmentType(prismContext).id(777L)) + .delete(new AssignmentType(prismContext).id(777L)) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -1641,7 +1639,7 @@ public void test175ReplaceAssignments() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT) - .replace(newAssignment) + .replace(newAssignment) .asObjectDelta(""); delta.applyTo(expectedUser); @@ -2037,9 +2035,9 @@ public void test428DeleteAlreadyLoadedVisibleAttributeValue() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR_GROUP_NAME), attrGroupNameDefinition) - .replace("ALUMNI") + .replace("ALUMNI") .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR_MANAGER), attrManagerDefinition) - .delete("bob") + .delete("bob") .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2076,7 +2074,7 @@ public void test430AddHiddenAttributeValues() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR_MEMBER), attrMemberDefinition) - .add("tbrown", "jsmith") + .add("tbrown", "jsmith") .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2117,7 +2115,7 @@ public void test432AddHiddenAttributeValuesDuplicate() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR_MEMBER), attrMemberDefinition) - .add("tbrown", "jsmith") + .add("tbrown", "jsmith") .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2166,7 +2164,7 @@ public void test435DeleteHiddenAttributeValues() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR_MEMBER), attrMemberDefinition) - .delete("tbrown", "jsmith") + .delete("tbrown", "jsmith") .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2212,7 +2210,7 @@ public void test436DeleteHiddenAttributeValuesDuplicate() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR_MEMBER), attrMemberDefinition) - .delete("tbrown", "jsmith") + .delete("tbrown", "jsmith") .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2256,7 +2254,7 @@ public void test440ReplaceHiddenAttributeValues() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ItemPath.create(ShadowType.F_ATTRIBUTES, ATTR_MEMBER), attrMemberDefinition) - .replace("alice", "bob") + .replace("alice", "bob") .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2297,7 +2295,7 @@ public void test450DeleteWholeContainer() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ShadowType.F_ATTRIBUTES) - .delete(existingAttributes) + .delete(existingAttributes) .asObjectDelta(""); expectedShadow.asObjectable().setAttributes(null); @@ -2348,7 +2346,7 @@ public void test455AddWholeContainer() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ShadowType.F_ATTRIBUTES) - .add(attributes.clone()) + .add(attributes.clone()) .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2398,7 +2396,6 @@ safe insertions (can be improved) assertCounts(10 + getExtraSafeInsertionSelects(5), 14 + getExtraSafeInsertionSelects(5)); } - /** * This is really tricky. We try to add another value to single-valued attributes container. */ @@ -2420,7 +2417,7 @@ public void test458AddWholeContainerDifferentValue() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ShadowType.F_ATTRIBUTES) - .add(attributes.clone()) + .add(attributes.clone()) .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2490,7 +2487,7 @@ public void test460ReplaceWholeContainer() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ShadowType.F_ATTRIBUTES) - .replace(attributes.clone()) + .replace(attributes.clone()) .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2548,7 +2545,7 @@ public void test465ReplaceWholeContainerToNull() throws Exception { ObjectDelta delta = getPrismContext().deltaFor(ShadowType.class) .item(ShadowType.F_ATTRIBUTES) - .replace() + .replace() .asObjectDelta(""); delta.applyTo(expectedShadow); @@ -2654,7 +2651,7 @@ public void test900AddDeleteValuePerformance() throws Exception { long overallStart = System.currentTimeMillis(); long lastBatchStart = overallStart; int lastBatchFrom = 0; - for (int i = 0; i < ADD_VALUE_ITERATIONS;) { + for (int i = 0; i < ADD_VALUE_ITERATIONS; ) { String valueA = String.format("value-%09d-a", i); String valueB = String.format("value-%09d-b", i); List> addModifications = getPrismContext().deltaFor(UserType.class) diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ListAccountShadowOwnerTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ListAccountShadowOwnerTest.java index e17a518a4a5..287b67fcff2 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ListAccountShadowOwnerTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ListAccountShadowOwnerTest.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.List; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -30,11 +29,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -/** - * @author lazyman - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class ListAccountShadowOwnerTest extends BaseSQLRepoTest { @Test diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTest.java index b4e9755b127..d54dadf30e5 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTest.java @@ -18,7 +18,6 @@ import java.util.*; import javax.xml.datatype.XMLGregorianCalendar; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -42,11 +41,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableRowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.LookupTableType; -/** - * @author mederly - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class LookupTableTest extends BaseSQLRepoTest { private static final File TEST_DIR = new File("src/test/resources/lookup"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTestReindex.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTestReindex.java index f12ad6f36a2..d5cee040fa7 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTestReindex.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/LookupTableTestReindex.java @@ -7,22 +7,20 @@ package com.evolveum.midpoint.repo.sql; -import com.evolveum.midpoint.repo.api.RepoModifyOptions; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; +import com.evolveum.midpoint.repo.api.RepoModifyOptions; + /** * The same as LookupTableTest but with "executeIfNoChanges" (a.k.a. "reindex") option set. * Although this flag causes no special behavior for lookup table rows, it's better to check. * * @author mederly */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class LookupTableTestReindex extends LookupTableTest { protected RepoModifyOptions getModifyOptions() { return RepoModifyOptions.createExecuteIfNoChanges(); } - } diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java index 5c0a578414d..137133a231a 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyAssignmentTest.java @@ -15,7 +15,6 @@ import org.hibernate.Session; import org.hibernate.query.Query; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -27,11 +26,7 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -/** - * @author lazyman - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ModifyAssignmentTest extends BaseSQLRepoTest { private static final File TEST_DIR = new File("src/test/resources/modify/assignment"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java index 841d64789e9..72974ee04df 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTest.java @@ -21,7 +21,6 @@ import org.hibernate.Session; import org.jetbrains.annotations.NotNull; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -63,11 +62,7 @@ import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType; -/** - * @author lazyman - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ModifyTest extends BaseSQLRepoTest { private static final File TEST_DIR = new File("src/test/resources/modify"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java index 442a128a97d..76b206212b8 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyTestReindex.java @@ -7,6 +7,17 @@ package com.evolveum.midpoint.repo.sql; +import static java.util.Collections.emptySet; +import static org.testng.AssertJUnit.assertEquals; + +import javax.xml.namespace.QName; + +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.query.Query; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.MutablePrismPropertyDefinition; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismProperty; @@ -17,27 +28,13 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; -import org.hibernate.Session; -import org.hibernate.Transaction; -import org.hibernate.query.Query; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; - -import static java.util.Collections.emptySet; -import static org.testng.AssertJUnit.assertEquals; /** * The same as ModifyTest but with "executeIfNoChanges" (a.k.a. "reindex") option set. * Although this option should do no harm in objects other than certification cases and lookup tables, * it is better to check. - * - * @author mederly */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class ModifyTestReindex extends ModifyTest { @Override @@ -199,7 +196,7 @@ public void testReindexCertificationCampaignCase() throws Exception { } /** - * MID-5128 + * MID-5128 */ @Test public void testReindexShadow() throws Exception { @@ -209,7 +206,7 @@ public void testReindexShadow() throws Exception { PrismObject shadow = prismContext.createObjectable(ShadowType.class) .name("unstable") .beginMetadata() - .modifyApproverRef(APPROVER_OID, UserType.COMPLEX_TYPE) + .modifyApproverRef(APPROVER_OID, UserType.COMPLEX_TYPE) .end() .asPrismObject(); MutablePrismPropertyDefinition def = prismContext.definitionFactory().createPropertyDefinition(new QName("http://temp/", "attr1"), DOMUtil.XSD_STRING); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java index d4011284e6b..cda13a0d75f 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ModifyUser.java @@ -6,9 +6,17 @@ */ package com.evolveum.midpoint.repo.sql; +import java.io.File; +import java.util.Arrays; + +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.delta.*; +import com.evolveum.midpoint.prism.delta.ObjectDelta; +import com.evolveum.midpoint.prism.delta.PropertyDelta; +import com.evolveum.midpoint.prism.delta.ReferenceDelta; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.prism.util.PrismAsserts; import com.evolveum.midpoint.prism.util.PrismTestUtil; @@ -21,20 +29,10 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.Arrays; - /** * This is not real test, it's just used to check how hibernate handles insert/modify of different objects. - * - * @author lazyman */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class ModifyUser extends BaseSQLRepoTest { private static final String USER_FULLNAME = "Guybrush Threepwood"; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ObjectDeltaUpdaterTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ObjectDeltaUpdaterTest.java index 87aa76e72c8..5b04227b897 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ObjectDeltaUpdaterTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ObjectDeltaUpdaterTest.java @@ -7,6 +7,20 @@ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.assertEquals; + +import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; + +import java.io.File; +import java.util.*; + +import org.hibernate.Session; +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ItemDelta; import com.evolveum.midpoint.prism.delta.ObjectDelta; @@ -26,27 +40,11 @@ import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.hibernate.Session; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.*; - -import static com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext; -import static org.testng.AssertJUnit.assertEquals; /** - * Created by Viliam Repan (lazyman). - * * Note: Tests related to extension and attributes were moved into ExtensionTest. */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class ObjectDeltaUpdaterTest extends BaseSQLRepoTest { private static final File DATA_FOLDER = new File("./src/test/resources/update"); @@ -184,8 +182,8 @@ public void test130AddDeleteAssignment() throws Exception { .description("asdf") .targetRef("444", OrgType.COMPLEX_TYPE) .beginMetadata() - .createChannel("zzz") - .modifyApproverRef("555", UserType.COMPLEX_TYPE) + .createChannel("zzz") + .modifyApproverRef("555", UserType.COMPLEX_TYPE) .end()) .delete(new AssignmentType(prismContext).id(1L)) .asItemDeltas(); @@ -277,7 +275,7 @@ public void test147DeleteAssignmentActivation() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_ACTIVATION) - .delete(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ENABLED)) + .delete(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ENABLED)) .asItemDeltas(); TestStatementInspector.start(); @@ -310,7 +308,7 @@ public void test148AddAssignmentActivation() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_ACTIVATION) - .add(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ARCHIVED)) + .add(new ActivationType(prismContext).administrativeStatus(ActivationStatusType.ARCHIVED)) .asItemDeltas(); TestStatementInspector.start(); @@ -345,7 +343,7 @@ public void test149ReplaceAssignmentActivationWithNull() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_ACTIVATION) - .replace() + .replace() .asItemDeltas(); TestStatementInspector.start(); @@ -378,8 +376,8 @@ public void test150AddDeleteLinkRef() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_LINK_REF) - .add(createRef(ShadowType.COMPLEX_TYPE, "789")) - .delete(createRef(ShadowType.COMPLEX_TYPE, "456")) + .add(createRef(ShadowType.COMPLEX_TYPE, "789")) + .delete(createRef(ShadowType.COMPLEX_TYPE, "456")) .asItemDeltas(); TestStatementInspector.start(); @@ -452,9 +450,9 @@ public void test170ModifyEmployeeTypeAndMetadataCreateChannel() throws Exception List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_EMPLOYEE_TYPE) - .add("one", "two") + .add("one", "two") .item(UserType.F_METADATA, MetadataType.F_CREATE_CHANNEL) - .replace("asdf") + .replace("asdf") .asItemDeltas(); TestStatementInspector.start(); @@ -486,9 +484,9 @@ public void test180ReplaceSomeMetadataItems() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF) - .replace(createRef(UserType.COMPLEX_TYPE, "111")) + .replace(createRef(UserType.COMPLEX_TYPE, "111")) .item(UserType.F_METADATA, MetadataType.F_CREATE_CHANNEL) - .replace("zxcv") + .replace("zxcv") .asItemDeltas(); TestStatementInspector.start(); @@ -524,7 +522,7 @@ public void test185AddModifyApproverRef() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF) - .add(createRef(UserType.COMPLEX_TYPE, "654")) + .add(createRef(UserType.COMPLEX_TYPE, "654")) .asItemDeltas(); TestStatementInspector.start(); @@ -559,7 +557,7 @@ public void test187DeleteModifyApproverRef() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF) - .delete(createRef(UserType.COMPLEX_TYPE, "654")) + .delete(createRef(UserType.COMPLEX_TYPE, "654")) .asItemDeltas(); TestStatementInspector.start(); @@ -590,14 +588,14 @@ public void test190ReplaceWholeMetadata() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_METADATA) - .replace(new MetadataType(prismContext) - .createChannel("ch1") - .modifierRef(createRef(UserType.COMPLEX_TYPE, "44")) - .createApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) - .createApproverRef(createRef(UserType.COMPLEX_TYPE, "77")) - .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) - .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "66")) - ) + .replace(new MetadataType(prismContext) + .createChannel("ch1") + .modifierRef(createRef(UserType.COMPLEX_TYPE, "44")) + .createApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) + .createApproverRef(createRef(UserType.COMPLEX_TYPE, "77")) + .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) + .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "66")) + ) .asItemDeltas(); TestStatementInspector.start(); @@ -647,14 +645,14 @@ public void test192DeleteWholeMetadata() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_METADATA) - .delete(new MetadataType(prismContext) - .createChannel("ch1") - .modifierRef(createRef(UserType.COMPLEX_TYPE, "44")) - .createApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) - .createApproverRef(createRef(UserType.COMPLEX_TYPE, "77")) - .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) - .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "66")) - ) + .delete(new MetadataType(prismContext) + .createChannel("ch1") + .modifierRef(createRef(UserType.COMPLEX_TYPE, "44")) + .createApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) + .createApproverRef(createRef(UserType.COMPLEX_TYPE, "77")) + .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "55")) + .modifyApproverRef(createRef(UserType.COMPLEX_TYPE, "66")) + ) .asItemDeltas(); TestStatementInspector.start(); @@ -745,7 +743,7 @@ public void test200ReplaceAssignmentMetadataCreateChannel() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_METADATA, MetadataType.F_CREATE_CHANNEL) - .replace("asdf2") + .replace("asdf2") .asItemDeltas(); TestStatementInspector.start(); @@ -776,9 +774,9 @@ public void test210ReplaceSomeAssignmentMetadataItems() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF) - .replace(createRef(UserType.COMPLEX_TYPE, "1112")) + .replace(createRef(UserType.COMPLEX_TYPE, "1112")) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_METADATA, MetadataType.F_CREATE_CHANNEL) - .replace("zxcv2") + .replace("zxcv2") .asItemDeltas(); TestStatementInspector.start(); @@ -815,7 +813,7 @@ public void test220AddAssignmentModifyApproverRef() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF) - .add(createRef(UserType.COMPLEX_TYPE, "6542")) + .add(createRef(UserType.COMPLEX_TYPE, "6542")) .asItemDeltas(); TestStatementInspector.start(); @@ -851,7 +849,7 @@ public void test222DeleteAssignmentModifyApproverRef() throws Exception { List> modifications = prismContext.deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT, 2, AssignmentType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF) - .delete(createRef(UserType.COMPLEX_TYPE, "6542")) + .delete(createRef(UserType.COMPLEX_TYPE, "6542")) .asItemDeltas(); TestStatementInspector.start(); @@ -1073,7 +1071,7 @@ public void test270ModifyOperationExecution() throws Exception { assertOperationExecutionSize(userOid, 1); oe = createOperationExecution("repo2"); - Collection> deltas = prismContext.deltaFor(UserType.class) + Collection> deltas = prismContext.deltaFor(UserType.class) .item(UserType.F_OPERATION_EXECUTION) .add(oe.asPrismContainerValue().clone()) .asItemDeltas(); @@ -1113,7 +1111,7 @@ public void test280AddPhoto() throws Exception { OperationResult result = new OperationResult("test280AddPhoto"); ObjectDelta delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid); - delta.addModificationAddProperty(UserType.F_JPEG_PHOTO, new byte[]{ 1, 2, 3 }); + delta.addModificationAddProperty(UserType.F_JPEG_PHOTO, new byte[] { 1, 2, 3 }); TestStatementInspector.start(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); @@ -1140,7 +1138,7 @@ public void test290ReplacePhoto() throws Exception { OperationResult result = new OperationResult("test290ReplacePhoto"); ObjectDelta delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid); - delta.addModificationReplaceProperty(UserType.F_JPEG_PHOTO, new byte[]{4,5,6}); + delta.addModificationReplaceProperty(UserType.F_JPEG_PHOTO, new byte[] { 4, 5, 6 }); TestStatementInspector.start(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); @@ -1167,7 +1165,7 @@ public void test300DeletePhoto() throws Exception { OperationResult result = new OperationResult("test300DeletePhoto"); ObjectDelta delta = prismContext.deltaFactory().object().createEmptyModifyDelta(UserType.class, userOid); - delta.addModificationDeleteProperty(UserType.F_JPEG_PHOTO, new byte[]{4,5,6}); + delta.addModificationDeleteProperty(UserType.F_JPEG_PHOTO, new byte[] { 4, 5, 6 }); TestStatementInspector.start(); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgPhotoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgPhotoTest.java index 66dbae902c7..4aac37536b7 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgPhotoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgPhotoTest.java @@ -6,25 +6,21 @@ */ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; + +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import java.io.File; -import static org.testng.AssertJUnit.assertEquals; - -/** - * @author mederly - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class OrgPhotoTest extends AbstractPhotoTest { private static final File ORG_FILE = new File(TEST_DIR, "org.xml"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java index 5497bac4e04..04b49bee447 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/OrgStructTest.java @@ -20,7 +20,6 @@ import org.hibernate.Session; import org.hibernate.criterion.Restrictions; import org.hibernate.query.Query; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -35,18 +34,14 @@ import com.evolveum.midpoint.schema.constants.SchemaConstants; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.ObjectTypeUtil; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.logging.Trace; -import com.evolveum.midpoint.util.logging.TraceManager; import com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class OrgStructTest extends BaseSQLRepoTest { private static final File TEST_DIR = new File("src/test/resources/orgstruct"); @@ -211,10 +206,10 @@ private void assertSubordinate(boolean expected, String upperOrgOid, String... l logger.debug("=======> {}: {}", upperOrgOid, lowerObjectOidCol); boolean actual = repositoryService.isAnySubordinate(upperOrgOid, lowerObjectOidCol); if (expected != actual) { - logger.error("=======X {}: {}; expected={}, actual={}", new Object[]{upperOrgOid, lowerObjectOidCol, expected, actual}); + logger.error("=======X {}: {}; expected={}, actual={}", new Object[] { upperOrgOid, lowerObjectOidCol, expected, actual }); assertEquals("Wrong subordinate match: " + upperOrgOid + " to " + lowerObjectOidCol, expected, actual); } else { - logger.debug("=======O {}: {}; got={}", new Object[]{upperOrgOid, lowerObjectOidCol, expected}); + logger.debug("=======O {}: {}; got={}", new Object[] { upperOrgOid, lowerObjectOidCol, expected }); } } @@ -290,7 +285,7 @@ public void test002modifyOrgStructAddRef() throws Exception { logger.info("before modify"); for (ROrgClosure c : orgClosure) { - logger.info("{}\t{}", new Object[]{c.getAncestor().getOid(), c.getDescendant().getOid()}); + logger.info("{}\t{}", new Object[] { c.getAncestor().getOid(), c.getDescendant().getOid() }); } AssertJUnit.assertEquals(3, orgClosure.size()); } finally { @@ -305,7 +300,7 @@ public void test002modifyOrgStructAddRef() throws Exception { logger.info("after modify"); for (ROrgClosure c : orgClosure) { - logger.info("{}\t{}", new Object[]{c.getAncestor().getOid(), c.getDescendant().getOid()}); + logger.info("{}\t{}", new Object[] { c.getAncestor().getOid(), c.getDescendant().getOid() }); } AssertJUnit.assertEquals(4, orgClosure.size()); @@ -359,7 +354,7 @@ public void test002modifyOrgStructAddRefIncorrect() throws Exception { logger.info("after modify incorrect - closure"); for (ROrgClosure c : orgClosure) { - logger.info("{}\t{}", new Object[]{c.getAncestor().getOid(), c.getDescendant().getOid()}); + logger.info("{}\t{}", new Object[] { c.getAncestor().getOid(), c.getDescendant().getOid() }); } AssertJUnit.assertEquals(5, orgClosure.size()); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/PerformanceTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/PerformanceTest.java index e0e27e49b48..d05a2414d57 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/PerformanceTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/PerformanceTest.java @@ -6,6 +6,16 @@ */ package com.evolveum.midpoint.repo.sql; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.*; +import javax.xml.namespace.QName; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.*; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.repo.sql.type.XMLGregorianCalendarType; @@ -14,37 +24,23 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import javax.xml.namespace.QName; -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.util.*; -/** - * @author lazyman - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class PerformanceTest extends BaseSQLRepoTest { - private static final String[] GIVEN_NAMES = {"James", "Josephine", "Art", "Lenna", "Donette", "Simona", "Mitsue", + private static final String[] GIVEN_NAMES = { "James", "Josephine", "Art", "Lenna", "Donette", "Simona", "Mitsue", "Leota", "Sage", "Kris", "Minna", "Abel", "Kiley", "Graciela", "Cammy", "Mattie", "Meaghan", "Gladys", "Yuki", "Fletcher", "Bette", "Veronika", "Willard", "Maryann", "Alisha", "Allene", "Chanel", "Ezekiel", "Willow", "Bernardo", "Ammie", "Francine", "Ernie", "Albina", "Alishia", "Solange", "Jose", "Rozella", "Valentine", - "Kati", "Youlanda", "Dyan", "Roxane", "Lavera", "Erick", "Fatima", "Jina", "Kanisha", "Emerson"}; - private static final String[] FAMILY_NAMES = {"Butt", "Darakjy", "Venere", "Paprocki", "Foller", "Morasca", "Tollner", + "Kati", "Youlanda", "Dyan", "Roxane", "Lavera", "Erick", "Fatima", "Jina", "Kanisha", "Emerson" }; + private static final String[] FAMILY_NAMES = { "Butt", "Darakjy", "Venere", "Paprocki", "Foller", "Morasca", "Tollner", "Dilliard", "Wieser", "Marrier", "Amigon", "Maclead", "Caldarera", "Ruta", "Albares", "Poquette", "Garufi", "Rim", "Whobrey", "Flosi", "Nicka", "Inouye", "Kolmetz", "Royster", "Slusarski", "Iturbide", "Caudy", "Chui", "Kusko", "Figeroa", "Corrio", "Vocelka", "Stenseth", "Glick", "Sergi", "Shinko", "Stockham", "Ostrosky", "Gillian", "Rulapaugh", "Schemmer", "Oldroyd", "Campain", "Perin", "Ferencz", "Saylors", "Briddick", "Waycott", "Bowley", "Malet", "Bolognia", "Nestle", "Uyetake", "Mastella", "Klonowski", "Wenner", "Monarrez", "Seewald", "Ahle", "Juhas", "Pugh", "Vanausdal", "Hollack", "Lindall", "Yglesias", "Buvens", "Weight", - "Morocco", "Eroman"}; + "Morocco", "Eroman" }; private static final int ORG_COUNT = 10; private static final int USER_PER_ORG_COUNT = 10000; @@ -129,14 +125,13 @@ public void test300Get() throws Exception { int COUNT = 100; for (int i = 0; i < COUNT; i++) { - logger.info("Get operation {} of {}", i+1, COUNT); + logger.info("Get operation {} of {}", i + 1, COUNT); repositoryService.getObject(UserType.class, oid, null, result); } long duration = System.currentTimeMillis() - time; - logger.info("xxx>> time: {} ms, per get: {} ms", duration, (double) duration/COUNT); + logger.info("xxx>> time: {} ms, per get: {} ms", duration, (double) duration / COUNT); } - private ResourceType createResource(int resourceId) throws SchemaException, IOException { PrismObject prism = prismContext.parseObject(new File(FOLDER_BASIC, "resource-opendj.xml")); @@ -215,7 +210,7 @@ private UserType createUserType(int userId, String orgOid) throws SchemaExceptio } private OrgType createOrgType(String name, String description, String identifier, String locality, - String parentRefOid) { + String parentRefOid) { OrgType org = new OrgType(); org.setOid(UUID.randomUUID().toString()); org.setName(createPoly(name)); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/QueryInterpreter2Test.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/QueryInterpreter2Test.java index 082f0efa223..648ec7f194d 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/QueryInterpreter2Test.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/QueryInterpreter2Test.java @@ -41,7 +41,6 @@ import org.hibernate.Session; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -74,12 +73,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import com.evolveum.prism.xml.ns._public.query_3.QueryType; -/** - * @author lazyman - * @author mederly - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class QueryInterpreter2Test extends BaseSQLRepoTest { private static final File TEST_DIR = new File("./src/test/resources/query"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RAnyConverterStaticTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RAnyConverterStaticTest.java index 3e94527e285..ddd125bd56b 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RAnyConverterStaticTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RAnyConverterStaticTest.java @@ -12,7 +12,6 @@ import javax.xml.namespace.QName; import org.hibernate.Session; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; @@ -40,7 +39,6 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class RAnyConverterStaticTest extends BaseSQLRepoTest { private static final String NS_P = "http://example.com/p"; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RUtilTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RUtilTest.java index 7153bdc783c..d14a4b8a28c 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RUtilTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/RUtilTest.java @@ -11,18 +11,13 @@ import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.AssertJUnit; import org.testng.annotations.Test; import com.evolveum.midpoint.repo.sql.util.RUtil; -/** - * @author lazyman - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class RUtilTest extends BaseSQLRepoTest { private static final String USER_BIG = "user-big.xml"; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java index 8944c8cded1..ff593b1d063 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/ResourceModifyTest.java @@ -15,7 +15,6 @@ import java.util.List; import java.util.Random; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -32,11 +31,7 @@ import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; -/** - * @author Radovan Semancik - */ @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class ResourceModifyTest extends BaseSQLRepoTest { private static final File TEST_DIR = new File("src/test/resources/modify"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchIterativeTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchIterativeTest.java index c77d9ce8b50..2308144344b 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchIterativeTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchIterativeTest.java @@ -14,7 +14,6 @@ import java.util.ArrayList; import java.util.List; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; @@ -33,7 +32,6 @@ import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class SearchIterativeTest extends BaseSQLRepoTest { private static final int BASE = 100000; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchShadowOwnerTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchShadowOwnerTest.java index 78cace7e5e0..9e2e62338da 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchShadowOwnerTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchShadowOwnerTest.java @@ -4,7 +4,16 @@ * This work is dual-licensed under the Apache License 2.0 * and European Union Public License. See LICENSE file for details. */ - package com.evolveum.midpoint.repo.sql; +package com.evolveum.midpoint.repo.sql; + +import static org.testng.AssertJUnit.assertNotNull; + +import java.io.File; +import java.util.List; + +import org.springframework.test.context.ContextConfiguration; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; import com.evolveum.midpoint.prism.Objectable; import com.evolveum.midpoint.prism.PrismObject; @@ -16,21 +25,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.AssertJUnit; -import org.testng.annotations.Test; - -import java.io.File; -import java.util.List; - -import static org.testng.AssertJUnit.assertNotNull; - -/** - * @author lazyman - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class SearchShadowOwnerTest extends BaseSQLRepoTest { @Test @@ -66,7 +61,7 @@ public void searchShadowOwner() throws Exception { OperationResult result = new OperationResult("List owner"); //look for account owner - PrismObject user = repositoryService.searchShadowOwner("11223344", null, result); + PrismObject user = repositoryService.searchShadowOwner("11223344", null, result); assertNotNull("No owner for account", user); PrismProperty name = user.findProperty(ObjectType.F_NAME); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchTest.java index dc58b9a319d..fb9cc608d01 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SearchTest.java @@ -18,7 +18,6 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.xml.namespace.QName; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; @@ -45,7 +44,6 @@ import com.evolveum.prism.xml.ns._public.types_3.ItemPathType; @ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class SearchTest extends BaseSQLRepoTest { private static final String DESCRIPTION_TO_FIND = "tralala"; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SequenceTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SequenceTest.java index 03b0ce752c0..c33dff478df 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SequenceTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SequenceTest.java @@ -7,19 +7,8 @@ package com.evolveum.midpoint.repo.sql; -import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.schema.result.OperationResult; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; -import com.evolveum.midpoint.util.exception.SystemException; -import com.evolveum.midpoint.util.logging.LoggingUtils; -import com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.hibernate.Session; -import org.hibernate.jdbc.Work; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.fail; import java.io.File; import java.sql.Connection; @@ -29,15 +18,21 @@ import java.util.Collections; import java.util.List; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.fail; +import org.hibernate.Session; +import org.hibernate.jdbc.Work; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; -/** - * @author Pavol Mederly - */ +import com.evolveum.midpoint.prism.PrismObject; +import com.evolveum.midpoint.schema.result.OperationResult; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; +import com.evolveum.midpoint.util.exception.SystemException; +import com.evolveum.midpoint.util.logging.LoggingUtils; +import com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class SequenceTest extends BaseSQLRepoTest { private static final String TEST_DIR = "src/test/resources/sequence/"; @@ -185,7 +180,6 @@ public void test033_TenThreadsReturning() throws Exception { concurrencyUniversal("Test033", "sequence-unbound.xml", 10000L, mts, true); } - private void concurrencyUniversal(String name, String sequenceFileName, long duration, WorkerThread[] workerThreads, boolean alwaysOrder) throws Exception { Session session = getFactory().openSession(); @@ -221,7 +215,7 @@ public void execute(Connection connection) throws SQLException { } long endTime = System.currentTimeMillis() + STOP_TIMEOUT; - for (;;) { + for (; ; ) { long remaining = endTime - System.currentTimeMillis(); if (remaining <= 0) { break; @@ -283,7 +277,6 @@ class WorkerThread extends Thread { this(id, 0); } - public volatile boolean stop = false; @Override @@ -326,6 +319,6 @@ public void runOnce() throws SchemaException, ObjectNotFoundException { public void setOid(String oid) { this.oid = oid; } - } + } } diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SpringApplicationContextTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SpringApplicationContextTest.java index e94b02262db..035894d377c 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SpringApplicationContextTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/SpringApplicationContextTest.java @@ -7,19 +7,14 @@ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.assertNotNull; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.hibernate5.LocalSessionFactoryBean; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -import static org.testng.AssertJUnit.assertNotNull; - -/** - * @author lazyman - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class SpringApplicationContextTest extends BaseSQLRepoTest { @Autowired diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/UserPhotoTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/UserPhotoTest.java index 78d6f9443b1..6f6e611dca2 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/UserPhotoTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/UserPhotoTest.java @@ -6,25 +6,21 @@ */ package com.evolveum.midpoint.repo.sql; +import static org.testng.AssertJUnit.assertEquals; + +import java.io.File; + +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.util.PrismTestUtil; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import java.io.File; -import static org.testng.AssertJUnit.assertEquals; - -/** - * @author mederly - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class UserPhotoTest extends AbstractPhotoTest { private static final File TEST_DIR = new File("src/test/resources/photo"); diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java index 302818e5b80..82f3b19a449 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureConcurrencyTest.java @@ -11,7 +11,6 @@ import java.util.*; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; @@ -25,11 +24,7 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -/** - * @author mederly - */ @ContextConfiguration(locations = { "../../../../../../ctx-test.xml" }) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) public class OrgClosureConcurrencyTest extends AbstractOrgClosureTest { private static final int[] ORG_CHILDREN_IN_LEVEL = { 5, 3, 3, 3 }; @@ -53,13 +48,6 @@ public class OrgClosureConcurrencyTest extends AbstractOrgClosureTest { */ public static final long TIMEOUT = 1800L * 1000L; - // very small scenario -// private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 2, 1 }; -// private static final int[] USER_CHILDREN_IN_LEVEL = null; -// private static final int[] PARENTS_IN_LEVEL = { 0, 1, 2 }; -// private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 1, 1 }; -// private static final int[] NODE_ROUNDS_FOR_LEVELS = { 1, 2, 1 }; - private OrgClosureTestConfiguration configuration; public OrgClosureConcurrencyTest() { @@ -512,5 +500,4 @@ void addObject(ObjectType objectType) throws Exception { } } } - } diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureCorrectnessTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureCorrectnessTest.java index cee25c7dd63..8df02b40859 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureCorrectnessTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureCorrectnessTest.java @@ -7,30 +7,18 @@ package com.evolveum.midpoint.repo.sql.closure; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -/** - * @author mederly - */ -@ContextConfiguration(locations = {"../../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../../ctx-test.xml" }) public class OrgClosureCorrectnessTest extends AbstractOrgClosureTest { - private static final int[] ORG_CHILDREN_IN_LEVEL = { 4, 3, 3 }; + private static final int[] ORG_CHILDREN_IN_LEVEL = { 4, 3, 3 }; private static final int[] USER_CHILDREN_IN_LEVEL = null; - private static final int[] PARENTS_IN_LEVEL = { 0, 2, 2 }; + private static final int[] PARENTS_IN_LEVEL = { 0, 2, 2 }; private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 5, 10 }; private static final int[] NODE_ROUNDS_FOR_LEVELS = { 1, 5, 10 }; - // trivial case for debugging -// private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 2, 1 }; -// private static final int[] USER_CHILDREN_IN_LEVEL = null; -// private static final int[] PARENTS_IN_LEVEL = { 0, 1, 2 }; -// private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 1, 1 }; -// private static final int[] NODE_ROUNDS_FOR_LEVELS = { 1, 1, 1 }; - private OrgClosureTestConfiguration configuration; public OrgClosureCorrectnessTest() { @@ -45,13 +33,40 @@ public OrgClosureCorrectnessTest() { configuration.setNodeRoundsForLevel(NODE_ROUNDS_FOR_LEVELS); } - @Test public void test100LoadOrgStructure() throws Exception { _test100LoadOrgStructure(); } - @Test public void test150CheckClosure() throws Exception { _test150CheckClosure(); } - @Test public void test200AddRemoveLinks() throws Exception { _test200AddRemoveLinks(); } - @Test public void test200AddRemoveLinksUsingReplace() throws Exception { _test200AddRemoveLinks(true); } - @Test public void test300AddRemoveOrgs() throws Exception { _test300AddRemoveOrgs(); } - @Test public void test390CyclePrevention() throws Exception { _test390CyclePrevention(); } - @Test public void test410RandomUnloadOrgStructure() throws Exception { _test410RandomUnloadOrgStructure(); } + @Test + public void test100LoadOrgStructure() throws Exception { + _test100LoadOrgStructure(); + } + + @Test + public void test150CheckClosure() throws Exception { + _test150CheckClosure(); + } + + @Test + public void test200AddRemoveLinks() throws Exception { + _test200AddRemoveLinks(); + } + + @Test + public void test200AddRemoveLinksUsingReplace() throws Exception { + _test200AddRemoveLinks(true); + } + + @Test + public void test300AddRemoveOrgs() throws Exception { + _test300AddRemoveOrgs(); + } + + @Test + public void test390CyclePrevention() throws Exception { + _test390CyclePrevention(); + } + + @Test + public void test410RandomUnloadOrgStructure() throws Exception { + _test410RandomUnloadOrgStructure(); + } @Override public OrgClosureTestConfiguration getConfiguration() { diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureOverwriteAddTest.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureOverwriteAddTest.java index a47ee0f440d..b9171e5295a 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureOverwriteAddTest.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosureOverwriteAddTest.java @@ -7,28 +7,27 @@ package com.evolveum.midpoint.repo.sql.closure; +import static org.testng.AssertJUnit.assertFalse; + +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.repo.api.RepoAddOptions; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - -import static org.testng.AssertJUnit.assertFalse; /** * MID-4407 * * @author mederly */ -@ContextConfiguration(locations = {"../../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../../ctx-test.xml" }) public class OrgClosureOverwriteAddTest extends AbstractOrgClosureTest { - private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 1 }; + private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 1 }; private static final int[] USER_CHILDREN_IN_LEVEL = null; - private static final int[] PARENTS_IN_LEVEL = { 0, 1 }; + private static final int[] PARENTS_IN_LEVEL = { 0, 1 }; private OrgClosureTestConfiguration configuration; diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java index 111d7c6374b..0a7bed74e31 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest1.java @@ -7,23 +7,18 @@ package com.evolveum.midpoint.repo.sql.closure; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -/** - * @author mederly - */ -@ContextConfiguration(locations = {"../../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../../ctx-test.xml" }) public class OrgClosurePerformanceTest1 extends AbstractOrgClosureTest { // relatively smaller graph - private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 2, 3, 4, 5, 0}; + private static final int[] ORG_CHILDREN_IN_LEVEL = { 1, 2, 3, 4, 5, 0 }; private static final int[] USER_CHILDREN_IN_LEVEL = null; - private static final int[] PARENTS_IN_LEVEL = { 0, 1, 2, 3, 3, 3}; - private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 5, 15,15,15,0 }; - private static final int[] NODE_ROUNDS_FOR_LEVELS = { 1, 5, 15,15,15,0 }; + private static final int[] PARENTS_IN_LEVEL = { 0, 1, 2, 3, 3, 3 }; + private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 5, 15, 15, 15, 0 }; + private static final int[] NODE_ROUNDS_FOR_LEVELS = { 1, 5, 15, 15, 15, 0 }; private OrgClosureTestConfiguration configuration; @@ -39,11 +34,30 @@ public OrgClosurePerformanceTest1() { configuration.setNodeRoundsForLevel(NODE_ROUNDS_FOR_LEVELS); } - @Test public void test100LoadOrgStructure() throws Exception { _test100LoadOrgStructure(); } - @Test public void test150CheckClosure() throws Exception { _test150CheckClosure(); } - @Test public void test200AddRemoveLinks() throws Exception { _test200AddRemoveLinks(); } - @Test public void test300AddRemoveOrgs() throws Exception { _test300AddRemoveOrgs(); } - @Test public void test410RandomUnloadOrgStructure() throws Exception { _test410RandomUnloadOrgStructure(); } + @Test + public void test100LoadOrgStructure() throws Exception { + _test100LoadOrgStructure(); + } + + @Test + public void test150CheckClosure() throws Exception { + _test150CheckClosure(); + } + + @Test + public void test200AddRemoveLinks() throws Exception { + _test200AddRemoveLinks(); + } + + @Test + public void test300AddRemoveOrgs() throws Exception { + _test300AddRemoveOrgs(); + } + + @Test + public void test410RandomUnloadOrgStructure() throws Exception { + _test410RandomUnloadOrgStructure(); + } @Override public OrgClosureTestConfiguration getConfiguration() { diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest2.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest2.java index d12dafdc959..de32900ed5b 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest2.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/closure/OrgClosurePerformanceTest2.java @@ -7,23 +7,18 @@ package com.evolveum.midpoint.repo.sql.closure; -import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Test; -/** - * @author mederly - */ -@ContextConfiguration(locations = {"../../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +@ContextConfiguration(locations = { "../../../../../../ctx-test.xml" }) public class OrgClosurePerformanceTest2 extends AbstractOrgClosureTest { // relatively bigger graph - private static final int[] ORG_CHILDREN_IN_LEVEL = { 2, 5, 3, 3, 5, 4 }; + private static final int[] ORG_CHILDREN_IN_LEVEL = { 2, 5, 3, 3, 5, 4 }; private static final int[] USER_CHILDREN_IN_LEVEL = null; - private static final int[] PARENTS_IN_LEVEL = { 0, 1, 2, 2, 2, 2 }; - private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 10, 15,15,15,15 }; - private static final int[] NODE_ROUNDS_FOR_LEVELS = { 5, 10, 15,15,15,15 }; + private static final int[] PARENTS_IN_LEVEL = { 0, 1, 2, 2, 2, 2 }; + private static final int[] LINK_ROUNDS_FOR_LEVELS = { 0, 10, 15, 15, 15, 15 }; + private static final int[] NODE_ROUNDS_FOR_LEVELS = { 5, 10, 15, 15, 15, 15 }; private OrgClosureTestConfiguration configuration; @@ -39,11 +34,30 @@ public OrgClosurePerformanceTest2() { configuration.setNodeRoundsForLevel(NODE_ROUNDS_FOR_LEVELS); } - @Test public void test100LoadOrgStructure() throws Exception { _test100LoadOrgStructure(); } - @Test public void test150CheckClosure() throws Exception { _test150CheckClosure(); } - @Test public void test200AddRemoveLinks() throws Exception { _test200AddRemoveLinks(); } - @Test public void test300AddRemoveOrgs() throws Exception { _test300AddRemoveOrgs(); } - @Test public void test410RandomUnloadOrgStructure() throws Exception { _test410RandomUnloadOrgStructure(); } + @Test + public void test100LoadOrgStructure() throws Exception { + _test100LoadOrgStructure(); + } + + @Test + public void test150CheckClosure() throws Exception { + _test150CheckClosure(); + } + + @Test + public void test200AddRemoveLinks() throws Exception { + _test200AddRemoveLinks(); + } + + @Test + public void test300AddRemoveOrgs() throws Exception { + _test300AddRemoveOrgs(); + } + + @Test + public void test410RandomUnloadOrgStructure() throws Exception { + _test410RandomUnloadOrgStructure(); + } @Override public OrgClosureTestConfiguration getConfiguration() { diff --git a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/OrgStructGenerator.java b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/OrgStructGenerator.java index 4eb9eba1f3d..02a1f7be8be 100644 --- a/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/OrgStructGenerator.java +++ b/repo/repo-sql-impl-test/src/test/java/com/evolveum/midpoint/repo/sql/util/OrgStructGenerator.java @@ -7,16 +7,6 @@ package com.evolveum.midpoint.repo.sql.util; -import com.evolveum.midpoint.prism.util.PrismTestUtil; -import com.evolveum.midpoint.repo.sql.BaseSQLRepoTest; -import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; -import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; -import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; -import org.apache.commons.io.output.FileWriterWithEncoding; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.context.ContextConfiguration; -import org.testng.annotations.Test; - import java.io.File; import java.io.Writer; import java.nio.charset.StandardCharsets; @@ -25,16 +15,22 @@ import java.util.List; import java.util.UUID; -/** - * Created by Viliam Repan (lazyman). - */ -@ContextConfiguration(locations = {"../../../../../ctx-test.xml"}) -@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +import org.apache.commons.io.output.FileWriterWithEncoding; +import org.springframework.test.context.ContextConfiguration; +import org.testng.annotations.Test; + +import com.evolveum.midpoint.prism.util.PrismTestUtil; +import com.evolveum.midpoint.repo.sql.BaseSQLRepoTest; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType; +import com.evolveum.prism.xml.ns._public.types_3.PolyStringType; + +@ContextConfiguration(locations = { "../../../../../ctx-test.xml" }) public class OrgStructGenerator extends BaseSQLRepoTest { @Test(enabled = false) public void generateOrgStructure() throws Exception { - List orgs = generateOrgStructure(0, new int[]{1, 20, 25, 2}, "Org", null); + List orgs = generateOrgStructure(0, new int[] { 1, 20, 25, 2 }, "Org", null); System.out.println(orgs.size()); @@ -90,7 +86,6 @@ private OrgType createOrgType(String name, ObjectReferenceType parentRef) throws orgType.getParentOrgRef().add(parentRef); } - prismContext.adopt(orgType); return orgType;