Index: lams_learning/test/java/WEB-INF/spring/applicationContext.xml
===================================================================
diff -u
--- lams_learning/test/java/WEB-INF/spring/applicationContext.xml (revision 0)
+++ lams_learning/test/java/WEB-INF/spring/applicationContext.xml (revision 158bef216ccd6dcfe5506ebd5b6b18598a20dfa9)
@@ -0,0 +1,201 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ messages
+
+
+
+
+
+
+
+ com.mysql.jdbc.Driver
+ jdbc:mysql://localhost/lams
+ lams
+ lamsdemo
+
+
+
+
+
+
+
+
+
+
+ com/lamsinternational/lams/usermanagement/AuthenticationMethod.hbm.xml
+ com/lamsinternational/lams/usermanagement/AuthenticationMethodType.hbm.xml
+ com/lamsinternational/lams/usermanagement/Organisation.hbm.xml
+ com/lamsinternational/lams/usermanagement/OrganisationType.hbm.xml
+ com/lamsinternational/lams/usermanagement/Role.hbm.xml
+ com/lamsinternational/lams/usermanagement/User.hbm.xml
+ com/lamsinternational/lams/usermanagement/UserOrganisation.hbm.xml
+ com/lamsinternational/lams/usermanagement/UserOrganisationRole.hbm.xml
+ com/lamsinternational/lams/usermanagement/Workspace.hbm.xml
+ com/lamsinternational/lams/usermanagement/WorkspaceFolder.hbm.xml
+
+
+ com/lamsinternational/lams/learningdesign/Activity.hbm.xml
+ com/lamsinternational/lams/learningdesign/Group.hbm.xml
+ com/lamsinternational/lams/learningdesign/Grouping.hbm.xml
+ com/lamsinternational/lams/learningdesign/LearningDesign.hbm.xml
+ com/lamsinternational/lams/learningdesign/LearningLibrary.hbm.xml
+ com/lamsinternational/lams/learningdesign/Transition.hbm.xml
+
+
+
+ com/lamsinternational/lams/lesson/LearnerProgress.hbm.xml
+ com/lamsinternational/lams/lesson/Lesson.hbm.xml
+
+
+
+ com/lamsinternational/lams/tool/Tool.hbm.xml
+ com/lamsinternational/lams/tool/ToolSession.hbm.xml
+ com/lamsinternational/lams/tool/ToolSessionState.hbm.xml
+
+
+
+
+ net.sf.hibernate.dialect.MySQLDialect
+ false
+ 5
+ 20
+ 1800
+ 50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PROPAGATION_REQUIRED,readOnly
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+ PROPAGATION_REQUIRED
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_learning/test/java/WEB-INF/spring/dataAccessContext.xml
===================================================================
diff -u
--- lams_learning/test/java/WEB-INF/spring/dataAccessContext.xml (revision 0)
+++ lams_learning/test/java/WEB-INF/spring/dataAccessContext.xml (revision 158bef216ccd6dcfe5506ebd5b6b18598a20dfa9)
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ /WEB-INF/spring/dbConnection.properties
+
+
+
+
+ messages
+
+
+
+
+
+
+ ${jdbc.driverClassName}
+ ${jdbc.url}
+ ${jdbc.username}
+ ${jdbc.password}
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_learning/test/java/WEB-INF/spring/dbConnection.properties
===================================================================
diff -u
--- lams_learning/test/java/WEB-INF/spring/dbConnection.properties (revision 0)
+++ lams_learning/test/java/WEB-INF/spring/dbConnection.properties (revision 158bef216ccd6dcfe5506ebd5b6b18598a20dfa9)
@@ -0,0 +1,19 @@
+# Properties file with Hibernate-related settings.
+# Applied by PropertyPlaceholderConfigurer from "dbConnection.xml".
+# Targetted at system administrators, to avoid touching the context XML files.
+
+#jdbc configuration
+jdbc.driverClassName=com.mysql.jdbc.Driver
+jdbc.url=jdbc:mysql://localhost/lams
+jdbc.username=lams
+jdbc.password=lamsdemo
+
+#Hibernate configuration
+hibernate.show_sql=false
+hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect
+
+#Connection Pooling configuration
+hibernate.c3p0.minPoolSize=5
+hibernate.c3p0.maxPoolSize=20
+hibernate.c3p0.timeout=1800
+hibernate.c3p0.max_statement=50
\ No newline at end of file
Index: lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml
===================================================================
diff -u
--- lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml (revision 0)
+++ lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml (revision 158bef216ccd6dcfe5506ebd5b6b18598a20dfa9)
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_learning/test/java/com/lamsinternational/lams/BaseTestCase.java
===================================================================
diff -u
--- lams_learning/test/java/com/lamsinternational/lams/BaseTestCase.java (revision 0)
+++ lams_learning/test/java/com/lamsinternational/lams/BaseTestCase.java (revision 158bef216ccd6dcfe5506ebd5b6b18598a20dfa9)
@@ -0,0 +1,63 @@
+package com.lamsinternational.lams;
+
+import net.sf.hibernate.Session;
+import net.sf.hibernate.SessionFactory;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+import org.springframework.orm.hibernate.SessionFactoryUtils;
+import org.springframework.orm.hibernate.SessionHolder;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+
+import com.lamsinternational.lams.lesson.dao.hibernate.LessonDAO;
+
+import junit.framework.TestCase;
+/*
+ * Created on Dec 4, 2004
+ */
+
+/**
+ * @author manpreet
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class BaseTestCase extends TestCase {
+
+ private static String CONFIG_PATH = "/WEB-INF/spring/";
+
+ protected ApplicationContext context;
+
+ public BaseTestCase() {
+ String configLocations[] = new String[3];
+ configLocations[0] = CONFIG_PATH+"applicationContext.xml";
+ configLocations[1] = CONFIG_PATH+"dataAccessContext.xml";
+ configLocations[2] = CONFIG_PATH+"learningApplicationContext.xml";
+ context = new ClassPathXmlApplicationContext(configLocations);
+ }
+
+ protected void setUp() throws Exception{
+ SessionFactory sessionFactory = (SessionFactory)getBean("coreSessionFactory");
+ Session s = sessionFactory.openSession();
+ TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(s));
+ }
+
+ protected Object getBean(String beanName) {
+ if (context == null) context = new FileSystemXmlApplicationContext(CONFIG_PATH+"applicationContext.xml");
+ Object o = context.getBean(beanName);
+ return o;
+ }
+
+ protected void tearDown() throws Exception{
+ super.tearDown();
+ SessionFactory sessionFactory = (SessionFactory)getBean("coreSessionFactory");
+ SessionHolder holder = (SessionHolder)TransactionSynchronizationManager.getResource(sessionFactory);
+ if (holder != null) {
+ Session s = holder.getSession();
+ s.flush();
+ TransactionSynchronizationManager.unbindResource(sessionFactory);
+ SessionFactoryUtils.closeSessionIfNecessary(s, sessionFactory);
+ }
+ }
+}
Index: lams_learning/test/java/com/lamsinternational/lams/lesson/dao/hibernate/LessonDAOTest.java
===================================================================
diff -u
--- lams_learning/test/java/com/lamsinternational/lams/lesson/dao/hibernate/LessonDAOTest.java (revision 0)
+++ lams_learning/test/java/com/lamsinternational/lams/lesson/dao/hibernate/LessonDAOTest.java (revision 158bef216ccd6dcfe5506ebd5b6b18598a20dfa9)
@@ -0,0 +1,69 @@
+/*
+ * Created on Nov 26, 2004
+ *
+ * Last modified on Nov 26, 2004
+ */
+package com.lamsinternational.lams.lesson.dao.hibernate;
+
+import java.util.Iterator;
+
+import net.sf.hibernate.LockMode;
+import net.sf.hibernate.Session;
+import net.sf.hibernate.SessionFactory;
+
+import org.lamsfoundation.lams.learning.service.ILearnerService;
+import org.lamsfoundation.lams.learning.service.TestLearnerService;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.FileSystemXmlApplicationContext;
+import org.springframework.orm.hibernate.SessionFactoryUtils;
+import org.springframework.orm.hibernate.SessionHolder;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+
+import com.lamsinternational.lams.BaseTestCase;
+import com.lamsinternational.lams.lesson.*;
+import com.lamsinternational.lams.lesson.dao.ILessonDAO;
+import com.lamsinternational.lams.usermanagement.User;
+
+import junit.framework.TestCase;
+
+/**
+ * TODO Add description here
+ *
+ *
+ * View Source
+ *
+ *
+ * @author Fei Yang
+ */
+public class LessonDAOTest extends BaseTestCase {
+
+ private static String CONFIG_PATH = "test/java/";
+
+ private String errorMessage = "";
+ private ILessonDAO lessonDAO = null;
+ private ApplicationContext ctx;
+
+ protected void setUp() throws Exception{
+ super.setUp();
+ lessonDAO = (LessonDAO)getBean("lessonDAO");
+ }
+
+ protected void tearDown() throws Exception{
+ lessonDAO = null;
+ super.tearDown();
+ }
+
+ public void testGetLesson() throws Exception {
+ ILearnerService learnerService = (ILearnerService)getBean("learnerService");
+ Lesson lesson = lessonDAO.getLesson(new Long(1));
+ boolean success = lesson != null;
+ Iterator i = lesson.getLearners().iterator();
+ while (i.hasNext()) {
+ User user = (User)i.next();
+ success = success && (user != null);
+ System.out.println(user.getUserId());
+ }
+ assertTrue(success);
+ }
+
+}