[jboss-svn-commits] JBL Code SVN: r28262 - in labs/jbossrules/trunk/drools-guvnor/src: main/java/org/drools/guvnor/server/util and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Jul 20 23:49:25 EDT 2009


Author: michael.neale at jboss.com
Date: 2009-07-20 23:49:25 -0400 (Mon, 20 Jul 2009)
New Revision: 28262

Modified:
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/DiscussionRecord.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/util/TestEnvironmentSessionHelper.java
   labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/PackageDeploymentServletTest.java
   labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/RestAPIServletTest.java
Log:
fixing the build...

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/DiscussionRecord.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/DiscussionRecord.java	2009-07-21 03:09:14 UTC (rev 28261)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/client/rpc/DiscussionRecord.java	2009-07-21 03:49:25 UTC (rev 28262)
@@ -1,15 +1,15 @@
 package org.drools.guvnor.client.rpc;
 
 import java.io.Serializable;
+import java.util.Calendar;
 import java.util.Date;
-import java.util.Calendar;
 
 /**
  * This is a discussion record item.
  * @author Michael Neale
  */
 public class DiscussionRecord implements Serializable {
-    public long timestamp = Calendar.getInstance().getTimeInMillis();
+    public long timestamp = (new Date()).getTime();
     public String note;
     public String author;
 }

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/util/TestEnvironmentSessionHelper.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/util/TestEnvironmentSessionHelper.java	2009-07-21 03:09:14 UTC (rev 28261)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/util/TestEnvironmentSessionHelper.java	2009-07-21 03:49:25 UTC (rev 28262)
@@ -28,7 +28,6 @@
 import org.drools.repository.JackrabbitRepositoryConfigurator;
 import org.drools.repository.RepositorySessionUtil;
 import org.drools.repository.RulesRepositoryAdministrator;
-import org.apache.jackrabbit.core.TransientRepository;
 
 /**
  * This is only to be used for testing, eg in hosted mode, or unit tests.
@@ -37,67 +36,47 @@
  */
 public class TestEnvironmentSessionHelper {
 
+
     public static Repository repository;
 
-    /** we keep the last session, and close it when creating a new one */
-    public static Session lastSession;
 
-    /**
-     * Return a session, blow away and create a new empty repo if this is the first time this is called.
-     */
     public static Session getSession() throws Exception {
         return getSession(true);
     }
 
-    /** Don't use this one unless you plan to close the session yourself in tests... */
-    public static Session getSessionKeepOpen() {
-        return getRepo(true);
-    }
-
-
     public static synchronized Session getSession(boolean erase) {
-        if (lastSession != null) {
-            lastSession.logout();
-        }
-        lastSession = getRepo(erase);
-        return lastSession;
-    }
+    	try {
+	        if (repository == null) {
 
+	            if (erase) {
+	                File repoDir = new File("repository");
+	                System.out.println("DELETE test repo dir: " + repoDir.getAbsolutePath());
+	                RepositorySessionUtil.deleteDir( repoDir );
+	                System.out.println("TEST repo dir deleted.");
+	            }
 
-
-
-    private static Session getRepo(boolean erase) {
-        try {
-
-            if (repository == null) {
-                if (erase) {
-                    File repoDir = new File("repository");
-                    System.out.println("DELETE test repo dir: " + repoDir.getAbsolutePath());
-                    RepositorySessionUtil.deleteDir( repoDir );
-                    System.out.println("TEST repo dir deleted.");
-                }
-
-                JCRRepositoryConfigurator config = new JackrabbitRepositoryConfigurator();
+	            JCRRepositoryConfigurator config = new JackrabbitRepositoryConfigurator();
                 String home = System.getProperty("guvnor.repository.dir");
-                repository = config.getJCRRepository(home);
+	            repository = config.getJCRRepository(home);
 
-                Session testSession = repository.login(
-                                                                         new SimpleCredentials("alan_parsons", "password".toCharArray()));
+	            Session testSession = repository.login(
+	                                                                     new SimpleCredentials("alan_parsons", "password".toCharArray()));
 
-                RulesRepositoryAdministrator admin = new RulesRepositoryAdministrator(testSession);
-                if (erase && admin.isRepositoryInitialized()) {
+	            RulesRepositoryAdministrator admin = new RulesRepositoryAdministrator(testSession);
+	            if (erase && admin.isRepositoryInitialized()) {
 
-                    admin.clearRulesRepository( );
-                }
-                config.setupRulesRepository( testSession );
+	                admin.clearRulesRepository( );
+	            }
+	            config.setupRulesRepository( testSession );
+	            return testSession;
+	        } else {
+	            return repository.login(
+	                             new SimpleCredentials("alan_parsons", "password".toCharArray()));
+	        }
+    	} catch (RepositoryException e) {
+    		throw new IllegalStateException(e);
+    	}
 
-                return testSession;
-            } else {
-                return repository.login(new SimpleCredentials("alan_parsons", "password".toCharArray()));
-            }
-        } catch (RepositoryException e) {
-            throw new IllegalStateException(e);
-        }
     }
 
 

Modified: labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/PackageDeploymentServletTest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/PackageDeploymentServletTest.java	2009-07-21 03:09:14 UTC (rev 28261)
+++ labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/PackageDeploymentServletTest.java	2009-07-21 03:49:25 UTC (rev 28262)
@@ -36,7 +36,7 @@
 
 
 	public void testLoadingRules() throws Exception {
-		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSessionKeepOpen() );
+		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSession( true ) );
 
 		ServiceImplementation impl = new ServiceImplementation();
 		impl.repository = repo;

Modified: labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/RestAPIServletTest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/RestAPIServletTest.java	2009-07-21 03:09:14 UTC (rev 28261)
+++ labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/files/RestAPIServletTest.java	2009-07-21 03:49:25 UTC (rev 28262)
@@ -116,7 +116,7 @@
 	}
 
 	public void testPost() throws Exception {
-		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSessionKeepOpen() );
+		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSession() );
 		PackageItem pkg = repo.createPackage("testPostRestServlet", "");
 
 		HashMap<String, String> headers = new HashMap<String, String>() {
@@ -162,7 +162,7 @@
 
 	public void testPut() throws Exception {
 
-		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSessionKeepOpen() );
+		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSession() );
 		PackageItem pkg = repo.createPackage("testPutRestServlet", "");
 		AssetItem ass = pkg.addAsset("asset1", "abc");
 		ass.updateFormat("drl");
@@ -196,7 +196,7 @@
 
 
 	public void testDelete() throws Exception {
-		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSessionKeepOpen() );
+		RulesRepository repo = new RulesRepository( TestEnvironmentSessionHelper.getSession() );
 		PackageItem pkg = repo.createPackage("testDeleteRestServlet", "");
 		AssetItem ass = pkg.addAsset("asset1", "abc");
 		ass.updateFormat("drl");



More information about the jboss-svn-commits mailing list