exo-jcr SVN: r778 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 09:55:06 -0500 (Thu, 19 Nov 2009)
New Revision: 778
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
Log:
EXOJCR-203: JBC init fix in test
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-19 14:40:34 UTC (rev 777)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-19 14:55:06 UTC (rev 778)
@@ -637,7 +637,8 @@
*/
public Object put(Fqn name, Object key, Object value) throws Exception
{
- LOG.error("The method 'put(Fqn name, Object key, Object value))' should not be called.");
+ LOG.error("The method 'put(Fqn name, Object key, Object value))' should not be called. " + name + " " + key + " "
+ + value);
throw new JDBCCacheLoaderException("The method 'put(Fqn name, Object key, Object value))' should not be called.");
}
@@ -646,7 +647,8 @@
*/
public void put(Fqn name, Map<Object, Object> attributes) throws Exception
{
- LOG.error("The method 'put(Fqn name, Map<Object, Object> attributes)' should not be called.");
+ LOG.error("The method 'put(Fqn name, Map<Object, Object> attributes)' should not be called. " + name + " "
+ + attributes);
throw new JDBCCacheLoaderException(
"The method 'put(Fqn name, Map<Object, Object> attributes)' should not be called.");
}
@@ -656,7 +658,7 @@
*/
public Object remove(Fqn fqn, Object key) throws Exception
{
- LOG.error("The method 'remove(Fqn fqn, Object key)' should not be called.");
+ LOG.error("The method 'remove(Fqn fqn, Object key)' should not be called. " + fqn + " " + key);
throw new JDBCCacheLoaderException("The method 'remove(Fqn fqn, Object key)' should not be called.");
}
@@ -665,7 +667,7 @@
*/
public void remove(Fqn fqn) throws Exception
{
- LOG.error("The method 'remove(Fqn fqn)' should not be called.");
+ LOG.error("The method 'remove(Fqn fqn)' should not be called. " + fqn);
throw new JDBCCacheLoaderException("The method 'remove(Fqn fqn)' should not be called.");
}
@@ -674,7 +676,7 @@
*/
public void removeData(Fqn fqn) throws Exception
{
- LOG.error("The method 'removeData(Fqn fqn)' should not be called.");
+ LOG.error("The method 'removeData(Fqn fqn)' should not be called. " + fqn);
throw new JDBCCacheLoaderException("The method 'removeData(Fqn fqn)' should not be called.");
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java 2009-11-19 14:40:34 UTC (rev 777)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java 2009-11-19 14:55:06 UTC (rev 778)
@@ -80,10 +80,11 @@
Node<Serializable, Object> cacheRoot = cache.getRoot();
// prepare cache structures
+ cache.startBatch();
nodes = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.NODES));
props = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.PROPS));
locks = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.LOCKS));
-
+ cache.endBatch(true);
// JCR connection
conn = new JBossCacheStorageConnection(cache, nodes, props, locks);
}
16 years, 8 months
exo-jcr SVN: r777 - in jcr/branches/1.12.0-JBC/component/core/src/test: java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directories.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 09:40:34 -0500 (Thu, 19 Nov 2009)
New Revision: 777
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCWorkspaceDataContainerTestBase.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
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/resources/conf/standalone/test-jbosscache-config-exoloader.xml
Log:
EXOJCR-203: JDBC & JBC conn tests reorg
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCWorkspaceDataContainerTestBase.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCWorkspaceDataContainerTestBase.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCWorkspaceDataContainerTestBase.java 2009-11-19 14:40:34 UTC (rev 777)
@@ -0,0 +1,340 @@
+package org.exoplatform.services.jcr.impl.storage;
+
+import org.apache.commons.dbcp.BasicDataSourceFactory;
+import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
+import org.exoplatform.services.jcr.access.AccessControlList;
+import org.exoplatform.services.jcr.config.ContainerEntry;
+import org.exoplatform.services.jcr.config.RepositoryEntry;
+import org.exoplatform.services.jcr.config.SimpleParameterEntry;
+import org.exoplatform.services.jcr.config.ValueStorageEntry;
+import org.exoplatform.services.jcr.config.ValueStorageFilterEntry;
+import org.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.jcr.impl.storage.value.StandaloneStoragePluginProvider;
+import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
+import org.exoplatform.services.jcr.util.IdGenerator;
+
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+
+import junit.framework.TestCase;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 19.11.2009
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public class JDBCWorkspaceDataContainerTestBase extends TestCase
+{
+
+ protected JDBCWorkspaceDataContainer persistentContainer;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ initPersistence();
+ }
+
+ protected void initPersistence() throws Exception
+ {
+ // Create WorkspaceEntry
+ ContainerEntry containerEntry = new ContainerEntry();
+ List<SimpleParameterEntry> params = new ArrayList<SimpleParameterEntry>();
+ params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, "hsqldb"));
+ params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.SWAPDIR_PROP, "/target/temp/swap/ws"));
+ containerEntry.setParameters(params);
+
+ // Initialize id generator.
+ new IdGenerator(new IDGeneratorServiceImpl());
+
+ // Set system property Context.INITIAL_CONTEXT_FACTORY to initial context.
+ System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.exoplatform.services.naming.SimpleContextFactory");
+
+ // Create data source. Will be created new data source to new test.
+ String dataSourceName = "jdbcjcr_" + IdGenerator.generate();
+ createNewDataSource(dataSourceName);
+
+ WorkspaceEntry ws =
+ getNewWs("ws_to_jbdc_cache_loader", true, dataSourceName, "/target/temp/ws_to_jbdc_cache_loader/values",
+ containerEntry);
+
+ RepositoryEntry re = new RepositoryEntry();
+ re.addWorkspace(ws);
+
+ ValueStoragePluginProvider valueStoragePluginProvider = new StandaloneStoragePluginProvider(ws);
+
+ persistentContainer = new JDBCWorkspaceDataContainer(ws, re, null, valueStoragePluginProvider);
+ }
+
+ protected WorkspaceEntry getNewWs(String wsName, boolean isMultiDb, String dsName, String vsPath, ContainerEntry entry)
+ throws Exception
+ {
+ List params = new ArrayList();
+
+ params.add(new SimpleParameterEntry("sourceName", dsName));
+ params.add(new SimpleParameterEntry("db-type", "generic"));
+ params.add(new SimpleParameterEntry("multi-db", isMultiDb ? "true" : "false"));
+ params.add(new SimpleParameterEntry("update-storage", "true"));
+ params.add(new SimpleParameterEntry("max-buffer-size", "204800"));
+
+ if (entry.getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT) != null)
+ {
+ params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, entry
+ .getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT)));
+ }
+
+ String oldSwap = entry.getParameterValue("swap-directory");
+ String newSwap = oldSwap.substring(0, oldSwap.lastIndexOf('/')) + '/' + wsName;
+
+ params.add(new SimpleParameterEntry("swap-directory", newSwap));
+
+ ContainerEntry containerEntry =
+ new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
+ (ArrayList)params);
+ containerEntry.setParameters(params);
+
+ if (vsPath != null)
+ {
+ ArrayList<ValueStorageFilterEntry> vsparams = new ArrayList<ValueStorageFilterEntry>();
+ ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
+ filterEntry.setPropertyType("Binary");
+ vsparams.add(filterEntry);
+
+ ValueStorageEntry valueStorageEntry =
+ new ValueStorageEntry("org.exoplatform.services.jcr.impl.storage.value.fs.SimpleFileValueStorage", vsparams);
+ ArrayList<SimpleParameterEntry> spe = new ArrayList<SimpleParameterEntry>();
+ spe.add(new SimpleParameterEntry("path", vsPath));
+ valueStorageEntry.setId(IdGenerator.generate());
+ valueStorageEntry.setParameters(spe);
+ valueStorageEntry.setFilters(vsparams);
+
+ // containerEntry.setValueStorages();
+ containerEntry.setParameters(params);
+ ArrayList list = new ArrayList(1);
+ list.add(valueStorageEntry);
+
+ containerEntry.setValueStorages(list);
+ }
+
+ WorkspaceEntry workspaceEntry =
+ new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
+ workspaceEntry.setContainer(containerEntry);
+
+ // // 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);
+
+ // workspaceEntry
+ return workspaceEntry;
+ }
+
+ protected void createNewDataSource(String dataSourceName) throws Exception
+ {
+ Properties properties = new Properties();
+
+ properties.setProperty("driverClassName", "org.hsqldb.jdbcDriver");
+ String newurl = "jdbc:hsqldb:file:target/temp/data/" + dataSourceName;
+
+ properties.setProperty("url", newurl);
+ properties.setProperty("username", "sa");
+ properties.setProperty("password", "");
+ DataSource bds = BasicDataSourceFactory.createDataSource(properties);
+ if (!newurl.contains("hsqldb"))
+ {
+ createDatabase(bds, dataSourceName);
+ }
+
+ new InitialContext().rebind(dataSourceName, bds);
+ }
+
+ protected void createDatabase(DataSource ds, String dbName) throws SQLException
+ {
+ Connection connection = ds.getConnection();
+ PreparedStatement st = connection.prepareStatement("create database " + dbName);
+ st.executeQuery();
+ }
+
+ protected void initJCRRoot() throws Exception
+ {
+ // prepare
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
+
+ // add root (/) with jcr:primaryType
+ addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.NT_UNSTRUCTURED, Constants.ROOT_PARENT_UUID);
+
+ // 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();
+ }
+
+ protected void deleteJCRRoot() throws Exception
+ {
+ // prepare
+
+ // delete root (/) etc
+ }
+
+ /**
+ * Add Node to the connection but doesn't save it.
+ *
+ * @param conn WorkspaceStorageConnection
+ * @param root QPath
+ * @param nodeId String
+ * @param primaryType InternalQName
+ * @throws Exception
+ */
+ protected void addDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, InternalQName primaryType, String parentNodeId)
+ throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(root, nodeId, 1, primaryType, new InternalQName[0], 0, parentNodeId,
+ new AccessControlList()));
+
+ // add property (/jcr:primaryType)
+ conn.add(createProperty(root, nodeId, Constants.JCR_PRIMARYTYPE, primaryType, false));
+ }
+
+ /**
+ * Add Property to the connection but doesn't save it.
+ *
+ * @param conn WorkspaceStorageConnection
+ * @param nodePath QPath
+ * @param nodeId String
+ * @param propertyName InternalQName
+ * @param propertyValue Object
+ * @return TransientPropertyData
+ * @throws Exception
+ */
+ protected TransientPropertyData addDbProperty(WorkspaceStorageConnection conn, QPath nodePath, String nodeId,
+ InternalQName propertyName, Object propertyValue, boolean multiValued) throws Exception
+ {
+ TransientPropertyData propData = createProperty(nodePath, nodeId, propertyName, propertyValue, multiValued);
+
+ conn.add(propData);
+
+ return propData;
+ }
+
+ /**
+ * Create Property data.
+ *
+ * @param nodePath QPath
+ * @param nodeId String
+ * @param propertyName InternalQName
+ * @param propertyValue Object
+ * @return TransientPropertyData
+ * @throws Exception
+ */
+ protected TransientPropertyData createProperty(QPath nodePath, String nodeId, InternalQName propertyName,
+ Object propertyValue, boolean multiValued) throws Exception
+ {
+ String propId = IdGenerator.generate();
+ QPath propPath = QPath.makeChildPath(nodePath, propertyName);
+ TransientPropertyData propData = new TransientPropertyData(propPath, propId, 1, 1, nodeId, multiValued);
+
+ List<Object> values = new ArrayList<Object>();
+ if (multiValued)
+ {
+ if (propertyValue instanceof List<?>)
+ {
+ values.addAll((List<?>)propertyValue);
+ }
+ else
+ throw new Exception("propertyValue should be a List");
+ }
+ else
+ {
+ values.add(propertyValue);
+ }
+
+ for (Object value : values)
+ {
+ if (value instanceof InternalQName)
+ {
+ propData.setValue(new TransientValueData((InternalQName)value));
+ }
+ else if (value instanceof String)
+ {
+ propData.setValue(new TransientValueData((String)value));
+ }
+ else if (value instanceof InputStream)
+ {
+ propData.setValue(new TransientValueData((InputStream)value));
+ }
+ }
+
+ return propData;
+ }
+
+ /**
+ * Delete Property to the connection but doesn't save it.
+ *
+ * NOT IMPLEMENTED!
+ *
+ * @param conn WorkspaceStorageConnection
+ * @param root QPath
+ * @param nodeId String
+ * @param primaryType InternalQName
+ * @throws Exception
+ */
+ protected void deleteDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, InternalQName primaryType)
+ throws Exception
+ {
+ // add property (/jcr:primaryType)
+ //deleteDbProperty(conn, root, Constants.ROOT_UUID, Constants.JCR_PRIMARYTYPE, primaryType, false);
+
+ // dlete root (/)
+ //conn.delete(new TransientNodeData(root, nodeId, 1, primaryType, new InternalQName[0], 0, null,
+ // new AccessControlList()));
+ }
+
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/JDBCWorkspaceDataContainerTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-19 14:29:05 UTC (rev 776)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-19 14:40:34 UTC (rev 777)
@@ -18,22 +18,16 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import junit.framework.TestCase;
-
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.impl.storage.JDBCWorkspaceDataContainerTestBase;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import org.jboss.cache.Node;
import org.jboss.cache.Modification.ModificationType;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
/**
* This abstract class contains only methods for creating a fake {@link Modification} instances. It doesn't use real cache.
*
@@ -41,14 +35,9 @@
* @version $Id$
*
*/
-public abstract class AbstractCacheLoaderTest extends TestCase
+public abstract class AbstractCacheLoaderTest extends JDBCWorkspaceDataContainerTestBase
{
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
/**
* Returns {@link Modification} like as node added. NodeData is written to /$NODE/IDxxxx as an attribute by key ITEM_DATA.
*
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java 2009-11-19 14:29:05 UTC (rev 776)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java 2009-11-19 14:40:34 UTC (rev 777)
@@ -18,14 +18,16 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import junit.framework.TestCase;
-
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.storage.JDBCWorkspaceDataContainerTestBase;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
@@ -42,7 +44,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id$
*/
-public abstract class AbstractJBossCacheStorageConnectionTest extends TestCase
+public abstract class AbstractJBossCacheStorageConnectionTest extends JDBCWorkspaceDataContainerTestBase
{
protected JBossCacheStorageConnection conn;
@@ -93,7 +95,9 @@
protected void initJBC() throws Exception
{
- // empty here
+ // inject JDBC DC via JBC ComponentRegistry
+ ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().registerComponent(this.persistentContainer,
+ WorkspaceDataContainer.class);
}
/**
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 14:29:05 UTC (rev 776)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 14:40:34 UTC (rev 777)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import junit.framework.TestCase;
-
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.ItemData;
@@ -31,14 +29,10 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
-import java.io.IOException;
import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
import java.util.List;
import javax.jcr.lock.LockException;
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-19 14:29:05 UTC (rev 776)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-19 14:40:34 UTC (rev 777)
@@ -18,17 +18,13 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import org.apache.commons.dbcp.BasicDataSourceFactory;
import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
import org.exoplatform.services.jcr.access.AccessControlList;
import org.exoplatform.services.jcr.config.ContainerEntry;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.SimpleParameterEntry;
-import org.exoplatform.services.jcr.config.ValueStorageEntry;
-import org.exoplatform.services.jcr.config.ValueStorageFilterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -45,19 +41,12 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
/**
* @author <a href="mailto:reshetnyak.alex@gmail.com">Alex Reshetnyak</a>
@@ -126,264 +115,6 @@
persistentContainer = new JDBCWorkspaceDataContainer(ws, re, null, valueStoragePluginProvider);
}
- 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));
- params.add(new SimpleParameterEntry("db-type", "generic"));
- params.add(new SimpleParameterEntry("multi-db", isMultiDb ? "true" : "false"));
- params.add(new SimpleParameterEntry("update-storage", "true"));
- params.add(new SimpleParameterEntry("max-buffer-size", "204800"));
-
- if (entry.getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT) != null)
- {
- params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, entry
- .getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT)));
- }
-
- String oldSwap = entry.getParameterValue("swap-directory");
- String newSwap = oldSwap.substring(0, oldSwap.lastIndexOf('/')) + '/' + wsName;
-
- params.add(new SimpleParameterEntry("swap-directory", newSwap));
-
- ContainerEntry containerEntry =
- new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
- (ArrayList)params);
- containerEntry.setParameters(params);
-
- if (vsPath != null)
- {
- ArrayList<ValueStorageFilterEntry> vsparams = new ArrayList<ValueStorageFilterEntry>();
- ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
- filterEntry.setPropertyType("Binary");
- vsparams.add(filterEntry);
-
- ValueStorageEntry valueStorageEntry =
- new ValueStorageEntry("org.exoplatform.services.jcr.impl.storage.value.fs.SimpleFileValueStorage", vsparams);
- ArrayList<SimpleParameterEntry> spe = new ArrayList<SimpleParameterEntry>();
- spe.add(new SimpleParameterEntry("path", vsPath));
- valueStorageEntry.setId(IdGenerator.generate());
- valueStorageEntry.setParameters(spe);
- valueStorageEntry.setFilters(vsparams);
-
- // containerEntry.setValueStorages();
- containerEntry.setParameters(params);
- ArrayList list = new ArrayList(1);
- list.add(valueStorageEntry);
-
- containerEntry.setValueStorages(list);
- }
-
- WorkspaceEntry workspaceEntry =
- new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
- workspaceEntry.setContainer(containerEntry);
-
- // // 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);
-
- // workspaceEntry
- return workspaceEntry;
- }
-
- private void createNewDataSource(String dataSourceName) throws Exception
- {
- Properties properties = new Properties();
-
- properties.setProperty("driverClassName", "org.hsqldb.jdbcDriver");
- String newurl = "jdbc:hsqldb:file:target/temp/data/" + dataSourceName;
-
- properties.setProperty("url", newurl);
- properties.setProperty("username", "sa");
- properties.setProperty("password", "");
- DataSource bds = BasicDataSourceFactory.createDataSource(properties);
- if (!newurl.contains("hsqldb"))
- {
- createDatabase(bds, dataSourceName);
- }
-
- new InitialContext().rebind(dataSourceName, bds);
- }
-
- private void createDatabase(DataSource ds, String dbName) throws SQLException
- {
- Connection connection = ds.getConnection();
- PreparedStatement st = connection.prepareStatement("create database " + dbName);
- st.executeQuery();
- }
-
- private void initJCRRoot() throws Exception
- {
- // prepare
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- // add root (/) with jcr:primaryType
- addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, Constants.NT_UNSTRUCTURED, Constants.ROOT_PARENT_UUID);
-
- // 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();
- }
-
- 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, Constants.ROOT_PARENT_UUID);
-
- // 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 Node to the connection but doesn't save it.
- *
- * @param conn WorkspaceStorageConnection
- * @param root QPath
- * @param nodeId String
- * @param primaryType InternalQName
- * @throws Exception
- */
- private void addDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, InternalQName primaryType, String parentNodeId)
- throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(root, nodeId, 1, primaryType, new InternalQName[0], 0, parentNodeId,
- new AccessControlList()));
-
- // add property (/jcr:primaryType)
- conn.add(createProperty(root, nodeId, Constants.JCR_PRIMARYTYPE, primaryType, false));
- }
-
- /**
- * Add Property to the connection but doesn't save it.
- *
- * @param conn WorkspaceStorageConnection
- * @param nodePath QPath
- * @param nodeId String
- * @param propertyName InternalQName
- * @param propertyValue Object
- * @return TransientPropertyData
- * @throws Exception
- */
- private TransientPropertyData addDbProperty(WorkspaceStorageConnection conn, QPath nodePath, String nodeId,
- InternalQName propertyName, Object propertyValue, boolean multiValued) throws Exception
- {
- TransientPropertyData propData = createProperty(nodePath, nodeId, propertyName, propertyValue, multiValued);
-
- conn.add(propData);
-
- return propData;
- }
-
- /**
- * Create Property data.
- *
- * @param nodePath QPath
- * @param nodeId String
- * @param propertyName InternalQName
- * @param propertyValue Object
- * @return TransientPropertyData
- * @throws Exception
- */
- private TransientPropertyData createProperty(QPath nodePath, String nodeId, InternalQName propertyName,
- Object propertyValue, boolean multiValued) throws Exception
- {
- String propId = IdGenerator.generate();
- QPath propPath = QPath.makeChildPath(nodePath, propertyName);
- TransientPropertyData propData = new TransientPropertyData(propPath, propId, 1, 1, nodeId, multiValued);
-
- List<Object> values = new ArrayList<Object>();
- if (multiValued)
- {
- if (propertyValue instanceof List<?>)
- {
- values.addAll((List<?>)propertyValue);
- }
- else
- throw new Exception("propertyValue should be a List");
- }
- else
- {
- values.add(propertyValue);
- }
-
- for (Object value : values)
- {
- if (value instanceof InternalQName)
- {
- propData.setValue(new TransientValueData((InternalQName)value));
- }
- else if (value instanceof String)
- {
- propData.setValue(new TransientValueData((String)value));
- }
- else if (value instanceof InputStream)
- {
- propData.setValue(new TransientValueData((InputStream)value));
- }
- }
-
- 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 =============
public void testAddNode() throws Exception
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml 2009-11-19 14:29:05 UTC (rev 776)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/resources/conf/standalone/test-jbosscache-config-exoloader.xml 2009-11-19 14:40:34 UTC (rev 777)
@@ -21,7 +21,7 @@
use_incoming_packet_handler="true" />
<PING num_initial_members="3" timeout="2000" /-->
- <TCP bind_addr="localhost" start_port="7800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
+ <TCP bind_addr="localhost" start_port="9800" loopback="true" recv_buf_size="20000000" send_buf_size="640000" discard_incompatible_packets="true"
max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" enable_bundling="true" use_send_queues="false" sock_conn_timeout="300"
skip_suspected_members="true" use_concurrent_stack="true" thread_pool.enabled="true" thread_pool.min_threads="1" thread_pool.max_threads="25"
thread_pool.keep_alive_time="5000" thread_pool.queue_enabled="false" thread_pool.queue_max_size="100" thread_pool.rejection_policy="run"
16 years, 8 months
exo-jcr SVN: r776 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-19 09:29:05 -0500 (Thu, 19 Nov 2009)
New Revision: 776
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-242: Locking tests moved to another class
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java 2009-11-19 14:29:05 UTC (rev 776)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import org.exoplatform.services.jcr.impl.core.lock.LockData;
+
+import java.util.List;
+
+import javax.jcr.lock.LockException;
+
+/**
+ * @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
+ * @version $Id$
+ *
+ */
+public class JBossCacheStorageConnectionLockTest extends AbstractJBossCacheStorageConnectionTest
+{
+ public void testAddLock() throws Exception
+ {
+ // ordinary add lock
+ LockData lockData = new LockData("testAddLock", "token's hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(), conn.getLockData("testAddLock").getTokenHash());
+ }
+
+ public void testAddLockTwice() throws Exception
+ {
+ // ordinary add lock
+ {
+ LockData lockData = new LockData("testAddLockTwice", "token's hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(), conn.getLockData("testAddLockTwice").getTokenHash());
+ }
+ // try to lock once more
+ try
+ {
+ // add lock to the same node twice
+ LockData lockData = new LockData("testAddLockTwice", "other token's hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ fail("exception expected, because can't lock node twice");
+ }
+ catch (LockException e)
+ {
+ }
+ }
+
+ public void testRefreshLock() throws Exception
+ {
+ // ordinary add lock
+ {
+ LockData lockData = new LockData("testRefreshLock", "token's hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(), conn.getLockData("testRefreshLock").getTokenHash());
+ }
+ // try to refresh lock (updates creation time to extend lifetime)
+ // refresh is performed by writing new lock data (only difference is changed creation time)
+ {
+ LockData lockData = new LockData("testRefreshLock", "token's hash", true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ assertEquals(lockData.getTokenHash(), conn.getLockData("testRefreshLock").getTokenHash());
+ }
+ }
+
+ public void testGetLocks() throws Exception
+ {
+ // clean up any existing
+ List<LockData> locks = conn.getLocksData();
+ for (LockData lock : locks)
+ {
+ conn.removeLockData(lock.getNodeIdentifier());
+ }
+ // check empty
+ locks = conn.getLocksData();
+ assertEquals(0, locks.size());
+ // fill
+ int count = 3;
+ for (int i = 0; i < count; i++)
+ {
+ LockData lockData = new LockData("testGetLocks" + i, "token's hash " + i, true, true, "owner", 1000);
+ conn.addLockData(lockData);
+ }
+ // assert
+ locks = conn.getLocksData();
+ assertEquals(count, locks.size());
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionLockTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 14:22:41 UTC (rev 775)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 14:29:05 UTC (rev 776)
@@ -624,75 +624,6 @@
}
- public void testAddLock() throws Exception
- {
- // ordinary add lock
- LockData lockData = new LockData("testAddLock", "token's hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(), conn.getLockData("testAddLock").getTokenHash());
- }
-
- public void testAddLockTwice() throws Exception
- {
- // ordinary add lock
- {
- LockData lockData = new LockData("testAddLockTwice", "token's hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(), conn.getLockData("testAddLockTwice").getTokenHash());
- }
- // try to lock once more
- try
- {
- // add lock to the same node twice
- LockData lockData = new LockData("testAddLockTwice", "other token's hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- fail("exception expected, because can't lock node twice");
- }
- catch (LockException e)
- {
- }
- }
-
- public void testRefreshLock() throws Exception
- {
- // ordinary add lock
- {
- LockData lockData = new LockData("testRefreshLock", "token's hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(), conn.getLockData("testRefreshLock").getTokenHash());
- }
- // try to refresh lock (updates creation time to extend lifetime)
- // refresh is performed by writing new lock data (only difference is changed creation time)
- {
- LockData lockData = new LockData("testRefreshLock", "token's hash", true, true, "owner", 1000);
- conn.addLockData(lockData);
- assertEquals(lockData.getTokenHash(), conn.getLockData("testRefreshLock").getTokenHash());
- }
- }
-
- public void testGetLocks() throws Exception
- {
- // clean up any existing
- List<LockData> locks = conn.getLocksData();
- for (LockData lock : locks)
- {
- conn.removeLockData(lock.getNodeIdentifier());
- }
- // check empty
- locks = conn.getLocksData();
- assertEquals(0, locks.size());
- // fill
- int count = 3;
- for (int i = 0; i < count; i++)
- {
- LockData lockData = new LockData("testGetLocks" + i, "token's hash " + i, true, true, "owner", 1000);
- conn.addLockData(lockData);
- }
- // assert
- locks = conn.getLocksData();
- assertEquals(count, locks.size());
- }
-
public void testAddNodeFail() throws Exception
{
// add root (/)
16 years, 8 months
exo-jcr SVN: r775 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2009-11-19 09:22:41 -0500 (Thu, 19 Nov 2009)
New Revision: 775
Removed:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java
Log:
EXOJCR-202: IndexerCacheLoaderRuntime test removed
Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java 2009-11-19 14:07:11 UTC (rev 774)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderRuntimeTest.java 2009-11-19 14:22:41 UTC (rev 775)
@@ -1,922 +0,0 @@
-/*
- * Copyright (C) 2003-2009 eXo Platform SAS.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation; either version 3
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see<http://www.gnu.org/licenses/>.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import org.apache.commons.dbcp.BasicDataSourceFactory;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.TermQuery;
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.container.configuration.ConfigurationManagerImpl;
-import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.config.ContainerEntry;
-import org.exoplatform.services.jcr.config.QueryHandlerEntry;
-import org.exoplatform.services.jcr.config.RepositoryEntry;
-import org.exoplatform.services.jcr.config.SimpleParameterEntry;
-import org.exoplatform.services.jcr.config.ValueStorageEntry;
-import org.exoplatform.services.jcr.config.ValueStorageFilterEntry;
-import org.exoplatform.services.jcr.config.WorkspaceEntry;
-import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.ValueData;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.LocationFactory;
-import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
-import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
-import org.exoplatform.services.jcr.impl.core.nodetype.registration.JcrNodeTypeDataPersister;
-import org.exoplatform.services.jcr.impl.core.nodetype.registration.NodeTypeDataPersister;
-import org.exoplatform.services.jcr.impl.core.query.RepositoryIndexSearcherHolder;
-import org.exoplatform.services.jcr.impl.core.query.SearchManager;
-import org.exoplatform.services.jcr.impl.core.query.SystemSearchManagerHolder;
-import org.exoplatform.services.jcr.impl.core.query.cacheloader.IndexerCacheLoader;
-import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
-import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.JBossCacheWorkspaceDataManager;
-import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
-import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
-import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer;
-import org.exoplatform.services.jcr.impl.storage.value.StandaloneStoragePluginProvider;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
-import org.exoplatform.services.jcr.util.IdGenerator;
-import org.jboss.cache.Modification;
-
-import java.io.InputStream;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date:
- *
- * @author <a href="karpenko.sergiy(a)gmail.com">Karpenko Sergiy</a>
- * @version $Id: IndexerCacheLoaderRuntimeTest.java 111 2008-11-11 11:11:11Z serg $
- */
-public class IndexerCacheLoaderRuntimeTest extends AbstractCacheLoaderTest
-{
-
- private JDBCWorkspaceDataContainer persistentContainer;
-
- private IndexerCacheLoader loader;
-
- SearchManager manager;
-
- //IndexInterceptorHolder holder;
-
- public void createNewDataSource(String dataSourceName) throws Exception
- {
-
- Properties properties = new Properties();
-
- properties.setProperty("driverClassName", "org.hsqldb.jdbcDriver");
- String newurl = "jdbc:hsqldb:file:target/temp/data/" + dataSourceName;
-
- properties.setProperty("url", newurl);
- properties.setProperty("username", "sa");
- properties.setProperty("password", "");
- DataSource bds = BasicDataSourceFactory.createDataSource(properties);
- if (!newurl.contains("hsqldb"))
- {
- createDatabase(bds, dataSourceName);
- }
-
- new InitialContext().rebind(dataSourceName, bds);
- }
-
- public void setUp() throws Exception
- {
- super.setUp();
-
- initPersistence();
-
- loader = new IndexerCacheLoader();
- //loader.injectDependencies(holder);
-
- initJCRRoot();
-
- manager.start();
- }
-
- public void testAddNode() throws Exception
- {
- List<Modification> modifications = new ArrayList<Modification>();
-
- // prepare add node to storage
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- String node1id = IdGenerator.generate();
- QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
-
- // add node (/) with jcr:primaryType
- NodeData nodeData =
- new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList());
- conn.add(nodeData);
- modifications.addAll(this.addNode(nodeData));
-
- // add property (/jcr:primaryType)
- TransientPropertyData propData =
- createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
- conn.add(propData);
- modifications.addAll(this.addProperty(propData));
-
- conn.commit();
- loader.put(modifications);
-
- // check do we really have node and its property
- conn = persistentContainer.openConnection();
- NodeData nd = (NodeData)conn.getItemData(node1id);
- assertNotNull(nd);
- assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
-
- PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
- assertNotNull(pd);
- assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
-
- // find node by search engine
- SearchIndex index = ((SearchIndex)manager.getHandler());
- IndexReader reader = index.getIndexReader();
-
- IndexSearcher searcher = new IndexSearcher(reader);
-
- Query query = new TermQuery(new Term("_:UUID", node1id));
- Hits hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- }
-
- public void testRemoveNode() throws Exception
- {
- List<Modification> modifications = new ArrayList<Modification>();
-
- // prepare add node to storage
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- String node1id = IdGenerator.generate();
- QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
-
- // add node (/) with jcr:primaryType
- NodeData nodeData =
- new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList());
- conn.add(nodeData);
- modifications.addAll(this.addNode(nodeData));
-
- // add property (/jcr:primaryType)
- TransientPropertyData propData =
- createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
- conn.add(propData);
- modifications.addAll(this.addProperty(propData));
-
- conn.commit();
- loader.put(modifications);
-
- // check do we really have node and its property
- conn = persistentContainer.openConnection();
- NodeData nd = (NodeData)conn.getItemData(node1id);
- assertNotNull(nd);
- assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
-
- PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
- assertNotNull(pd);
- assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
-
- // find node by search engine
- SearchIndex index = ((SearchIndex)manager.getHandler());
- IndexReader reader = index.getIndexReader();
-
- IndexSearcher searcher = new IndexSearcher(reader);
-
- Query query = new TermQuery(new Term("_:UUID", node1id));
- Hits hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- // remove node1
- modifications.clear();
-
- // PropertyData prop = (PropertyData)node.get(1);
- // NodeData n = (NodeData)node.get(0);
-
- conn.delete(pd);
- modifications.addAll(removeProperty(pd));
- conn.delete(nd);
- modifications.addAll(removeNode(nd));
- conn.commit();
-
- // check removing
- conn = persistentContainer.openConnection();
- nd = (NodeData)conn.getItemData(node1id);
- assertNull(nd);
-
- loader.put(modifications);
-
- // check index;
- reader = index.getIndexReader();
-
- searcher = new IndexSearcher(reader);
- hit = searcher.search(query);
- assertEquals(0, hit.length());
- }
-
- // public void testRenameNode() throws Exception
- // {
- // List<Modification> modifications = new ArrayList<Modification>();
- //
- // // prepare add node to storage
- // WorkspaceStorageConnection conn = persistentContainer.openConnection();
- //
- // String node1id = IdGenerator.generate();
- // QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
- //
- // // add node (/) with jcr:primaryType
- // NodeData nodeData =
- // new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- // Constants.ROOT_UUID, new AccessControlList());
- // conn.add(nodeData);
- // modifications.addAll(this.addNode(nodeData));
- //
- // // add property (/jcr:primaryType)
- // TransientPropertyData propData =
- // createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
- // conn.add(propData);
- // modifications.addAll(this.addProperty(propData));
- //
- // conn.commit();
- // loader.put(modifications);
- //
- // // check do we really have node and its property
- // conn = persistentContainer.openConnection();
- // NodeData nd = (NodeData)conn.getItemData(node1id);
- // assertNotNull(nd);
- // assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
- //
- // PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
- // assertNotNull(pd);
- // assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
- //
- // // find node by search engine
- // SearchIndex index = ((SearchIndex)manager.getHandler());
- // IndexReader reader = index.getIndexReader();
- //
- // IndexSearcher searcher = new IndexSearcher(reader);
- //
- // Query query = new TermQuery(new Term("_:UUID", node1id));
- // Hits hit = searcher.search(query);
- // assertEquals(1, hit.length());
- //
- // modifications.clear();
- //
- // conn = persistentContainer.openConnection();
- //
- // QPath newnode1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
- // NodeData newnodeData =
- // new TransientNodeData(newnode1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- // Constants.ROOT_UUID, new AccessControlList());
- //
- // conn.rename(newnodeData);
- //
- // }
-
- public void testUpdateAddProperty() throws Exception
- {
-
- List<Modification> modifications = new ArrayList<Modification>();
-
- // prepare add node to storage
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- String node1id = IdGenerator.generate();
- QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
-
- // add node (/) with jcr:primaryType
- NodeData nodeData =
- new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList());
- conn.add(nodeData);
- modifications.addAll(this.addNode(nodeData));
-
- // add property (/jcr:primaryType)
- TransientPropertyData propData =
- createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
- conn.add(propData);
- modifications.addAll(this.addProperty(propData));
-
- conn.commit();
- loader.put(modifications);
-
- // check do we really have node and its property
- conn = persistentContainer.openConnection();
- NodeData nd = (NodeData)conn.getItemData(node1id);
- assertNotNull(nd);
- assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
-
- PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
- assertNotNull(pd);
- assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
-
- // find node by search engine
- SearchIndex index = ((SearchIndex)manager.getHandler());
- IndexReader reader = index.getIndexReader();
-
- IndexSearcher searcher = new IndexSearcher(reader);
-
- Query query = new TermQuery(new Term("_:UUID", node1id));
- Hits hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- modifications.clear();
- // prepare
- TransientPropertyData newPropData =
- createProperty(node1path, node1id, new InternalQName(Constants.NS_DEFAULT_URI, "myProp"), "JCR DATA VALUE",
- false);
-
- conn = persistentContainer.openConnection();
- conn.add(newPropData);
- modifications.addAll(addProperty(newPropData));
- conn.commit();
-
- loader.put(modifications);
-
- // tests it
- WorkspaceStorageConnection connection = persistentContainer.openConnection();
-
- PropertyData destPropData = (PropertyData)connection.getItemData(newPropData.getIdentifier());
-
- assertNotNull(destPropData);
- assertEquals(newPropData.getIdentifier(), destPropData.getIdentifier());
- assertEquals(newPropData.getParentIdentifier(), destPropData.getParentIdentifier());
- assertEquals(newPropData.getPersistedVersion(), destPropData.getPersistedVersion());
- assertEquals(newPropData.getType(), destPropData.getType());
- assertEquals(newPropData.getQPath(), destPropData.getQPath());
- assertEquals(newPropData.getValues().size(), destPropData.getValues().size());
- assertEquals(1, destPropData.getValues().size());
-
- ValueData valueData = destPropData.getValues().get(0);
- assertEquals("JCR DATA VALUE", new String(valueData.getAsByteArray(), "UTF-8"));
-
- reader = index.getIndexReader();
-
- searcher = new IndexSearcher(reader);
-
- query = new TermQuery(new Term("_:UUID", node1id));
- hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- query = new TermQuery(new Term("FULL:myProp", "data"));
- hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- }
-
- public void testUpdateRemoveProperty() throws Exception
- {
-
- List<Modification> modifications = new ArrayList<Modification>();
-
- // prepare add node to storage
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- String node1id = IdGenerator.generate();
- QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
-
- // add node (/) with jcr:primaryType
- NodeData nodeData =
- new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList());
- conn.add(nodeData);
- modifications.addAll(this.addNode(nodeData));
-
- // add property (/jcr:primaryType)
- TransientPropertyData propData =
- createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
- conn.add(propData);
- modifications.addAll(this.addProperty(propData));
-
- // add additonal property
- TransientPropertyData propData2 =
- createProperty(node1path, node1id, new InternalQName(Constants.NS_DEFAULT_URI, "myProp2"), "JCR DATA VALUE",
- false);
- conn.add(propData2);
- modifications.addAll(addProperty(propData2));
-
- conn.commit();
- loader.put(modifications);
-
- // check do we really have node and its property
- conn = persistentContainer.openConnection();
- NodeData nd = (NodeData)conn.getItemData(node1id);
- assertNotNull(nd);
- assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
-
- PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
- assertNotNull(pd);
- assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
-
- // find node by search engine
- SearchIndex index = ((SearchIndex)manager.getHandler());
- IndexReader reader = index.getIndexReader();
-
- IndexSearcher searcher = new IndexSearcher(reader);
-
- Query query = new TermQuery(new Term("_:UUID", node1id));
- Hits hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- query = new TermQuery(new Term("FULL:myProp2", "data"));
- hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- modifications.clear();
-
- // remove property
- conn = persistentContainer.openConnection();
- conn.delete(propData2);
- modifications.addAll(removeProperty(propData2));
- conn.commit();
-
- loader.put(modifications);
-
- // tests it
- WorkspaceStorageConnection connection = persistentContainer.openConnection();
-
- PropertyData destPropData = (PropertyData)connection.getItemData(propData2.getIdentifier());
-
- assertNull(destPropData);
-
- reader = index.getIndexReader();
-
- searcher = new IndexSearcher(reader);
-
- query = new TermQuery(new Term("_:UUID", node1id));
- hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- query = new TermQuery(new Term("FULL:myProp2", "data"));
- hit = searcher.search(query);
- assertEquals(0, hit.length());
-
- }
-
- public void testUpdateProperty() throws Exception
- {
-
- List<Modification> modifications = new ArrayList<Modification>();
-
- // prepare add node to storage
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- String node1id = IdGenerator.generate();
- QPath node1path = QPath.makeChildPath(Constants.ROOT_PATH, "[]node:1");
-
- // add node (/) with jcr:primaryType
- NodeData nodeData =
- new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList());
- conn.add(nodeData);
- modifications.addAll(this.addNode(nodeData));
-
- // add property (/jcr:primaryType)
- TransientPropertyData propData =
- createProperty(node1path, node1id, Constants.JCR_PRIMARYTYPE, Constants.NT_UNSTRUCTURED, false);
- conn.add(propData);
- modifications.addAll(this.addProperty(propData));
-
- // add additonal property
- TransientPropertyData propData2 =
- createProperty(node1path, node1id, new InternalQName(Constants.NS_DEFAULT_URI, "myProp2"), "JCR DATA VALUE",
- false);
- conn.add(propData2);
- modifications.addAll(addProperty(propData2));
-
- conn.commit();
- loader.put(modifications);
-
- // check do we really have node and its property
- conn = persistentContainer.openConnection();
- NodeData nd = (NodeData)conn.getItemData(node1id);
- assertNotNull(nd);
- assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
-
- PropertyData pd = (PropertyData)conn.getItemData(propData.getIdentifier());
- assertNotNull(pd);
- assertEquals(propData.getQPath().getAsString(), pd.getQPath().getAsString());
-
- // find node by search engine
- SearchIndex index = ((SearchIndex)manager.getHandler());
- IndexReader reader = index.getIndexReader();
-
- IndexSearcher searcher = new IndexSearcher(reader);
-
- Query query = new TermQuery(new Term("_:UUID", node1id));
- Hits hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- query = new TermQuery(new Term("FULL:myProp2", "data"));
- hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- modifications.clear();
-
- // update property
- conn = persistentContainer.openConnection();
-
- TransientPropertyData newpropData2 =
- new TransientPropertyData(propData2.getQPath(), propData2.getIdentifier(), propData2.getPersistedVersion(),
- propData2.getType(), propData2.getParentIdentifier(), propData2.isMultiValued());
-
- newpropData2.setValue(new TransientValueData("newvalue"));
-
- conn.update(newpropData2);
- modifications.addAll(updateProperty(newpropData2));
- conn.commit();
-
- loader.put(modifications);
-
- // tests it
- WorkspaceStorageConnection connection = persistentContainer.openConnection();
-
- PropertyData destPropData = (PropertyData)connection.getItemData(propData2.getIdentifier());
-
- assertNotNull(destPropData);
-
- reader = index.getIndexReader();
-
- searcher = new IndexSearcher(reader);
-
- query = new TermQuery(new Term("_:UUID", node1id));
- hit = searcher.search(query);
- assertEquals(1, hit.length());
-
- query = new TermQuery(new Term("FULL:myProp2", "data"));
- hit = searcher.search(query);
- assertEquals(0, hit.length());
-
- query = new TermQuery(new Term("FULL:myProp2", "newvalue"));
- hit = searcher.search(query);
- assertEquals(1, hit.length());
- }
-
- /**
- * Add 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 addDbNode(WorkspaceStorageConnection conn, QPath root, String nodeId, String parentId,
- InternalQName primaryType) throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(root, nodeId, 1, primaryType, new InternalQName[0], 0, parentId,
- new AccessControlList()));
-
- // add property (/jcr:primaryType)
- addDbProperty(conn, root, nodeId, Constants.JCR_PRIMARYTYPE, primaryType, false);
- }
-
- /**
- * Add Property to the connection but doesn't save it.
- *
- * @param conn WorkspaceStorageConnection
- * @param nodePath QPath
- * @param nodeId String
- * @param propertyName InternalQName
- * @param propertyValue Object
- * @return TransientPropertyData
- * @throws Exception
- */
- private TransientPropertyData addDbProperty(WorkspaceStorageConnection conn, QPath nodePath, String nodeId,
- InternalQName propertyName, Object propertyValue, boolean multiValued) throws Exception
- {
- TransientPropertyData propData = createProperty(nodePath, nodeId, propertyName, propertyValue, multiValued);
-
- conn.add(propData);
-
- return propData;
- }
-
- private void createDatabase(DataSource ds, String dbName) throws SQLException
- {
- Connection connection = ds.getConnection();
- PreparedStatement st = connection.prepareStatement("create database " + dbName);
- st.executeQuery();
- }
-
- /**
- * Create Node to the connection but doesn't save it.
- *
- * @param path QPath
- * @param nodeId String
- * @param primaryType InternalQName
- * @param mixinTypeNames InternalQName
- * @throws Exception
- */
- private List<ItemData> createNode(QPath path, String nodeId, InternalQName primaryType,
- InternalQName[] mixinTypeNames) throws Exception
- {
- List<ItemData> list = new ArrayList<ItemData>();
-
- // add node
- list.add(new TransientNodeData(path, nodeId, 1, primaryType, (mixinTypeNames == null ? new InternalQName[0]
- : null), 0, null, new AccessControlList()));
-
- // add property (/jcr:primaryType)
- list.add(createProperty(path, Constants.ROOT_UUID, Constants.JCR_PRIMARYTYPE, primaryType, false));
-
- return list;
- }
-
- /**
- * Create Property.
- *
- * @param nodePath QPath
- * @param nodeId String
- * @param propertyName InternalQName
- * @param propertyValue Object
- * @return TransientPropertyData
- * @throws Exception
- */
- private TransientPropertyData createProperty(QPath nodePath, String nodeId, InternalQName propertyName,
- Object propertyValue, boolean multiValued) throws Exception
- {
- String propId = IdGenerator.generate();
- QPath propPath = QPath.makeChildPath(nodePath, propertyName);
- TransientPropertyData propData = new TransientPropertyData(propPath, propId, 1, 1, nodeId, multiValued);
-
- List<Object> values = new ArrayList<Object>();
- if (multiValued)
- {
- if (propertyValue instanceof List)
- {
- values.addAll((List<Object>)propertyValue);
- }
- else
- throw new Exception("propertyValue should be a List");
- }
- else
- {
- values.add(propertyValue);
- }
-
- for (Object value : values)
- {
- if (value instanceof InternalQName)
- {
- propData.setValue(new TransientValueData((InternalQName)value));
- }
- else if (value instanceof String)
- {
- propData.setValue(new TransientValueData((String)value));
- }
- else if (value instanceof InputStream)
- {
- propData.setValue(new TransientValueData((InputStream)value));
- }
- }
-
- 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()));
- }
-
- private void deleteJCRRoot() throws Exception
- {
- // prepare
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- // add root (/) with jcr:primaryType
- addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, null, 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();
- }
-
- private void initJCRRoot() throws Exception
- {
- // prepare
- WorkspaceStorageConnection conn = persistentContainer.openConnection();
-
- // add root (/) with jcr:primaryType
- addDbNode(conn, Constants.ROOT_PATH, Constants.ROOT_UUID, null, 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();
- }
-
- protected WorkspaceEntry getNewWs(String wsName, boolean isMultiDb, String dsName, String vsPath,
- ContainerEntry entry) throws Exception
- {
-
- List params = new ArrayList();
-
- params.add(new SimpleParameterEntry("sourceName", dsName));
- params.add(new SimpleParameterEntry("db-type", "generic"));
- params.add(new SimpleParameterEntry("multi-db", isMultiDb ? "true" : "false"));
- params.add(new SimpleParameterEntry("update-storage", "true"));
- params.add(new SimpleParameterEntry("max-buffer-size", "204800"));
-
- if (entry.getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT) != null)
- {
- params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, entry
- .getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT)));
- }
-
- String oldSwap = entry.getParameterValue("swap-directory");
- String newSwap = oldSwap.substring(0, oldSwap.lastIndexOf('/')) + '/' + wsName;
-
- params.add(new SimpleParameterEntry("swap-directory", newSwap));
-
- ContainerEntry containerEntry =
- new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
- (ArrayList)params);
- containerEntry.setParameters(params);
-
- if (vsPath != null)
- {
-
- ArrayList<ValueStorageFilterEntry> vsparams = new ArrayList<ValueStorageFilterEntry>();
- ValueStorageFilterEntry filterEntry = new ValueStorageFilterEntry();
- filterEntry.setPropertyType("Binary");
- vsparams.add(filterEntry);
-
- ValueStorageEntry valueStorageEntry =
- new ValueStorageEntry("org.exoplatform.services.jcr.impl.storage.value.fs.SimpleFileValueStorage", vsparams);
- ArrayList<SimpleParameterEntry> spe = new ArrayList<SimpleParameterEntry>();
- spe.add(new SimpleParameterEntry("path", vsPath));
- valueStorageEntry.setId(IdGenerator.generate());
- valueStorageEntry.setParameters(spe);
- valueStorageEntry.setFilters(vsparams);
-
- // containerEntry.setValueStorages();
- containerEntry.setParameters(params);
- ArrayList list = new ArrayList(1);
- list.add(valueStorageEntry);
-
- containerEntry.setValueStorages(list);
-
- }
-
- WorkspaceEntry workspaceEntry =
- new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
- workspaceEntry.setContainer(containerEntry);
-
- // Indexer
- ArrayList qParams = new ArrayList();
- qParams.add(new SimpleParameterEntry("indexDir", "target/temp/index/db1/ws" + IdGenerator.generate()));
- QueryHandlerEntry qEntry =
- new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
- workspaceEntry.setQueryHandler(qEntry);
-
- // 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);
-
- // 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;
- }
-
- protected void initPersistence() throws Exception
- {
- //holder = new IndexInterceptorHolder();
-
- // Create WorkspaceEntry
- ContainerEntry containerEntry = new ContainerEntry();
- List<SimpleParameterEntry> params = new ArrayList<SimpleParameterEntry>();
- params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, "hsqldb"));
- params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.SWAPDIR_PROP, "/target/temp/swap/ws"));
- containerEntry.setParameters(params);
-
- // Initialize id generator.
- new IdGenerator(new IDGeneratorServiceImpl());
-
- // Set system property Context.INITIAL_CONTEXT_FACTORY to initial context.
- System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.exoplatform.services.naming.SimpleContextFactory");
-
- // Create data source. Will be created new data source to new test.
- String dataSourceName = "jdbcjcr_" + IdGenerator.generate();
- createNewDataSource(dataSourceName);
-
- WorkspaceEntry ws =
- getNewWs("ws_to_jbdc_cache_loader", true, dataSourceName, "/target/temp/ws_to_jbdc_cache_loader/lalues",
- containerEntry);
-
- RepositoryEntry re = new RepositoryEntry();
- re.addWorkspace(ws);
-
- ValueStoragePluginProvider valueStoragePluginProvider = new StandaloneStoragePluginProvider(ws);
-
- persistentContainer = new JDBCWorkspaceDataContainer(ws, re, null, valueStoragePluginProvider);
-
- NamespaceRegistryImpl nsReg = new NamespaceRegistryImpl();
- nsReg.start();
- SystemDataContainerHolder<WorkspaceDataContainer> systemDataContainerHolder =
- new SystemDataContainerHolder(persistentContainer);
-
- WorkspacePersistentDataManager itemMgr =
- new JBossCacheWorkspaceDataManager(persistentContainer, systemDataContainerHolder);
-
- RepositoryIndexSearcherHolder indexSearcherHolder = new RepositoryIndexSearcherHolder();
-
- NodeTypeDataPersister persister = new JcrNodeTypeDataPersister(itemMgr, false);
- NodeTypeDataManager ntReg =
- new NodeTypeDataManagerImpl(re, new LocationFactory(nsReg), nsReg, persister, itemMgr, indexSearcherHolder);
-
- SystemSearchManagerHolder parentSearchManager = null;
- DocumentReaderService extractor = null;
- ConfigurationManager cfm = new ConfigurationManagerImpl();
-
- // manager =
- // new SearchManager(ws.getQueryHandler(), nsReg, ntReg, itemMgr, parentSearchManager, extractor, cfm,
- // indexSearcherHolder, holder);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- // delete all in DB
- super.tearDown();
- }
-
-}
16 years, 8 months
exo-jcr SVN: r774 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-19 09:07:11 -0500 (Thu, 19 Nov 2009)
New Revision: 774
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-203 : The test JBossCacheStorageConnectionTest was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 14:03:57 UTC (rev 773)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 14:07:11 UTC (rev 774)
@@ -693,4 +693,31 @@
assertEquals(count, locks.size());
}
+ public void testAddNodeFail() throws Exception
+ {
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, null, new AccessControlList()));
+
+ // add node (/node)
+ String node1id = "1";
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList()));
+
+ // add /jcr:system
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
+
+ try {
+ // add /jcr:system twice
+ conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
+
+ fail("The node jcr:system shouldnot be save");
+ } catch (Exception e) {
+ //ok
+ }
+ }
}
16 years, 8 months
exo-jcr SVN: r773 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 09:03:57 -0500 (Thu, 19 Nov 2009)
New Revision: 773
Removed:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java
Log:
EXOJCR-203: tree based impl deleted
Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java 2009-11-19 14:02:09 UTC (rev 772)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ExoJCRTreeCacheLoaderTest.java 2009-11-19 14:03:57 UTC (rev 773)
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 30.10.2009
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-public class ExoJCRTreeCacheLoaderTest extends JBossCacheTreeStorageConnectionTest
-{
-
- @Override
- protected void initJBCConfig()
- {
- jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
- }
-
-
-
-}
16 years, 8 months
exo-jcr SVN: r772 - in jcr/branches/1.12.0-JBC/component/core/src: test/java/org/exoplatform/services/jcr/impl/storage/jbosscache and 1 other directory.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 09:02:09 -0500 (Thu, 19 Nov 2009)
New Revision: 772
Removed:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java
Log:
EXOJCR-203: tree based impl deleted
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java 2009-11-19 13:59:33 UTC (rev 771)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorage.java 2009-11-19 14:02:09 UTC (rev 772)
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.jboss.cache.Fqn;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 31.10.2009
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-@Deprecated
-public abstract class JBossCacheTreeStorage
-{
-
- @Deprecated
- public static final String TREE = "$TREE".intern();
-
- @Deprecated
- public static final String ITEMS = "$ITEMS".intern();
-
- public static final String ITEM_DATA = "$data".intern();
-
- public static final String ITEM_ID = "$id".intern();
-
- @Deprecated
- protected final Fqn<String> treeRoot;
-
- protected final Fqn<String> itemsRoot;
-
- @Deprecated
- protected JBossCacheTreeStorage(Fqn<String> treeRoot, Fqn<String> itemsRoot)
- {
- this.itemsRoot = itemsRoot;
-
- this.treeRoot = treeRoot;
- }
-
- @Deprecated
- protected Fqn<String> makeNodeFqn(QPath nodePath)
- {
- QPathEntry[] path = nodePath.getEntries();
- String[] fqns = new String[path.length];
-
- for (int i = 0; i < path.length; i++)
- {
- fqns[i] = path[i].getAsString(true);
- }
-
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
- }
-
- @Deprecated
- protected Fqn<String> makeParentFqn(QPath propertyPath)
- {
- QPathEntry[] path = propertyPath.getEntries();
- int pathLen = path.length - 1;
- String[] fqns = new String[pathLen];
-
- for (int i = 0; i < pathLen; i++)
- {
- fqns[i] = path[i].getAsString(true);
- }
-
- return Fqn.fromRelativeFqn(treeRoot, Fqn.fromElements(fqns));
- }
-
- protected Fqn<String> makeItemFqn(String nodeId)
- {
- return Fqn.fromRelativeFqn(itemsRoot, Fqn.fromString(nodeId));
- }
-
-}
Deleted: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java 2009-11-19 13:59:33 UTC (rev 771)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnection.java 2009-11-19 14:02:09 UTC (rev 772)
@@ -1,443 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.core.lock.LockData;
-import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
-import org.jboss.cache.Cache;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import javax.jcr.InvalidItemStateException;
-import javax.jcr.RepositoryException;
-
-/**
- * DEPRECATED - DO NOT USE!
- *
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 23.10.2009<br/>
- *
- * Cache contains several regions:<br/>
- * Workspace tree. /$ROOT: On each leaf (JBossCache Node) an JCR Item Id stored.<br/>
- * Items map. /$ITEMS: Key=Id, Value = ItemData.<br/>
- * References map ??? /$REFS: Key=NodeId, Value = PropertyId.<br/>
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-@Deprecated
-public class JBossCacheTreeStorageConnection extends JBossCacheTreeStorage implements WorkspaceStorageConnection
-{
-
- protected static final Log LOG = ExoLogger.getLogger("jcr.JBossCacheStorageConnection");
-
- private final Cache<Serializable, Object> cache;
-
- //private final Node<Serializable, Object> treeRoot;
-
- //private final Node<Serializable, Object> itemsRoot;
-
- /**
- * Start batching flag. 'true' if batching was started, 'false' if batching is not start.
- */
- private boolean batchStarted = false;
-
- /**
- * JBossCacheStorageConnection constructor.
- *
- * @param cache Cache<Serializable, Object>
- */
- @Deprecated
- public JBossCacheTreeStorageConnection(Cache<Serializable, Object> cache, Node<Serializable, Object> treeRoot,
- Node<Serializable, Object> itemsRoot)
- {
- super(treeRoot.getFqn(), itemsRoot.getFqn());
-
- this.cache = cache;
- //this.itemsRoot = itemsRoot;
- //this.treeRoot = treeRoot;
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(NodeData data) throws RepositoryException, UnsupportedOperationException, InvalidItemStateException,
- IllegalStateException
- {
- startBatch();
- cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
- cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data); // treePrint(treeRoot);
- }
-
- /**
- * {@inheritDoc}
- */
- public void add(PropertyData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- Fqn<String> parentFqn = makeParentFqn(data.getQPath());
-
- // add an attr to the parent node as key=PropertyName value=PropertyId
- cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
- cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(NodeData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- cache.removeNode(makeNodeFqn(data.getQPath()));
- cache.removeNode(makeItemFqn(data.getIdentifier()));
- }
-
- /**
- * {@inheritDoc}
- */
- public void delete(PropertyData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- // delete attr on parent by key=PropertyName
- cache.remove(makeParentFqn(data.getQPath()), data.getQPath().getName().getAsString());
- cache.removeNode(makeItemFqn(data.getIdentifier()));
- }
-
- /**
- * {@inheritDoc}
- */
- public List<NodeData> getChildNodesData(NodeData parent) throws RepositoryException, IllegalStateException
- {
- //Set<Object> childNames = cache.getChildrenNames(makeNodeFqn(parent.getQPath()));
- Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
- if (parentNode == null)
- {
- throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
- }
-
- Set<Node<Serializable, Object>> childNodes = parentNode.getChildren();
-
- List<NodeData> childs = new ArrayList<NodeData>();
- for (Node<Serializable, Object> child : childNodes)
- {
- String childId = (String)child.get(ITEM_ID);
-
- // TODO NodeData or PropertyData? As ItemData check then and cast.
- NodeData node = (NodeData)cache.get(makeItemFqn(childId), ITEM_DATA);
- if (node == null)
- {
- throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
- }
- childs.add(node);
- }
-
- return childs;
- }
-
- private void treePrint(Node<Serializable, Object> node)
- {
- for (Node<Serializable, Object> child : node.getChildren())
- {
- System.out.println(child.toString());
- for (Serializable key : child.getKeys())
- {
- System.out.println("\t" + key + "=" + child.get(key));
- }
- if (!child.isLeaf())
- {
- treePrint(child);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
- {
- // TODO treeRoot.getChild(f) possible if f not a direct child???
- Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parent.getQPath()));
- if (parentNode == null)
- {
- throw new IllegalStateException("Get child Nodes error: parent not found " + parent.getQPath().getAsString());
- }
-
- List<PropertyData> childs = new ArrayList<PropertyData>();
-
- for (Serializable key : parentNode.getKeys())
- {
- if (!key.equals(ITEM_ID))
- {
- String propId = (String)parentNode.get(key);
- // TODO NodeData or PropertyData? As ItemData check then and cast.
- PropertyData property = (PropertyData)cache.get(makeItemFqn(propId), ITEM_DATA);
- if (property == null)
- {
- throw new RepositoryException("One of childs is null. Parent " + parent.getQPath().getAsString());
- }
- childs.add(property);
- }
- }
-
- return childs;
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> listChildPropertiesData(NodeData parent) throws RepositoryException, IllegalStateException
- {
- // TODO it's same as getChild... now
- return getChildPropertiesData(parent);
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(NodeData parentData, QPathEntry name) throws RepositoryException, IllegalStateException
- {
- Node<Serializable, Object> parentNode = cache.getNode(makeNodeFqn(parentData.getQPath()));
- if (parentNode == null)
- {
- throw new IllegalStateException("Get Item data error: parent not found " + parentData.getQPath().getAsString());
- }
-
- // TODO check performance of Node vs Property get
-
- String propertyId = (String)parentNode.get(name.getAsString());
- if (propertyId != null)
- {
- // it's Property Item
- return (PropertyData)cache.get(makeItemFqn(propertyId), ITEM_DATA);
- }
- else
- {
- // it's Node Item
- Node<Serializable, Object> node = parentNode.getChild(name.getAsString(true)); // TODO String not Fqn?
- if (node != null)
- {
- String nodeId = (String)node.get(ITEM_ID);
- if (nodeId != null)
- {
- return (NodeData)cache.get(makeItemFqn(nodeId), ITEM_DATA);
- }
- }
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- public ItemData getItemData(String identifier) throws RepositoryException, IllegalStateException
- {
- return (ItemData)cache.get(makeItemFqn(identifier), ITEM_DATA);
- }
-
- /**
- * {@inheritDoc}
- */
- public List<PropertyData> getReferencesData(String nodeIdentifier) throws RepositoryException,
- IllegalStateException, UnsupportedOperationException
- {
- // TODO refs impl
- return new ArrayList<PropertyData>();
- }
-
- /**
- * {@inheritDoc}
- */
- public void rename(NodeData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
- // TODO move Node to a new position at the tree,
- // but prev location was in prev DELETE.
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(NodeData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
-
- // TODO it's put anyway.. but with check?
- Object prev = cache.put(makeNodeFqn(data.getQPath()), ITEM_ID, data.getIdentifier());
- if (prev == null)
- {
- throw new IllegalStateException("Node was deleted (tree)");
- }
-
- prev = cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
- if (prev == null)
- {
- throw new IllegalStateException("Node was deleted (items)");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void update(PropertyData data) throws RepositoryException, UnsupportedOperationException,
- InvalidItemStateException, IllegalStateException
- {
- startBatch();
-
- // TODO it's put anyway.. but with check?
- Fqn<String> parentFqn = makeParentFqn(data.getQPath());
- Object prev = cache.put(parentFqn, data.getQPath().getName().getAsString(), data.getIdentifier());
- if (prev == null)
- {
- throw new IllegalStateException("Property was deleted (tree)");
- }
-
- prev = cache.put(makeItemFqn(data.getIdentifier()), ITEM_DATA, data);
- if (prev == null)
- {
- throw new IllegalStateException("Property was deleted (items)");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void commit() throws IllegalStateException, RepositoryException
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("commit " + batchStarted);
- }
-
- // end batch
- if (batchStarted)
- {
- this.cache.endBatch(true); // treePrint(treeRoot);
- batchStarted = false;
- }
- else
- {
- // TODO
- LOG.warn("Commit call without changes made.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void rollback() throws IllegalStateException, RepositoryException
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("rollback " + batchStarted);
- }
-
- // rollback batch
- if (batchStarted)
- {
- this.cache.endBatch(false);
- batchStarted = false;
- }
- else
- {
- // TODO
- LOG.warn("Rollback call without changes made.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isOpened()
- {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- public void close() throws IllegalStateException, RepositoryException
- {
- // TODO Auto-generated method stub
- }
-
- /**
- * Start batching.
- */
- private void startBatch()
- {
- if (!batchStarted)
- {
- batchStarted = true;
- this.cache.startBatch();
- }
- }
-
- /**
- * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLockData(java.lang.String)
- */
- public LockData getLockData(String identifier)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#getLocksData()
- */
- public List<LockData> getLocksData()
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#addLockData(org.exoplatform.services.jcr.impl.core.lock.LockData)
- */
- public void addLockData(LockData lockData) throws RepositoryException
- {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * @see org.exoplatform.services.jcr.storage.WorkspaceStorageConnection#removeLockData(java.lang.String)
- */
- public void removeLockData(String identifier) throws RepositoryException
- {
- // TODO Auto-generated method stub
-
- }
-
-}
Deleted: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java 2009-11-19 13:59:33 UTC (rev 771)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheTreeStorageConnectionTest.java 2009-11-19 14:02:09 UTC (rev 772)
@@ -1,685 +0,0 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.impl.storage.jbosscache;
-
-import junit.framework.TestCase;
-
-import org.exoplatform.services.jcr.access.AccessControlList;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.ItemData;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-import org.jboss.cache.Cache;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * <br/>Date: 25.10.2009
- *
- * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
- * @version $Id$
- */
-public class JBossCacheTreeStorageConnectionTest extends TestCase
-{
-
- protected JBossCacheTreeStorageConnection conn;
-
- protected Cache<Serializable, Object> cache;
-
- protected Node<Serializable, Object> tree;
-
- protected Node<Serializable, Object> items;
-
- protected String jbcConfig;
-
- /**
- * {@inheritDoc}
- */
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // JBossCache
- initJBCConfig();
-
- cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig);
-
- Node<Serializable, Object> cacheRoot = cache.getRoot();
- //Node<Serializable, Object> wsRoot = cacheRoot.addChild(Fqn.fromElements("repo", "ws"));
-
- // prepare cache structures
- tree = cacheRoot.addChild(Fqn.fromString(JBossCacheTreeStorage.TREE));
- items = cacheRoot.addChild(Fqn.fromString(JBossCacheTreeStorage.ITEMS));
-
- // run cache
- cache.create();
- cache.start();
-
- // JCR connection
- conn = new JBossCacheTreeStorageConnection(cache, tree, items);
- }
-
- protected void initJBCConfig() {
- jbcConfig = "conf/standalone/test-jbosscache-config-jdbcloader.xml";
- }
-
- /**
- * {@inheritDoc}
- */
- protected void tearDown() throws Exception
- {
-
- cache.stop();
- cache.destroy();
-
- super.tearDown();
- }
-
- private void treePrint(Node<Serializable, Object> node)
- {
- for (Node<Serializable, Object> child : node.getChildren())
- {
- System.out.println(child.toString());
- for (Serializable key : child.getKeys())
- {
- System.out.println("\t" + key + "=" + child.get(key));
- }
- if (!child.isLeaf())
- {
- treePrint(child);
- }
- }
- }
-
- private Fqn<String> makeFqn(Node<Serializable, Object> root, QPath nodePath)
- {
- QPathEntry[] path = nodePath.getEntries();
- String[] fqns = new String[path.length];
-
- for (int i = 0; i < path.length; i++)
- {
- fqns[i] = path[i].getAsString(true);
- }
-
- return Fqn.fromRelativeFqn(root.getFqn(), Fqn.fromElements(fqns));
- }
-
- public void testAddNode() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add node (/node)
- String node1id = "1";
- QPath node1path = QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
-
- // check in tree
- treePrint(tree);
-
- // get root node ([]:1)
- Node<Serializable, Object> rootNode =
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertNotNull("Node expected", rootNode);
-
- assertEquals("Childs expected", 2, rootNode.getChildren().size());
-
- for (Node<Serializable, Object> child : rootNode.getChildren())
- {
- String nodeName = child.getFqn().getLastElementAsString();
- String nodeId = (String)child.get(JBossCacheStorageConnection.ITEM_ID);
- if (nodeName.equals(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)))
- {
- assertEquals("Node id wrong", node1id, nodeId);
- }
- else if (nodeName
- .equals(Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1]
- .getAsString(true)))
- {
- assertEquals("Node id wrong", Constants.SYSTEM_UUID, nodeId);
- }
- else
- {
- fail("Wrong Node name " + nodeName);
- }
- }
-
- // check in items
- treePrint(items);
-
- Node<Serializable, Object> itemsNode = items.getChild(Fqn.fromElements(node1id));
- assertNotNull("Node item data should exists", itemsNode);
-
- Object dataObject = itemsNode.get(JBossCacheStorageConnection.ITEM_DATA);
- assertTrue("Node item data is not a Node", dataObject instanceof NodeData);
-
- NodeData data = (NodeData)dataObject;
- assertEquals("Node id wrong", node1id, data.getIdentifier());
- assertEquals("Node path wrong", node1path, data.getQPath());
- }
-
- public void testAddProperty() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add property (/jcr:primaryType)
- String propId1 = "1";
- QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
- TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
- String propValue1 = "Property value #1";
- propData1.setValue(new TransientValueData(propValue1));
- conn.add(propData1);
-
- // add property (/jcr:mixinTypes)
- String propId2 = "2";
- QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
- TransientPropertyData propData2 = new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false);
- String propValue2 = "Property value #2";
- propData2.setValue(new TransientValueData(propValue2));
- conn.add(propData2);
-
- // check in tree
- treePrint(tree);
-
- Node<Serializable, Object> rootNode =
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertEquals("Attributes ammount wrong", 3, rootNode.getKeys().size());
-
- String pid1 = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
- assertNotNull("Property ID should exists", pid1);
- assertEquals("Property ID wrong", propId1, pid1);
-
- String pid2 = (String)rootNode.get(Constants.JCR_MIXINTYPES.getAsString());
- assertNotNull("Property ID should exists", pid2);
- assertEquals("Property ID wrong", propId2, pid2);
-
- // TODO check order
- int index = 0;
- for (Serializable key : rootNode.getKeys())
- {
- //System.out.println(key);
- //index++;
- }
-
- // check in items
- treePrint(items);
-
- Node<Serializable, Object> itemsProp1 = items.getChild(Fqn.fromElements(propId1));
- Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
- assertNotNull("Property item data should exists", data1Object);
- assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
-
- PropertyData data1 = (PropertyData)data1Object;
- assertEquals("Property id wrong", propId1, data1.getIdentifier());
- assertEquals("Property path wrong", propPath1, data1.getQPath());
- assertEquals("Property Value wrong", propValue1, new String(data1.getValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
-
- Node<Serializable, Object> itemsProp2 = items.getChild(Fqn.fromElements(propId2));
- Object data2Object = itemsProp2.get(JBossCacheStorageConnection.ITEM_DATA);
- assertNotNull("Property item data should exists", data2Object);
- assertTrue("Property item data is not a Property", data2Object instanceof PropertyData);
-
- PropertyData data2 = (PropertyData)data2Object;
- assertEquals("Property id wrong", propId2, data2.getIdentifier());
- assertEquals("Property path wrong", propPath2, data2.getQPath());
- assertEquals("Property Value wrong", propValue2, new String(data2.getValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
- }
-
- public void testDeleteNode() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add node (/node)
- String node1id = "1";
- QPath node1path = QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
-
- // get root node ([]:1)
- Node<Serializable, Object> rootNode =
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertEquals("Number of childs wrong", 2, rootNode.getChildren().size());
-
- // delete /node
- conn.delete(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // check in tree
- treePrint(tree);
-
- Node<Serializable, Object> node =
- rootNode.getChild(Fqn
- .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
-
- assertNull("Node should be deleted", node);
-
- assertEquals("Childs expected", 1, rootNode.getChildren().size());
-
- Node<Serializable, Object> child = rootNode.getChildren().iterator().next();
- assertEquals("Node name wrong",
- Constants.JCR_SYSTEM_PATH.getEntries()[Constants.JCR_SYSTEM_PATH.getEntries().length - 1].getAsString(true),
- child.getFqn().getLastElementAsString());
-
- assertEquals("Node id wrong", Constants.SYSTEM_UUID, (String)child.get(JBossCacheStorageConnection.ITEM_ID));
-
- // check in items
- treePrint(items);
-
- assertNull("Node item data should not exists", items.getChild(Fqn.fromElements(node1id)));
- assertNotNull("Node item data should exists", items.getChild(Fqn.fromElements(Constants.SYSTEM_UUID)));
- }
-
- public void testDeleteProperty() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add property (/jcr:primaryType)
- String propId1 = "1";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
- 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 = "2";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
- 1, 1, Constants.ROOT_UUID, false));
-
- // get root node ([]:1)
- Node<Serializable, Object> rootNode =
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- // delete /jcr:primaryType
- conn.delete(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE),
- propId1, 1, 1, Constants.ROOT_UUID, false));
-
- // check in tree
- treePrint(tree);
-
- assertEquals("Number of childs wrong", 2, rootNode.getKeys().size());
-
- assertNull("Property should be deleted", rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString()));
-
- assertNotNull("Property should exists", rootNode.get(Constants.JCR_MIXINTYPES.getAsString()));
-
- // check in items
- treePrint(items);
-
- assertNull("Property item data should not exists", items.getChild(Fqn.fromElements(propId1)));
- assertNotNull("Property item data should exists", items.getChild(Fqn.fromElements(propId2)));
- }
-
- public void testUpdateNode() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add node (/node)
- String node1id = "1";
- QPath node1path = QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // get root node ([]:1)
- Node<Serializable, Object> rootNode =
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- // update /node (order number)
- int nodeOrderNumb = 1;
- conn.update(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0],
- nodeOrderNumb, Constants.ROOT_UUID, new AccessControlList()));
-
- // check in tree
- treePrint(tree);
-
- Node<Serializable, Object> node =
- rootNode.getChild(Fqn
- .fromElements(node1path.getEntries()[node1path.getEntries().length - 1].getAsString(true)));
-
- assertNotNull("Node should exists", node);
- assertEquals("Child expected", 1, rootNode.getChildren().size());
-
- // check in items
- treePrint(items);
-
- Node<Serializable, Object> itemNode = items.getChild(Fqn.fromElements(node1id));
- assertNotNull("Node item data should exists", itemNode);
-
- Object dataObject = itemNode.get(JBossCacheStorageConnection.ITEM_DATA);
- assertTrue("Node item data should be a NodeData", dataObject instanceof NodeData);
- assertEquals("Node id wrong", node1id, ((NodeData)dataObject).getIdentifier());
- assertEquals("Node path wrong", node1path, ((NodeData)dataObject).getQPath());
- assertEquals("Node order number wrong", nodeOrderNumb, ((NodeData)dataObject).getOrderNumber());
- }
-
- public void testUpdateProperty() throws Exception
- {
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add property (/prop1)
- String propId1 = "1";
- QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
- TransientPropertyData propData1 = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
- String propValue1 = "Property value #1";
- propData1.setValue(new TransientValueData(propValue1));
- conn.add(propData1);
-
- // update property (/prop1) with new value
- TransientPropertyData propDataU = new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false);
- String propValueU = "Updated Property value #1";
- propDataU.setValue(new TransientValueData(propValueU));
- conn.update(propDataU);
-
- // check in tree
- treePrint(tree);
-
- Node<Serializable, Object> rootNode =
- tree.getChild(Fqn.fromElements(Constants.ROOT_PATH.getEntries()[Constants.ROOT_PATH.getEntries().length - 1]
- .getAsString(true)));
-
- assertEquals("Attributes ammount wrong", 2, rootNode.getKeys().size());
-
- String pid = (String)rootNode.get(Constants.JCR_PRIMARYTYPE.getAsString());
- assertEquals("Property ID wrong", propId1, pid);
-
- // check in items
- treePrint(items);
-
- Node<Serializable, Object> itemsProp1 = items.getChild(Fqn.fromElements(propId1));
- Object data1Object = itemsProp1.get(JBossCacheStorageConnection.ITEM_DATA);
- assertNotNull("Property item data should exists", data1Object);
- assertTrue("Property item data is not a Property", data1Object instanceof PropertyData);
-
- PropertyData data1 = (PropertyData)data1Object;
- assertEquals("Property id wrong", propId1, data1.getIdentifier());
- assertEquals("Property path wrong", propPath1, data1.getQPath());
- assertEquals("Property Value wrong", propValueU, new String(data1.getValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
- }
-
- public void testGetNodeByName() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add node (/node)
- String node1id = "1";
- QPath node1path = QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
-
- // check
- ItemData nodeItem =
- conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()),
- node1path.getEntries()[node1path.getEntries().length - 1]);
-
- assertTrue("Node expected", nodeItem.isNode());
- assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
- assertEquals("Node path wrong", node1path, nodeItem.getQPath());
- }
-
- public void testGetPropertyByName() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add property (/jcr:primaryType)
- String propId1 = "1";
- QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
- conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 = "2";
- QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
- conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
-
- // check
- ItemData propItem =
- conn.getItemData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()),
- propPath1.getEntries()[propPath1.getEntries().length - 1]);
-
- assertFalse("Proeprty expected", propItem.isNode());
- assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
- assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
- }
-
- public void testGetNodeById() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add node (/node)
- String node1id = "1";
- QPath node1path = QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
-
- // check
- ItemData nodeItem = conn.getItemData(node1id);
-
- assertTrue("Node expected", nodeItem.isNode());
- assertEquals("Node id wrong", node1id, nodeItem.getIdentifier());
- assertEquals("Node path wrong", node1path, nodeItem.getQPath());
- }
-
- public void testGetPropertyById() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add property (/jcr:primaryType)
- String propId1 = "1";
- QPath propPath1 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE);
- conn.add(new TransientPropertyData(propPath1, propId1, 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 = "2";
- QPath propPath2 = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES);
- conn.add(new TransientPropertyData(propPath2, propId2, 1, 1, Constants.ROOT_UUID, false));
-
- // check
- ItemData propItem = conn.getItemData(propId1);
-
- assertFalse("Proeprty expected", propItem.isNode());
- assertEquals("Proeprty id wrong", propId1, propItem.getIdentifier());
- assertEquals("Proeprty path wrong", propPath1, propItem.getQPath());
- }
-
- public void testGetChildNodes() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add node (/node)
- String node1id = "1";
- QPath node1path = QPath.parse("[]:1[]node:1");
- conn.add(new TransientNodeData(node1path, node1id, 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
- Constants.ROOT_UUID, new AccessControlList()));
-
- // add /jcr:system
- conn.add(new TransientNodeData(Constants.JCR_SYSTEM_PATH, Constants.SYSTEM_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_UUID, new AccessControlList()));
-
- // check in tree
- treePrint(tree);
-
- List<NodeData> childs =
- conn.getChildNodesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
- Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- assertEquals("Childs amount wrong", 2, childs.size());
-
- for (NodeData child : childs)
- {
- if (child.getQPath().equals(node1path))
- {
- assertEquals("Node id wrong", node1id, child.getIdentifier());
- }
- else if (child.getQPath().equals(Constants.JCR_SYSTEM_PATH))
- {
- assertEquals("Node id wrong", Constants.SYSTEM_UUID, child.getIdentifier());
- }
- else
- {
- fail("Wrong Node found");
- }
- }
- }
-
- public void testGetChildProperties() throws Exception
- {
- // TODO prepare using JCR WDC API (not a right way, JBC API better... but read assumes the write works)
- // add root (/)
- conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
- new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- // add property (/jcr:primaryType)
- String propId1 = "1";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_PRIMARYTYPE), propId1,
- 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/jcr:mixinTypes)
- String propId2 = "2";
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_MIXINTYPES), propId2,
- 1, 1, Constants.ROOT_UUID, false));
-
- // add property (/a)
- String propId3 = "3";
- InternalQName propName3 = InternalQName.parse("[]a");
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName3), propId3, 1, 1,
- Constants.ROOT_UUID, false));
-
- // add property (/b)
- String propId4 = "4";
- InternalQName propName4 = InternalQName.parse("[]b");
- conn.add(new TransientPropertyData(QPath.makeChildPath(Constants.ROOT_PATH, propName4), propId4, 1, 1,
- Constants.ROOT_UUID, false));
-
- // check
- treePrint(tree);
-
- List<PropertyData> childs =
- conn.getChildPropertiesData(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1,
- Constants.NT_UNSTRUCTURED, new InternalQName[0], 0, Constants.ROOT_PARENT_UUID, new AccessControlList()));
-
- assertEquals("Childs amount wrong", 4, childs.size());
-
- for (PropertyData child : childs)
- {
- if (child.getQPath().getName().equals(Constants.JCR_PRIMARYTYPE))
- {
- assertEquals("Property id wrong", propId1, child.getIdentifier());
- }
- else if (child.getQPath().getName().equals(Constants.JCR_MIXINTYPES))
- {
- assertEquals("Property id wrong", propId2, child.getIdentifier());
- }
- else if (child.getQPath().getName().equals(propName3))
- {
- assertEquals("Property id wrong", propId3, child.getIdentifier());
- }
- else if (child.getQPath().getName().equals(propName4))
- {
- assertEquals("Property id wrong", propId4, child.getIdentifier());
- }
- else
- {
- fail("Wrong Property found");
- }
- }
- }
-
-}
16 years, 8 months
exo-jcr SVN: r771 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: pnedonosko
Date: 2009-11-19 08:59:33 -0500 (Thu, 19 Nov 2009)
New Revision: 771
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
Log:
EXOJCR-203: conn tests
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java 2009-11-19 13:59:33 UTC (rev 771)
@@ -0,0 +1,200 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.impl.storage.jbosscache;
+
+import junit.framework.TestCase;
+
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.PropertyData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 25.10.2009
+ *
+ * @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
+ * @version $Id$
+ */
+public abstract class AbstractJBossCacheStorageConnectionTest extends TestCase
+{
+
+ protected JBossCacheStorageConnection conn;
+
+ protected Cache<Serializable, Object> cache;
+
+ protected Node<Serializable, Object> nodes;
+
+ protected Node<Serializable, Object> props;
+
+ protected Node<Serializable, Object> locks;
+
+ protected String jbcConfig;
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // JBossCache
+ initJBCConfig();
+
+ cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig, false);
+
+ initJBC();
+
+ // run cache
+ cache.create();
+ cache.start();
+
+ Node<Serializable, Object> cacheRoot = cache.getRoot();
+
+ // prepare cache structures
+ nodes = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.NODES));
+ props = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.PROPS));
+ locks = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.LOCKS));
+
+ // JCR connection
+ conn = new JBossCacheStorageConnection(cache, nodes, props, locks);
+ }
+
+ protected void initJBCConfig()
+ {
+ jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
+ }
+
+ protected void initJBC() throws Exception
+ {
+ // empty here
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void tearDown() throws Exception
+ {
+
+ cache.stop();
+ cache.destroy();
+
+ super.tearDown();
+ }
+
+ protected void treePrint(Node<Serializable, Object> node)
+ {
+ for (Node<Serializable, Object> child : node.getChildren())
+ {
+ System.out.println(child.toString());
+ for (Serializable key : child.getKeys())
+ {
+ System.out.println("\t" + key + "=" + child.get(key));
+ }
+ if (!child.isLeaf())
+ {
+ treePrint(child);
+ }
+ }
+ }
+
+ protected void checkNode(Node<Serializable, Object> rootNode, String nodeId, QPath nodePath)
+ {
+ Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(nodeId));
+
+ // check Node
+ Object dataObject = node.get(JBossCacheStorageConnection.ITEM_DATA);
+ assertTrue("Node item data is not a Node", dataObject instanceof NodeData);
+
+ NodeData data = (NodeData)dataObject;
+ assertEquals("Node id wrong", nodeId, data.getIdentifier());
+ assertEquals("Node path wrong", nodePath, data.getQPath());
+ }
+
+ protected void checkProp(String propId, QPath propPath, Object propValue) throws UnsupportedEncodingException,
+ IllegalStateException, IOException
+ {
+ Node<Serializable, Object> prop = props.getChild(Fqn.fromElements(propId));
+ Object dataObject = prop.get(JBossCacheStorage.ITEM_DATA);
+ assertNotNull("Property item data should exists", dataObject);
+ assertTrue("Property item data is not a Property", dataObject instanceof PropertyData);
+
+ PropertyData propData = (PropertyData)dataObject;
+ assertEquals("Property id wrong", propId, propData.getIdentifier());
+ assertEquals("Property path wrong", propPath, propData.getQPath());
+ assertEquals("Property Value wrong", propValue, new String(propData.getValues().get(0).getAsByteArray(),
+ Constants.DEFAULT_ENCODING));
+ }
+
+ protected void checkChildProp(Node<Serializable, Object> node, InternalQName propName, String propId, QPath propPath,
+ Object propValue) throws UnsupportedEncodingException, IllegalStateException, IOException
+ {
+ String pid = (String)node.get(propName.getAsString());
+
+ assertNotNull("Property ID should exists", pid);
+ assertEquals("Property ID wrong", propId, pid);
+
+ checkProp(propId, propPath, propValue);
+ }
+
+ protected void checkChildNode(Node<Serializable, Object> rootNode, String childId, QPath childPath)
+ {
+ checkChildNode(rootNode, childId, childPath, -1, -1);
+ }
+
+ protected void checkChildNode(Node<Serializable, Object> rootNode, String childId, QPath childPath, int orderNum,
+ int version)
+ {
+ Node<Serializable, Object> childNode =
+ rootNode.getChild(Fqn
+ .fromElements(childPath.getEntries()[childPath.getEntries().length - 1].getAsString(true)));
+
+ assertNotNull("Child Node should exists", childNode);
+ String childNodeId = (String)childNode.get(JBossCacheStorage.ITEM_ID);
+ Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(childNodeId));
+ assertNotNull("Node by ID should exists", node);
+
+ Object childNodeObject = node.get(JBossCacheStorage.ITEM_DATA);
+ assertTrue("Node item data is not a Node", childNodeObject instanceof NodeData);
+ NodeData childNodeData = (NodeData)childNodeObject;
+ assertEquals("Node id wrong", childId, childNodeData.getIdentifier());
+ assertEquals("Node path wrong", childPath, childNodeData.getQPath());
+
+ if (orderNum >= 0)
+ {
+ assertEquals("Node order number wrong", orderNum, childNodeData.getOrderNumber());
+ }
+
+ if (version >= 0)
+ {
+ assertEquals("Node persisted version wrong", version, childNodeData.getPersistedVersion());
+ }
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractJBossCacheStorageConnectionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 12:53:34 UTC (rev 770)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnectionTest.java 2009-11-19 13:59:33 UTC (rev 771)
@@ -51,161 +51,9 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter Nedonosko</a>
* @version $Id$
*/
-public class JBossCacheStorageConnectionTest extends TestCase
+public class JBossCacheStorageConnectionTest extends AbstractJBossCacheStorageConnectionTest
{
- protected JBossCacheStorageConnection conn;
-
- protected Cache<Serializable, Object> cache;
-
- protected Node<Serializable, Object> nodes;
-
- protected Node<Serializable, Object> props;
-
- protected Node<Serializable, Object> locks;
-
- protected String jbcConfig;
-
- /**
- * {@inheritDoc}
- */
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // JBossCache
- initJBCConfig();
-
- cache = new DefaultCacheFactory<Serializable, Object>().createCache(jbcConfig, false);
-
- initJBC();
-
- // run cache
- cache.create();
- cache.start();
-
- Node<Serializable, Object> cacheRoot = cache.getRoot();
-
- // prepare cache structures
- nodes = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.NODES));
- props = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.PROPS));
- locks = cacheRoot.addChild(Fqn.fromString(JBossCacheStorage.LOCKS));
-
- // JCR connection
- conn = new JBossCacheStorageConnection(cache, nodes, props, locks);
- }
-
- protected void initJBCConfig()
- {
- jbcConfig = "conf/standalone/test-jbosscache-config-jdbcloader.xml";
- }
-
- protected void initJBC() throws Exception
- {
- // empty here
- }
-
- /**
- * {@inheritDoc}
- */
- protected void tearDown() throws Exception
- {
-
- cache.stop();
- cache.destroy();
-
- super.tearDown();
- }
-
- private void treePrint(Node<Serializable, Object> node)
- {
- for (Node<Serializable, Object> child : node.getChildren())
- {
- System.out.println(child.toString());
- for (Serializable key : child.getKeys())
- {
- System.out.println("\t" + key + "=" + child.get(key));
- }
- if (!child.isLeaf())
- {
- treePrint(child);
- }
- }
- }
-
- private void checkNode(Node<Serializable, Object> rootNode, String nodeId, QPath nodePath)
- {
- Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(nodeId));
-
- // check Node
- Object dataObject = node.get(JBossCacheStorageConnection.ITEM_DATA);
- assertTrue("Node item data is not a Node", dataObject instanceof NodeData);
-
- NodeData data = (NodeData)dataObject;
- assertEquals("Node id wrong", nodeId, data.getIdentifier());
- assertEquals("Node path wrong", nodePath, data.getQPath());
- }
-
- private void checkProp(String propId, QPath propPath, Object propValue) throws UnsupportedEncodingException,
- IllegalStateException, IOException
- {
- Node<Serializable, Object> prop = props.getChild(Fqn.fromElements(propId));
- Object dataObject = prop.get(JBossCacheStorage.ITEM_DATA);
- assertNotNull("Property item data should exists", dataObject);
- assertTrue("Property item data is not a Property", dataObject instanceof PropertyData);
-
- PropertyData propData = (PropertyData)dataObject;
- assertEquals("Property id wrong", propId, propData.getIdentifier());
- assertEquals("Property path wrong", propPath, propData.getQPath());
- assertEquals("Property Value wrong", propValue, new String(propData.getValues().get(0).getAsByteArray(),
- Constants.DEFAULT_ENCODING));
- }
-
- private void checkChildProp(Node<Serializable, Object> node, InternalQName propName, String propId, QPath propPath,
- Object propValue) throws UnsupportedEncodingException, IllegalStateException, IOException
- {
- String pid = (String)node.get(propName.getAsString());
-
- assertNotNull("Property ID should exists", pid);
- assertEquals("Property ID wrong", propId, pid);
-
- checkProp(propId, propPath, propValue);
- }
-
- private void checkChildNode(Node<Serializable, Object> rootNode, String childId, QPath childPath)
- {
- checkChildNode(rootNode, childId, childPath, -1, -1);
- }
-
- private void checkChildNode(Node<Serializable, Object> rootNode, String childId, QPath childPath, int orderNum,
- int version)
- {
- Node<Serializable, Object> childNode =
- rootNode.getChild(Fqn
- .fromElements(childPath.getEntries()[childPath.getEntries().length - 1].getAsString(true)));
-
- assertNotNull("Child Node should exists", childNode);
- String childNodeId = (String)childNode.get(JBossCacheStorage.ITEM_ID);
- Node<Serializable, Object> node = nodes.getChild(Fqn.fromElements(childNodeId));
- assertNotNull("Node by ID should exists", node);
-
- Object childNodeObject = node.get(JBossCacheStorage.ITEM_DATA);
- assertTrue("Node item data is not a Node", childNodeObject instanceof NodeData);
- NodeData childNodeData = (NodeData)childNodeObject;
- assertEquals("Node id wrong", childId, childNodeData.getIdentifier());
- assertEquals("Node path wrong", childPath, childNodeData.getQPath());
-
- if (orderNum >= 0)
- {
- assertEquals("Node order number wrong", orderNum, childNodeData.getOrderNumber());
- }
-
- if (version >= 0)
- {
- assertEquals("Node persisted version wrong", version, childNodeData.getPersistedVersion());
- }
- }
-
public void testAddNode() throws Exception
{
// add root (/)
16 years, 8 months
exo-jcr SVN: r770 - in jcr/branches/1.12.0-JBC/component/core/src: main/java/org/exoplatform/services/jcr/impl/dataflow/persistent and 2 other directories.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-19 07:53:34 -0500 (Thu, 19 Nov 2009)
New Revision: 770
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/dataflow/LockPlainChangesLogImpl.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java
Log:
EXOJCR-242: Updated low-level locking logic.
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/dataflow/LockPlainChangesLogImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/dataflow/LockPlainChangesLogImpl.java 2009-11-19 12:19:05 UTC (rev 769)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/dataflow/LockPlainChangesLogImpl.java 2009-11-19 12:53:34 UTC (rev 770)
@@ -44,6 +44,12 @@
super(items, sessionId, eventType);
}
+ public LockPlainChangesLogImpl(List<ItemState> items, String sessionId, int eventType, LockData lockData)
+ {
+ super(items, sessionId, eventType);
+ this.lockData = lockData;
+ }
+
public LockData getLockData()
{
return lockData;
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-11-19 12:19:05 UTC (rev 769)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/VersionableWorkspaceDataManager.java 2009-11-19 12:53:34 UTC (rev 770)
@@ -22,6 +22,7 @@
import org.exoplatform.services.jcr.dataflow.CompositeChangesLog;
import org.exoplatform.services.jcr.dataflow.DataManager;
import org.exoplatform.services.jcr.dataflow.ItemState;
+import org.exoplatform.services.jcr.dataflow.LockPlainChangesLogImpl;
import org.exoplatform.services.jcr.dataflow.PairChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.dataflow.PlainChangesLogImpl;
@@ -32,9 +33,8 @@
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.observation.ExtendedEvent;
import org.exoplatform.services.jcr.util.IdGenerator;
-import org.exoplatform.services.log.ExoLogger;
-import org.exoplatform.services.log.Log;
import java.util.ArrayList;
import java.util.List;
@@ -118,40 +118,40 @@
return super.getItemData(parentData, name);
}
-// /**
-// * {@inheritDoc}
-// */
-// public ItemData getItemData(String identifier) throws RepositoryException
-// {
-// // from cache at first
-// ItemData cdata = persistentManager.getCachedItemData(identifier);
-// if (cdata != null)
-// return super.getItemData(identifier);
-//
-// if (!this.equals(versionDataManager) && !identifier.equals(Constants.ROOT_UUID))
-// {
-// // search in System cache for /jcr:system nodes only
-// cdata = versionDataManager.persistentManager.getCachedItemData(identifier);
-// if (cdata != null)
-// if (isSystemDescendant(cdata.getQPath()))
-// return versionDataManager.getItemData(identifier);
-// else
-// return null;
-// }
-//
-// // then from persistence
-// ItemData data = super.getItemData(identifier);
-// if (data != null)
-// return data;
-// else if (!this.equals(versionDataManager))
-// {
-// // try from version storage if not the same
-// data = versionDataManager.getItemData(identifier);
-// if (data != null && isSystemDescendant(data.getQPath()))
-// return data;
-// }
-// return null;
-// }
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public ItemData getItemData(String identifier) throws RepositoryException
+ // {
+ // // from cache at first
+ // ItemData cdata = persistentManager.getCachedItemData(identifier);
+ // if (cdata != null)
+ // return super.getItemData(identifier);
+ //
+ // if (!this.equals(versionDataManager) && !identifier.equals(Constants.ROOT_UUID))
+ // {
+ // // search in System cache for /jcr:system nodes only
+ // cdata = versionDataManager.persistentManager.getCachedItemData(identifier);
+ // if (cdata != null)
+ // if (isSystemDescendant(cdata.getQPath()))
+ // return versionDataManager.getItemData(identifier);
+ // else
+ // return null;
+ // }
+ //
+ // // then from persistence
+ // ItemData data = super.getItemData(identifier);
+ // if (data != null)
+ // return data;
+ // else if (!this.equals(versionDataManager))
+ // {
+ // // try from version storage if not the same
+ // data = versionDataManager.getItemData(identifier);
+ // if (data != null && isSystemDescendant(data.getQPath()))
+ // return data;
+ // }
+ // return null;
+ // }
public void save(CompositeChangesLog changesLog) throws RepositoryException, InvalidItemStateException
{
@@ -185,18 +185,39 @@
if (vstates.size() > 0)
{
- versionLog.addLog((pairId != null) ? new PairChangesLog(vstates, changes.getSessionId(), changes
- .getEventType(), pairId) : new PlainChangesLogImpl(vstates, changes.getSessionId(), changes
- .getEventType()));
+ if (pairId != null)
+ {
+ versionLog.addLog(new PairChangesLog(vstates, changes.getSessionId(), changes.getEventType(), pairId));
+ }
+ else if (changes.getEventType() == ExtendedEvent.LOCK)
+ {
+ versionLog.addLog(new LockPlainChangesLogImpl(vstates, changes.getSessionId(), changes.getEventType(),
+ ((LockPlainChangesLogImpl)changes).getLockData()));
+ }
+ else
+ {
+ versionLog.addLog(new PlainChangesLogImpl(vstates, changes.getSessionId(), changes.getEventType()));
+ }
saveVersions = true;
}
if (nvstates.size() > 0)
{
- nonVersionLog.addLog((pairId != null) ? new PairChangesLog(nvstates, changes.getSessionId(), changes
- .getEventType(), pairId) : new PlainChangesLogImpl(nvstates, changes.getSessionId(), changes
- .getEventType()));
+ if (pairId != null)
+ {
+ nonVersionLog
+ .addLog(new PairChangesLog(nvstates, changes.getSessionId(), changes.getEventType(), pairId));
+ }
+ else if (changes.getEventType() == ExtendedEvent.LOCK)
+ {
+ nonVersionLog.addLog(new LockPlainChangesLogImpl(nvstates, changes.getSessionId(), changes
+ .getEventType(), ((LockPlainChangesLogImpl)changes).getLockData()));
+ }
+ else
+ {
+ nonVersionLog.addLog(new PlainChangesLogImpl(nvstates, changes.getSessionId(), changes.getEventType()));
+ }
saveNonVersions = true;
}
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-19 12:19:05 UTC (rev 769)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JBossCacheStorageConnection.java 2009-11-19 12:53:34 UTC (rev 770)
@@ -390,7 +390,8 @@
{
if (LOG.isDebugEnabled())
{
- LOG.debug("FATAL Parent not found " + parentData.getQPath().getAsString() + " for " + name.getAsString(true));
+ LOG.debug("FATAL Parent not found " + parentData.getQPath().getAsString() + " for "
+ + name.getAsString(true));
}
// TODO should be Exception, but after OPT branch optimization merge, current impl requires it as null returned
@@ -723,6 +724,7 @@
*/
public void addLockData(LockData lockData) throws RepositoryException
{
+ startBatch();
if (lockData == null)
{
throw new RepositoryException("Lock data to write can't be null!");
@@ -761,7 +763,8 @@
*/
public void removeLockData(String identifier) throws RepositoryException
{
- if (identifier != null)
+ startBatch();
+ if (identifier == null)
{
throw new RepositoryException("Item ID to clear lock can't be null!");
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java 2009-11-19 12:19:05 UTC (rev 769)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java 2009-11-19 12:53:34 UTC (rev 770)
@@ -21,7 +21,6 @@
import org.exoplatform.services.jcr.JcrImplBaseTest;
import org.exoplatform.services.jcr.core.CredentialsImpl;
import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.NodeImpl;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
@@ -65,7 +64,7 @@
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws");
- NodeImpl node2 = (NodeImpl)session2.getNodeByUUID(node1.getUUID());
+ NodeImpl node2 = (NodeImpl)session2.getItem(node1.getPath());
// check node locked
assertTrue(node2.isLocked());
// check session2 has NO access to lock
@@ -89,7 +88,7 @@
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws");
- NodeImpl node2 = (NodeImpl)session2.getNodeByUUID(node1.getUUID());
+ NodeImpl node2 = (NodeImpl)session2.getItem(node1.getPath());
// check node locked
assertTrue(node1.isLocked());
assertTrue(node2.isLocked());
@@ -128,7 +127,7 @@
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws");
- NodeImpl node2 = (NodeImpl)session2.getNodeByUUID(node1.getUUID());
+ NodeImpl node2 = (NodeImpl)session2.getItem(node1.getPath());
// lock through session2, as session-scoped
Lock lock2 = node2.lock(false, true);
// check session2 has access to lock
@@ -153,7 +152,7 @@
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
SessionImpl session2 = (SessionImpl)repository.login(credentials, "ws");
- NodeImpl node2 = (NodeImpl)session2.getNodeByUUID(node1.getUUID());
+ NodeImpl node2 = (NodeImpl)session2.getItem(node1.getPath());
// lock through session2, as open-scoped
Lock lock2 = node2.lock(false, false);
// check session2 has access to lock
16 years, 8 months
exo-jcr SVN: r769 - jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock.
by do-not-reply@jboss.org
Author: nzamosenchuk
Date: 2009-11-19 07:19:05 -0500 (Thu, 19 Nov 2009)
New Revision: 769
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java
Log:
EXOJCR-243: test updated.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java 2009-11-19 12:09:52 UTC (rev 768)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/core/lock/TestSessionLockManager.java 2009-11-19 12:19:05 UTC (rev 769)
@@ -56,7 +56,7 @@
public void testAddLockToken() throws RepositoryException
{
NodeImpl node1 = (NodeImpl)testRoot.addNode("testAddLockToken");
- node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ node1.addMixin("mix:lockable");
session.save();
// lock through session1
Lock lock1 = node1.lock(false, true);
@@ -80,7 +80,7 @@
public void testLockUnlock() throws RepositoryException
{
NodeImpl node1 = (NodeImpl)testRoot.addNode("testLockUnlock");
- node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ node1.addMixin("mix:lockable");
session.save();
// lock through session1
Lock lock1 = node1.lock(false, false);
@@ -107,7 +107,7 @@
public void testGetLock() throws RepositoryException
{
NodeImpl node1 = (NodeImpl)testRoot.addNode("testGetLock");
- node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ node1.addMixin("mix:lockable");
session.save();
// lock
Lock lock1 = node1.lock(false, false);
@@ -122,7 +122,7 @@
{
// checks that session-scoped locks are removed on logout
NodeImpl node1 = (NodeImpl)testRoot.addNode("testRemoveOnLogOut");
- node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ node1.addMixin("mix:lockable");
session.save();
// create new session2
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
@@ -147,7 +147,7 @@
{
// checks that open-scoped locks are not removed on logout
NodeImpl node1 = (NodeImpl)testRoot.addNode("testNotRemoveOnLogOut");
- node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ node1.addMixin("mix:lockable");
session.save();
// create new session2
CredentialsImpl credentials = new CredentialsImpl("admin", "admin".toCharArray());
@@ -177,7 +177,7 @@
int REMOVER_SCHEDULE_TIME = 10000; // 10s?! need to place correct value
int lockTimeOut = 2000;
NodeImpl node1 = (NodeImpl)testRoot.addNode("testRemoveByTimeOut");
- node1.addMixin(Constants.MIX_LOCKABLE.getAsString());
+ node1.addMixin("mix:lockable");
session.save();
// set time out 2s
node1.lock(false, lockTimeOut);
16 years, 8 months