exo-jcr SVN: r535 - 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-10 03:56:46 -0500 (Tue, 10 Nov 2009)
New Revision: 535
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
Log:
EXOJCR-202: IndexerCacheLoaderTest updated
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-11-10 08:54:53 UTC (rev 534)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-11-10 08:56:46 UTC (rev 535)
@@ -90,8 +90,30 @@
indexerCacheLoader.put(modification);
assertNotNull(searchManager.getAddedNodes());
assertNotNull(searchManager.getRemovedNodes());
+ assertTrue(searchManager.getRemovedNodes().isEmpty());
}
+ public void testRemoveNode() throws Exception
+ {
+ QPath node1path = QPath.parse("[]:1[]node:1");
+ NodeData node =
+ new TransientNodeData(node1path, "n123456", 1, Constants.NT_UNSTRUCTURED, new InternalQName[0], 0,
+ Constants.ROOT_UUID, new AccessControlList());
+
+ QPath prop1path = QPath.makeChildPath(node1path, Constants.JCR_PRIMARYTYPE);
+ PropertyData prop = new TransientPropertyData(prop1path, "p123456", 0, PropertyType.NAME, "n123456", false);
+
+ List<Modification> modification = new ArrayList<Modification>();
+
+ modification.add(removeNode(node));
+ modification.add(removeProperty(prop));
+ indexerCacheLoader.put(modification);
+ assertTrue(searchManager.getAddedNodes().isEmpty());
+ assertNotNull(searchManager.getRemovedNodes());
+ assertFalse(searchManager.getRemovedNodes().isEmpty());
+
+ }
+
private class DummySearchManager implements SearchManager
{
16 years, 8 months
exo-jcr SVN: r534 - 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-10 03:54:53 -0500 (Tue, 10 Nov 2009)
New Revision: 534
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
Log:
EXOJCR-204: Updated abstract test-class
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-10 08:12:16 UTC (rev 533)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-10 08:54:53 UTC (rev 534)
@@ -39,17 +39,46 @@
public abstract class AbstractCacheLoaderTest extends TestCase
{
+ protected static boolean addPUTDATA = true;
+
/**
* Returns {@link Modification} like as node added. NodeData is written to /$NODE/IDxxxx as an attribute by key ITEM_DATA.
*
+ * PUT_DATA /$NODES/ParentId/ChildName
+ * PUT_KEY_VALUE /$NODES/ParentId/ChildName.Id
+ * PUT_DATA /$NODES/Id
+ * PUT_KEY_VALUE /$NODES/Id.Item_data
+ *
* @param data
* @return
*/
- public Modification addNode(NodeData data)
+ public List<Modification> addNode(NodeData data)
{
- String fqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
- return new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
- (Object)data);
+ List<Modification> list = new ArrayList<Modification>();
+
+ if (data.getParentIdentifier() != null)
+ {
+ // if not root:
+ // write to : /$NODES/ParentID/ChildName
+ // key=ITEM_ID val = uuid
+ String childFqn =
+ "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier() + "/"
+ + data.getQPath().getEntries()[data.getQPath().getEntries().length - 1].getAsString();
+ // Fire modification child added
+ if (addPUTDATA)
+ list.add(new Modification(ModificationType.PUT_DATA, Fqn.fromString(childFqn)));
+ // add modification that value is written by key ITEM_ID
+ list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(childFqn), JBossCacheStorage.ITEM_ID,
+ data.getIdentifier()));
+ }
+ String nodeFqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
+ // add PUT_DATA modification
+ if (addPUTDATA)
+ list.add(new Modification(ModificationType.PUT_DATA, Fqn.fromString(nodeFqn)));
+
+ list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(nodeFqn), JBossCacheStorage.ITEM_DATA,
+ data));
+ return list;
}
/**
@@ -57,27 +86,54 @@
* so {@link Modification} instance contains additional data: Key=ITEM_DATA, value=NodeData - data of already removed
* node.
*
+ * REMOVE_NODE /$NODES/ParentId/ChildName
+ * REMOVE_NODE /$NODES/Id
+ *
* @param data
* @return
*/
- public Modification removeNode(NodeData data)
+ public List<Modification> removeNode(NodeData data)
{
+ List<Modification> list = new ArrayList<Modification>();
+ if (data.getParentIdentifier() != null)
+ {
+ // remove child from parent
+ String childFqn =
+ "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier() + "/"
+ + data.getQPath().getEntries()[data.getQPath().getEntries().length - 1].getAsString();
+ list.add(new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(childFqn)));
+ }
String fqn = "/" + JBossCacheStorage.NODES + "/" + data.getIdentifier();
- return new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
- (Object)data);
+ list.add(new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), JBossCacheStorage.ITEM_DATA, data));
+ return list;
}
/**
* Returns {@link Modification} like as property added. PropertyData is written to /$PROPERTY/IDxxxx as an attribute by key ITEM_DATA.
*
+ * PUT_KEY_VALUE /$NODES/ParentId.propertyName
+ * PUT_DATA /$PROPERTIES/Id
+ * PUT_KEY_VALUE /$PROPERTIES/Id.Item_data
+ *
* @param data
* @return
*/
- public Modification addProperty(PropertyData data)
+ public List<Modification> addProperty(PropertyData data)
{
+ List<Modification> list = new ArrayList<Modification>();
+ String parentFqn = "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier();
+ // write attribute to parent's map
+ list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(parentFqn), data.getQPath().getName()
+ .getAsString(), data.getIdentifier()));
+
String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
- return new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
- (Object)data);
+ // add modification PUT_DATA if enabled
+ if (addPUTDATA)
+ list.add(new Modification(ModificationType.PUT_DATA, Fqn.fromString(fqn)));
+ // put property data
+ list
+ .add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), JBossCacheStorage.ITEM_DATA, data));
+ return list;
}
/**
@@ -86,17 +142,20 @@
* filed of {@link Modification} instance contains same PropertyData (meaning that there was an old value, so this is an update, no add
* action)
*
+ * PUT_KEY_VALUE /$PROPERTIES/Id.Item_data
+ *
* @param data
* @return
*/
- public Modification updateProperty(PropertyData data)
+ public List<Modification> updateProperty(PropertyData data)
{
+ List<Modification> list = new ArrayList<Modification>();
String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
Modification modification =
- new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
- (Object)data);
+ new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(fqn), JBossCacheStorage.ITEM_DATA, data);
modification.setOldValue(data);
- return modification;
+ list.add(modification);
+ return list;
}
/**
@@ -104,17 +163,26 @@
* so {@link Modification} instance contains additional data: Key=ITEM_DATA, value=PropertyData - data of already removed
* node.
*
+ * REMOVE_KEY_VALUE /$NODES/ParentId.propertyName
+ * REMOVE_NODE /$PROPERTIES/Id
+ *
* @param data
* @return
*/
- public Modification removeProperty(PropertyData data)
+ public List<Modification> removeProperty(PropertyData data)
{
+ List<Modification> list = new ArrayList<Modification>();
+ String parentFqn = "/" + JBossCacheStorage.NODES + "/" + data.getParentIdentifier();
+ // write attribute to parent's map
+ list.add(new Modification(ModificationType.REMOVE_KEY_VALUE, Fqn.fromString(parentFqn), data.getQPath().getName()
+ .getAsString()));
+
String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
Modification modification =
- new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), (Object)JBossCacheStorage.ITEM_DATA,
- (Object)data);
+ new Modification(ModificationType.REMOVE_NODE, Fqn.fromString(fqn), JBossCacheStorage.ITEM_DATA, data);
modification.setOldValue(data);
- return modification;
+ list.add(modification);
+ return list;
}
/**
@@ -122,6 +190,9 @@
* This imitates situation when WorkspaceDataManager walks thought transaction changes log, and on the beginning of each plain
* changes log, such sequence is generated.
*
+ * PUT_KEY_VALUE /$SESSION.sessionId
+ * PUT_KEY_VALUE /$SESSION.userId
+ *
* @param sessionId
* @param userId
* @return
@@ -139,8 +210,17 @@
return list;
}
- public Modification removeSession()
+ /**
+ * Removes Session inforamtion.
+ *
+ * REMOVE_NODE /$SESSION
+ *
+ * @return
+ */
+ public List<Modification> removeSession()
{
- return new Modification(ModificationType.REMOVE_NODE, Fqn.fromString("/" + JBossCacheStorage.SESSION));
+ List<Modification> list = new ArrayList<Modification>();
+ list.add(new Modification(ModificationType.REMOVE_NODE, Fqn.fromString("/" + JBossCacheStorage.SESSION)));
+ return list;
}
}
16 years, 8 months
exo-jcr SVN: r533 - 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: tolusha
Date: 2009-11-10 03:12:16 -0500 (Tue, 10 Nov 2009)
New Revision: 533
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/LockCacheLoaderTest.java
Log:
EXOJCR-205: test fix
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-10 07:53:00 UTC (rev 532)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-10 08:12:16 UTC (rev 533)
@@ -135,14 +135,12 @@
// add UserID by the key USER_ID
list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString("/" + JBossCacheStorage.SESSION),
JBossCacheStorage.USER_ID, userId));
- // remove all the attributes from /$SESSION
- list.add(new Modification(ModificationType.REMOVE_DATA, Fqn.fromString("/" + JBossCacheStorage.SESSION)));
// return
return list;
}
public Modification removeSession()
{
- return new Modification(ModificationType.REMOVE_DATA, Fqn.fromString("/" + JBossCacheStorage.SESSION));
+ return new Modification(ModificationType.REMOVE_NODE, Fqn.fromString("/" + JBossCacheStorage.SESSION));
}
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-10 07:53:00 UTC (rev 532)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-10 08:12:16 UTC (rev 533)
@@ -51,7 +51,6 @@
public void setUp() throws Exception
{
-
this.lockManager = new TesterLockManagerImpl();
this.lockCacheLoader = new LockCacheLoader(lockManager);
}
@@ -63,13 +62,13 @@
String sessionId = "session1";
TransientPropertyData lockIsDeepData =
- new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), IdGenerator.generate(), 1,
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), "prop1", 1,
PropertyType.BOOLEAN, nodeIdentifier, false);
TransientValueData lockIsDeepValue = new TransientValueData(false);
lockIsDeepData.setValue(lockIsDeepValue);
TransientPropertyData lockOwnerData =
- new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKOWNER), IdGenerator.generate(), 1,
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKOWNER), "prop2", 1,
PropertyType.BOOLEAN, nodeIdentifier, false);
TransientValueData lockOwner = new TransientValueData("__system");
lockOwnerData.setValue(lockOwner);
@@ -90,13 +89,13 @@
String sessionId = "session1";
TransientPropertyData lockIsDeepData =
- new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), IdGenerator.generate(), 1,
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), "prop1", 1,
PropertyType.BOOLEAN, nodeIdentifier, false);
TransientValueData lockIsDeepValue = new TransientValueData(false);
lockIsDeepData.setValue(lockIsDeepValue);
TransientPropertyData lockOwnerData =
- new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKOWNER), IdGenerator.generate(), 1,
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKOWNER), "prop2", 1,
PropertyType.BOOLEAN, nodeIdentifier, false);
TransientValueData lockOwner = new TransientValueData("__system");
lockOwnerData.setValue(lockOwner);
16 years, 8 months
exo-jcr SVN: r532 - 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: tolusha
Date: 2009-11-10 02:53:00 -0500 (Tue, 10 Nov 2009)
New Revision: 532
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterSystemDataContainerHolder.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspaceEntry.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspacePersistedDataManager.java
Modified:
jcr/branches/1.12.0-JBC/component/core/pom.xml
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
Log:
EXOJCR-205: add dummy classes
Modified: jcr/branches/1.12.0-JBC/component/core/pom.xml
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-11-10 07:27:27 UTC (rev 531)
+++ jcr/branches/1.12.0-JBC/component/core/pom.xml 2009-11-10 07:53:00 UTC (rev 532)
@@ -569,8 +569,8 @@
</systemProperties>
<includes>
<include>**/**/JBossCacheServiceTest__.java</include>
- <include>**/**/TestItem__.java</include>
-
+ <include>**/**/TestItem__.java</include>
+ <include>**/**/LockCacheLoaderTest.java</include>
<include>**/**/JBossCacheStorageConnectionTest.java</include>
</includes>
</configuration>
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-10 07:27:27 UTC (rev 531)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-10 07:53:00 UTC (rev 532)
@@ -16,21 +16,10 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import com.sun.tools.corba.se.idl.toJavaPortable.ValueFactory;
-
-import com.thoughtworks.xstream.core.ReferenceByIdMarshaller.IDGenerator;
-
import org.exoplatform.services.jcr.datamodel.InternalQName;
-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.lock.LockManager;
-import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
-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.util.IdGenerator;
@@ -41,8 +30,6 @@
import javax.jcr.PropertyType;
-import junit.framework.TestCase;
-
/**
* Created by The eXo Platform SAS.
*
@@ -72,8 +59,8 @@
public void testLock() throws Exception
{
List<Modification> modifications = new ArrayList<Modification>();
- String nodeIdentifier = IdGenerator.generate();
- String sessionId = IdGenerator.generate();
+ String nodeIdentifier = "node1";
+ String sessionId = "session1";
TransientPropertyData lockIsDeepData =
new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), IdGenerator.generate(), 1,
@@ -99,8 +86,8 @@
public void testUnLock() throws Exception
{
List<Modification> modifications = new ArrayList<Modification>();
- String nodeIdentifier = IdGenerator.generate();
- String sessionId = IdGenerator.generate();
+ String nodeIdentifier = "node1";
+ String sessionId = "session1";
TransientPropertyData lockIsDeepData =
new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), IdGenerator.generate(), 1,
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-10 07:27:27 UTC (rev 531)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-10 07:53:00 UTC (rev 532)
@@ -44,7 +44,7 @@
public TesterLockManagerImpl()
{
- this(null, null);
+ this(new TesterWorkspacePersistedDataManager(null, null), new TesterWorkspaceEntry());
}
/**
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterSystemDataContainerHolder.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterSystemDataContainerHolder.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterSystemDataContainerHolder.java 2009-11-10 07:53:00 UTC (rev 532)
@@ -0,0 +1,43 @@
+/*
+ * 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.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class TesterSystemDataContainerHolder<DC> extends SystemDataContainerHolder
+{
+
+ /**
+ * TesterSystemDataContainerHolder constructor.
+ *
+ * @param dataContainer
+ */
+ public TesterSystemDataContainerHolder(WorkspaceDataContainer dataContainer)
+ {
+ super(dataContainer);
+ }
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterSystemDataContainerHolder.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspaceEntry.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspaceEntry.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspaceEntry.java 2009-11-10 07:53:00 UTC (rev 532)
@@ -0,0 +1,32 @@
+/*
+ * 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.exoplatform.services.jcr.config.WorkspaceEntry;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class TesterWorkspaceEntry extends WorkspaceEntry
+{
+
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspaceEntry.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspacePersistedDataManager.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspacePersistedDataManager.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspacePersistedDataManager.java 2009-11-10 07:53:00 UTC (rev 532)
@@ -0,0 +1,53 @@
+/*
+ * 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.exoplatform.services.jcr.dataflow.persistent.ItemsPersistenceListener;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import org.exoplatform.services.jcr.impl.storage.SystemDataContainerHolder;
+import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class TesterWorkspacePersistedDataManager extends WorkspacePersistentDataManager
+{
+
+ /**
+ * TesterWorkspacePersistedDataManager constructor.
+ *
+ * @param dataContainer
+ * @param systemDataContainerHolder
+ */
+ public TesterWorkspacePersistedDataManager(WorkspaceDataContainer dataContainer,
+ SystemDataContainerHolder<WorkspaceDataContainer> systemDataContainerHolder)
+ {
+ super(dataContainer, new TesterSystemDataContainerHolder<WorkspaceDataContainer>(null));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addItemPersistenceListener(ItemsPersistenceListener listener)
+ {
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterWorkspacePersistedDataManager.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 8 months
exo-jcr SVN: r531 - 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: tolusha
Date: 2009-11-10 02:27:27 -0500 (Tue, 10 Nov 2009)
New Revision: 531
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
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/LockCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
Log:
EXOJCR-205: test added
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-09 17:45:28 UTC (rev 530)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-10 07:27:27 UTC (rev 531)
@@ -110,7 +110,8 @@
else if (lockChanges.get(0).getType() == ModificationType.REMOVE_KEY_VALUE
&& lockChanges.get(1).getType() == ModificationType.REMOVE_KEY_VALUE)
{
- performUnLock(lockChanges, sessionId);
+ PropertyData propertyData = (PropertyData)lockChanges.get(0).getOldValue();
+ performUnLock(lockChanges, sessionId, propertyData.getParentIdentifier());
}
else
{
@@ -275,12 +276,11 @@
}
}
- private void performUnLock(List<Modification> lockChanges, String sessionId)
+ private void performUnLock(List<Modification> lockChanges, String sessionId, String nodeIdentifier)
{
- // TODO parent nodeIdentifier
try
{
- lockManager.internalUnLock(sessionId, "nodeIdentifier");
+ lockManager.internalUnLock(sessionId, nodeIdentifier);
}
catch (LockException e)
{
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-09 17:45:28 UTC (rev 530)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-10 07:27:27 UTC (rev 531)
@@ -141,4 +141,8 @@
return list;
}
+ public Modification removeSession()
+ {
+ return new Modification(ModificationType.REMOVE_DATA, Fqn.fromString("/" + JBossCacheStorage.SESSION));
+ }
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-09 17:45:28 UTC (rev 530)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-10 07:27:27 UTC (rev 531)
@@ -32,6 +32,7 @@
import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
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.util.IdGenerator;
import org.jboss.cache.Modification;
@@ -53,7 +54,7 @@
public class LockCacheLoaderTest extends AbstractCacheLoaderTest
{
- private LockManagerImpl lockManager;
+ private TesterLockManagerImpl lockManager;
private LockCacheLoader lockCacheLoader;
@@ -64,29 +65,62 @@
public void setUp() throws Exception
{
- this.valueFactory = new ValueFactoryImpl(new LocationFactory(new NamespaceRegistryImpl()));
this.lockManager = new TesterLockManagerImpl();
this.lockCacheLoader = new LockCacheLoader(lockManager);
}
public void testLock() throws Exception
{
- List<Modification> modifcations = new ArrayList<Modification>();
- String parentIdentifier = IdGenerator.generate();
+ List<Modification> modifications = new ArrayList<Modification>();
+ String nodeIdentifier = IdGenerator.generate();
+ String sessionId = IdGenerator.generate();
- TransientPropertyData propertyData =
+ TransientPropertyData lockIsDeepData =
new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), IdGenerator.generate(), 1,
- PropertyType.BOOLEAN, parentIdentifier, false);
+ PropertyType.BOOLEAN, nodeIdentifier, false);
+ TransientValueData lockIsDeepValue = new TransientValueData(false);
+ lockIsDeepData.setValue(lockIsDeepValue);
- propertyData =
+ TransientPropertyData lockOwnerData =
new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKOWNER), IdGenerator.generate(), 1,
- PropertyType.BOOLEAN, parentIdentifier, false);
+ PropertyType.BOOLEAN, nodeIdentifier, false);
+ TransientValueData lockOwner = new TransientValueData("__system");
+ lockOwnerData.setValue(lockOwner);
- modifcations.add(addProperty(propertyData));
+ modifications.addAll(setSession(sessionId, "userId"));
+ modifications.add(addProperty(lockIsDeepData));
+ modifications.add(addProperty(lockOwnerData));
+ modifications.add(removeSession());
+ lockCacheLoader.put(modifications);
+
+ assertEquals(nodeIdentifier, lockManager.getNodeIdentifier());
}
public void testUnLock() throws Exception
{
+ List<Modification> modifications = new ArrayList<Modification>();
+ String nodeIdentifier = IdGenerator.generate();
+ String sessionId = IdGenerator.generate();
+ TransientPropertyData lockIsDeepData =
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), IdGenerator.generate(), 1,
+ PropertyType.BOOLEAN, nodeIdentifier, false);
+ TransientValueData lockIsDeepValue = new TransientValueData(false);
+ lockIsDeepData.setValue(lockIsDeepValue);
+
+ TransientPropertyData lockOwnerData =
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKOWNER), IdGenerator.generate(), 1,
+ PropertyType.BOOLEAN, nodeIdentifier, false);
+ TransientValueData lockOwner = new TransientValueData("__system");
+ lockOwnerData.setValue(lockOwner);
+
+ modifications.addAll(setSession(sessionId, "userId"));
+ modifications.add(removeProperty(lockIsDeepData));
+ modifications.add(removeProperty(lockOwnerData));
+ modifications.add(removeSession());
+ lockCacheLoader.put(modifications);
+
+ assertEquals(nodeIdentifier, lockManager.getNodeIdentifier());
+ assertEquals(sessionId, lockManager.getSessionid());
}
}
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-09 17:45:28 UTC (rev 530)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-10 07:27:27 UTC (rev 531)
@@ -20,6 +20,8 @@
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+import javax.jcr.lock.LockException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -31,6 +33,10 @@
public class TesterLockManagerImpl extends LockManagerImpl
{
+ private String nodeIdentifier;
+
+ private String sessionId;
+
public TesterLockManagerImpl(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
{
super(dataManager, config);
@@ -40,4 +46,32 @@
{
this(null, null);
}
+
+ /**
+ * Internal lock
+ */
+ public synchronized void internalLock(String nodeIdentifier) throws LockException
+ {
+ this.nodeIdentifier = nodeIdentifier;
+ }
+
+ /**
+ * Internal lock
+ */
+ public synchronized void internalUnLock(String nodeIdentifier, String sessionId) throws LockException
+ {
+ this.nodeIdentifier = nodeIdentifier;
+ this.sessionId = sessionId;
+ }
+
+ public String getNodeIdentifier()
+ {
+ return nodeIdentifier;
+ }
+
+ public String getSessionid()
+ {
+ return sessionId;
+ }
+
}
16 years, 8 months
exo-jcr SVN: r530 - 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-09 12:45:28 -0500 (Mon, 09 Nov 2009)
New Revision: 530
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-201 : The JDBCCacheLoader.
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-09 17:35:16 UTC (rev 529)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-09 17:45:28 UTC (rev 530)
@@ -22,15 +22,16 @@
import java.util.ArrayList;
import java.util.List;
-import org.exoplatform.services.idgenerator.IDGeneratorService;
import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
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.WorkspaceEntry;
+import org.exoplatform.services.jcr.datamodel.NodeData;
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.ConfigurationHelper;
import org.exoplatform.services.jcr.util.IdGenerator;
@@ -44,6 +45,7 @@
*/
public class JDBCCacheLoaderTest extends JBossCacheStorageConnectionTest
{
+ JDBCWorkspaceDataContainer persistentContainer;
/**
* {@inheritDoc}
@@ -87,7 +89,7 @@
ValueStoragePluginProvider valueStoragePluginProvider = new StandaloneStoragePluginProvider(ws);
- JDBCWorkspaceDataContainer persistentContainer = new JDBCWorkspaceDataContainer(ws, re, null, valueStoragePluginProvider);
+ persistentContainer = new JDBCWorkspaceDataContainer(ws, re, null, valueStoragePluginProvider);
((CacheSPI<Serializable, Object>)cache).getComponentRegistry().registerComponent(persistentContainer,
WorkspaceDataContainer.class);
@@ -106,6 +108,11 @@
conn.commit();
// tests it
+ WorkspaceStorageConnection connection = persistentContainer.openConnection();
+
+ NodeData nd = (NodeData) connection.getItemData("1");
+ assertNotNull(nd);
+ assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
}
public void testDeleteNode() throws Exception {
16 years, 8 months
exo-jcr SVN: r529 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-09 12:35:16 -0500 (Mon, 09 Nov 2009)
New Revision: 529
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-201 : The JDBCCacheLoader.
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-09 17:22:55 UTC (rev 528)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-09 17:35:16 UTC (rev 529)
@@ -126,6 +126,7 @@
break;
case REMOVE_NODE:
System.out.println(m);
+ doRemove(m, jdbcConnection, getID(m.getFqn()));
break;
case MOVE:
System.out.println(m);
@@ -145,6 +146,26 @@
}
}
+ /**
+ * Get ID from Fqn.
+ * @param fqn
+ * @return
+ */
+ private String getID(Fqn<String> fqn)
+ {
+ //TODO
+ return fqn.toString().split("/")[2];
+ }
+
+ /**
+ * Remove NodeData or PropertyData.
+ *
+ * @param modification
+ * @param jdbcConnection
+ * @param identifier
+ * @throws IllegalStateException
+ * @throws RepositoryException
+ */
private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
throws IllegalStateException, RepositoryException
{
16 years, 8 months
exo-jcr SVN: r528 - jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2009-11-09 12:22:55 -0500 (Mon, 09 Nov 2009)
New Revision: 528
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java
Log:
EXOJCR-201 : The JDBCCacheLoader.
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-09 16:36:32 UTC (rev 527)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-09 17:22:55 UTC (rev 528)
@@ -43,8 +43,10 @@
import org.exoplatform.services.jcr.datamodel.PropertyData;
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.storage.jdbc.JDBCStorageConnection;
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.WorkspaceStorageConnection;
+import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
@@ -58,6 +60,8 @@
import java.util.Map;
import java.util.Set;
+import javax.jcr.RepositoryException;
+
/**
* Created by The eXo Platform SAS.
*
@@ -94,11 +98,118 @@
*/
public void put(List<Modification> modifications) throws Exception
{
- // TODO
System.out.println(modifications);
+
+ JDBCStorageConnection jdbcConnection = (JDBCStorageConnection)dataContainer.openConnection();
+
+ try
+ {
+ for (Modification m : modifications)
+ {
+ switch (m.getType())
+ {
+ case PUT_DATA:
+ System.out.println(m);
+ break;
+ case PUT_DATA_ERASE:
+ System.out.println(m);
+ break;
+ case PUT_KEY_VALUE:
+ System.out.println(m);
+ doAddOrUpdate(m, jdbcConnection);
+ break;
+ case REMOVE_DATA:
+ System.out.println(m);
+ break;
+ case REMOVE_KEY_VALUE:
+ System.out.println(m);
+ break;
+ case REMOVE_NODE:
+ System.out.println(m);
+ break;
+ case MOVE:
+ System.out.println(m);
+ break;
+ default:
+ throw new CacheException("Unknown modification " + m.getType());
+ }
+ }
+
+ if (jdbcConnection != null)
+ jdbcConnection.commit();
+ }
+ finally
+ {
+ if (jdbcConnection != null && jdbcConnection.isOpened())
+ jdbcConnection.rollback();
+ }
+ }
+ private void doRemove(Modification modification, JDBCStorageConnection jdbcConnection, String identifier)
+ throws IllegalStateException, RepositoryException
+ {
+
+ ItemData itemData = jdbcConnection.getItemData(identifier);
+
+ if (itemData instanceof NodeData)
+ jdbcConnection.delete((NodeData) itemData);
+ if (itemData instanceof PropertyData)
+ jdbcConnection.delete((PropertyData) itemData);
}
+
+ private boolean isNodeData(Fqn<String> fqn)
+ {
+ return fqn.toString().startsWith("/" +JBossCacheStorage.NODES);
+ }
+
+ /**
+ * Performs ADD and UPDATE to NodeData and PropertyData.
+ * @param modification
+ * @param jdbcConnection
+ * @throws IllegalStateException
+ * @throws RepositoryException
+ */
+ private void doAddOrUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
+ throws IllegalStateException, RepositoryException
+ {
+ if (modification.getValue() instanceof NodeData)
+ {
+ //add or update node data
+ NodeData nodeData = (NodeData)modification.getValue();
+ ItemData itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
+
+ if (itemData == null)
+ {
+ //add
+ jdbcConnection.add(nodeData);
+ }
+ else
+ {
+ //update
+ jdbcConnection.update(nodeData);
+ }
+ }
+ else if (modification.getValue() instanceof PropertyData)
+ {
+ //add or update property data
+ PropertyData propertyData = (PropertyData)modification.getValue();
+
+ ItemData itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
+
+ if (itemData == null)
+ {
+ //add
+ jdbcConnection.add(propertyData);
+ }
+ else
+ {
+ //update
+ jdbcConnection.update(propertyData);
+ }
+ }
+ }
+
protected QPathEntry[] makeNodePath(Fqn<String> nodeFqn) throws NumberFormatException, IllegalNameException
{
List<String> elements = nodeFqn.peekElements();
16 years, 8 months
exo-jcr SVN: r527 - 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-09 11:36:32 -0500 (Mon, 09 Nov 2009)
New Revision: 527
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
EXOJCR-201 : test JDBCCacheLoadetTest.
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-09 16:03:30 UTC (rev 526)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-09 16:36:32 UTC (rev 527)
@@ -22,6 +22,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.exoplatform.services.idgenerator.IDGeneratorService;
+import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
import org.exoplatform.services.jcr.config.ContainerEntry;
import org.exoplatform.services.jcr.config.RepositoryEntry;
import org.exoplatform.services.jcr.config.SimpleParameterEntry;
@@ -31,6 +33,7 @@
import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.storage.value.ValueStoragePluginProvider;
import org.exoplatform.services.jcr.util.ConfigurationHelper;
+import org.exoplatform.services.jcr.util.IdGenerator;
import org.jboss.cache.CacheSPI;
@@ -73,6 +76,9 @@
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());
WorkspaceEntry ws = configurationHelper.getNewWs("ws_to_jbdc_cache_loader", true, "data-source", "/target/temp/ws_to_jbdc_cache_loader/lalues", containerEntry);
@@ -101,5 +107,15 @@
// tests it
}
+
+ public void testDeleteNode() throws Exception {
+
+ // prepare
+ super.testDeleteNode();
+ conn.commit();
+
+ // tests it
+
+ }
}
16 years, 8 months
exo-jcr SVN: r526 - 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: tolusha
Date: 2009-11-09 11:03:30 -0500 (Mon, 09 Nov 2009)
New Revision: 526
Added:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
Modified:
jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
Log:
EXOJCR-205: base test added
Modified: jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-09 16:00:47 UTC (rev 525)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-09 16:03:30 UTC (rev 526)
@@ -51,7 +51,7 @@
/**
* Lock manager.
*/
- private LockManagerImpl lockManager;
+ private final LockManagerImpl lockManager;
/**
* Logger.
@@ -59,6 +59,16 @@
private final Log log = ExoLogger.getLogger("jcr.LockCacheLoader");
/**
+ * LockCacheLoader constructor.
+ *
+ * @param lockManager
+ */
+ public LockCacheLoader(LockManagerImpl lockManager)
+ {
+ this.lockManager = lockManager;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -77,11 +87,12 @@
case PUT_DATA_ERASE :
break;
case PUT_DATA :
- // changesLog begin
- int pos = getElementPosition(m.getFqn(), JBossCacheStorage.SESSION);
- sessionId = (String)m.getFqn().get(pos + 1);
break;
case PUT_KEY_VALUE :
+ if (m.getKey().equals(JBossCacheStorage.SESSION_ID))
+ {
+ sessionId = (String)m.getValue();
+ }
break;
case REMOVE_DATA :
break;
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-09 16:03:30 UTC (rev 526)
@@ -0,0 +1,92 @@
+/*
+ * 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 com.sun.tools.corba.se.idl.toJavaPortable.ValueFactory;
+
+import com.thoughtworks.xstream.core.ReferenceByIdMarshaller.IDGenerator;
+
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+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.lock.LockManager;
+import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
+import org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl;
+import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
+import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
+import org.exoplatform.services.jcr.util.IdGenerator;
+import org.jboss.cache.Modification;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.PropertyType;
+
+import junit.framework.TestCase;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class LockCacheLoaderTest extends AbstractCacheLoaderTest
+{
+
+ private LockManagerImpl lockManager;
+
+ private LockCacheLoader lockCacheLoader;
+
+ private ValueFactoryImpl valueFactory;
+
+ private final QPath testRoot = QPath.makeChildPath(Constants.ROOT_PATH, new InternalQName("", "testRoot"));
+
+ public void setUp() throws Exception
+ {
+
+ this.valueFactory = new ValueFactoryImpl(new LocationFactory(new NamespaceRegistryImpl()));
+ this.lockManager = new TesterLockManagerImpl();
+ this.lockCacheLoader = new LockCacheLoader(lockManager);
+ }
+
+ public void testLock() throws Exception
+ {
+ List<Modification> modifcations = new ArrayList<Modification>();
+ String parentIdentifier = IdGenerator.generate();
+
+ TransientPropertyData propertyData =
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKISDEEP), IdGenerator.generate(), 1,
+ PropertyType.BOOLEAN, parentIdentifier, false);
+
+ propertyData =
+ new TransientPropertyData(QPath.makeChildPath(testRoot, Constants.JCR_LOCKOWNER), IdGenerator.generate(), 1,
+ PropertyType.BOOLEAN, parentIdentifier, false);
+
+ modifcations.add(addProperty(propertyData));
+ }
+
+ public void testUnLock() throws Exception
+ {
+
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java (rev 0)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java 2009-11-09 16:03:30 UTC (rev 526)
@@ -0,0 +1,43 @@
+/*
+ * 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.exoplatform.services.jcr.config.WorkspaceEntry;
+import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
+import org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * <br/>Date: 2009
+ *
+ * @author <a href="mailto:anatoliy.bazko@exoplatform.com.ua">Anatoliy Bazko</a>
+ * @version $Id$
+ */
+public class TesterLockManagerImpl extends LockManagerImpl
+{
+
+ public TesterLockManagerImpl(WorkspacePersistentDataManager dataManager, WorkspaceEntry config)
+ {
+ super(dataManager, config);
+ }
+
+ public TesterLockManagerImpl()
+ {
+ this(null, null);
+ }
+}
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/TesterLockManagerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 8 months