[jboss-svn-commits] JBL Code SVN: r24236 - in labs/jbossrules/trunk/drools-repository/src: test/java/org/drools/repository and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 4 06:19:36 EST 2008
Author: michael.neale at jboss.com
Date: 2008-12-04 06:19:36 -0500 (Thu, 04 Dec 2008)
New Revision: 24236
Modified:
labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/RulesRepository.java
labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/RulesRepositoryTest.java
Log:
GUVNOR-70
Modified: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/RulesRepository.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/RulesRepository.java 2008-12-04 11:16:08 UTC (rev 24235)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/RulesRepository.java 2008-12-04 11:19:36 UTC (rev 24236)
@@ -3,6 +3,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
@@ -961,9 +962,25 @@
}
/**
- *
- * @param byteArray
+ * Import the repository from a stream.
*/
+ public void importRepository(InputStream in) {
+ new RulesRepositoryAdministrator( this.session ).clearRulesRepository();
+ try {
+ this.session.getWorkspace().importXML( "/", in,
+ ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW );
+ session.save();
+ } catch (RepositoryException e) {
+ throw new RulesRepositoryException(e);
+ } catch (IOException e) {
+ throw new RulesRepositoryException(e);
+ }
+ }
+
+ /**
+ * Clean and import the rules repository.
+ * Will run any needed migrations as well.
+ */
public void importRulesRepository(byte[] byteArray) {
try {
new RulesRepositoryAdministrator( this.session ).clearRulesRepository();
Modified: labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/RulesRepositoryTest.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/RulesRepositoryTest.java 2008-12-04 11:16:08 UTC (rev 24235)
+++ labs/jbossrules/trunk/drools-repository/src/test/java/org/drools/repository/RulesRepositoryTest.java 2008-12-04 11:19:36 UTC (rev 24236)
@@ -1010,22 +1010,22 @@
assertNotNull( repo.loadState( newName ) );
}
-
+
public void testRemoveState() {
RulesRepository repo = RepositorySessionUtil.getRepository();
StateItem[] items = repo.listStates();
assertTrue( items.length > 0 );
-
+
final String name = "stateThatHasALongNameAndWillBeRenamed";
repo.createState( name );
-
+
StateItem[] items2 = repo.listStates();
assertEquals( items.length + 1,
items2.length );
-
+
repo.loadState( name ).remove();
repo.save();
-
+
StateItem[] items3 = repo.listStates();
assertEquals( items2.length -1,
items3.length );
@@ -1035,7 +1035,7 @@
} catch ( RulesRepositoryException e ) {
// Works
}
-
+
}
public void testImportExport() {
@@ -1055,6 +1055,10 @@
assertFalse( repo.containsPackage( "testImportExport" ) );
repo.importRulesRepository( repository_unitest );
assertTrue( repo.containsPackage( "testImportExport" ) );
+
+ repo.importRepository(new ByteArrayInputStream(repository_unitest));
+ assertTrue( repo.containsPackage( "testImportExport" ) );
+
} catch ( Exception e ) {
fail( "Can't throw any exception." );
e.printStackTrace();
More information about the jboss-svn-commits
mailing list