diff --git a/src/test/java/org/olat/basesecurity/BaseSecurityTest.java b/src/test/java/org/olat/basesecurity/BaseSecurityTest.java index f51fffaab029c42f30d8e0e00e64b3ba6c3a547a..87f253c754277388bec857a630f367c242223f5d 100644 --- a/src/test/java/org/olat/basesecurity/BaseSecurityTest.java +++ b/src/test/java/org/olat/basesecurity/BaseSecurityTest.java @@ -37,7 +37,6 @@ import java.util.Map; import junit.framework.Assert; -import org.junit.After; import org.junit.Test; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; @@ -714,18 +713,6 @@ public class BaseSecurityTest extends OlatTestCase { System.out.println("end testGetIdentitiesByPowerSearchWithDate"); } - - - @After - public void tearDown() throws Exception { - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - e.printStackTrace(); - } catch (Error err) { - err.printStackTrace(); - } - } //////////////////// // Helper diff --git a/src/test/java/org/olat/catalog/CatalogManagerTest.java b/src/test/java/org/olat/catalog/CatalogManagerTest.java deleted file mode 100644 index 02e31ec7aea7481232ed76aae1abaf8cbcee711c..0000000000000000000000000000000000000000 --- a/src/test/java/org/olat/catalog/CatalogManagerTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** -* OLAT - Online Learning and Training<br> -* http://www.olat.org -* <p> -* Licensed under the Apache License, Version 2.0 (the "License"); <br> -* you may not use this file except in compliance with the License.<br> -* You may obtain a copy of the License at -* <p> -* http://www.apache.org/licenses/LICENSE-2.0 -* <p> -* Unless required by applicable law or agreed to in writing,<br> -* software distributed under the License is distributed on an "AS IS" BASIS, <br> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> -* See the License for the specific language governing permissions and <br> -* limitations under the License. -* <p> -* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br> -* University of Zurich, Switzerland. -* <hr> -* <a href="http://www.openolat.org"> -* OpenOLAT - Online Learning and Training</a><br> -* This file has been modified by the OpenOLAT community. Changes are licensed -* under the Apache 2.0 license as the original file. -* <p> -*/ -package org.olat.catalog; - -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.Test; -import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.test.OlatTestCase; - -/** - * Description:<br> - * TODO: patrickb Class Description for CatalogManagerTest - * - * <P> - * Initial Date: 17.04.2007 <br> - * @author patrickb - */ -public class CatalogManagerTest extends OlatTestCase { - - private static Logger log = Logger.getLogger(CatalogManagerTest.class.getName()); - - - /** - * - * - */ - @Test - public void testGetChildrenOf(){ - //TODO:pb: unit test for CatalogManagerTest - } - - - - - /** - * TearDown is called after each test - */ - @After public void tearDown() { - try { - DB db = DBFactory.getInstance(); - db.closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - } - } - - -} diff --git a/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java b/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java index 94942df43d4c0b269420131b7698260a9be03c65..b3d95718157facdebeaa793642304fbdc8bad53a 100644 --- a/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java +++ b/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java @@ -39,7 +39,6 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.apache.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -47,6 +46,8 @@ import org.olat.commons.calendar.model.Kalendar; import org.olat.commons.calendar.model.KalendarEvent; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.test.JMSCodePointServerJunitHelper; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; @@ -63,7 +64,7 @@ import org.olat.testutils.codepoints.client.TemporaryPausedThread; */ public class ICalFileCalendarManagerTest extends OlatTestCase { - private static Logger log = Logger.getLogger(ICalFileCalendarManagerTest.class.getName()); + private static OLog log = Tracing.createLoggerFor(ICalFileCalendarManagerTest.class); private static String CODEPOINT_SERVER_ID = "ICalFileCalendarManagerTest"; private static Identity test = null; @@ -555,7 +556,6 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { @After public void tearDown() throws Exception { try { JMSCodePointServerJunitHelper.stopServer(); - DBFactory.getInstance().closeSession(); } catch (Exception e) { log.error("tearDown failed: ", e); } diff --git a/src/test/java/org/olat/commons/coordinate/cluster/jms/JMSTest.java b/src/test/java/org/olat/commons/coordinate/cluster/jms/JMSTest.java index 3eda2d30bca023c15ae920a6c0a98034b190b0c9..05a4c6841b7206a1d33905f6da112c87a5381671 100644 --- a/src/test/java/org/olat/commons/coordinate/cluster/jms/JMSTest.java +++ b/src/test/java/org/olat/commons/coordinate/cluster/jms/JMSTest.java @@ -30,7 +30,6 @@ import static org.junit.Assert.assertNotNull; import java.util.UUID; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DBFactory; @@ -64,11 +63,6 @@ public class JMSTest extends OlatTestCase { isInitialized = true; } } - - @After - public void tearDown() throws Exception { - DBFactory.getInstance().closeSession(); - } /** * diff --git a/src/test/java/org/olat/core/util/filter/impl/AddBaseURLToMediaRelativeURLFilterTest.java b/src/test/java/org/olat/core/util/filter/impl/AddBaseURLToMediaRelativeURLFilterTest.java index 67229a1e8a531e521088cd9760292228c627f9c7..8e5aa113bb200ccf1f1f5d542b8dd5fd323793ea 100644 --- a/src/test/java/org/olat/core/util/filter/impl/AddBaseURLToMediaRelativeURLFilterTest.java +++ b/src/test/java/org/olat/core/util/filter/impl/AddBaseURLToMediaRelativeURLFilterTest.java @@ -24,8 +24,6 @@ import junit.framework.Assert; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import org.olat.core.util.filter.Filter; import org.olat.core.util.filter.FilterFactory; @@ -37,7 +35,6 @@ import org.olat.core.util.filter.FilterFactory; * Initial Date: 17.07.2009 <br> * @author gnaegi */ -@RunWith(JUnit4.class) public class AddBaseURLToMediaRelativeURLFilterTest { protected Filter filter; diff --git a/src/test/java/org/olat/course/assessment/AssessmentManagerTest.java b/src/test/java/org/olat/course/assessment/AssessmentManagerTest.java index 554442b27a664328b4b148790d5be76e848e7862..dce14e941d792f770b813ba1ed2edf56549f6ed7 100644 --- a/src/test/java/org/olat/course/assessment/AssessmentManagerTest.java +++ b/src/test/java/org/olat/course/assessment/AssessmentManagerTest.java @@ -40,13 +40,13 @@ import java.util.List; import java.util.Map; import java.util.UUID; -import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.id.IdentityEnvironment; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.resource.OresHelper; import org.olat.course.CourseFactory; import org.olat.course.CourseModule; @@ -72,7 +72,7 @@ import org.olat.test.OlatTestCase; */ public class AssessmentManagerTest extends OlatTestCase { - private static Logger log = Logger.getLogger(AssessmentManagerTest.class.getName()); + private static OLog log = Tracing.createLoggerFor(AssessmentManagerTest.class); private AssessmentManager assessmentManager; private ICourse course; @@ -108,15 +108,6 @@ public class AssessmentManagerTest extends OlatTestCase { } } - @After - public void tearDown() throws Exception { - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("tearDown failed: ", e); - } - } - /** * Tests the AssessmentManager methods. * diff --git a/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java b/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java index 64cfcb8c75a9ca09cbbab6f2bc1a8ea81b5222f5..b20ca4cfe254f700cf20103aaace9645565d13af 100644 --- a/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java +++ b/src/test/java/org/olat/course/auditing/UserNodeAuditManagerTest.java @@ -75,12 +75,7 @@ public class UserNodeAuditManagerTest extends OlatTestCase { public void tearDown() throws Exception { //remove demo course on file system //FIXME: this does not remove all data from the database, see repositoryManger - CourseFactory.deleteCourse(course); - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("tearDown failed: ", e); - } + CourseFactory.deleteCourse(course); } /** diff --git a/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java b/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java index a08dd79689c1751117aea1a2107fb6b00be52982..34d0d5c44195e8d1ed4b660dee05278d731727f3 100644 --- a/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java +++ b/src/test/java/org/olat/course/config/CourseConfigManagerImplTest.java @@ -29,7 +29,6 @@ package org.olat.course.config; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DBFactory; @@ -56,7 +55,6 @@ public class CourseConfigManagerImplTest extends OlatTestCase { private static ICourse course1; private static boolean isSetup = false; - private static boolean isTearDown = false; /** @@ -102,22 +100,4 @@ public class CourseConfigManagerImplTest extends OlatTestCase { VFSItem cc1File = CourseConfigManagerImpl.getConfigFile(course1); assertFalse("CourseConfig file no longer exists.", cc1File != null); } - - /** - * TearDown is called after each test. - * - * @throws Exception - */ - @After - public void tearDown() throws Exception { - if (isTearDown) return; - try { - DBFactory.getInstance().closeSession(); - isTearDown = true; - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - e.printStackTrace(); - throw e; - } - } } \ No newline at end of file diff --git a/src/test/java/org/olat/course/groupsandrights/CourseGroupManagementTest.java b/src/test/java/org/olat/course/groupsandrights/CourseGroupManagementTest.java index 403668d3d53f017b5e8c0b7e8f7c8a3b9e586f6a..89f7dbbbbed0cb2798658e3a88477f588b881d7d 100644 --- a/src/test/java/org/olat/course/groupsandrights/CourseGroupManagementTest.java +++ b/src/test/java/org/olat/course/groupsandrights/CourseGroupManagementTest.java @@ -31,13 +31,13 @@ import static org.junit.Assert.assertTrue; import java.util.UUID; -import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; import org.olat.group.area.BGArea; @@ -57,7 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class CourseGroupManagementTest extends OlatTestCase { - private static Logger log = Logger.getLogger(CourseGroupManagementTest.class.getName()); + private static OLog log = Tracing.createLoggerFor(CourseGroupManagementTest.class); private Identity id1, id2, id3; @Autowired @@ -83,16 +83,6 @@ public class CourseGroupManagementTest extends OlatTestCase { log.error("Exception in setUp(): " + e); } } - - @After - public void tearDown() throws Exception { - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - throw e; - } - } /** rights tests */ @Test diff --git a/src/test/java/org/olat/course/nodes/projectbroker/ProjectBrokerManagerTest.java b/src/test/java/org/olat/course/nodes/projectbroker/ProjectBrokerManagerTest.java index 90861e010c70f118c441059d313a8b2049e20b06..f5864cdc803520f2960040781bde4e6ee28c4a4b 100644 --- a/src/test/java/org/olat/course/nodes/projectbroker/ProjectBrokerManagerTest.java +++ b/src/test/java/org/olat/course/nodes/projectbroker/ProjectBrokerManagerTest.java @@ -43,8 +43,6 @@ import java.util.UUID; import junit.framework.Assert; -import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.SecurityGroupImpl; @@ -71,8 +69,7 @@ import org.olat.test.OlatTestCase; */ public class ProjectBrokerManagerTest extends OlatTestCase { - // - private static Logger log = Logger.getLogger(ProjectBrokerManagerTest.class.getName()); + /* * ::Test Setup:: */ @@ -358,20 +355,5 @@ private Project createProject(String name, Identity creator, Long projectBrokerI return project; } - /** - * @see junit.framework.TestCase#tearDown() - */ - @After public void tearDown() throws Exception { -// TODO: Does not cleanup Demo-course because other Test which use Demo-Course too, will be have failures -// ICourse course = CourseFactory.loadCourse(resourceableId); -// CourseFactory.deleteCourse(course); - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("tearDown failed: ", e); - } - } - - } diff --git a/src/test/java/org/olat/group/test/BGAreaManagerTest.java b/src/test/java/org/olat/group/test/BGAreaManagerTest.java index fbc384bb66df99e0aa0fb68330889f64988ec0cd..9ccacf44b151525aba80a220574ff1d4a6f7f540 100644 --- a/src/test/java/org/olat/group/test/BGAreaManagerTest.java +++ b/src/test/java/org/olat/group/test/BGAreaManagerTest.java @@ -40,7 +40,6 @@ import java.util.concurrent.TimeUnit; import junit.framework.Assert; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; @@ -91,16 +90,6 @@ public class BGAreaManagerTest extends OlatTestCase { log.error("Exception in setUp(): " + e); } } - - @After - public void tearDown() throws Exception { - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - throw e; - } - } @Test public void testCreateLoadBGArea() { diff --git a/src/test/java/org/olat/group/test/BGRightManagerTest.java b/src/test/java/org/olat/group/test/BGRightManagerTest.java index 416b315d236ce3057f7aee215fd0190f60bcd457..029d0fb9620ccd25df5676516bb778b9103df89d 100644 --- a/src/test/java/org/olat/group/test/BGRightManagerTest.java +++ b/src/test/java/org/olat/group/test/BGRightManagerTest.java @@ -36,8 +36,6 @@ import java.util.UUID; import junit.framework.Assert; -import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; @@ -45,6 +43,8 @@ import org.olat.basesecurity.Policy; import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.course.groupsandrights.CourseRights; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; @@ -64,7 +64,7 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class BGRightManagerTest extends OlatTestCase { - private static Logger log = Logger.getLogger(BGRightManagerTest.class.getName()); + private static OLog log = Tracing.createLoggerFor(BGRightManagerTest.class); private Identity id1, id2, id3, id4; @Autowired @@ -95,21 +95,6 @@ public class BGRightManagerTest extends OlatTestCase { } } - /** - * TearDown is called after each test. - * - * @throws Exception - */ - @After - public void tearDown() throws Exception { - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - throw e; - } - } - /** * Test if the add right doesn't generate errors */ diff --git a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java index e6ed4e77b5010152ec8b51c3d48559fab0caf57f..c9cd6ff63ff91b68557a81b4f5a22ac9a07af8e0 100644 --- a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java +++ b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java @@ -32,11 +32,9 @@ import java.util.UUID; import junit.framework.Assert; -import org.junit.After; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.commons.persistence.PersistenceHelper; import org.olat.core.commons.services.mark.MarkManager; import org.olat.core.id.Identity; @@ -84,16 +82,6 @@ public class BusinessGroupDAOTest extends OlatTestCase { @Autowired private MarkManager markManager; - @After - public void tearDown() throws Exception { - try { - DBFactory.getInstance().commitAndCloseSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - throw e; - } - } - @Test public void should_service_present() { Assert.assertNotNull(businessGroupDao); diff --git a/src/test/java/org/olat/group/test/BusinessGroupRelationDAOTest.java b/src/test/java/org/olat/group/test/BusinessGroupRelationDAOTest.java index 3dc759d33135f95f63355b8739f0ef77ddba8062..45eceb9dac9512d0e68d33936a1dd43dcc094218 100644 --- a/src/test/java/org/olat/group/test/BusinessGroupRelationDAOTest.java +++ b/src/test/java/org/olat/group/test/BusinessGroupRelationDAOTest.java @@ -25,11 +25,9 @@ import java.util.UUID; import junit.framework.Assert; -import org.junit.After; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupShort; @@ -59,15 +57,6 @@ public class BusinessGroupRelationDAOTest extends OlatTestCase { @Autowired private BaseSecurity securityManager; - @After - public void shutdown() { - try { - DBFactory.getInstance().commitAndCloseSession(); - } catch (Exception e) { - e.printStackTrace(); - } - } - @Test public void should_service_present() { Assert.assertNotNull(businessGroupDao); diff --git a/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java b/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java index 9eade2339a36e5cba7ab2586cbc76fbc1dfe5955..3daafbd670a82a02b44c0c40ed38f92d4ecef3bb 100644 --- a/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java +++ b/src/test/java/org/olat/group/test/BusinessGroupServiceTest.java @@ -31,7 +31,6 @@ import java.util.UUID; import junit.framework.Assert; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; @@ -41,7 +40,6 @@ import org.olat.basesecurity.SecurityGroupImpl; import org.olat.collaboration.CollaborationTools; import org.olat.collaboration.CollaborationToolsFactory; import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.id.Roles; import org.olat.core.id.User; @@ -176,16 +174,6 @@ public class BusinessGroupServiceTest extends OlatTestCase { initialize = true; } - @After - public void tearDown() throws Exception { - try { - DBFactory.getInstance().commitAndCloseSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - throw e; - } - } - @Test public void should_service_present() { Assert.assertNotNull(businessGroupService); diff --git a/src/test/java/org/olat/modules/fo/ForumManagerTest.java b/src/test/java/org/olat/modules/fo/ForumManagerTest.java index 4d09c78de5be1368bec1ce864d70a13bbd69c870..de98ba2a21d599b287fc0fe4c75e4be699f3eee5 100644 --- a/src/test/java/org/olat/modules/fo/ForumManagerTest.java +++ b/src/test/java/org/olat/modules/fo/ForumManagerTest.java @@ -34,12 +34,11 @@ import java.util.Date; import java.util.Iterator; import java.util.List; -import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; import org.olat.user.UserManager; @@ -50,7 +49,7 @@ import org.olat.user.UserManager; public class ForumManagerTest extends OlatTestCase { - private static Logger log = Logger.getLogger(ForumManagerTest.class.getName()); + private static OLog log = Tracing.createLoggerFor(ForumManagerTest.class); public Identity u1; public Identity u2; @@ -114,18 +113,9 @@ public class ForumManagerTest extends OlatTestCase { log.error("Exception in setUp(): "+e); } } - - /** - * TearDown is called after each test - */ - @After public void tearDown(){ - try{ - DBFactory.getInstance().closeSession(); - } - catch(Exception e) {log.error("Exception in tearDown(): "+e);} - } - @Test public void testGetMessagesByForumID() throws Exception { + @Test + public void testGetMessagesByForumID() throws Exception { log.debug("Start testGetMessagesByForumID()"); ForumManager foma = ForumManager.getInstance(); diff --git a/src/test/java/org/olat/modules/ims/cp/CPManagerTest.java b/src/test/java/org/olat/modules/ims/cp/CPManagerTest.java index 5e270cdc6d8bb1b6fb6dd63134fd515bb91637da..359ca0dbef04d78a1e81c6047ecea4875dee56f3 100644 --- a/src/test/java/org/olat/modules/ims/cp/CPManagerTest.java +++ b/src/test/java/org/olat/modules/ims/cp/CPManagerTest.java @@ -25,14 +25,16 @@ */ package org.olat.modules.ims.cp; -import org.apache.log4j.Logger; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.OLATResourceable; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.resource.OresHelper; import org.olat.core.util.vfs.VFSItem; import org.olat.core.util.vfs.VFSLeaf; @@ -40,7 +42,6 @@ import org.olat.ims.cp.CPManager; import org.olat.ims.cp.ContentPackage; import org.olat.ims.cp.objects.CPItem; import org.olat.ims.cp.objects.CPOrganization; -import org.olat.modules.fo.ForumManagerTest; import org.olat.test.OlatTestCase; /** @@ -55,7 +56,7 @@ public class CPManagerTest extends OlatTestCase { private static final String ITEM_ID = "this_is_a_great_inital_item_identifier"; private static final String PAGE_TITLE = "fancy page"; - private static final Logger log = Logger.getLogger(ForumManagerTest.class.getName()); + private static final OLog log = Tracing.createLoggerFor(CPManagerTest.class); private CPManager mgr = null; private ContentPackage cp; @@ -79,11 +80,6 @@ public class CPManagerTest extends OlatTestCase { @After public void tearDown() { cp.getRootDir().delete(); - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - } } @Test diff --git a/src/test/java/org/olat/modules/wiki/WikiUnitTest.java b/src/test/java/org/olat/modules/wiki/WikiUnitTest.java index 0b000b7d853348156bdbb0b29a8cf36502c502c2..6b58228f8f48c3210310869cefd0ce2d05d7f201 100644 --- a/src/test/java/org/olat/modules/wiki/WikiUnitTest.java +++ b/src/test/java/org/olat/modules/wiki/WikiUnitTest.java @@ -31,10 +31,7 @@ import static org.junit.Assert.assertNotNull; import java.util.List; -import org.junit.After; -import org.junit.Before; import org.junit.Test; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.OLATResourceable; import org.olat.modules.wiki.versioning.ChangeInfo; import org.olat.test.OlatTestCase; @@ -50,10 +47,8 @@ import org.olat.test.OlatTestCase; public class WikiUnitTest extends OlatTestCase { private static final String WIKI_CONTENT = "==heading==\n'''bold'''\n[[Image:test.jpg|bla]]"; - - @Before public void setup() throws Exception {/***/} - - @Test public void testWikiStuff() { + @Test + public void testWikiStuff() { WikiManager wikiMgr = WikiManager.getInstance(); OLATResourceable ores = wikiMgr.createWiki(); Wiki wiki = wikiMgr.getOrLoadWiki(ores); @@ -98,9 +93,4 @@ public class WikiUnitTest extends OlatTestCase { //clean up wikiMgr.deleteWiki(ores); } - - @After public void tearDown() throws Exception { - DBFactory.getInstance().closeSession(); - } - } diff --git a/src/test/java/org/olat/modules/wiki/versioning/diff/CookbookDiffTest.java b/src/test/java/org/olat/modules/wiki/versioning/diff/CookbookDiffTest.java index 6a91a1e2358b086f48b3b4607f627fd41a23e6de..e988f8762e305fded8f40aeac8409ae9ab920100 100644 --- a/src/test/java/org/olat/modules/wiki/versioning/diff/CookbookDiffTest.java +++ b/src/test/java/org/olat/modules/wiki/versioning/diff/CookbookDiffTest.java @@ -31,7 +31,6 @@ import static org.junit.Assert.assertEquals; import java.util.Iterator; import java.util.List; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.modules.wiki.versioning.ChangeInfo; @@ -45,14 +44,13 @@ public class CookbookDiffTest { private CookbookDifferenceService differenceService; - - @Before public void setup() throws Exception { + @Before + public void setup() { differenceService = new CookbookDifferenceService(); } - @After public void tearDown() throws Exception {} - - @Test public void testAddText() { + @Test + public void testAddText() { String text1 = "Line1\nLine2\nDies ist ein Text."; String text2 = text1 + "Text2"; List<ChangeInfo> diffList = differenceService.diff(text1,text2); diff --git a/src/test/java/org/olat/note/NoteTest.java b/src/test/java/org/olat/note/NoteTest.java index 8bd8976695c6af697483e8ef2f227158f6b88884..3bea20ac3744241bd5f7886d175fe460e3c0c713 100644 --- a/src/test/java/org/olat/note/NoteTest.java +++ b/src/test/java/org/olat/note/NoteTest.java @@ -32,13 +32,13 @@ import static org.junit.Assert.assertTrue; import java.util.List; import java.util.UUID; -import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.resource.OLATResourceManager; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; @@ -55,7 +55,7 @@ public class NoteTest extends OlatTestCase implements OLATResourceable { private long RESOURCE_ID = 42; private String RESOURCE_TYPE = "org.olat.note.NoteTest"; - private static Logger log = Logger.getLogger(NoteTest.class); + private static OLog log = Tracing.createLoggerFor(NoteTest.class); private static boolean isInitialized = false; private static Identity identity = null; private static org.olat.resource.OLATResource res = null; @@ -65,7 +65,8 @@ public class NoteTest extends OlatTestCase implements OLATResourceable { /** * @see junit.framework.TestCase#setUp() */ - @Before public void setup() { + @Before + public void setup() { if (NoteTest.isInitialized == false) { try { nm = NoteManager.getInstance(); @@ -83,23 +84,9 @@ public class NoteTest extends OlatTestCase implements OLATResourceable { } } } - - /** - * @see junit.framework.TestCase#tearDown() - */ - @After public void tearDown() { - try { - DBFactory.getInstance().closeSession(); - } catch (Exception e) { - log.error("tearDown failed: ", e); - } - } - /** - * - * - */ - @Test public void testGenericLoadDeleteNote() { + @Test + public void testGenericLoadDeleteNote() { Long resourceTypeId = res.getResourceableId(); String resourceTypeName = res.getResourceableTypeName(); Note n = nm.loadNoteOrCreateInRAM(identity, resourceTypeName, resourceTypeId); diff --git a/src/test/java/org/olat/portfolio/EPArtefactManagerTest.java b/src/test/java/org/olat/portfolio/EPArtefactManagerTest.java index 83f93bae3589b92c2f1b4adccab47a8d803bcb87..fa396fce038c2fa73a1f43046b8fded587c44d9d 100644 --- a/src/test/java/org/olat/portfolio/EPArtefactManagerTest.java +++ b/src/test/java/org/olat/portfolio/EPArtefactManagerTest.java @@ -29,7 +29,6 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DB; @@ -83,11 +82,6 @@ public class EPArtefactManagerTest extends OlatTestCase { } } - @After - public void tearDown() { - dbInstance.commitAndCloseSession(); - } - @Test public void testManagers() { assertNotNull(dbInstance); diff --git a/src/test/java/org/olat/portfolio/EPFrontendManagerTest.java b/src/test/java/org/olat/portfolio/EPFrontendManagerTest.java index 120dcc82c26acf765c76f692e4f2fa11dd408df3..ecb30bd58c8b34d45bf6d79599bcadeb01dd2f74 100644 --- a/src/test/java/org/olat/portfolio/EPFrontendManagerTest.java +++ b/src/test/java/org/olat/portfolio/EPFrontendManagerTest.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; @@ -107,11 +106,6 @@ public class EPFrontendManagerTest extends OlatTestCase { } } - @After - public void tearDown() { - dbInstance.commitAndCloseSession(); - } - @Test public void testManagers() { assertNotNull(dbInstance); diff --git a/src/test/java/org/olat/portfolio/EPStructureManagerTest.java b/src/test/java/org/olat/portfolio/EPStructureManagerTest.java index de712f228f30cfa60eb90b36768ae4c5d1726c9b..5488d0a6cb13444bbb3478bb0d65debdbf83b9cd 100644 --- a/src/test/java/org/olat/portfolio/EPStructureManagerTest.java +++ b/src/test/java/org/olat/portfolio/EPStructureManagerTest.java @@ -30,7 +30,6 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; @@ -96,18 +95,12 @@ public class EPStructureManagerTest extends OlatTestCase { } } - @After - public void tearDown() { - dbInstance.commitAndCloseSession(); - } - @Test public void testManagers() { assertNotNull(dbInstance); assertNotNull(epStructureManager); } - @Test public void testGetStructureElementsForUser(){ PortfolioStructure el = epFrontendManager.createAndPersistPortfolioDefaultMap(ident1, "users-test-map", "a-map-to-test-get-afterwards"); diff --git a/src/test/java/org/olat/portfolio/EPStructureToArtefactTest.java b/src/test/java/org/olat/portfolio/EPStructureToArtefactTest.java index 987da16a15b45f2fbe15855c1f406ce9cf5eb9b3..7b67a65425b841f0f9a24386a493f6013ff45e39 100644 --- a/src/test/java/org/olat/portfolio/EPStructureToArtefactTest.java +++ b/src/test/java/org/olat/portfolio/EPStructureToArtefactTest.java @@ -30,7 +30,6 @@ import java.util.Calendar; import java.util.Date; import java.util.List; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DB; @@ -76,11 +75,6 @@ public class EPStructureToArtefactTest extends OlatTestCase { } } - @After - public void tearDown() { - dbInstance.commitAndCloseSession(); - } - @Test public void createStructureToArtefactLink() { //create structure element diff --git a/src/test/java/org/olat/properties/PropertyTest.java b/src/test/java/org/olat/properties/PropertyTest.java index 8e1da8eea56440d2c473f4e2553dfefaa4efdde5..75bab13753146ac51cd4c179a05bf7eef2551228 100644 --- a/src/test/java/org/olat/properties/PropertyTest.java +++ b/src/test/java/org/olat/properties/PropertyTest.java @@ -38,7 +38,6 @@ import java.util.UUID; import junit.framework.Assert; -import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DB; import org.olat.core.id.Identity; @@ -61,10 +60,7 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class PropertyTest extends OlatTestCase { - private static OLog log = Tracing.createLoggerFor(PropertyTest.class); - private static Identity identity, id2, id3, id4 ; - private static BusinessGroup group = null; - private static OLATResource res; + private static final OLog log = Tracing.createLoggerFor(PropertyTest.class); @Autowired private DB dbInstance; @@ -72,35 +68,18 @@ public class PropertyTest extends OlatTestCase { private PropertyManager pm; @Autowired private BusinessGroupService businessGroupService; - - /** - * @see junit.framework.TestCase#setUp() - */ - @Before - public void setup() { - if(res == null) { - // identity with null User should be ok for test case - identity = JunitTestHelper.createAndPersistIdentityAsUser("foo-" + UUID.randomUUID().toString()); - id2 = JunitTestHelper.createAndPersistIdentityAsUser("eis-" + UUID.randomUUID().toString()); - id3 = JunitTestHelper.createAndPersistIdentityAsUser("zwoi-" + UUID.randomUUID().toString()); - id4 = JunitTestHelper.createAndPersistIdentityAsUser("drp-" + UUID.randomUUID().toString()); - res = JunitTestHelper.createRandomResource(); - - List<BusinessGroup> l = businessGroupService.findBusinessGroupsOwnedBy(identity, null); - if (l.size() == 0) { - group = businessGroupService.createBusinessGroup(identity, "a buddygroup", "a desc", -1, -1, false, false, null); - } else { - group = (BusinessGroup)l.get(0); - } - } - } /** * testGenericInsertFindDelete */ @Test public void testGenericInsertFindDelete() { + //create resource, identity and group OLATResource ores = JunitTestHelper.createRandomResource(); + Identity identity = JunitTestHelper.createAndPersistIdentityAsUser("prop-1-" + UUID.randomUUID().toString()); + BusinessGroup group = businessGroupService.createBusinessGroup(identity, "a buddygroup", "a desc", -1, -1, false, false, null); + dbInstance.commitAndCloseSession(); + Property p = pm.createPropertyInstance(identity, group, ores, "catgeneric", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); dbInstance.commitAndCloseSession(); @@ -119,8 +98,11 @@ public class PropertyTest extends OlatTestCase { @Test public void testFindWithResourceIdList() { - //create a property + //create resource, identity OLATResource ores = JunitTestHelper.createRandomResource(); + Identity identity = JunitTestHelper.createAndPersistIdentityAsUser("prop-2-" + UUID.randomUUID().toString()); + dbInstance.commitAndCloseSession(); + //create the property Property p = pm.createPropertyInstance(identity, null, ores, "catidlist", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); dbInstance.commitAndCloseSession(); @@ -142,7 +124,7 @@ public class PropertyTest extends OlatTestCase { @Test public void testFindWithIdentityList() { - //create a property + //create identities, resource and properties Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("cat-id-1-" + UUID.randomUUID().toString()); Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("cat-id-2-" + UUID.randomUUID().toString()); Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("cat-id-3-" + UUID.randomUUID().toString()); @@ -177,7 +159,13 @@ public class PropertyTest extends OlatTestCase { */ @Test public void testGetAllResourceTypeNames() { + //create resource, identity and group OLATResource ores = JunitTestHelper.createRandomResource(); + Identity identity = JunitTestHelper.createAndPersistIdentityAsUser("prop-3-" + UUID.randomUUID().toString()); + BusinessGroup group = businessGroupService.createBusinessGroup(identity, "a buddygroup", "a desc", -1, -1, false, false, null); + dbInstance.commitAndCloseSession(); + + //create a property Property p = pm.createPropertyInstance(identity, group, ores, "catall", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); dbInstance.commitAndCloseSession(); @@ -191,8 +179,13 @@ public class PropertyTest extends OlatTestCase { * testListProperties */ @Test - public void testListProperties(){ + public void testListProperties() { + //create resource, identity and group OLATResource ores = JunitTestHelper.createRandomResource(); + Identity identity = JunitTestHelper.createAndPersistIdentityAsUser("prop-4-" + UUID.randomUUID().toString()); + BusinessGroup group = businessGroupService.createBusinessGroup(identity, "a buddygroup", "a desc", -1, -1, false, false, null); + dbInstance.commitAndCloseSession(); + Property p = pm.createPropertyInstance(identity, group, ores, "cat", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); @@ -210,6 +203,7 @@ public class PropertyTest extends OlatTestCase { */ @Test public void testUserInsertFindDelete() { + //create identity and property Identity id = JunitTestHelper.createAndPersistIdentityAsUser("user-prop-" + UUID.randomUUID().toString()); Property p = pm.createUserPropertyInstance(id, "catuser", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); @@ -224,11 +218,12 @@ public class PropertyTest extends OlatTestCase { pm.deleteProperty(p); p = pm.findUserProperty(id, "catuser", "TestProperty"); assertNull(p); + dbInstance.commitAndCloseSession(); } @Test public void testDeleteUserData() { - //create some properties + //create some identities and properties Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("del-user-1-" + UUID.randomUUID().toString()); Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("del-user-2-" + UUID.randomUUID().toString()); Property p10 = pm.createPropertyInstance(id1, null, null, "prop-del-1", "TestProperty", new Float(1.1), new Long(123456), "stringValue", "textValue"); @@ -241,6 +236,7 @@ public class PropertyTest extends OlatTestCase { //delete user 1 datas pm.deleteUserData(id1, "del-" + id1.getName()); + dbInstance.commitAndCloseSession(); //check if really deleted Property p10x = pm.findUserProperty(id1, "prop-del-1", "TestProperty"); @@ -259,7 +255,12 @@ public class PropertyTest extends OlatTestCase { */ @Test public void testPerf500Properties() { - + //create identity, group and resource + OLATResource res = JunitTestHelper.createRandomResource(); + Identity identity = JunitTestHelper.createAndPersistIdentityAsUser("prop-5-" + UUID.randomUUID().toString()); + BusinessGroup group = businessGroupService.createBusinessGroup(identity, "a buddygroup", "a desc", -1, -1, false, false, null); + dbInstance.commitAndCloseSession(); + long start, stop; long count = 500; @@ -270,7 +271,7 @@ public class PropertyTest extends OlatTestCase { log.info("CREATE generic property test started..."); start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { - Property p = pm.createPropertyInstance(identity, group, res, "cat", "TestProperty" + i, new Float(1.1), new Long(123456), "stringValue", "textValue"); + Property p = pm.createPropertyInstance(identity, group, res, "perf500", "TestProperty" + i, new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); if(i % 50 == 0) { @@ -282,7 +283,7 @@ public class PropertyTest extends OlatTestCase { stop = System.currentTimeMillis(); log.info("CREATE generic property test: " + (stop-start) + " ms (" + (count * 1000 / (stop-start)) + "/sec)"); // some find identitites tests - List<Identity> ids = pm.findIdentitiesWithProperty(null, null, "cat", "TestProperty", false); + List<Identity> ids = pm.findIdentitiesWithProperty(null, null, "perf500", null, false); Assert.assertNotNull("Identities cannot be null", ids); Assert.assertFalse("Identities cannot be empty", ids.isEmpty()); Assert.assertTrue("Identities must contains reference identity", ids.contains(identity)); @@ -291,7 +292,7 @@ public class PropertyTest extends OlatTestCase { log.info("Preparing user/group properties test. Creating additional properties.."); start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { - Property pUser = pm.createUserPropertyInstance(identity, "cat", "TestProperty" + i, new Float(1.1), new Long(123456), "stringValue", "textValue"); + Property pUser = pm.createUserPropertyInstance(identity, "perf500", "TestProperty" + i, new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(pUser); if(i % 50 == 0) { dbInstance.commitAndCloseSession(); @@ -307,7 +308,7 @@ public class PropertyTest extends OlatTestCase { log.info("FIND generic property test started..."); start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { - Property p = pm.findProperty(identity, group, res, "cat", "TestProperty" + i); + Property p = pm.findProperty(identity, group, res, "perf500", "TestProperty" + i); assertNotNull("Must find the p (count=" + i + ")", p); dbInstance.commitAndCloseSession(); } @@ -318,7 +319,7 @@ public class PropertyTest extends OlatTestCase { log.info("FIND user property test started..."); start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { - Property p = pm.findUserProperty(identity, "cat", "TestProperty" + i); + Property p = pm.findUserProperty(identity, "perf500", "TestProperty" + i); assertNotNull("Must find the p (count=" + i + ")", p); dbInstance.commitAndCloseSession(); } @@ -329,7 +330,7 @@ public class PropertyTest extends OlatTestCase { log.info("FIND and DELETE generic property test started..."); start = System.currentTimeMillis(); for (int i = 0; i < count; i++) { - Property p = pm.findUserProperty(identity, "cat", "TestProperty" + i); + Property p = pm.findUserProperty(identity, "perf500", "TestProperty" + i); pm.deleteProperty(p); } stop = System.currentTimeMillis(); @@ -346,6 +347,13 @@ public class PropertyTest extends OlatTestCase { */ @Test public void testFloatValues() { + //create identity, group and resource + OLATResource res = JunitTestHelper.createRandomResource(); + Identity identity = JunitTestHelper.createAndPersistIdentityAsUser("prop-6-" + UUID.randomUUID().toString()); + BusinessGroup group = businessGroupService.createBusinessGroup(identity, "a buddygroup", "a desc", -1, -1, false, false, null); + dbInstance.commitAndCloseSession(); + + Property original, copy; //gs:changed to FLOAT(65,30) to be compatible with hsqldb and auto generated ddl // Define my own MAX float value because the db precision changed from DECIMAL(78,36) to DECIMAL(65,30) @@ -418,9 +426,18 @@ public class PropertyTest extends OlatTestCase { @Test public void testFindIdentities() { + //create identities, group and resource + OLATResource res = JunitTestHelper.createRandomResource(); + Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("prop-7-" + UUID.randomUUID().toString()); + Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("prop-10-" + UUID.randomUUID().toString()); + Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("prop-11-" + UUID.randomUUID().toString()); + Identity id4 = JunitTestHelper.createAndPersistIdentityAsUser("prop-12-" + UUID.randomUUID().toString()); + BusinessGroup group = businessGroupService.createBusinessGroup(id1, "a buddygroup", "a desc", -1, -1, false, false, null); + dbInstance.commitAndCloseSession(); + String propName = UUID.randomUUID().toString(); - Property p = pm.createPropertyInstance(identity, group, res, "cat", propName, new Float(1.1), new Long(123456), "stringValue", "textValue"); + Property p = pm.createPropertyInstance(id1, group, res, "cat", propName, new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); p = pm.createPropertyInstance(id2, group, res, "cat", propName, new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); @@ -428,7 +445,7 @@ public class PropertyTest extends OlatTestCase { pm.saveProperty(p); p = pm.createPropertyInstance(id4, group, res, "cat", propName, new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); - p = pm.createPropertyInstance(identity, group, res, "cat2", propName, new Float(1.1), new Long(123456), "stringValue", "textValue"); + p = pm.createPropertyInstance(id1, group, res, "cat2", propName, new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); p = pm.createPropertyInstance(id2, group, res, "cat2", propName, new Float(1.1), new Long(123456), "stringValue", "textValue"); pm.saveProperty(p); @@ -453,18 +470,25 @@ public class PropertyTest extends OlatTestCase { @Test public void testFindProperties() { + //create identities, group and resource + OLATResource res = JunitTestHelper.createRandomResource(); + Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("prop-8-" + UUID.randomUUID().toString()); + Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("prop-9-" + UUID.randomUUID().toString()); + BusinessGroup group = businessGroupService.createBusinessGroup(id1, "a buddygroup", "a desc", -1, -1, false, false, null); + dbInstance.commitAndCloseSession(); + String category = "cat3"; String propertyName = "TestProperty3"; String textValue = "textValue3"; - Property p = pm.createPropertyInstance(identity, group, res, category, propertyName, new Float(1.1), new Long(123456), "stringValue", textValue); + Property p = pm.createPropertyInstance(id1, group, res, category, propertyName, new Float(1.1), new Long(123456), "stringValue", textValue); pm.saveProperty(p); p = pm.createPropertyInstance(id2, group, res, category, propertyName, new Float(1.1), new Long(123456), "stringValue", textValue); pm.saveProperty(p); - List<Property> propertyList = pm.findProperties(identity, group, res.getResourceableTypeName(), res.getResourceableId(), category, propertyName); + List<Property> propertyList = pm.findProperties(id1, group, res.getResourceableTypeName(), res.getResourceableId(), category, propertyName); assertEquals(1, propertyList.size()); assertEquals(propertyName, ((Property)propertyList.get(0)).getName() ); assertEquals(textValue, ((Property)propertyList.get(0)).getTextValue() ); - int deletedCount1 = pm.deleteProperties(identity, group, res, category, propertyName); + int deletedCount1 = pm.deleteProperties(id1, group, res, category, propertyName); Assert.assertEquals(1, deletedCount1); int deletedCount2 = pm.deleteProperties(id2, group, res, category, propertyName); Assert.assertEquals(1, deletedCount2); diff --git a/src/test/java/org/olat/registration/RegistrationManagerTest.java b/src/test/java/org/olat/registration/RegistrationManagerTest.java index bf3098682a0c43aadad3001f30b00aa1004c3d47..b930c3ab5c301704f7c510a810c1c7f0da947893 100644 --- a/src/test/java/org/olat/registration/RegistrationManagerTest.java +++ b/src/test/java/org/olat/registration/RegistrationManagerTest.java @@ -27,13 +27,12 @@ package org.olat.registration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertFalse; import java.util.UUID; -import org.junit.After; import org.junit.Test; import org.olat.core.commons.persistence.DBFactory; import org.olat.test.OlatTestCase; @@ -174,12 +173,4 @@ public class RegistrationManagerTest extends OlatTestCase { assertFalse(registrationManager.validateEmailUsername("aoi@cyberia.ch")); assertTrue(registrationManager.validateEmailUsername("aoi@blog.cyberiacafe.ch")); } - - /* (non-Javadoc) - * @see junit.framework.TestCase#tearDown() - */ - @After public void tearDown() throws Exception { - DBFactory.getInstance().closeSession(); - } - } diff --git a/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java b/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java index 973a4bfeddbb258be332e1d1ef057131e17c40a2..02d0730de93cbda1066daf1dda2d6d02565f2056 100644 --- a/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java +++ b/src/test/java/org/olat/repository/RepositoryManagerConcurrentTest.java @@ -86,7 +86,6 @@ public class RepositoryManagerConcurrentTest extends OlatTestCase { @After public void tearDown() { try { JMSCodePointServerJunitHelper.stopServer(); - DBFactory.getInstance().closeSession(); } catch (Exception e) { log.error("tearDown failed", e); } diff --git a/src/test/java/org/olat/repository/RepositoryManagerTest.java b/src/test/java/org/olat/repository/RepositoryManagerTest.java index 48eb8259b134baed7f6c176b68a87b990b655b9c..0f3cc78c8525b154724734a4a7cba3740637dc0c 100644 --- a/src/test/java/org/olat/repository/RepositoryManagerTest.java +++ b/src/test/java/org/olat/repository/RepositoryManagerTest.java @@ -104,7 +104,6 @@ public class RepositoryManagerTest extends OlatTestCase { @After public void tearDown() { try { JMSCodePointServerJunitHelper.stopServer(); - DBFactory.getInstance().closeSession(); } catch (Exception e) { log.error("tearDown failed", e); } diff --git a/src/test/java/org/olat/resource/OLATResourceManagerTest.java b/src/test/java/org/olat/resource/OLATResourceManagerTest.java index fba636d791bd61df0b5c311e5455ebeb41d8e8ff..4e85d9ccb110d4879039e4962380061c42b86184 100644 --- a/src/test/java/org/olat/resource/OLATResourceManagerTest.java +++ b/src/test/java/org/olat/resource/OLATResourceManagerTest.java @@ -248,7 +248,6 @@ public class OLATResourceManagerTest extends OlatTestCase implements OLATResourc */ @After public void tearDown() throws Exception { JMSCodePointServerJunitHelper.stopServer(); - DBFactory.getInstance().closeSession(); } diff --git a/src/test/java/org/olat/resource/accesscontrol/ACOrderManagerTest.java b/src/test/java/org/olat/resource/accesscontrol/ACOrderManagerTest.java index 39eced03619efc4c3970f76b0db0c464826a54ee..bbf5d697c2bd3e6c45876d3d2952747c18187252 100644 --- a/src/test/java/org/olat/resource/accesscontrol/ACOrderManagerTest.java +++ b/src/test/java/org/olat/resource/accesscontrol/ACOrderManagerTest.java @@ -28,7 +28,6 @@ import java.math.BigDecimal; import java.util.List; import java.util.UUID; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DB; @@ -102,11 +101,6 @@ public class ACOrderManagerTest extends OlatTestCase { } } - @After - public void tearDown() { - dbInstance.commitAndCloseSession(); - } - @Test public void testManagers() { assertNotNull(acOfferManager); diff --git a/src/test/java/org/olat/resource/accesscontrol/ACTransactionManagerTest.java b/src/test/java/org/olat/resource/accesscontrol/ACTransactionManagerTest.java index dcb04bb321117bfc7ed08d8af4212bb7678e0f3f..17ceae2de037203ac95e9ece5484fadac0c34be0 100644 --- a/src/test/java/org/olat/resource/accesscontrol/ACTransactionManagerTest.java +++ b/src/test/java/org/olat/resource/accesscontrol/ACTransactionManagerTest.java @@ -27,7 +27,6 @@ import java.util.Collections; import java.util.List; import java.util.UUID; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.persistence.DB; @@ -92,11 +91,6 @@ public class ACTransactionManagerTest extends OlatTestCase { } } - @After - public void tearDown() { - dbInstance.commitAndCloseSession(); - } - @Test public void testManagers() { assertNotNull(acOfferManager); diff --git a/src/test/java/org/olat/restapi/CatalogTest.java b/src/test/java/org/olat/restapi/CatalogTest.java index 7de4baf7ff31329c27fda60506bf154e240efb88..9f33e1d515cbf82b4ba9b72d2c3f2663a08f9a47 100644 --- a/src/test/java/org/olat/restapi/CatalogTest.java +++ b/src/test/java/org/olat/restapi/CatalogTest.java @@ -48,7 +48,6 @@ import org.apache.http.client.methods.HttpPut; import org.apache.http.message.BasicNameValuePair; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; @@ -148,12 +147,7 @@ public class CatalogTest extends OlatJerseyTestCase { DBFactory.getInstance().intermediateCommit(); } - - @After - public void tearDown() throws Exception { - DBFactory.getInstance().closeSession(); - } - + @Test public void testGetRoots() throws IOException, URISyntaxException { RestConnection conn = new RestConnection(); diff --git a/src/test/java/org/olat/restapi/CourseGroupMgmtTest.java b/src/test/java/org/olat/restapi/CourseGroupMgmtTest.java index 2428751ec16002182851b76595a92b0545a62913..8e571120d3526669074c0d8857a0891e41e5e22c 100644 --- a/src/test/java/org/olat/restapi/CourseGroupMgmtTest.java +++ b/src/test/java/org/olat/restapi/CourseGroupMgmtTest.java @@ -55,7 +55,6 @@ import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.OLog; @@ -149,7 +148,6 @@ public class CourseGroupMgmtTest extends OlatJerseyTestCase { if(conn != null) { conn.shutdown(); } - DBFactory.getInstance().closeSession(); } catch (Exception e) { log.error("Exception in tearDown(): " + e); throw e; diff --git a/src/test/java/org/olat/restapi/GroupMgmtTest.java b/src/test/java/org/olat/restapi/GroupMgmtTest.java index 7c298500fd1acbfbbbfc0669aefc48379fe5b55b..6bb98378e8e5565fb7af55ececd922c7ef86969d 100644 --- a/src/test/java/org/olat/restapi/GroupMgmtTest.java +++ b/src/test/java/org/olat/restapi/GroupMgmtTest.java @@ -253,7 +253,6 @@ public class GroupMgmtTest extends OlatJerseyTestCase { if(conn != null) { conn.shutdown(); } - DBFactory.getInstance().closeSession(); } catch (Exception e) { log.error("Exception in tearDown(): " + e); e.printStackTrace(); diff --git a/src/test/java/org/olat/restapi/RepositoryEntriesTest.java b/src/test/java/org/olat/restapi/RepositoryEntriesTest.java index e3f4017a492cae0e8a869fb38bf6eb2da17e155e..c735321dd733533c06a2789c19217a79e3c7f6fb 100644 --- a/src/test/java/org/olat/restapi/RepositoryEntriesTest.java +++ b/src/test/java/org/olat/restapi/RepositoryEntriesTest.java @@ -53,7 +53,6 @@ import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.util.EntityUtils; -import org.apache.log4j.Logger; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; import org.junit.Assert; @@ -64,6 +63,8 @@ import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.id.Roles; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; @@ -82,6 +83,8 @@ import org.springframework.beans.factory.annotation.Autowired; * @author srosse, stephane.rosse@frentix.com, http: */ public class RepositoryEntriesTest extends OlatJerseyTestCase { + + private static final OLog log = Tracing.createLoggerFor(RepositoryEntriesTest.class); @Autowired private BaseSecurity securityManager; @@ -307,7 +310,6 @@ public class RepositoryEntriesTest extends OlatJerseyTestCase { @Test public void testImportTest() throws IOException, URISyntaxException { - Logger log = Logger.getLogger(getClass().getName()); URL cpUrl = RepositoryEntriesTest.class.getResource("qti-demo.zip"); assertNotNull(cpUrl); File cp = new File(cpUrl.toURI()); @@ -344,7 +346,6 @@ public class RepositoryEntriesTest extends OlatJerseyTestCase { @Test public void testImportQuestionnaire() throws IOException, URISyntaxException { - Logger log = Logger.getLogger(getClass().getName()); URL cpUrl = RepositoryEntriesTest.class.getResource("questionnaire-demo.zip"); assertNotNull(cpUrl); File cp = new File(cpUrl.toURI()); @@ -381,7 +382,6 @@ public class RepositoryEntriesTest extends OlatJerseyTestCase { @Test public void testImportWiki() throws IOException, URISyntaxException { - Logger log = Logger.getLogger(getClass().getName()); URL cpUrl = RepositoryEntriesTest.class.getResource("wiki-demo.zip"); assertNotNull(cpUrl); File cp = new File(cpUrl.toURI()); @@ -417,7 +417,6 @@ public class RepositoryEntriesTest extends OlatJerseyTestCase { @Test public void testImportBlog() throws IOException, URISyntaxException { - Logger log = Logger.getLogger(getClass().getName()); URL cpUrl = RepositoryEntriesTest.class.getResource("blog-demo.zip"); assertNotNull(cpUrl); File cp = new File(cpUrl.toURI()); diff --git a/src/test/java/org/olat/restapi/UserMgmtTest.java b/src/test/java/org/olat/restapi/UserMgmtTest.java index 50108dddff3e64b89efe419172b3bd8ab7fdca7b..5935a2aeda3e284abbb4a5cfb5510ede4164e097 100644 --- a/src/test/java/org/olat/restapi/UserMgmtTest.java +++ b/src/test/java/org/olat/restapi/UserMgmtTest.java @@ -60,7 +60,6 @@ import org.apache.http.client.methods.HttpPut; import org.apache.http.util.EntityUtils; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.BaseSecurity; @@ -279,16 +278,6 @@ public class UserMgmtTest extends OlatJerseyTestCase { dbInstance.commitAndCloseSession(); setuped = true; } - - @After - public void tearDown() throws Exception { - try { - dbInstance.closeSession(); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } @Test public void testGetUsers() throws IOException, URISyntaxException { diff --git a/src/test/java/org/olat/search/service/document/file/FileDocumentFactoryTest.java b/src/test/java/org/olat/search/service/document/file/FileDocumentFactoryTest.java index 7e88352a487794d9c5c0462636ef2f11eed66770..8ef724ff0be53d72a7f492df30e6158cd46ba9f9 100644 --- a/src/test/java/org/olat/search/service/document/file/FileDocumentFactoryTest.java +++ b/src/test/java/org/olat/search/service/document/file/FileDocumentFactoryTest.java @@ -35,15 +35,11 @@ import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; -import org.apache.log4j.Logger; import org.apache.lucene.document.Document; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.core.commons.modules.bc.vfs.OlatNamedContainerImpl; import org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl; -import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.DBFactory; import org.olat.core.util.FileUtils; import org.olat.core.util.resource.OresHelper; import org.olat.core.util.vfs.LocalFileImpl; @@ -59,7 +55,6 @@ import org.springframework.beans.factory.annotation.Autowired; */ public class FileDocumentFactoryTest extends OlatTestCase { - private static Logger log = Logger.getLogger(FileDocumentFactoryTest.class.getName()); // variables for test fixture @Autowired @@ -69,23 +64,11 @@ public class FileDocumentFactoryTest extends OlatTestCase { /** * @see junit.framework.TestCase#setUp() */ - @Before public void setup()throws Exception { + @Before + public void setup()throws Exception { //clear database from errors rootPath = "/search_junit_test_folder"; } - - /** - * TearDown is called after each test - */ - @After public void tearDown() { - try { - DB db = DBFactory.getInstance(); - db.closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - } - } - @Test public void testIsFileSupported() { assertTrue("html must be supported", fileDocumentFactory.isFileSupported(new LocalFileImpl(new File("test.html")))); diff --git a/src/test/java/org/olat/test/AllTestsJunit4.java b/src/test/java/org/olat/test/AllTestsJunit4.java index ab4c0ef7f16d026eb30d7df5be88039d895e38e0..7235870dcb111167c92d0d9a3a765b8787b4a0da 100644 --- a/src/test/java/org/olat/test/AllTestsJunit4.java +++ b/src/test/java/org/olat/test/AllTestsJunit4.java @@ -120,7 +120,6 @@ import org.junit.runners.Suite; org.olat.search.service.document.file.FileDocumentFactoryTest.class, org.olat.search.service.document.file.PDFDocumentTest.class, org.olat.search.service.document.file.OfficeDocumentTest.class, - org.olat.catalog.CatalogManagerTest.class,//ok org.olat.notifications.NotificationsManagerTest.class,//fail org.olat.registration.RegistrationManagerTest.class,//ok org.olat.course.nodes.projectbroker.ProjectBrokerManagerTest.class, diff --git a/src/test/java/org/olat/user/EmailCheckPerformanceTest.java b/src/test/java/org/olat/user/EmailCheckPerformanceTest.java index ef181f9be2e9688581ee52240e05f8f73d371d5e..2f5423c09d9f6f4752706528558a2594ecc893bd 100644 --- a/src/test/java/org/olat/user/EmailCheckPerformanceTest.java +++ b/src/test/java/org/olat/user/EmailCheckPerformanceTest.java @@ -22,14 +22,12 @@ package org.olat.user; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.AuthHelper; import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.Constants; -import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.id.User; @@ -56,38 +54,11 @@ public class EmailCheckPerformanceTest extends OlatTestCase { /** * @see junit.framework.TestCase#setUp() */ - @Before public void setup()throws Exception { + @Before + public void setup()throws Exception { createUsers(); } - /** - * TearDown is called after each test - */ - @After public void tearDown() { - try { - DB db = DBFactory.getInstance(); - db.closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - } - } - - - -// @Test public void testExistEmailAddress() throws Exception { -// System.out.println("testExistEmailAddress..."); -// int MAX_LOOP = 100; -// long startTime = System.currentTimeMillis(); -// for (int i = 0; i<MAX_LOOP; i++) { -// boolean test = ManagerFactory.getManager().existEmailAddress("test_" + i + "@test.ti"); -// if (test == true) { -// System.out.println("TEST EMAIL EXIST 1"); -// } -// } -// long endTime = System.currentTimeMillis(); -// testExistEmailAddressTime = (endTime - startTime); -// log.info("testExistEmailAddress takes time=" + (endTime - startTime) ); -// } @Test public void testUserManger() throws Exception { System.out.println("testUserManger start..."); diff --git a/src/test/java/org/olat/user/UserPropertiesPerformanceTest.java b/src/test/java/org/olat/user/UserPropertiesPerformanceTest.java index f0d83f16e6933b1a6c1ce78b498e89b0b55fc96f..b423a999a208f49d21a4c5399464ff922eab6d43 100644 --- a/src/test/java/org/olat/user/UserPropertiesPerformanceTest.java +++ b/src/test/java/org/olat/user/UserPropertiesPerformanceTest.java @@ -27,9 +27,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.log4j.Logger; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.olat.basesecurity.AuthHelper; import org.olat.basesecurity.BaseSecurity; @@ -41,6 +38,8 @@ import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.id.User; import org.olat.core.id.UserConstants; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; import org.olat.test.OlatTestCase; @@ -58,26 +57,9 @@ import org.olat.test.OlatTestCase; */ public class UserPropertiesPerformanceTest extends OlatTestCase { - private static Logger log = Logger.getLogger(UserPropertiesPerformanceTest.class.getName()); + private static OLog log = Tracing.createLoggerFor(UserPropertiesPerformanceTest.class); - @Before - public void startup() { - System.out.println("test started "+this.getClass().getName()); - } - - /** - * TearDown is called after each test - */ - @After - public void tearDown() { - try { - DB db = DBFactory.getInstance(); - db.closeSession(); - } catch (Exception e) { - log.error("Exception in tearDown(): " + e); - } - } /** * Create 50'000 users and after each step of 10'000 perform some search