diff --git a/pom.xml b/pom.xml index ea253962106d91ac00d786b8c16b541ab6c14ef7..f2d0df642bd7c232c55b11d2a07166271f9eed99 100644 --- a/pom.xml +++ b/pom.xml @@ -1602,12 +1602,6 @@ <!-- check with mvn dependency:tree to see what other dep. get downloaded --> <dependencies> - <dependency> - <groupId>org.openolat.testutils</groupId> - <artifactId>codepoints-full</artifactId> - <version>1.0.3</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-core</artifactId> @@ -1964,11 +1958,6 @@ <artifactId>commons-lang</artifactId> <version>2.6</version> </dependency> - <dependency> - <groupId>org.openolat.testutils</groupId> - <artifactId>codepoints</artifactId> - <version>1.0.3</version> - </dependency> <dependency> <groupId>org.infinispan</groupId> <artifactId>infinispan-core</artifactId> diff --git a/src/main/java/org/olat/collaboration/CollaborationTools.java b/src/main/java/org/olat/collaboration/CollaborationTools.java index 1b7a72b9e4a6c75b66689ab3ca51df41d5cf2bed..9ecd6a96150ba08c036a46d5360ee8e722201726 100644 --- a/src/main/java/org/olat/collaboration/CollaborationTools.java +++ b/src/main/java/org/olat/collaboration/CollaborationTools.java @@ -109,7 +109,6 @@ import org.olat.properties.NarrowedPropertyManager; import org.olat.properties.Property; import org.olat.properties.PropertyManager; import org.olat.repository.RepositoryEntry; -import org.olat.testutils.codepoints.server.Codepoint; /** * Description:<BR> @@ -253,7 +252,6 @@ public class CollaborationTools implements Serializable { */ public Controller createForumController(UserRequest ureq, WindowControl wControl, boolean isAdmin, boolean isGuestOnly, final SubscriptionContext subsContext) { - Codepoint.codepoint(CollaborationTools.class, "createForumController-init"); final boolean isAdm = isAdmin; final boolean isGuest = isGuestOnly; @@ -303,13 +301,10 @@ public class CollaborationTools implements Serializable { // TODO: is there a nicer solution without setting an instance variable //final List<Forum> forumHolder = new ArrayList<Forum>(); - Codepoint.codepoint(CollaborationTools.class, "pre_sync_enter"); //TODO gsync Forum forum = coordinatorManager.getCoordinator().getSyncer().doInSync(ores, new SyncerCallback<Forum>(){ public Forum execute() { - Codepoint.codepoint(CollaborationTools.class, "sync_enter"); - //was: synchronized (CollaborationTools.class) { Forum aforum; Long forumKey; @@ -335,7 +330,6 @@ public class CollaborationTools implements Serializable { + ores.getResourceableTypeName() + "/" + ores.getResourceableId()); } } - Codepoint.codepoint(CollaborationTools.class, "sync_exit"); return aforum; }}); return forum; diff --git a/src/main/java/org/olat/commons/coordinate/cluster/ClusterSyncer.java b/src/main/java/org/olat/commons/coordinate/cluster/ClusterSyncer.java index b3edea15070c6914ba9a9d6abdec725fdf9522f4..5a9f3d86e121822293e5703b89b484560820c173 100644 --- a/src/main/java/org/olat/commons/coordinate/cluster/ClusterSyncer.java +++ b/src/main/java/org/olat/commons/coordinate/cluster/ClusterSyncer.java @@ -35,7 +35,6 @@ import org.olat.core.util.coordinate.SyncerExecutor; import org.olat.core.util.coordinate.util.DerivedStringSyncer; import org.olat.core.util.resource.OresHelper; import org.olat.resource.lock.pessimistic.PessimisticLockManager; -import org.olat.testutils.codepoints.server.Codepoint; /** * Description:<br> @@ -68,7 +67,6 @@ public class ClusterSyncer implements Syncer { * @see org.olat.core.util.coordinate.Syncer#doInSync(org.olat.core.id.OLATResourceable, org.olat.core.util.coordinate.SyncerCallback) */ public <T> T doInSync(OLATResourceable ores, SyncerCallback<T> callback) { - Codepoint.hierarchicalCodepoint(ClusterSyncer.class, "doInSync-before-sync", 3); getData().setSyncObject(ores);// Store ores-object for assertAlreadyDoInSyncFor(ores) String asset = OresHelper.createStringRepresenting(ores); @@ -92,7 +90,6 @@ public class ClusterSyncer implements Syncer { // until the transaction is committed or rollbacked try { getPessimisticLockManager().findOrPersistPLock(asset); - Codepoint.hierarchicalCodepoint(ClusterSyncer.class, "doInSync-in-sync",3 ); // now execute the task, which may or may not contain further db queries. res = callback.execute(); @@ -121,7 +118,6 @@ public class ClusterSyncer implements Syncer { log.warn("execution time exceeded limit of "+executionTimeThreshold+": "+(stop-start), new AssertException("generate stacktrace")); } } - Codepoint.hierarchicalCodepoint(ClusterSyncer.class, "doInSync-after-sync",3); return res; } diff --git a/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_activemq.xml b/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_activemq.xml index 768043a7ba509e14135a658612a3dae7974b4868..c6a55f926e5121ffe42cec21b61b93af738dab1b 100644 --- a/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_activemq.xml +++ b/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_activemq.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="sysbus.topic" class="org.apache.activemq.command.ActiveMQTopic"> <constructor-arg value="olat/${instance.id}/sysbus" /> @@ -13,13 +13,4 @@ <property name="brokerURL" value="${jms.broker.url}" /> </bean> - <bean id="org.olat.core.util.codepoint.CodepointServer" - class="org.olat.testutils.codepoints.server.impl.JMSCodepointServer" - destroy-method="close" init-method="springInit"> - <constructor-arg value="${codepoint_server.enabled}" - type="boolean" index="0" /> <!-- whether or not the codepoint server is enabled --> - <property name="brokerUrl" value="${codepoint.jms.broker.url}" /><!-- e.g.: tcp://localhost:61616 --> - <property name="uniqueNodeId" value="${instance.id}-${node.id}" /><!-- the unique id of the codepoint server --> - </bean> - </beans> \ No newline at end of file diff --git a/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_jndi.xml b/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_jndi.xml index 89da4350ae8b52fb59f7a545d0e5cbe19287becd..975a4d2f03177fc839b3ff8ed442c4d65143cf3f 100644 --- a/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_jndi.xml +++ b/src/main/java/org/olat/commons/coordinate/cluster/_spring/coordinate_jms_jndi.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> + http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="sysbus.topic" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true"> <property name="jndiName"><value>${sysbus.broker.jndi}</value></property> @@ -12,15 +12,5 @@ <bean name="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true"> <property name="jndiName"><value>${jms.broker.jndi}</value></property> </bean> - - <!-- Only for testing --> - <bean id="org.olat.core.util.codepoint.CodepointServer" - class="org.olat.testutils.codepoints.server.impl.JMSCodepointServer" - destroy-method="close" init-method="springInit"> - <constructor-arg value="false" - type="boolean" index="0" /><!-- ${codepoint_server.enabled} whether or not the codepoint server is enabled --> - <property name="brokerUrl" value="${codepoint.jms.broker.url}" /><!-- e.g.: tcp://localhost:61616 --> - <property name="uniqueNodeId" value="${instance.id}-${node.id}" /><!-- the unique id of the codepoint server --> - </bean> </beans> \ No newline at end of file diff --git a/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java b/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java index 78b508dfefecacc63a91f5765daabd68ea7b3847..ae77058bae85a07de02dbd08c20a33ffdd5a9c9c 100644 --- a/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java +++ b/src/main/java/org/olat/commons/coordinate/cluster/jms/ClusterAdminControllerCluster.java @@ -212,10 +212,10 @@ public class ClusterAdminControllerCluster extends BasicController { void updatePerfInfos() { // collect performance information - List<PerfItem> li = PerformanceMonitorHelper.getPerfItems(); - li.addAll(clusBus.getPerfItems()); - perfInfoVc.contextPut("perfs", li); - if (PerformanceMonitorHelper.isStarted()) { + + boolean started = true; + perfInfoVc.contextPut("perfs", null); + if (started) { perfInfoVc.contextPut("started", "started"); } else { perfInfoVc.contextPut("started", "notstarted"); @@ -319,14 +319,9 @@ public class ClusterAdminControllerCluster extends BasicController { } } } else if (source == toggleStartStop) { - if (!PerformanceMonitorHelper.toggleStartStop()) { - getWindowControl().setInfo("Could not start PerformanceMonitor. CodepointServer not enabled in VM?"); - } else { - clusBus.resetStats(); - updatePerfInfos(); - } + clusBus.resetStats(); + updatePerfInfos(); } else if (source == resetStats) { - PerformanceMonitorHelper.resetStats(); clusBus.resetStats(); updatePerfInfos(); } diff --git a/src/main/java/org/olat/commons/coordinate/cluster/jms/PerformanceMonitorHelper.java b/src/main/java/org/olat/commons/coordinate/cluster/jms/PerformanceMonitorHelper.java deleted file mode 100644 index 7cbfde4374816ec0d4b1fa796f7bbab7c5920afd..0000000000000000000000000000000000000000 --- a/src/main/java/org/olat/commons/coordinate/cluster/jms/PerformanceMonitorHelper.java +++ /dev/null @@ -1,169 +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. -*/ -package org.olat.commons.coordinate.cluster.jms; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; - -import org.olat.testutils.codepoints.client.CodepointClient; -import org.olat.testutils.codepoints.client.CommunicationException; -import org.olat.testutils.codepoints.client.Probe; -import org.olat.testutils.codepoints.client.StatId; -import org.olat.testutils.codepoints.server.Codepoint; - -public class PerformanceMonitorHelper { - - private static boolean isStarted_ = false; - - private static CodepointClient codepointClient = null; - - private static Map<String,Probe> probes_ = new HashMap<String,Probe>(); - - public static synchronized boolean isStarted() { - return isStarted_; - } - - public static synchronized List<PerfItem> getPerfItems() { - if (!isStarted_ || (codepointClient==null)) { - return new LinkedList<PerfItem>(); - } - List<PerfItem> ll = new LinkedList<PerfItem>(); - try { - ll.add(new PerfItem( - "DBImpl session initialize initialize", 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - codepointClient.getCodepoint("org.olat.core.commons.persistence.DBImpl.initializeSession").getHitCount())); - ll.add(new PerfItem( - "DBImpl session initialize close", 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - codepointClient.getCodepoint("org.olat.core.commons.persistence.DBImpl.closeSession").getHitCount())); - ll.add(new PerfItem( - "ClusterCacher received event", 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - codepointClient.getCodepoint("org.olat.core.util.cache.n.impl.cluster.ClusterCacher.event").getHitCount())); - ll.add(new PerfItem( - "ClusterCacher invalidate cache entry", 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - codepointClient.getCodepoint("org.olat.core.util.cache.n.impl.cluster.ClusterCacher.invalidateKeys").getHitCount())); - ll.add(new PerfItem( - "ClusterCacher send 'invalidate cache entry' event", 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - codepointClient.getCodepoint("org.olat.core.util.cache.n.impl.cluster.ClusterCacher.sendChangedKeys").getHitCount())); - - Set<Entry<String, Probe>> s = probes_.entrySet(); - for (Iterator<Entry<String, Probe>> it = s.iterator(); it.hasNext();) { - Entry<String, Probe> entry = it.next(); - Probe p = entry.getValue(); - ll.add( - new PerfItem( - entry.getKey(), - p.getStatValue(StatId.MIN_TIME_ELAPSED), - p.getStatValue(StatId.MAX_TIME_ELAPSED), - p.getStatValue(StatId.LAST_TIME_ELAPSED), - p.getStatValue(StatId.TOTAL_AVERAGE_TIME_ELAPSED), - p.getStatValue(StatId.LAST_10MEASUREMENT_AVERAGE_TIME_ELAPSED), - p.getStatValue(StatId.LAST_100MEASUREMENT_AVERAGE_TIME_ELAPSED), - p.getStatValue(StatId.LAST_1000MEASUREMENT_AVERAGE_TIME_ELAPSED), - p.getStatValue(StatId.TOTAL_FREQUENCY), - p.getStatValue(StatId.LAST_10_FREQUENCY), - p.getStatValue(StatId.LAST_100_FREQUENCY), - p.getStatValue(StatId.LAST_1000_FREQUENCY), - p.getStart().getHitCount())); - } - } catch (CommunicationException e) { - ll.add(new PerfItem("Codepoint problem - no stats available there", -1,-1,-1,-1,-1, -1, -1, -1, -1, -1, -1, -1 )); - } - return ll; - } - - public static synchronized boolean toggleStartStop() { - if (isStarted_) { - // then stop - isStarted_ = false; - for (Iterator<Probe> it = probes_.values().iterator(); it - .hasNext();) { - Probe p = it.next(); - try{ - p.close(); - } catch(CommunicationException e) { - // ignore - } - } - probes_.clear(); - codepointClient.close(); - codepointClient = null; - return true; - } else { - // then start - isStarted_ = true; - try{ - codepointClient = Codepoint.getLocalLoopCodepointClient(); - } catch(RuntimeException re) { - isStarted_ = false; - return false; - } - try { - codepointClient.setAllHitCounts(0); - probes_.put("ClusterSyncer.doInSync", - codepointClient.startProbingBetween( - "org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync-before-sync.org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync", - "org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync-in-sync.org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync")); - probes_.put("DBImpl session initialize->close", - codepointClient.startProbingBetween( - "org.olat.core.commons.persistence.DBImpl.initializeSession", - "org.olat.core.commons.persistence.DBImpl.closeSession")); - probes_.put("DispatcherAction.execute", - codepointClient.startProbingBetween( - "org.olat.core.dispatcher.DispatcherAction.execute-start", - "org.olat.core.dispatcher.DispatcherAction.execute-end")); - probes_.put("DBQueryImpl.list", - codepointClient.startProbingBetween( - "org.olat.core.commons.persistence.DBQueryImpl.list-entry", - "org.olat.core.commons.persistence.DBQueryImpl.list-exit")); - } catch (CommunicationException e) { - // ignore ? - } - return true; - } - } - - public static synchronized void resetStats() { - if (!isStarted_) { - return; - } - Set<Entry<String, Probe>> s = probes_.entrySet(); - for (Iterator<Entry<String, Probe>> it = s.iterator(); it.hasNext();) { - Entry<String, Probe> entry = it.next(); - try { - entry.getValue().clearStats(); - entry.getValue().getStart().setHitCount(0); - entry.getValue().getEnd().setHitCount(0); - } catch (CommunicationException e) { - // well, ignore - } - } - - } -} diff --git a/src/main/java/org/olat/core/commons/persistence/DBQueryImpl.java b/src/main/java/org/olat/core/commons/persistence/DBQueryImpl.java index e7bdd506c886fd69e586bc9184019ca244076d7c..8f5c2d4b8190b9a30b553e4075c3660bfff6d7e0 100644 --- a/src/main/java/org/olat/core/commons/persistence/DBQueryImpl.java +++ b/src/main/java/org/olat/core/commons/persistence/DBQueryImpl.java @@ -48,7 +48,6 @@ import org.hibernate.type.Type; import org.olat.core.logging.DBRuntimeException; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; -import org.olat.testutils.codepoints.server.Codepoint; /** * A <b>DBQueryImpl</b> is a wrapper around a Hibernate Query object. * @@ -119,7 +118,6 @@ public class DBQueryImpl implements DBQuery { * @see org.olat.core.commons.persistence.DBQuery#list() */ public List list() { - Codepoint.codepoint(getClass(), "list-entry"); final long startTime = System.currentTimeMillis(); try{ boolean doLog = log.isDebug(); @@ -181,8 +179,6 @@ public class DBQueryImpl implements DBQuery { catch (HibernateException he) { String msg ="Error in list()" ; throw new DBRuntimeException(msg, he); - } finally { - Codepoint.codepoint(getClass(), "list-exit", query); } } diff --git a/src/main/java/org/olat/core/gui/components/Window.java b/src/main/java/org/olat/core/gui/components/Window.java index efea94ccef222a8fb19344054b7351dc728317c9..cc0f3fdd0e645433c03a43e076e72b0ee345918f 100644 --- a/src/main/java/org/olat/core/gui/components/Window.java +++ b/src/main/java/org/olat/core/gui/components/Window.java @@ -86,7 +86,6 @@ import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; import org.olat.core.util.component.ComponentTraverser; import org.olat.core.util.component.ComponentVisitor; -import org.olat.testutils.codepoints.server.Codepoint; /** * Description: <br> @@ -1116,7 +1115,6 @@ public class Window extends AbstractComponent { if (toDispatch) { latestDispatchComponentInfo = target.getComponentName() + " :" + target.getExtendedDebugInfo(); latestDispatchedComp = target; - Codepoint.setThreadLocalLogDetails(latestDispatchComponentInfo); // dispatch wbackofficeImpl.fireCycleEvent(Window.ABOUT_TO_DISPATCH); diff --git a/src/main/java/org/olat/course/CourseFactory.java b/src/main/java/org/olat/course/CourseFactory.java index 70a79a6a2363bcdf679039ec2a18a7d9bb745793..08212f5dcc4470557f79de0f3736c8e6801c314b 100644 --- a/src/main/java/org/olat/course/CourseFactory.java +++ b/src/main/java/org/olat/course/CourseFactory.java @@ -133,7 +133,6 @@ import org.olat.repository.model.RepositoryEntrySecurity; import org.olat.resource.OLATResource; import org.olat.resource.references.ReferenceImpl; import org.olat.resource.references.ReferenceManager; -import org.olat.testutils.codepoints.server.Codepoint; import org.olat.user.UserManager; import org.olat.util.logging.activity.LoggingResourceable; @@ -427,8 +426,6 @@ public class CourseFactory extends BasicManager { targetCourse.saveRunStructure(); targetCourse.setEditorTreeModel((CourseEditorTreeModel) XStreamHelper.xstreamClone(sourceCourse.getEditorTreeModel())); targetCourse.saveEditorTreeModel(); - - Codepoint.codepoint(CourseFactory.class, "copyCourseAfterSaveTreeModel"); // copy course folder File fSourceCourseFolder = sourceCourse.getIsolatedCourseFolder().getBasefile(); diff --git a/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java b/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java index de7072196c16908b422d3fe90e7328ed207f6bb1..c928c588dc0f470e91183505f584e0f4dd8a43c6 100644 --- a/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java +++ b/src/main/java/org/olat/course/assessment/NewCachePersistingAssessmentManager.java @@ -61,7 +61,6 @@ import org.olat.course.properties.CoursePropertyManager; import org.olat.course.run.scoring.ScoreEvaluation; import org.olat.course.run.userview.UserCourseEnvironment; import org.olat.properties.Property; -import org.olat.testutils.codepoints.server.Codepoint; import org.olat.util.logging.activity.LoggingResourceable; @@ -862,12 +861,9 @@ public class NewCachePersistingAssessmentManager extends BasicManager implements // -: many entries (num of courses * visitors of given course) in the locktable. // we could also sync on the assessedIdentity. - Codepoint.codepoint(NewCachePersistingAssessmentManager.class, "beforeSyncUpdateUserEfficiencyStatement"); Long attempts = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(createOLATResourceableForLocking(assessedIdentity), new SyncerCallback<Long>(){ public Long execute() { Long attempts = null; - Codepoint.codepoint(NewCachePersistingAssessmentManager.class, "doInSyncUpdateUserEfficiencyStatement"); - log.debug("codepoint reached: doInSyncUpdateUserEfficiencyStatement by identity: " + identity.getName()); saveNodeScore(courseNode, assessedIdentity, scoreEvaluation.getScore(), cpm); saveNodePassed(courseNode, assessedIdentity, scoreEvaluation.getPassed(), cpm); saveAssessmentID(courseNode, assessedIdentity, scoreEvaluation.getAssessmentID(), cpm); @@ -882,10 +878,6 @@ public class NewCachePersistingAssessmentManager extends BasicManager implements } return attempts; }}); - // here used to be a codepoint which lead to error (OLAT-3570) in AssessmentWithCodepointsTest. - // The reason for this error was that the AuditManager appendToUserNodeLog() is not synchronized, so could be called by several threads simultaneously. - // The end effect of this error is data inconsistency: the score/passed info is stored but the userNodeLog info is not updated and the AssessmentChangedEvent is not fired. - // This case is very seldom, but could be avoided if the test could be protected by a lock. // node log @@ -900,8 +892,6 @@ public class NewCachePersistingAssessmentManager extends BasicManager implements am.appendToUserNodeLog(courseNode, assessedIdentity, assessedIdentity, ASSESSMENT_ID + " set to: " + scoreEvaluation.getAssessmentID().toString()); } - Codepoint.codepoint(NewCachePersistingAssessmentManager.class, "afterSyncUpdateUserEfficiencyStatement"); - log.debug("codepoint reached: afterSyncUpdateUserEfficiencyStatement by identity: " + identity.getName()); // notify about changes AssessmentChangedEvent ace = new AssessmentChangedEvent(AssessmentChangedEvent.TYPE_SCORE_EVAL_CHANGED, assessedIdentity); CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(ace, course); @@ -943,8 +933,6 @@ public class NewCachePersistingAssessmentManager extends BasicManager implements private Long saveScoreEvaluationInSync(CourseNode courseNode, Identity identity, Identity assessedIdentity, ScoreEvaluation scoreEvaluation, boolean incrementUserAttempts, final UserCourseEnvironment userCourseEnv, final CoursePropertyManager cpm) { Long attempts = null; - Codepoint.codepoint(NewCachePersistingAssessmentManager.class, "doInSyncUpdateUserEfficiencyStatement"); - log.debug("codepoint reached: doInSyncUpdateUserEfficiencyStatement by identity: " + identity.getName()); saveNodeScore(courseNode, assessedIdentity, scoreEvaluation.getScore(), cpm); log.debug("successfully saved node score : " + scoreEvaluation.getScore()); saveNodePassed(courseNode, assessedIdentity, scoreEvaluation.getPassed(), cpm); diff --git a/src/main/java/org/olat/course/nodes/FOCourseNode.java b/src/main/java/org/olat/course/nodes/FOCourseNode.java index 4322de25a086ae29791e0957b4607dfe53cdecc0..e5219f840819e189430c2356f31e874cd951346a 100644 --- a/src/main/java/org/olat/course/nodes/FOCourseNode.java +++ b/src/main/java/org/olat/course/nodes/FOCourseNode.java @@ -76,7 +76,6 @@ import org.olat.modules.fo.archiver.ForumArchiveManager; import org.olat.modules.fo.archiver.formatters.ForumStreamedRTFFormatter; import org.olat.properties.Property; import org.olat.repository.RepositoryEntry; -import org.olat.testutils.codepoints.server.Codepoint; /** * Initial Date: Feb 9, 2004 @@ -162,8 +161,7 @@ public class FOCourseNode extends AbstractAccessableCourseNode { final CoursePropertyManager cpm = courseEnv.getCoursePropertyManager(); final CourseNode thisCourseNode = this; Forum theForum = null; - - Codepoint.codepoint(FOCourseNode.class, "findCourseNodeProperty"); + Property forumKeyProp = cpm.findCourseNodeProperty(thisCourseNode, null, null, FORUM_KEY); //System.out.println("System.out.println - findCourseNodeProperty"); if(forumKeyProp!=null) { @@ -176,15 +174,11 @@ public class FOCourseNode extends AbstractAccessableCourseNode { } else { //creates resourceable from FOCourseNode.class and the current node id as key OLATResourceable courseNodeResourceable = OresHelper.createOLATResourceableInstance(FOCourseNode.class, new Long(this.getIdent())); - Codepoint.codepoint(FOCourseNode.class, "beforeDoInSync"); - //System.out.println("System.out.println - beforeDoInSync"); //o_clusterOK by:ld theForum = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(courseNodeResourceable, new SyncerCallback<Forum>(){ public Forum execute() { Forum forum = null; - Long forumKey; - Codepoint.codepoint(FOCourseNode.class,"doInSync"); - //System.out.println("Codepoint - doInSync"); + Long forumKey; Property forumKeyProperty = cpm.findCourseNodeProperty(thisCourseNode, null, null, FORUM_KEY); if (forumKeyProperty == null) { // First call of forum, create new forum and save forum key as property diff --git a/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectBrokerManagerImpl.java b/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectBrokerManagerImpl.java index a3662fa93c380e26f85bc1be64fef8847504f9be..288e73e2854b73064219d62ee795a1b092bac06b 100644 --- a/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectBrokerManagerImpl.java +++ b/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectBrokerManagerImpl.java @@ -68,7 +68,6 @@ import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; import org.olat.group.manager.BusinessGroupRelationDAO; import org.olat.properties.Property; -import org.olat.testutils.codepoints.server.Codepoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -171,7 +170,6 @@ public class ProjectBrokerManagerImpl extends BasicManager implements ProjectBro public boolean enrollProjectParticipant(final Identity identity, final Project project, final ProjectBrokerModuleConfiguration moduleConfig, final int nbrSelectedProjects, final boolean isParticipantInAnyProject) { OLATResourceable projectOres = OresHelper.createOLATResourceableInstance(Project.class, project.getKey()); logDebug("enrollProjectParticipant: start identity=" + identity + " project=" + project); - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync"); Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectOres, new SyncerCallback<Boolean>(){ public Boolean execute() { if ( existsProject( project.getKey() ) ) { @@ -209,13 +207,11 @@ public class ProjectBrokerManagerImpl extends BasicManager implements ProjectBro } } });// end of doInSync - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync"); return result.booleanValue(); } public boolean cancelProjectEnrollmentOf(final Identity identity, final Project project, final ProjectBrokerModuleConfiguration moduleConfig) { OLATResourceable projectOres = OresHelper.createOLATResourceableInstance(Project.class, project.getKey()); - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync"); Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectOres, new SyncerCallback<Boolean>(){ public Boolean execute() { if ( existsProject( project.getKey() ) ) { @@ -243,7 +239,6 @@ public class ProjectBrokerManagerImpl extends BasicManager implements ProjectBro } } });// end of doInSync - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync"); return result.booleanValue(); } diff --git a/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java b/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java index 0746611c2cae92cf28eeecb4000ccc00ab47c29b..3ee54b84107d475546c57266fc98f504cfec2a9c 100644 --- a/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java +++ b/src/main/java/org/olat/course/nodes/projectbroker/service/ProjectGroupManagerImpl.java @@ -54,7 +54,6 @@ import org.olat.properties.Property; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; -import org.olat.testutils.codepoints.server.Codepoint; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -219,7 +218,6 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou } public List<Identity> addCandidates(final List<Identity> addIdentities, final Project project) { - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync"); //TODO gsync List<Identity> addedIdentities = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<List<Identity>>(){ public List<Identity> execute() { @@ -235,12 +233,10 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou return addedIdentities; } });// end of doInSync - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync"); return addedIdentities; } public void removeCandidates(final List<Identity> addIdentities, final Project project) { - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync"); //TODO gsync CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(project.getProjectGroup(), new SyncerCallback<Boolean>(){ public Boolean execute() { @@ -253,11 +249,10 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou return Boolean.TRUE; } });// end of doInSync - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync"); } + @Override public BusinessGroupAddResponse acceptCandidates(final List<Identity> identities, final Project project, final Identity actionIdentity, final boolean autoSignOut, final boolean isAcceptSelectionManually) { - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "beforeDoInSync"); final Project reloadedProject = (Project) dbInstance.loadObject(project, true); final BusinessGroupAddResponse response = new BusinessGroupAddResponse(); final BusinessGroupService bgs = businessGroupService; @@ -285,8 +280,6 @@ public class ProjectGroupManagerImpl extends BasicManager implements ProjectGrou projectBrokerManager.setProjectState(reloadedProject, Project.STATE_ASSIGNED); logInfo("ProjectBroker: Accept candidate, change project-state=" + Project.STATE_ASSIGNED); } - - Codepoint.codepoint(ProjectBrokerManagerImpl.class, "afterDoInSync"); return response; } diff --git a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java index f3e619feac15115424c4e3030f64463e630c18da..ba908b6c984e2ee1a867df457622878614467b15 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java @@ -111,7 +111,6 @@ import org.olat.repository.model.SearchRepositoryEntryParameters; import org.olat.resource.OLATResource; import org.olat.resource.accesscontrol.manager.ACReservationDAO; import org.olat.resource.accesscontrol.model.ResourceReservation; -import org.olat.testutils.codepoints.server.Codepoint; import org.olat.user.UserDataDeletable; import org.olat.util.logging.activity.LoggingResourceable; import org.springframework.beans.factory.annotation.Autowired; @@ -758,8 +757,6 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD @Override public MailerResult deleteBusinessGroupWithMail(BusinessGroup businessGroupTodelete, String businessPath, Identity deletedBy, Locale locale) { - Codepoint.codepoint(this.getClass(), "deleteBusinessGroupWithMail"); - List<Identity> users = businessGroupRelationDAO.getMembers(businessGroupTodelete); // now delete the group first deleteBusinessGroup(businessGroupTodelete); diff --git a/src/main/java/org/olat/group/ui/NewAreaController.java b/src/main/java/org/olat/group/ui/NewAreaController.java index 08a3d62a1c1985cf7e16a842fc0791489e81b297..a7a15bd2bf44af4ccbea8e830d17998939b2586d 100644 --- a/src/main/java/org/olat/group/ui/NewAreaController.java +++ b/src/main/java/org/olat/group/ui/NewAreaController.java @@ -43,7 +43,6 @@ import org.olat.group.area.BGArea; import org.olat.group.area.BGAreaManager; import org.olat.group.ui.area.BGAreaFormController; import org.olat.resource.OLATResource; -import org.olat.testutils.codepoints.server.Codepoint; import org.olat.util.logging.activity.LoggingResourceable; /** @@ -128,7 +127,6 @@ public class NewAreaController extends BasicController { allNames.add(this.areaCreateController.getAreaName()); } - Codepoint.codepoint(this.getClass(), "createArea"); // create bulkgroups only if there is no name which already exists. newAreas = new HashSet<BGArea>(); newAreaNames = new HashSet<String>(); diff --git a/src/main/resources/serviceconfig/olat.properties b/src/main/resources/serviceconfig/olat.properties index 6383a880e6fd30b34a6e5387d107756872c57a38..c9d23697a23bdc76384aa2238baa2ae257afddcf 100644 --- a/src/main/resources/serviceconfig/olat.properties +++ b/src/main/resources/serviceconfig/olat.properties @@ -716,11 +716,9 @@ cluster.singleton.services = enabled jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false index.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false # Cluster (remote) jms.broker.url #jms.broker.url=failover:(tcp://localhost:61616?wireFormat.maxInactivityDuration=0) #search.broker.url=failover:(tcp://localhost:61616?wireFormat.maxInactivityDuration=0) -#codepoint.jms.broker.url=failover:(tcp://localhost:61616?wireFormat.maxInactivityDuration=0) #if you use the jndi connection jms.broker.jndi=OpenOLATConnectionFactory @@ -729,10 +727,6 @@ search.broker.jndi=queue/searchQueue index.broker.jndi=queue/indexQueue exam.broker.jndi=queue/examQueue - -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=false - ##### #query cache config for singlevm/cluster ##### diff --git a/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java b/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java index b3d95718157facdebeaa793642304fbdc8bad53a..a2dd21a141d175ee0fb0721c42eaf0c07c98c2bf 100644 --- a/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java +++ b/src/test/java/org/olat/commons/calendar/ICalFileCalendarManagerTest.java @@ -39,8 +39,6 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.olat.commons.calendar.model.Kalendar; import org.olat.commons.calendar.model.KalendarEvent; @@ -48,29 +46,19 @@ 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; -import org.olat.testutils.codepoints.client.BreakpointStateException; -import org.olat.testutils.codepoints.client.CodepointClient; -import org.olat.testutils.codepoints.client.CodepointClientFactory; -import org.olat.testutils.codepoints.client.CodepointRef; -import org.olat.testutils.codepoints.client.CommunicationException; -import org.olat.testutils.codepoints.client.TemporaryPausedThread; -/** - * - */ -public class ICalFileCalendarManagerTest extends OlatTestCase { - - private static OLog log = Tracing.createLoggerFor(ICalFileCalendarManagerTest.class); - private static String CODEPOINT_SERVER_ID = "ICalFileCalendarManagerTest"; - private static Identity test = null; +public class ICalFileCalendarManagerTest extends OlatTestCase { + private static final OLog log = Tracing.createLoggerFor(ICalFileCalendarManagerTest.class); - @Test public void testAddChangeRemoveEvent() { + @Test + public void testAddChangeRemoveEvent() { + Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ical-1-"); + String TEST_EVENT_ID = "id-testAddEvent"; CalendarManager manager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); Kalendar cal = manager.getPersonalCalendar(test).getKalendar(); @@ -108,30 +96,17 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { * Test concurrent add event with two threads and code-point to control concurrency. * */ - @Test public void testConcurrentAddEvent() { + @Test + public void testConcurrentAddEvent() { final String TEST_EVENT_ID_1 = "id-testConcurrentAddEvent-1"; final String TEST_EVENT_SUBJECT_1 = "testEvent1"; final String TEST_EVENT_ID_2 = "id-testConcurrentAddEvent-2"; final String TEST_EVENT_SUBJECT_2 = "testEvent2"; - + + final Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ical-2-"); final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); final List<Boolean> statusList = Collections.synchronizedList(new ArrayList<Boolean>(1)); - // enable breakpoint - - CodepointClient codepointClient = null; - CodepointRef codepointRef = null; - try { - codepointClient = CodepointClientFactory.createCodepointClient("vm://embedded?broker.persistent=false", CODEPOINT_SERVER_ID); - codepointRef = codepointClient.getCodepoint("org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync-in-sync.org.olat.commons.calendar.ICalFileCalendarManager.addEventTo"); - codepointRef.enableBreakpoint(); - System.out.println(); - } catch (Exception e) { - e.printStackTrace(); - fail("Could not initialzed CodepointClient"); - } - - final CountDownLatch doneSignal = new CountDownLatch(2); // thread 1 @@ -143,9 +118,9 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { Kalendar cal = calManager.getPersonalCalendar(test).getKalendar(); // 2. add Event1 => breakpoint hit - System.out.println("testConcurrentAddEvent thread1 addEvent1"); + log.info("testConcurrentAddEvent thread1 addEvent1"); calManager.addEventTo(cal, new KalendarEvent(TEST_EVENT_ID_1,TEST_EVENT_SUBJECT_1, new Date(), 1)); - System.out.println("testConcurrentAddEvent thread1 addEvent1 DONE"); + log.info("testConcurrentAddEvent thread1 addEvent1 DONE"); // 3. check event1 exist cal = calManager.getPersonalCalendar(test).getKalendar(); KalendarEvent event1 = cal.getEvent(TEST_EVENT_ID_1); @@ -159,7 +134,7 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); statusList.add(Boolean.TRUE); - System.out.println("testConcurrentAddEvent thread1 finished"); + log.info("testConcurrentAddEvent thread1 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { @@ -175,12 +150,11 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { // 1. load calendar CalendarManager calManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); Kalendar cal = calManager.getPersonalCalendar(test).getKalendar(); - // 2. sleep 1sec - sleep(1000); + // 3. add Event2 (breakpoint of thread1 blocks) - System.out.println("testConcurrentAddEvent thread2 addEvent2"); + log.info("testConcurrentAddEvent thread2 addEvent2"); calManager.addEventTo(cal, new KalendarEvent(TEST_EVENT_ID_2,TEST_EVENT_SUBJECT_2, new Date(), 1)); - System.out.println("testConcurrentAddEvent thread1 addEvent2 DONE"); + log.info("testConcurrentAddEvent thread1 addEvent2 DONE"); // 4. check event2 exist cal = calManager.getPersonalCalendar(test).getKalendar(); KalendarEvent event2 = cal.getEvent(TEST_EVENT_ID_2); @@ -192,7 +166,7 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); statusList.add(Boolean.TRUE); - System.out.println("testConcurrentAddEvent thread2 finished"); + log.info("testConcurrentAddEvent thread2 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { @@ -204,25 +178,6 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { thread1.start(); thread2.start(); - sleep(2000); - try { - // to see all registered code-points: comment-in next 2 lines - // List<CodepointRef> codepointList = codepointClient.listAllCodepoints(); - // System.out.println("codepointList=" + codepointList); - System.out.println("testConcurrentAddEvent start waiting for breakpoint reached"); - TemporaryPausedThread[] threads = codepointRef.waitForBreakpointReached(1000); - assertTrue("Did not reach breakpoint", threads.length > 0); - System.out.println("threads[0].getCodepointRef()=" + threads[0].getCodepointRef()); - codepointRef.disableBreakpoint(true); - System.out.println("testConcurrentAddEvent breakpoint reached => continue"); - } catch (BreakpointStateException e) { - e.printStackTrace(); - fail("Codepoints: BreakpointStateException=" + e.getMessage()); - } catch (CommunicationException e) { - e.printStackTrace(); - fail("Codepoints: CommunicationException=" + e.getMessage()); - } - try { boolean interrupt = doneSignal.await(10, TimeUnit.SECONDS); assertTrue("Test takes too long (more than 10s)", interrupt); @@ -232,26 +187,26 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { // if not -> they are in deadlock and the db did not detect it for (Exception exception : exceptionHolder) { - System.out.println("exception: "+exception.getMessage()); + log.info("exception: "+exception.getMessage()); exception.printStackTrace(); } assertTrue("It throws an exception in test => see sysout", exceptionHolder.isEmpty()); - codepointClient.close(); - System.out.println("testConcurrentAddEvent finish successful"); + log.info("testConcurrentAddEvent finish successful"); } /** * Test concurrent add/update event with two threads and code-point to control concurrency. * */ - @Test public void testConcurrentAddUpdateEvent() { + @Test + public void testConcurrentAddUpdateEvent() { final String TEST_EVENT_ID_1 = "id-testConcurrentAddUpdateEvent-1"; final String TEST_EVENT_SUBJECT_1 = "testEvent1"; final String TEST_EVENT_ID_2 = "id-testConcurrentAddUpdateEvent-2"; final String TEST_EVENT_SUBJECT_2 = "testEvent2"; final String TEST_EVENT_SUBJECT_2_UPDATED = "testUpdatedEvent2"; - + final Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ical-3-"); final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); final List<Boolean> statusList = Collections.synchronizedList(new ArrayList<Boolean>(1)); @@ -263,21 +218,7 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { KalendarEvent event2 = cal.getEvent(TEST_EVENT_ID_2); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_2, event2); assertEquals("Wrong calendar-event subject",event2.getSubject(), TEST_EVENT_SUBJECT_2); - System.out.println("testConcurrentAddUpdateEvent thread2 addEvent2 DONE"); - - // enable breakpoint - CodepointClient codepointClient = null; - CodepointRef codepointRef = null; - try { - codepointClient = CodepointClientFactory.createCodepointClient("vm://embedded?broker.persistent=false", CODEPOINT_SERVER_ID); - codepointRef = codepointClient.getCodepoint("org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync-in-sync.org.olat.commons.calendar.ICalFileCalendarManager.addEventTo"); - codepointRef.enableBreakpoint(); - System.out.println(); - } catch (Exception e) { - e.printStackTrace(); - fail("Could not initialzed CodepointClient"); - } - + log.info("testConcurrentAddUpdateEvent thread2 addEvent2 DONE"); final CountDownLatch doneSignal = new CountDownLatch(2); @@ -286,27 +227,27 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { public void run() { try { // 1. load calendar - CalendarManager calManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); - Kalendar cal = calManager.getPersonalCalendar(test).getKalendar(); + CalendarManager calendarManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); + Kalendar currentCalendar = calendarManager.getPersonalCalendar(test).getKalendar(); // 2. add Event1 => breakpoint hit - System.out.println("testConcurrentAddUpdateEvent thread1 addEvent1"); - calManager.addEventTo(cal, new KalendarEvent(TEST_EVENT_ID_1,TEST_EVENT_SUBJECT_1, new Date(), 1)); - System.out.println("testConcurrentAddUpdateEvent thread1 addEvent1 DONE"); + log.info("testConcurrentAddUpdateEvent thread1 addEvent1"); + calendarManager.addEventTo(currentCalendar, new KalendarEvent(TEST_EVENT_ID_1,TEST_EVENT_SUBJECT_1, new Date(), 1)); + log.info("testConcurrentAddUpdateEvent thread1 addEvent1 DONE"); // 3. check event1 exist - cal = calManager.getPersonalCalendar(test).getKalendar(); - KalendarEvent event1 = cal.getEvent(TEST_EVENT_ID_1); + currentCalendar = calendarManager.getPersonalCalendar(test).getKalendar(); + KalendarEvent event1 = currentCalendar.getEvent(TEST_EVENT_ID_1); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); // 4. sleep 2sec // 5. check event1 still exist (event2 added in meantime) - cal = calManager.getPersonalCalendar(test).getKalendar(); - event1 = cal.getEvent(TEST_EVENT_ID_1); + currentCalendar = calendarManager.getPersonalCalendar(test).getKalendar(); + event1 = currentCalendar.getEvent(TEST_EVENT_ID_1); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); statusList.add(Boolean.TRUE); - System.out.println("testConcurrentAddUpdateEvent thread1 finished"); + log.info("testConcurrentAddUpdateEvent thread1 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { @@ -319,29 +260,28 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { Thread thread2 = new Thread() { public void run() { try { - CalendarManager calManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); - Kalendar cal = calManager.getPersonalCalendar(test).getKalendar(); - // 2. sleep 1sec - sleep(1000); + CalendarManager calendarManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); + Kalendar calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + // 3. add Event2 (breakpoint of thread1 blocks) - System.out.println("testConcurrentAddUpdateEvent thread2 updateEvent2"); - calManager.updateEventFrom(cal, new KalendarEvent(TEST_EVENT_ID_2,TEST_EVENT_SUBJECT_2_UPDATED, new Date(), 1)); - System.out.println("testConcurrentAddUpdateEvent thread1 updateEvent2 DONE"); + log.info("testConcurrentAddUpdateEvent thread2 updateEvent2"); + calendarManager.updateEventFrom(calendar, new KalendarEvent(TEST_EVENT_ID_2,TEST_EVENT_SUBJECT_2_UPDATED, new Date(), 1)); + log.info("testConcurrentAddUpdateEvent thread1 updateEvent2 DONE"); // 4. check event2 exist - cal = calManager.getPersonalCalendar(test).getKalendar(); - KalendarEvent updatedEvent = cal.getEvent(TEST_EVENT_ID_2); + calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + KalendarEvent updatedEvent = calendar.getEvent(TEST_EVENT_ID_2); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_2, updatedEvent); assertEquals("Wrong calendar-event subject",updatedEvent.getSubject(), TEST_EVENT_SUBJECT_2_UPDATED); // 5. check event1 exist - cal = calManager.getPersonalCalendar(test).getKalendar(); - KalendarEvent event1 = cal.getEvent(TEST_EVENT_ID_1); + calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + KalendarEvent event1 = calendar.getEvent(TEST_EVENT_ID_1); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); // Delete Event - boolean removed = calManager.removeEventFrom(cal, new KalendarEvent(TEST_EVENT_ID_2,TEST_EVENT_SUBJECT_2_UPDATED, new Date(), 1)); + boolean removed = calendarManager.removeEventFrom(calendar, new KalendarEvent(TEST_EVENT_ID_2,TEST_EVENT_SUBJECT_2_UPDATED, new Date(), 1)); assertTrue(removed); statusList.add(Boolean.TRUE); - System.out.println("testConcurrentAddUpdateEvent thread2 finished"); + log.info("testConcurrentAddUpdateEvent thread2 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { @@ -352,25 +292,6 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { thread1.start(); thread2.start(); - sleep(2000); - - try { - // to see all registered code-points: comment-in next 2 lines - // List<CodepointRef> codepointList = codepointClient.listAllCodepoints(); - // System.out.println("codepointList=" + codepointList); - System.out.println("testConcurrentAddUpdateEvent start waiting for breakpoint reached"); - TemporaryPausedThread[] threads = codepointRef.waitForBreakpointReached(1000); - assertTrue("Did not reach breakpoint", threads.length > 0); - System.out.println("threads[0].getCodepointRef()=" + threads[0].getCodepointRef()); - codepointRef.disableBreakpoint(true); - System.out.println("testConcurrentAddUpdateEvent breakpoint reached => continue"); - } catch (BreakpointStateException e) { - e.printStackTrace(); - fail("Codepoints: BreakpointStateException=" + e.getMessage()); - } catch (CommunicationException e) { - e.printStackTrace(); - fail("Codepoints: CommunicationException=" + e.getMessage()); - } try { boolean interrupt = doneSignal.await(10, TimeUnit.SECONDS); @@ -381,26 +302,26 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { // if not -> they are in deadlock and the db did not detect it for (Exception exception : exceptionHolder) { - System.out.println("exception: "+exception.getMessage()); + log.info("exception: "+exception.getMessage()); exception.printStackTrace(); } assertTrue("It throws an exception in test => see sysout", exceptionHolder.isEmpty()); - codepointClient.close(); - System.out.println("testConcurrentAddUpdateEvent finish successful"); + log.info("testConcurrentAddUpdateEvent finish successful"); } /** * Test concurrent add/delete event with two threads and code-point to control concurrency. * */ - @Test public void testConcurrentAddRemoveEvent() { + @Test + public void testConcurrentAddRemoveEvent() { final String TEST_EVENT_ID_1 = "id-testConcurrentAddRemoveEvent-1"; final String TEST_EVENT_SUBJECT_1 = "testEvent1"; final String TEST_EVENT_ID_2 = "id-testConcurrentAddRemoveEvent-2"; final String TEST_EVENT_SUBJECT_2 = "testEvent2"; - + final Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ical-1-"); final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); final List<Boolean> statusList = Collections.synchronizedList(new ArrayList<Boolean>(1)); @@ -412,21 +333,7 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { KalendarEvent event2 = cal.getEvent(TEST_EVENT_ID_2); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_2, event2); assertEquals("Wrong calendar-event subject",event2.getSubject(), TEST_EVENT_SUBJECT_2); - System.out.println("testConcurrentAddRemoveEvent thread2 addEvent2 DONE"); - - // enable breakpoint - CodepointClient codepointClient = null; - CodepointRef codepointRef = null; - try { - codepointClient = CodepointClientFactory.createCodepointClient("vm://embedded?broker.persistent=false", CODEPOINT_SERVER_ID); - codepointRef = codepointClient.getCodepoint("org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync-in-sync.org.olat.commons.calendar.ICalFileCalendarManager.addEventTo"); - codepointRef.enableBreakpoint(); - System.out.println(); - } catch (Exception e) { - e.printStackTrace(); - fail("Could not initialzed CoepointClient"); - } - + log.info("testConcurrentAddRemoveEvent thread2 addEvent2 DONE"); final CountDownLatch doneSignal = new CountDownLatch(2); @@ -435,27 +342,27 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { public void run() { try { // 1. load calendar - CalendarManager calManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); - Kalendar cal = calManager.getPersonalCalendar(test).getKalendar(); + CalendarManager calendarManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); + Kalendar calendar = calendarManager.getPersonalCalendar(test).getKalendar(); // 2. add Event1 => breakpoint hit - System.out.println("testConcurrentAddRemoveEvent thread1 addEvent1"); - calManager.addEventTo(cal, new KalendarEvent(TEST_EVENT_ID_1,TEST_EVENT_SUBJECT_1, new Date(), 1)); - System.out.println("testConcurrentAddRemoveEvent thread1 addEvent1 DONE"); + log.info("testConcurrentAddRemoveEvent thread1 addEvent1"); + calendarManager.addEventTo(calendar, new KalendarEvent(TEST_EVENT_ID_1,TEST_EVENT_SUBJECT_1, new Date(), 1)); + log.info("testConcurrentAddRemoveEvent thread1 addEvent1 DONE"); // 3. check event1 exist - cal = calManager.getPersonalCalendar(test).getKalendar(); - KalendarEvent event1 = cal.getEvent(TEST_EVENT_ID_1); + calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + KalendarEvent event1 = calendar.getEvent(TEST_EVENT_ID_1); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); // 4. sleep 2sec // 5. check event1 still exist (event2 added in meantime) - cal = calManager.getPersonalCalendar(test).getKalendar(); - event1 = cal.getEvent(TEST_EVENT_ID_1); + calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + event1 = calendar.getEvent(TEST_EVENT_ID_1); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); statusList.add(Boolean.TRUE); - System.out.println("testConcurrentAddRemoveEvent thread1 finished"); + log.info("testConcurrentAddRemoveEvent thread1 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { @@ -468,26 +375,25 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { Thread thread2 = new Thread() { public void run() { try { - CalendarManager calManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); - Kalendar cal = calManager.getPersonalCalendar(test).getKalendar(); - // 2. sleep 1sec - sleep(1000); + CalendarManager calendarManager = CalendarManagerFactory.getJUnitInstance().getCalendarManager(); + Kalendar calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + // 3. add Event2 (breakpoint of thread1 blocks) - System.out.println("testConcurrentAddRemoveEvent thread2 removeEvent2"); - boolean removed = calManager.removeEventFrom(cal, new KalendarEvent(TEST_EVENT_ID_2,TEST_EVENT_SUBJECT_2, new Date(), 1)); + log.info("testConcurrentAddRemoveEvent thread2 removeEvent2"); + boolean removed = calendarManager.removeEventFrom(calendar, new KalendarEvent(TEST_EVENT_ID_2,TEST_EVENT_SUBJECT_2, new Date(), 1)); assertTrue(removed); - System.out.println("testConcurrentAddRemoveEvent thread1 removeEvent2 DONE"); + log.info("testConcurrentAddRemoveEvent thread1 removeEvent2 DONE"); // 4. check event2 exist - cal = calManager.getPersonalCalendar(test).getKalendar(); - KalendarEvent updatedEvent = cal.getEvent(TEST_EVENT_ID_2); + calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + KalendarEvent updatedEvent = calendar.getEvent(TEST_EVENT_ID_2); assertNull("Still found deleted event with id=" + TEST_EVENT_ID_2, updatedEvent); // 5. check event1 exist - cal = calManager.getPersonalCalendar(test).getKalendar(); - KalendarEvent event1 = cal.getEvent(TEST_EVENT_ID_1); + calendar = calendarManager.getPersonalCalendar(test).getKalendar(); + KalendarEvent event1 = calendar.getEvent(TEST_EVENT_ID_1); assertNotNull("Did not found event with id=" + TEST_EVENT_ID_1, event1); assertEquals("Wrong calendar-event subject",event1.getSubject(), TEST_EVENT_SUBJECT_1); statusList.add(Boolean.TRUE); - System.out.println("testConcurrentAddRemoveEvent thread2 finished"); + log.info("testConcurrentAddRemoveEvent thread2 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { @@ -498,25 +404,6 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { thread1.start(); thread2.start(); - sleep(2000); - - try { - // to see all registered code-points: comment-in next 2 lines - // List<CodepointRef> codepointList = codepointClient.listAllCodepoints(); - // System.out.println("codepointList=" + codepointList); - System.out.println("testConcurrentAddRemoveEvent start waiting for breakpoint reached"); - TemporaryPausedThread[] threads = codepointRef.waitForBreakpointReached(1000); - assertTrue("Did not reach breakpoint", threads.length > 0); - System.out.println("threads[0].getCodepointRef()=" + threads[0].getCodepointRef()); - codepointRef.disableBreakpoint(true); - System.out.println("testConcurrentAddRemoveEvent breakpoint reached => continue"); - } catch (BreakpointStateException e) { - e.printStackTrace(); - fail("Codepoints: BreakpointStateException=" + e.getMessage()); - } catch (CommunicationException e) { - e.printStackTrace(); - fail("Codepoints: CommunicationException=" + e.getMessage()); - } try { boolean interrupt = doneSignal.await(10, TimeUnit.SECONDS); @@ -527,38 +414,11 @@ public class ICalFileCalendarManagerTest extends OlatTestCase { // if not -> they are in deadlock and the db did not detect it for (Exception exception : exceptionHolder) { - System.out.println("exception: "+exception.getMessage()); + log.info("exception: "+exception.getMessage()); exception.printStackTrace(); } assertTrue("It throws an exception in test => see sysout", exceptionHolder.isEmpty()); - codepointClient.close(); - System.out.println("testConcurrentAddRemoveEvent finish successful"); - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#setUp() - */ - @Before public void setup() throws Exception { - test = JunitTestHelper.createAndPersistIdentityAsUser("test"); - // Setup for code-points - JMSCodePointServerJunitHelper.startServer(CODEPOINT_SERVER_ID); - DBFactory.getInstance().closeSession(); - } - - /* - * (non-Javadoc) - * - * @see junit.framework.TestCase#tearDown() - */ - @After public void tearDown() throws Exception { - try { - JMSCodePointServerJunitHelper.stopServer(); - } catch (Exception e) { - log.error("tearDown failed: ", e); - } + log.info("testConcurrentAddRemoveEvent finish successful"); } - } \ No newline at end of file diff --git a/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java b/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java index 4b2410902ae5db80f0399e16c3000de1e6439f62..2d65b66cd87154c7c610d9eb74bed41f3a1f9df2 100644 --- a/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java +++ b/src/test/java/org/olat/repository/manager/RepositoryEntryStatisticsDAOTest.java @@ -360,7 +360,6 @@ public class RepositoryEntryStatisticsDAOTest extends OlatTestCase { * Thread 1 : call incrementDownloadCounter after 100ms * Thread 2 : call incrementDownloadCounter after 300ms * Thread 3 : update access-value on repository-entry directly after 200ms - * Codepoint-breakpoint at IncrementDownloadCounterBackgroundTask in executeTask before update */ @Test public void concurrentIncrementDownloadCounter() { diff --git a/src/test/java/org/olat/resource/OLATResourceManagerTest.java b/src/test/java/org/olat/resource/OLATResourceManagerTest.java index 4e85d9ccb110d4879039e4962380061c42b86184..288dfe19dd1d2394c0981c4e198011da3517400b 100644 --- a/src/test/java/org/olat/resource/OLATResourceManagerTest.java +++ b/src/test/java/org/olat/resource/OLATResourceManagerTest.java @@ -36,23 +36,18 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Before; +import org.junit.Assert; import org.junit.Test; +import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.OLATResourceable; -import org.olat.core.logging.DBRuntimeException; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; -import org.olat.test.JMSCodePointServerJunitHelper; import org.olat.test.OlatTestCase; -import org.olat.testutils.codepoints.client.BreakpointStateException; -import org.olat.testutils.codepoints.client.CodepointClient; -import org.olat.testutils.codepoints.client.CodepointClientFactory; -import org.olat.testutils.codepoints.client.CodepointRef; -import org.olat.testutils.codepoints.client.CommunicationException; -import org.olat.testutils.codepoints.client.TemporaryPausedThread; +import org.springframework.beans.factory.annotation.Autowired; /** * A <b>OLATResourceManagerTest </b> is used for SecurityResourceManager @@ -61,162 +56,133 @@ import org.olat.testutils.codepoints.client.TemporaryPausedThread; * @author Andreas Ch. Kapp * */ -public class OLATResourceManagerTest extends OlatTestCase implements OLATResourceable { +public class OLATResourceManagerTest extends OlatTestCase { private static final OLog log = Tracing.createLoggerFor(OLATResourceManagerTest.class); - private static final String CODEPOINT_SERVER_ID = "OLATResourceManagerTest"; + @Autowired + private DB dbInstance; + @Autowired + private OLATResourceManager rm; /** * Test creation/insert/update and deletion of a resource */ - @Test public void testCreateInsertUpdateDeleteResource() { + @Test + public void testCreateInsertUpdateDeleteResource() { //create - OLATResourceManager rm = OLATResourceManager.getInstance(); - OLATResource res = rm.createOLATResourceInstance(this); + String resName = UUID.randomUUID().toString(); + TestResourceable resource = new TestResourceable(8213649l, resName); + OLATResource res = rm.createOLATResourceInstance( resource); + Assert.assertNotNull(res); rm.saveOLATResource(res); - assertNotNull(res); - assertTrue(res.getResourceableId().equals(this.getResourceableId())); - //Insert - rm.saveOLATResource(res); - rm.deleteOLATResource(res); + + Assert.assertEquals(new Long(8213649l), res.getResourceableId()); + Assert.assertEquals(resName, res.getResourceableTypeName()); + Assert.assertNotNull(res.getCreationDate()); + Assert.assertNotNull(res.getKey()); + dbInstance.commit(); } /** * Test find/persist of a resource */ - @Test public void testFindOrPersistResourceable() { - OLATResourceManager rm = OLATResourceManager.getInstance(); + @Test + public void testFindOrPersistResourceable() { + String resName = UUID.randomUUID().toString(); + TestResourceable resource = new TestResourceable(8213650l, resName); + //create by finding - OLATResource ores = rm.findOrPersistResourceable(this); - assertNotNull(ores); + OLATResource ores1 = rm.findOrPersistResourceable(resource); + Assert.assertNotNull(ores1); //only find - ores = rm.findOrPersistResourceable(this); - assertNotNull(ores); + OLATResource ores2 = rm.findOrPersistResourceable(resource); + Assert.assertNotNull(ores2); + Assert.assertEquals(ores1, ores2); } /** * Test type-only resource */ - @Test public void testInsertTypeOnly() { - OLATResourceManager rm = OLATResourceManager.getInstance(); - OLATResourceable oresable = new OLATResourceable() { - - public String getResourceableTypeName() { - return "typeonly"; - } - - public Long getResourceableId() { - return null; - } - }; - OLATResource ores = rm.findOrPersistResourceable(oresable); - assertNotNull(ores); - assertNull(ores.getResourceableId()); - //only find - ores = rm.findOrPersistResourceable(this); - assertNotNull(ores); + @Test + public void testInsertTypeOnly() { + TestResourceable resource = new TestResourceable(null, "typeonly"); + OLATResource ores1 = rm.findOrPersistResourceable(resource); + Assert.assertNotNull(ores1); + Assert.assertNull(ores1.getResourceableId()); } /** * Test deletion of a resource */ - @Test public void testDeleteResourceable() { - OLATResourceManager rm = OLATResourceManager.getInstance(); + @Test + public void testDeleteResourceable() { + String resName = UUID.randomUUID().toString(); + TestResourceable resource = new TestResourceable(8213651l, resName); + //delete on not persisted resourceable - rm.deleteOLATResourceable(this); + rm.deleteOLATResourceable(resource); //delete persisted resourceable - OLATResource ores = rm.findOrPersistResourceable(this); - assertNotNull(ores); - rm.deleteOLATResourceable(this); + OLATResource ores = rm.findOrPersistResourceable(resource); + Assert.assertNotNull(ores); + rm.deleteOLATResourceable(resource); + dbInstance.commit(); + + OLATResource deletedRes = rm.findResourceable(8213651l, resName); + Assert.assertNull(deletedRes); } /** * Test find/persist of a resource */ - @Test public void testConcurrentFindOrPersistResourceable() { - OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(this); - assertNotNull(ores); - OLATResourceManager.getInstance().deleteOLATResource(ores); - DBFactory.getInstance().closeSession(); - // now we are shure OLATResource is delete - + @Test + public void testConcurrentFindOrPersistResourceable() { final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1)); final List<OLATResource> statusList = Collections.synchronizedList(new ArrayList<OLATResource>(1)); - - // enable breakpoint - - CodepointClient codepointClient = null; - CodepointRef codepointRef = null; - try { - codepointClient = CodepointClientFactory.createCodepointClient("vm://localhost?broker.persistent=false", CODEPOINT_SERVER_ID); - codepointRef = codepointClient.getCodepoint("org.olat.commons.coordinate.cluster.ClusterSyncer.doInSync-in-sync.org.olat.resource.OLATResourceManager.findOrPersistResourceable"); - codepointRef.enableBreakpoint(); - } catch (Exception e) { - log.error("", e); - fail("Could not initialzed CodepointClient"); - } - final String resourceName = UUID.randomUUID().toString(); + final CountDownLatch doneSignal = new CountDownLatch(2); - // thread 1 - new Thread(new Runnable() { + Thread thread1 = new Thread(new Runnable() { public void run() { try { - OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(new TestResourceable(resourceName)); - assertNotNull(ores); - statusList.add(ores); + sleep(10); + OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(new TestResourceable(123123999l, resourceName)); + assertNotNull(resource); + statusList.add(resource); log.info("testConcurrentFindOrPersistResourceable thread1 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { DBFactory.getInstance().commitAndCloseSession(); + doneSignal.countDown(); } - }}).start(); + }}); - // thread 2 - new Thread(new Runnable() { + Thread thread2 = new Thread(new Runnable() { public void run() { try { - sleep(1000); - OLATResource ores = OLATResourceManager.getInstance().findOrPersistResourceable(new TestResourceable(resourceName)); - assertNotNull(ores); - statusList.add(ores); + sleep(10); + OLATResource resource = OLATResourceManager.getInstance().findOrPersistResourceable(new TestResourceable(123123999l, resourceName)); + assertNotNull(resource); + statusList.add(resource); log.info("testConcurrentFindOrPersistResourceable thread2 finished"); } catch (Exception ex) { exceptionHolder.add(ex);// no exception should happen } finally { DBFactory.getInstance().commitAndCloseSession(); + doneSignal.countDown(); } - }}).start(); + }}); + + thread1.start(); + thread2.start(); - sleep(2000); - // check thread 2 should not finished - assertEquals("Thread already finished => synchronization did not work",0,statusList.size()); try { - // to see all registered code-points: comment-in next 2 lines - // List<CodepointRef> codepointList = codepointClient.listAllCodepoints(); - // log.info("codepointList=" + codepointList); - log.info("testConcurrentFindOrPersistResourceable start waiting for breakpoint reached"); - TemporaryPausedThread[] threads = codepointRef.waitForBreakpointReached(1000); - assertTrue("Did not reach breakpoint", threads.length > 0); - log.info("threads[0].getCodepointRef()=" + threads[0].getCodepointRef()); - codepointRef.disableBreakpoint(true); - log.info("testConcurrentFindOrPersistResourceable breakpoint reached => continue"); - } catch (BreakpointStateException e) { - log.error("", e); - fail("Codepoints: BreakpointStateException=" + e.getMessage()); - } catch (CommunicationException e) { - log.error("", e); - fail("Codepoints: CommunicationException=" + e.getMessage()); + boolean interrupt = doneSignal.await(10, TimeUnit.SECONDS); + assertTrue("Test takes too long (more than 10s)", interrupt); + } catch (InterruptedException e) { + fail("" + e.getMessage()); } - // sleep until t1 and t2 should have terminated/excepted - int loopCount = 0; - while ( (statusList.size()<2) && (exceptionHolder.size()<1) && (loopCount<5)) { - sleep(1000); - loopCount++; - } - assertTrue("Threads did not finish in 5sec", loopCount<5); // if not -> they are in deadlock and the db did not detect it for (Exception exception : exceptionHolder) { log.error("exception: ", exception); @@ -226,51 +192,15 @@ public class OLATResourceManagerTest extends OlatTestCase implements OLATResourc } assertEquals("Missing created OresResource in statusList",2, statusList.size()); assertEquals("Created OresResource has not same key",statusList.get(0).getKey(), statusList.get(1).getKey()); - codepointClient.close(); log.info("testConcurrentFindOrPersistResourceable finish successful"); - - } - - /** - * @see junit.framework.TestCase#setUp() - */ - @Before public void setup() throws Exception { - try { - // Setup for code-points - JMSCodePointServerJunitHelper.startServer(CODEPOINT_SERVER_ID); - } catch (Exception e) { - log.error("Error while generating database tables or opening hibernate session", e); - } - } - - /** - * @see junit.framework.TestCase#tearDown() - */ - @After public void tearDown() throws Exception { - JMSCodePointServerJunitHelper.stopServer(); - } - - - /** - * @see org.olat.core.id.OLATResourceablegetResourceableId() - */ - public Long getResourceableId() { - return new Long(1234567890L); - } - - /** - * @see org.olat.core.id.OLATResourceablegetResourceableTypeName() - */ - public String getResourceableTypeName() { - return this.getClass().getName(); } /** * Test resource for null values */ - @Test public void testNULLVALUE() { + @Test + public void testNULLVALUE() { NullTester ntester = new NullTester(); - OLATResourceManager rm = OLATResourceManager.getInstance(); // Uncomment for testing: OLATResource or = null; try { @@ -278,27 +208,19 @@ public class OLATResourceManagerTest extends OlatTestCase implements OLATResourc } catch (RuntimeException re) { assertNull(or); } - try { - DBFactory.getInstance().closeSession(); - } catch (DBRuntimeException e) { - //ignore - } } + /** * Resource with null value */ - class NullTester implements OLATResourceable { + private static class NullTester implements OLATResourceable { - /** - * @see org.olat.core.id.OLATResourceablegetResourceableId() - */ + @Override public Long getResourceableId() { return new Long(0); } - /** - * @see org.olat.core.id.OLATResourceablegetResourceableTypeName() - */ + @Override public String getResourceableTypeName() { return this.getClass().getName(); } @@ -308,20 +230,22 @@ public class OLATResourceManagerTest extends OlatTestCase implements OLATResourc // Inner class TestResourceable /////////////////////////////// private static class TestResourceable implements OLATResourceable { + private final Long resId; private final String resName; - public TestResourceable(String resourceName) { + public TestResourceable(Long resId, String resourceName) { + this.resId = resId; this.resName = resourceName; } + @Override public Long getResourceableId() { - return new Long(123123999); + return resId; } + @Override public String getResourceableTypeName() { return resName; } - } - -} +} \ No newline at end of file diff --git a/src/test/java/org/olat/test/JMSCodePointServerJunitHelper.java b/src/test/java/org/olat/test/JMSCodePointServerJunitHelper.java deleted file mode 100644 index 4cc46d9290e305fa97efec7d4c96b6f4019ee5b3..0000000000000000000000000000000000000000 --- a/src/test/java/org/olat/test/JMSCodePointServerJunitHelper.java +++ /dev/null @@ -1,69 +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.test; - -import javax.jms.JMSException; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.command.ActiveMQQueue; -import org.olat.testutils.codepoints.server.CodepointInstaller; -import org.olat.testutils.codepoints.server.impl.JMSCodepointServer; - -/** - * Description:<br> - * helper class for junit testing - * - * <P> - * Initial Date: 04.03.2010 <br> - * @author guido - */ -public class JMSCodePointServerJunitHelper { - - private static JMSCodepointServer codepointServer_; - - public static void startServer(String codePointServerId) { - if (codepointServer_ == null) { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); - ActiveMQQueue queue = new ActiveMQQueue("olat/codepoints"); - try { - codepointServer_ = new JMSCodepointServer(connectionFactory, queue, codePointServerId); - } catch (JMSException e) { - System.out.println("Error while creating codepoint server: "+e.getMessage()); - } - CodepointInstaller.installCodepointServer(codepointServer_); - System.out.println("JMSCodePointServerJunitHelper: Codepoint-Server started"); - } - } - - public static void stopServer() { - CodepointInstaller.installCodepointServer(null); - if (codepointServer_!=null) { - codepointServer_.close(); - codepointServer_ = null; - } - } - -} diff --git a/src/test/profile/mysql/olat.arquillian.properties b/src/test/profile/mysql/olat.arquillian.properties index 6e51a0a377d95b5bf26ddecd604f8184c5fb84e8..ff3525337a9675a3bd40922a168a71f7256cfc83 100644 --- a/src/test/profile/mysql/olat.arquillian.properties +++ b/src/test/profile/mysql/olat.arquillian.properties @@ -35,10 +35,7 @@ jmx.rmi.port=1009 # SingleVM jms.broker.url jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=false smtp.host=disabled # diff --git a/src/test/profile/mysql/olat.eclipse.properties b/src/test/profile/mysql/olat.eclipse.properties index 680947553cad6102a7c4cf6bca612e4baa76e0bc..685d36a5bc0aa315a6d8dbb59f39f72ebc1ee00b 100644 --- a/src/test/profile/mysql/olat.eclipse.properties +++ b/src/test/profile/mysql/olat.eclipse.properties @@ -29,14 +29,10 @@ jmx.rmi.port=1009 # SingleVM jms.broker.url jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false # Cluster (remote) jms.broker.url #jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) #search.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -#codepoint.jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=true smtp.host=testing # diff --git a/src/test/profile/mysql/olat.local.properties b/src/test/profile/mysql/olat.local.properties index 55f42606499946f62fd42aeef8b9503544b11d84..aabd913addccc5c5d9b71af70cab47547e071013 100644 --- a/src/test/profile/mysql/olat.local.properties +++ b/src/test/profile/mysql/olat.local.properties @@ -29,18 +29,12 @@ jmx.rmi.port=${test.env.jmx.rmi.port.0} # SingleVM jms.broker.url jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false # Cluster (remote) jms.broker.url #jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) #search.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -#codepoint.jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) - -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=true smtp.host=testing -# # # if you like to run your tests against mysql just uncomment the following. Please do not commit it! # diff --git a/src/test/profile/oracle/olat.eclipse.properties b/src/test/profile/oracle/olat.eclipse.properties index 3c58e0e5306bf3e078e217ce95089ed327946fc1..21a8137078043db46a5d9eb740c7a0f53b9814be 100644 --- a/src/test/profile/oracle/olat.eclipse.properties +++ b/src/test/profile/oracle/olat.eclipse.properties @@ -29,14 +29,10 @@ jmx.rmi.port=1009 # SingleVM jms.broker.url jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false # Cluster (remote) jms.broker.url #jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) #search.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -#codepoint.jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=true smtp.host=testing # diff --git a/src/test/profile/oracle/olat.local.properties b/src/test/profile/oracle/olat.local.properties index 5f25261d2cd8d28565ff6b9068c89fc872eedcd5..ce67c318e241406ec1bd08197221e0b03e2bac71 100644 --- a/src/test/profile/oracle/olat.local.properties +++ b/src/test/profile/oracle/olat.local.properties @@ -29,14 +29,10 @@ jmx.rmi.port=${test.env.jmx.rmi.port.0} # SingleVM jms.broker.url jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false # Cluster (remote) jms.broker.url #jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) #search.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -#codepoint.jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=true smtp.host=testing # diff --git a/src/test/profile/postgresql/olat.eclipse.properties b/src/test/profile/postgresql/olat.eclipse.properties index 1ebabe5352546fe38a3747ad3769497ca50a595b..048850fae3f8f45f52d9dd1598841371cdfa3a65 100644 --- a/src/test/profile/postgresql/olat.eclipse.properties +++ b/src/test/profile/postgresql/olat.eclipse.properties @@ -29,18 +29,12 @@ jmx.rmi.port=1009 # SingleVM jms.broker.url jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false # Cluster (remote) jms.broker.url #jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) #search.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -#codepoint.jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) - -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=true smtp.host=testing -# # # if you like to run your tests against mysql just uncomment the following. Please do not commit it! # diff --git a/src/test/profile/postgresql/olat.local.properties b/src/test/profile/postgresql/olat.local.properties index 9d4ea969ca5c3e22a4b4c18395a6e7f109ac9bcd..40d6919dd38949ffedad4a8ce817e0d10b21eff5 100644 --- a/src/test/profile/postgresql/olat.local.properties +++ b/src/test/profile/postgresql/olat.local.properties @@ -29,18 +29,12 @@ jmx.rmi.port=${test.env.jmx.rmi.port.0} # SingleVM jms.broker.url jms.broker.url=vm://embedded?broker.persistent=false search.broker.url=vm://embedded?broker.persistent=false -codepoint.jms.broker.url=vm://embedded?broker.persistent=false # Cluster (remote) jms.broker.url #jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) #search.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) -#codepoint.jms.broker.url=failover:(tcp://localhost:${test.env.jms.broker.port}?wireFormat.maxInactivityDuration=0) - -# enable/disable codepoint/breakpoint framework -codepoint_server.enabled=true smtp.host=testing -# # # if you like to run your tests against mysql just uncomment the following. Please do not commit it! #