Author: pnedonosko
Date: 2009-11-12 05:27:14 -0500 (Thu, 12 Nov 2009)
New Revision: 591
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-201: test for JDBC loader
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
===================================================================
---
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12
10:06:18 UTC (rev 590)
+++
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12
10:27:14 UTC (rev 591)
@@ -87,7 +87,20 @@
initJCRRoot();
}
+
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ // delete all in DB
+
+
+ super.tearDown();
+ }
+
+
+
protected void initPersistence() throws Exception
{
// Create WorkspaceEntry
@@ -122,7 +135,6 @@
private WorkspaceEntry getNewWs(String wsName, boolean isMultiDb, String dsName,
String vsPath, ContainerEntry entry)
throws Exception
{
-
List params = new ArrayList();
params.add(new SimpleParameterEntry("sourceName", dsName));
@@ -149,7 +161,6 @@
if (vsPath != null)
{
-
ArrayList<ValueStorageFilterEntry> vsparams = new
ArrayList<ValueStorageFilterEntry>();
ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
filterEntry.setPropertyType("Binary");
@@ -169,47 +180,44 @@
list.add(valueStorageEntry);
containerEntry.setValueStorages(list);
-
}
-
- // Indexer
- ArrayList qParams = new ArrayList();
- qParams.add(new SimpleParameterEntry("indexDir",
"../temp/index/" + IdGenerator.generate()));
- QueryHandlerEntry qEntry =
- new
QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex",
qParams);
-
+
WorkspaceEntry workspaceEntry =
new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(),
"nt:unstructured");
workspaceEntry.setContainer(containerEntry);
- ArrayList cacheParams = new ArrayList();
+// // Indexer
+// ArrayList qParams = new ArrayList();
+// qParams.add(new SimpleParameterEntry("indexDir",
"../temp/index/" + IdGenerator.generate()));
+// QueryHandlerEntry qEntry =
+// new
QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex",
qParams);
+// workspaceEntry.setQueryHandler(qEntry);
+//
+// // cache
+// ArrayList cacheParams = new ArrayList();
+// cacheParams.add(new SimpleParameterEntry("maxSize",
"2000"));
+// cacheParams.add(new SimpleParameterEntry("liveTime",
"20m"));
+// CacheEntry cacheEntry = new CacheEntry(cacheParams);
+//
cacheEntry.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl");
+// workspaceEntry.setCache(cacheEntry);
+//
+// // lock
+// LockManagerEntry lockManagerEntry = new LockManagerEntry();
+// lockManagerEntry.setTimeout(900000);
+// LockPersisterEntry persisterEntry = new LockPersisterEntry();
+//
persisterEntry.setType("org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister");
+// ArrayList lpParams = new ArrayList();
+// lpParams.add(new SimpleParameterEntry("path",
"../temp/lock"));
+// persisterEntry.setParameters(lpParams);
+// lockManagerEntry.setPersister(persisterEntry);
+// workspaceEntry.setLockManager(lockManagerEntry);
- cacheParams.add(new SimpleParameterEntry("maxSize", "2000"));
- cacheParams.add(new SimpleParameterEntry("liveTime", "20m"));
- CacheEntry cacheEntry = new CacheEntry(cacheParams);
-
cacheEntry.setType("org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl");
-
- workspaceEntry.setCache(cacheEntry);
-
- workspaceEntry.setQueryHandler(qEntry);
-
- LockManagerEntry lockManagerEntry = new LockManagerEntry();
- lockManagerEntry.setTimeout(900000);
- LockPersisterEntry persisterEntry = new LockPersisterEntry();
-
persisterEntry.setType("org.exoplatform.services.jcr.impl.core.lock.FileSystemLockPersister");
- ArrayList lpParams = new ArrayList();
- lpParams.add(new SimpleParameterEntry("path",
"../temp/lock"));
- persisterEntry.setParameters(lpParams);
- lockManagerEntry.setPersister(persisterEntry);
- workspaceEntry.setLockManager(lockManagerEntry);
-
// workspaceEntry
return workspaceEntry;
}
private void createNewDataSource(String dataSourceName) throws Exception
{
-
Properties properties = new Properties();
properties.setProperty("driverClassName",
"org.hsqldb.jdbcDriver");
@@ -251,7 +259,25 @@
conn.commit();
}
+
+ private void deleteJCRRoot() throws Exception
+ {
+ // prepare
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
+ // add root (/) with jcr:primaryType
+ addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID,
Constants.NT_UNSTRUCTURED);
+
+ // add property (/jcr:mixinTypes)
+ List<InternalQName> mixins = new ArrayList<InternalQName>();
+ mixins.add(Constants.MIX_REFERENCEABLE);
+ mixins.add(Constants.EXO_PRIVILEGEABLE);
+ mixins.add(Constants.EXO_OWNEABLE);
+ addDbProperty(conn, Constants.ROOT_PATH, Constants.ROOT_UUID,
Constants.JCR_MIXINTYPES, mixins, true);
+
+ conn.commit();
+ }
+
/**
* Add Property to the connection but doesn't save it.
*
@@ -322,6 +348,26 @@
return propData;
}
+
+ /**
+ * Delete Property to the connection but doesn't save it.
+ *
+ * @param conn WorkspaceStorageConnection
+ * @param root QPath
+ * @param nodeId String
+ * @param primaryType InternalQName
+ * @throws Exception
+ */
+ private void deleteDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId,
InternalQName primaryType)
+ throws Exception
+ {
+ // add property (/jcr:primaryType)
+ addDbProperty(conn, root, Constants.ROOT_UUID, Constants.JCR_PRIMARYTYPE,
primaryType, false);
+
+ // add root (/)
+ conn.delete(new TransientNodeData(root, nodeId, 1, primaryType, new
InternalQName[0], 0, null,
+ new AccessControlList()));
+ }
// ============= TESTS =============