exo-jcr SVN: r586 - 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-12 04:28:28 -0500 (Thu, 12 Nov 2009)
New Revision: 586
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 JDBCCacheLoaderTest was changed.
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 09:09:42 UTC (rev 585)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 09:28:28 UTC (rev 586)
@@ -18,8 +18,17 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import junit.framework.TestCase;
+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 org.apache.commons.dbcp.BasicDataSourceFactory;
import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
import org.exoplatform.services.jcr.access.AccessControlList;
@@ -34,8 +43,9 @@
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.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.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
@@ -45,18 +55,8 @@
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.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;
-
/**
* @author <a href="mailto:reshetnyak.alex@gmail.com">Alex Reshetnyak</a>
* @version $Id$
@@ -274,9 +274,37 @@
public void testAddProperty() throws Exception
{
// prepare
+ initJCRRoot();
+
+ String propId = IdGenerator.generate();
+ QPath propPath = QPath.makeChildPath(Constants.ROOT_PATH, Constants.JCR_DATA);
+ TransientPropertyData propData = new TransientPropertyData(propPath, propId, 1, 1, Constants.ROOT_UUID, false);
+ String propValue = "JCR DATA VALUE";
+ propData.setValue(new TransientValueData(propValue));
+
+ List<Modification> modifications = new ArrayList<Modification>();
+
+ modifications.addAll(addProperty(propData));
+
+ loader.put(modifications);
// tests
-
+ WorkspaceStorageConnection connection = persistentContainer.openConnection();
+
+ PropertyData destPropData = (PropertyData) connection.getItemData(propId);
+
+ assertNotNull(destPropData);
+ assertEquals(propData.getIdentifier(), destPropData.getIdentifier());
+ assertEquals(propData.getParentIdentifier(), destPropData.getParentIdentifier());
+ assertEquals(propData.getPersistedVersion(), destPropData.getPersistedVersion());
+ assertEquals(propData.getType(), destPropData.getType());
+ assertEquals(propData.getQPath(), destPropData.getQPath());
+ assertEquals(propData.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"));
+
}
public void testDeleteNode() throws Exception
16 years, 8 months
exo-jcr SVN: r585 - 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-12 04:09:42 -0500 (Thu, 12 Nov 2009)
New Revision: 585
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
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
Log:
EXOJCR-205: remove unecessary code, rename methods
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-12 09:07:00 UTC (rev 584)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-12 09:09:42 UTC (rev 585)
@@ -39,8 +39,6 @@
public abstract class AbstractCacheLoaderTest extends TestCase
{
- protected static boolean addPUTDATA = true;
-
public void setUp() throws Exception
{
super.setUp();
@@ -70,16 +68,14 @@
"/" + 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)));
+ 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_DATA, Fqn.fromString(nodeFqn)));
list.add(new Modification(ModificationType.PUT_KEY_VALUE, Fqn.fromString(nodeFqn), JBossCacheStorage.ITEM_DATA,
data));
@@ -133,8 +129,7 @@
String fqn = "/" + JBossCacheStorage.PROPS + "/" + data.getIdentifier();
// add modification PUT_DATA if enabled
- if (addPUTDATA)
- list.add(new Modification(ModificationType.PUT_DATA, Fqn.fromString(fqn)));
+ 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));
@@ -201,7 +196,7 @@
* @param userId
* @return
*/
- public List<Modification> setSession(String sessionId, String userId)
+ public List<Modification> addSessionInfo(String sessionId, String userId)
{
List<Modification> list = new ArrayList<Modification>();
// add SessionID by the key SESSION_ID
@@ -221,7 +216,7 @@
*
* @return
*/
- public List<Modification> removeSession()
+ public List<Modification> removeSessionInfo()
{
List<Modification> list = new ArrayList<Modification>();
list.add(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-12 09:07:00 UTC (rev 584)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoaderTest.java 2009-11-12 09:09:42 UTC (rev 585)
@@ -105,10 +105,10 @@
lockManager.addPendingLock(nodeIdentifier, new LockData(nodeIdentifier, "token", false, false, "__system", -1));
- modifications.addAll(setSession(sessionId, "userId"));
+ modifications.addAll(addSessionInfo(sessionId, "userId"));
modifications.addAll(addProperty(lockIsDeepData));
modifications.addAll(addProperty(lockOwnerData));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
lockCacheLoader.put(modifications);
assertEquals(nodeIdentifier, lockManager.getNodeIdentifier());
@@ -132,10 +132,10 @@
TransientValueData lockOwner = new TransientValueData("__system");
lockOwnerData.setValue(lockOwner);
- modifications.addAll(setSession(sessionId, "userId"));
+ modifications.addAll(addSessionInfo(sessionId, "userId"));
modifications.addAll(removeProperty(lockIsDeepData));
modifications.addAll(removeProperty(lockOwnerData));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
lockCacheLoader.put(modifications);
assertEquals(nodeIdentifier, lockManager.getNodeIdentifier());
@@ -153,9 +153,9 @@
lockManager.addLock(nodeIdentifier, new LockData(nodeIdentifier, "token", false, false, "__system", -1));
- modifications.addAll(setSession(sessionId, "userId"));
+ modifications.addAll(addSessionInfo(sessionId, "userId"));
modifications.addAll(addNode(node));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
lockCacheLoader.put(modifications);
assertNull(lockManager.getNodeIdentifier());
@@ -173,9 +173,9 @@
lockManager.addLock(nodeIdentifier, new LockData(nodeIdentifier, "token", false, false, "__system", -1));
- modifications.addAll(setSession(sessionId, "userId"));
+ modifications.addAll(addSessionInfo(sessionId, "userId"));
modifications.addAll(removeNode(node));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
lockCacheLoader.put(modifications);
assertEquals(nodeIdentifier, lockManager.getNodeIdentifier());
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-12 09:07:00 UTC (rev 584)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-12 09:09:42 UTC (rev 585)
@@ -130,9 +130,9 @@
registry.addEventListener(listener, new ListenerCriteria(Event.NODE_ADDED, null, true,
new String[]{Constants.ROOT_UUID}, null, false, "session1"));
- List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
+ List<Modification> modifications = new ArrayList<Modification>(addSessionInfo("session1", "admin"));
modifications.addAll(addNode(newNode));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
loader.put(modifications);
assertEquals(1, listener.eventList.size());
Event event = listener.eventList.get(0);
@@ -151,9 +151,9 @@
registry.addEventListener(listener, new ListenerCriteria(Event.NODE_ADDED,
lf.parseAbsPath("/").getInternalPath(), true, null, null, false, "session1"));
- List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
+ List<Modification> modifications = new ArrayList<Modification>(addSessionInfo("session1", "admin"));
modifications.addAll(addNode(newNode));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
loader.put(modifications);
assertEvent(Event.NODE_ADDED, node1path, listener, "admin");
@@ -169,9 +169,9 @@
registry.addEventListener(listener, new ListenerCriteria(Event.NODE_REMOVED, lf.parseAbsPath("/")
.getInternalPath(), true, null, null, false, "session1"));
- List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
+ List<Modification> modifications = new ArrayList<Modification>(addSessionInfo("session1", "admin"));
modifications.addAll(removeNode(newNode));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
loader.put(modifications);
assertEvent(Event.NODE_REMOVED, node1path, listener, "admin");
@@ -187,9 +187,9 @@
registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_ADDED, lf.parseAbsPath("/")
.getInternalPath(), true, null, null, false, "session1"));
- List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
+ List<Modification> modifications = new ArrayList<Modification>(addSessionInfo("session1", "admin"));
modifications.addAll(addProperty(newProperty));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
loader.put(modifications);
assertEvent(Event.PROPERTY_ADDED, prop1path, listener, "admin");
@@ -205,9 +205,9 @@
registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_CHANGED, lf.parseAbsPath("/")
.getInternalPath(), true, null, null, false, "session1"));
- List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
+ List<Modification> modifications = new ArrayList<Modification>(addSessionInfo("session1", "admin"));
modifications.addAll(updateProperty(newProperty));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
loader.put(modifications);
assertEvent(Event.PROPERTY_CHANGED, prop1path, listener, "admin");
@@ -223,9 +223,9 @@
registry.addEventListener(listener, new ListenerCriteria(Event.PROPERTY_REMOVED, lf.parseAbsPath("/")
.getInternalPath(), true, null, null, false, "session1"));
- List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
+ List<Modification> modifications = new ArrayList<Modification>(addSessionInfo("session1", "admin"));
modifications.addAll(removeProperty(newProperty));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
loader.put(modifications);
assertEvent(Event.PROPERTY_REMOVED, prop1path, listener, "admin");
@@ -274,10 +274,10 @@
lf.parseAbsPath("/").getInternalPath(), true, null, new InternalQName[]{Constants.NT_RESOURCE}, false,
"session1"));
- List<Modification> modifications = new ArrayList<Modification>(setSession("session1", "admin"));
+ List<Modification> modifications = new ArrayList<Modification>(addSessionInfo("session1", "admin"));
modifications.addAll(addNode(childNode1));
modifications.addAll(addNode(childNode2));
- modifications.addAll(removeSession());
+ modifications.addAll(removeSessionInfo());
loader.put(modifications);
// one event expected
assertEvent(Event.NODE_ADDED, child2path, listener, "admin");
16 years, 8 months
exo-jcr SVN: r584 - 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: areshetnyak
Date: 2009-11-12 04:07:00 -0500 (Thu, 12 Nov 2009)
New Revision: 584
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/JDBCCacheLoaderTest.java
Log:
EXOJCR-201 : The JDBCCacheLoaderTest was changed.
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-12 09:04:27 UTC (rev 583)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-12 09:07:00 UTC (rev 584)
@@ -252,7 +252,7 @@
/**
* Prepare list of modifications.
*
- * Will be checked the UPDATE or ADD.
+ * Will be checked the UPDATE, ADD, REMOVE.
*
* @param modifications
* @throws RepositoryException
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 09:04:27 UTC (rev 583)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 09:07:00 UTC (rev 584)
@@ -62,7 +62,7 @@
* @version $Id$
*
*/
-public class JDBCCacheLoaderTest extends TestCase
+public class JDBCCacheLoaderTest extends AbstractCacheLoaderTest
{
private JDBCWorkspaceDataContainer persistentContainer;
@@ -72,7 +72,7 @@
/**
* {@inheritDoc}
*/
- protected void setUp() throws Exception
+ public void setUp() throws Exception
{
super.setUp();
16 years, 8 months
exo-jcr SVN: r583 - 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-12 04:04:27 -0500 (Thu, 12 Nov 2009)
New Revision: 583
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
Log:
EXOJCR-201: test svn: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-12 08:40:48 UTC (rev 582)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java 2009-11-12 09:04:27 UTC (rev 583)
@@ -33,7 +33,7 @@
* This abstract class contains only methods for creating a fake {@link Modification} instances. It doesn't use real cache.
*
* @author <a href="mailto:nikolazius@gmail.com">Nikolay Zamosenchuk</a>
- * @version $Id: AbstractCacheLoaderClass.java 34360 2009-07-22 23:58:59Z aheritier $
+ * @version $Id$
*
*/
public abstract class AbstractCacheLoaderTest extends TestCase
Property changes on: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/AbstractCacheLoaderTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
16 years, 8 months
exo-jcr SVN: r582 - 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-12 03:40:48 -0500 (Thu, 12 Nov 2009)
New Revision: 582
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 was changed.
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-12 08:35:27 UTC (rev 581)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-12 08:40:48 UTC (rev 582)
@@ -264,23 +264,24 @@
for (int i = 0; i < modifications.size(); i++)
{
- if (modifications.get(i).getType() == ModificationType.PUT_KEY_VALUE)
+ Modification m = modifications.get(i);
+ if (m.getType() == ModificationType.PUT_KEY_VALUE)
{
ItemData itemData = null;
//Check add or update node data.
- if (modifications.get(i).getValue() instanceof NodeData)
+ if (m.getValue() instanceof NodeData)
{
- NodeData nodeData = (NodeData) modifications.get(i).getValue();
+ NodeData nodeData = (NodeData) m.getValue();
itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
// Set oldValueData for update node.
if (itemData != null)
modifications.get(i).setOldValue(itemData);
}
- else if (modifications.get(i).getValue() instanceof PropertyData)
+ else if (m.getValue() instanceof PropertyData)
{
- PropertyData propertyData = (PropertyData) modifications.get(i).getValue();
+ PropertyData propertyData = (PropertyData) m.getValue();
itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
// Set oldValueData for update property.
@@ -288,14 +289,17 @@
modifications.get(i).setOldValue(itemData);
}
}
- else if (modifications.get(i).getType() == ModificationType.REMOVE_NODE)
+ else if (m.getType() == ModificationType.REMOVE_NODE)
{
- if (modifications.get(i).getValue() instanceof ItemData) {
- String id = ((ItemData) (modifications.get(i).getValue())).getIdentifier();
+ if (m.getFqn().size() == 2
+ && (m.getFqn().get(1).equals(JBossCacheStorage.NODES)
+ || m.getFqn().get(1).equals(JBossCacheStorage.PROPS)))
+ {
+ String id = (String) m.getFqn().get(1);
ItemData removedItemData = jdbcConnection.getItemData(id);
-
+
// Set valueData for update property or node.
- if (removedItemData != null)
+ if (removedItemData != null)
modifications.get(i).setValue(removedItemData);
}
}
16 years, 8 months
exo-jcr SVN: r581 - 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-12 03:35:27 -0500 (Thu, 12 Nov 2009)
New Revision: 581
Modified:
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
Log:
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 08:31:37 UTC (rev 580)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 08:35:27 UTC (rev 581)
@@ -22,6 +22,7 @@
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.CacheEntry;
import org.exoplatform.services.jcr.config.ContainerEntry;
import org.exoplatform.services.jcr.config.LockManagerEntry;
@@ -32,7 +33,13 @@
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.NodeData;
+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;
@@ -67,13 +74,13 @@
*/
protected void setUp() throws Exception
{
-
+
super.setUp();
-
+
initPersistence();
-
+
loader = new JDBCCacheLoader();
- loader.injectDependencies(persistentContainer);
+ loader.injectDependencies(persistentContainer);
}
protected void initPersistence() throws Exception
@@ -221,22 +228,47 @@
PreparedStatement st = connection.prepareStatement("create database " + dbName);
st.executeQuery();
}
+
+
+ private void initJCRRoot() throws Exception {
+ // prepare
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
+ // add root (/)
+ conn.add(new TransientNodeData(Constants.ROOT_PATH, Constants.ROOT_UUID, 1, Constants.NT_UNSTRUCTURED,
+ new InternalQName[0], 0, null, 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);
+
+ conn.commit();
+ }
+
// ============= TESTS =============
-
+
public void testAddNode() throws Exception
{
- // prepare
+ // prepare
+ initJCRRoot();
// tests
- WorkspaceStorageConnection connection = persistentContainer.openConnection();
+ WorkspaceStorageConnection conn = persistentContainer.openConnection();
- NodeData nd = (NodeData)connection.getItemData("1");
- assertNotNull(nd);
- assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
-
- //Map<Serializable, Object> data = cache.getData(Fqn.fromString("/"+JBossCacheStorage.NODES + "/" + Constants.ROOT_UUID));
+ //??? Map<Serializable, Object> data = cache.getData(Fqn.fromString("/"+JBossCacheStorage.NODES + "/" + Constants.ROOT_UUID));
}
public void testAddProperty() throws Exception
@@ -255,7 +287,7 @@
// tests it
}
-
+
public void testDeleteProperty() throws Exception
{
@@ -264,7 +296,7 @@
// tests it
}
-
+
public void testUpdateNode() throws Exception
{
@@ -273,7 +305,7 @@
// tests it
}
-
+
public void testUpdateProperty() throws Exception
{
@@ -282,7 +314,7 @@
// tests it
}
-
+
public void testRenameNode() throws Exception
{
@@ -291,7 +323,7 @@
// tests it
}
-
+
public void testGetNodeByIdentifier() throws Exception
{
@@ -300,7 +332,7 @@
// tests it
}
-
+
public void testGetNodeByName() throws Exception
{
@@ -309,7 +341,7 @@
// tests it
}
-
+
public void testGetPropertyByIdentifier() throws Exception
{
@@ -318,7 +350,7 @@
// tests it
}
-
+
public void testGetPropertyByName() throws Exception
{
@@ -327,7 +359,7 @@
// tests it
}
-
+
public void testGetChildNodes() throws Exception
{
@@ -336,7 +368,7 @@
// tests it
}
-
+
public void testGetChildProperties() throws Exception
{
@@ -345,7 +377,7 @@
// tests it
}
-
+
public void testGetReferences() throws Exception
{
16 years, 8 months
exo-jcr SVN: r580 - 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-12 03:31:37 -0500 (Thu, 12 Nov 2009)
New Revision: 580
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/JDBCCacheLoaderTest.java
Log:
EXOJCR-201: test base for JDBC loader
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-12 08:30:40 UTC (rev 579)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-12 08:31:37 UTC (rev 580)
@@ -37,7 +37,6 @@
import org.jboss.cache.Modification.ModificationType;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.loader.AbstractCacheLoader;
import java.util.LinkedHashMap;
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 08:30:40 UTC (rev 579)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoaderTest.java 2009-11-12 08:31:37 UTC (rev 580)
@@ -18,19 +18,8 @@
*/
package org.exoplatform.services.jcr.impl.storage.jbosscache;
-import java.io.Serializable;
-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 junit.framework.TestCase;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.sql.DataSource;
-
import org.apache.commons.dbcp.BasicDataSourceFactory;
import org.exoplatform.services.idgenerator.impl.IDGeneratorServiceImpl;
import org.exoplatform.services.jcr.config.CacheEntry;
@@ -44,126 +33,83 @@
import org.exoplatform.services.jcr.config.ValueStorageFilterEntry;
import org.exoplatform.services.jcr.config.WorkspaceEntry;
import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.impl.Constants;
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.CacheSPI;
-import org.jboss.cache.Fqn;
+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;
+
/**
* @author <a href="mailto:reshetnyak.alex@gmail.com">Alex Reshetnyak</a>
* @version $Id$
*
*/
-public class JDBCCacheLoaderTest extends JBossCacheStorageConnectionTest
+public class JDBCCacheLoaderTest extends TestCase
{
- JDBCWorkspaceDataContainer persistentContainer;
-
+
+ private JDBCWorkspaceDataContainer persistentContainer;
+
+ private JDBCCacheLoader loader;
+
/**
* {@inheritDoc}
*/
protected void setUp() throws Exception
{
- try
- {
- super.setUp();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw e;
- }
+
+ super.setUp();
+
+ initPersistence();
+
+ loader = new JDBCCacheLoader();
+ loader.injectDependencies(persistentContainer);
}
- @Override
- protected void initJBC() throws Exception
+ protected void initPersistence() throws Exception
{
-
- // persistence container
- //WorkspaceDataContainer persistentContainer = new JDBCWorkspaceDataContainerTester();
-
// 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);
-
+
+ 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);
- ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().registerComponent(persistentContainer,
- WorkspaceDataContainer.class);
- }
+ ValueStoragePluginProvider valueStoragePluginProvider = new StandaloneStoragePluginProvider(ws);
- @Override
- protected void initJBCConfig()
- {
- jbcConfig = "conf/standalone/test-jbosscache-config-exoloader.xml";
+ persistentContainer = new JDBCWorkspaceDataContainer(ws, re, null, valueStoragePluginProvider);
}
-
- public void testAddNodeAndGetNode() throws Exception
- {
- // prepare
- super.testAddNode();
- conn.commit();
-
- cache.stop();
- cache.start();
-
- Map<Serializable, Object> data = cache.getData(Fqn.fromString("/"+JBossCacheStorage.NODES + "/" + Constants.ROOT_UUID));
-
-
- }
- public void testAddNode() throws Exception
+ private WorkspaceEntry getNewWs(String wsName, boolean isMultiDb, String dsName, String vsPath, ContainerEntry entry)
+ throws Exception
{
- // prepare
- super.testAddNode();
- 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 {
-
- // prepare
- super.testDeleteNode();
- conn.commit();
-
- // tests it
-
- }
-
- public WorkspaceEntry getNewWs(String wsName, boolean isMultiDb, String dsName, String vsPath, ContainerEntry entry)
- throws Exception
- {
List params = new ArrayList();
@@ -176,7 +122,7 @@
if (entry.getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT) != null)
{
params.add(new SimpleParameterEntry(JDBCWorkspaceDataContainer.DB_DIALECT, entry
- .getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT)));
+ .getParameterValue(JDBCWorkspaceDataContainer.DB_DIALECT)));
}
String oldSwap = entry.getParameterValue("swap-directory");
@@ -185,8 +131,8 @@
params.add(new SimpleParameterEntry("swap-directory", newSwap));
ContainerEntry containerEntry =
- new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
- (ArrayList) params);
+ new ContainerEntry("org.exoplatform.services.jcr.impl.storage.jdbc.JDBCWorkspaceDataContainer",
+ (ArrayList)params);
containerEntry.setParameters(params);
if (vsPath != null)
@@ -198,8 +144,7 @@
vsparams.add(filterEntry);
ValueStorageEntry valueStorageEntry =
- new ValueStorageEntry("org.exoplatform.services.jcr.impl.storage.value.fs.SimpleFileValueStorage",
- vsparams);
+ 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());
@@ -219,10 +164,10 @@
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);
+ new QueryHandlerEntry("org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex", qParams);
WorkspaceEntry workspaceEntry =
- new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
+ new WorkspaceEntry(wsName != null ? wsName : IdGenerator.generate(), "nt:unstructured");
workspaceEntry.setContainer(containerEntry);
ArrayList cacheParams = new ArrayList();
@@ -249,8 +194,8 @@
// workspaceEntry
return workspaceEntry;
}
-
- public void createNewDataSource(String dataSourceName) throws Exception
+
+ private void createNewDataSource(String dataSourceName) throws Exception
{
Properties properties = new Properties();
@@ -269,12 +214,145 @@
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();
}
+
+ // ============= TESTS =============
+
+ public void testAddNode() throws Exception
+ {
+ // prepare
+
+
+ // tests
+ WorkspaceStorageConnection connection = persistentContainer.openConnection();
+
+ NodeData nd = (NodeData)connection.getItemData("1");
+ assertNotNull(nd);
+ assertEquals("[]:1[]node:1", nd.getQPath().getAsString());
+
+ //Map<Serializable, Object> data = cache.getData(Fqn.fromString("/"+JBossCacheStorage.NODES + "/" + Constants.ROOT_UUID));
+ }
+
+ public void testAddProperty() throws Exception
+ {
+ // prepare
+
+ // tests
+
+ }
+
+ public void testDeleteNode() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testDeleteProperty() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testUpdateNode() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testUpdateProperty() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testRenameNode() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testGetNodeByIdentifier() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testGetNodeByName() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testGetPropertyByIdentifier() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testGetPropertyByName() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testGetChildNodes() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testGetChildProperties() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
+ public void testGetReferences() throws Exception
+ {
+
+ // prepare
+
+ // tests it
+
+ }
+
}
-
16 years, 8 months
exo-jcr SVN: r579 - 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-12 03:30:40 -0500 (Thu, 12 Nov 2009)
New Revision: 579
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 was changed.
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-12 08:20:53 UTC (rev 578)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-12 08:30:40 UTC (rev 579)
@@ -88,7 +88,7 @@
*/
public void put(List<Modification> modifications) throws Exception
{
- System.out.println(modifications);
+ LOG.info(modifications);
// Prepare modifications list.
// Will be changed Modification to ModificationEx and set operation type (ADD or UPDATE).
@@ -98,38 +98,37 @@
try
{
- for (int i=0; i<modifications.size(); i++)
+ for (Modification m : modifications)
{
- ModificationEx m = (ModificationEx) modifications.get(i);
switch (m.getType())
{
case PUT_DATA:
- System.out.println(m);
+ LOG.info(m);
break;
case PUT_DATA_ERASE:
- System.out.println(m);
+ LOG.info(m);
break;
case PUT_KEY_VALUE:
- System.out.println(m);
+ LOG.info(m);
- if (m.getOperaionType() == JCROperaionType.ADD)
+ if (m.getOldValue() != null)
+ doUpdate(m, jdbcConnection);
+ else
doAdd(m, jdbcConnection);
- else if (m.getOperaionType() == JCROperaionType.UPDATE)
- doUpdate(m, jdbcConnection);
break;
case REMOVE_DATA:
- System.out.println(m);
+ LOG.info(m);
break;
case REMOVE_KEY_VALUE:
- System.out.println(m);
+ LOG.info(m);
break;
case REMOVE_NODE:
- System.out.println(m);
+ LOG.info(m);
doRemove(m, jdbcConnection);
break;
case MOVE:
- System.out.println(m);
+ LOG.info(m);
break;
default:
throw new CacheException("Unknown modification " + m.getType());
@@ -206,7 +205,7 @@
* @throws IllegalStateException
* @throws RepositoryException
*/
- private void doAdd(ModificationEx modification, JDBCStorageConnection jdbcConnection)
+ private void doAdd(Modification modification, JDBCStorageConnection jdbcConnection)
throws IllegalStateException, RepositoryException
{
if (modification.getValue() instanceof NodeData)
@@ -232,7 +231,7 @@
* @throws IllegalStateException
* @throws RepositoryException
*/
- private void doUpdate(ModificationEx modification, JDBCStorageConnection jdbcConnection)
+ private void doUpdate(Modification modification, JDBCStorageConnection jdbcConnection)
throws IllegalStateException, RepositoryException
{
if (modification.getValue() instanceof NodeData)
@@ -270,13 +269,13 @@
{
ItemData itemData = null;
- //Check add or update node data
+ //Check add or update node data.
if (modifications.get(i).getValue() instanceof NodeData)
{
NodeData nodeData = (NodeData) modifications.get(i).getValue();
itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
- // Set oldValueData for update node
+ // Set oldValueData for update node.
if (itemData != null)
modifications.get(i).setOldValue(itemData);
}
@@ -285,18 +284,21 @@
PropertyData propertyData = (PropertyData) modifications.get(i).getValue();
itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
- // Set oldValueData for update property
+ // Set oldValueData for update property.
if (itemData != null)
modifications.get(i).setOldValue(itemData);
- } else {
- modifications.set(i, new ModificationEx(modifications.get(i)));
- continue;
- }
+ }
}
- else if (modifications.get(i).getType() == ModificationType.REMOVE_KEY_VALUE)
+ else if (modifications.get(i).getType() == ModificationType.REMOVE_NODE)
{
- (ItemData)(modifications.get(i).getValue());
- ItemData removedItemData = jdbcConnection.getItemData(.getIdentifier()));
+ if (modifications.get(i).getValue() instanceof ItemData) {
+ String id = ((ItemData) (modifications.get(i).getValue())).getIdentifier();
+ ItemData removedItemData = jdbcConnection.getItemData(id);
+
+ // Set valueData for update property or node.
+ if (removedItemData != null)
+ modifications.get(i).setValue(removedItemData);
+ }
}
}
}
16 years, 8 months
exo-jcr SVN: r578 - 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-12 03:20:53 -0500 (Thu, 12 Nov 2009)
New Revision: 578
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 was changed.
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-12 08:18:35 UTC (rev 577)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/JDBCCacheLoader.java 2009-11-12 08:20:53 UTC (rev 578)
@@ -275,25 +275,28 @@
{
NodeData nodeData = (NodeData) modifications.get(i).getValue();
itemData = jdbcConnection.getItemData(nodeData.getIdentifier());
+
+ // Set oldValueData for update node
+ if (itemData != null)
+ modifications.get(i).setOldValue(itemData);
}
else if (modifications.get(i).getValue() instanceof PropertyData)
{
PropertyData propertyData = (PropertyData) modifications.get(i).getValue();
itemData = jdbcConnection.getItemData(propertyData.getIdentifier());
+
+ // Set oldValueData for update property
+ if (itemData != null)
+ modifications.get(i).setOldValue(itemData);
} else {
modifications.set(i, new ModificationEx(modifications.get(i)));
continue;
}
-
- // Set ModificationEx to list with type UPDATE or ADD.
- if (itemData == null)
- modifications.set(i, new ModificationEx(modifications.get(i), JCROperaionType.ADD));
- else
- modifications.set(i, new ModificationEx(modifications.get(i), JCROperaionType.UPDATE));
}
- else
+ else if (modifications.get(i).getType() == ModificationType.REMOVE_KEY_VALUE)
{
- modifications.set(i, new ModificationEx(modifications.get(i)));
+ (ItemData)(modifications.get(i).getValue());
+ ItemData removedItemData = jdbcConnection.getItemData(.getIdentifier()));
}
}
}
@@ -361,12 +364,15 @@
{
NodeData parentNodeData = (NodeData) conn.getItemData((String)name.get(1));
- if (parentNodeData == null)
- throw new JDBCCacheLoaderException("The parent node with ID = " + (String)name.get(2) + " not exis, FQN = '" + name + "'.");
+// if (parentNodeData == null)
+// throw new JDBCCacheLoaderException("The parent node with ID = " + (String)name.get(1) + " not exis, FQN = '" + name + "'.");
- NodeData nodeData = (NodeData) conn.getItemData(parentNodeData, nodeName);
- if (nodeData != null)
- attrs.put(JBossCacheStorage.ITEM_ID, nodeData.getIdentifier());
+ if (parentNodeData != null)
+ {
+ NodeData nodeData = (NodeData) conn.getItemData(parentNodeData, nodeName);
+ if (nodeData != null)
+ attrs.put(JBossCacheStorage.ITEM_ID, nodeData.getIdentifier());
+ }
}
finally
{
16 years, 8 months
exo-jcr SVN: r577 - 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-12 03:18:35 -0500 (Thu, 12 Nov 2009)
New Revision: 577
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/IndexerCacheLoaderTest.java
jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
Log:
EXOJCR-201: bug fix
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-12 08:07:37 UTC (rev 576)
+++ jcr/branches/1.12.0-JBC/component/core/src/main/java/org/exoplatform/services/jcr/impl/storage/jbosscache/LockCacheLoader.java 2009-11-12 08:18:35 UTC (rev 577)
@@ -22,12 +22,10 @@
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
-import org.exoplatform.services.jcr.storage.WorkspaceDataContainer;
import org.exoplatform.services.jcr.util.IdGenerator;
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.Modification.ModificationType;
import org.jboss.cache.factories.annotations.Inject;
@@ -247,7 +245,7 @@
{
if (lockManager.hasPendingLocks(nodeIdentifier))
{
- System.out.println("Perform lock operation nodeIdentifier=" + nodeIdentifier);
+ log.info("Perform lock operation nodeIdentifier=" + nodeIdentifier);
lockManager.internalLock(nodeIdentifier);
}
else
@@ -297,7 +295,7 @@
{
try
{
- System.out.println("Perform unlock operation nodeIdentifier=" + nodeIdentifier + " sessionId=" + sessionId);
+ log.info("Perform unlock operation nodeIdentifier=" + nodeIdentifier + " sessionId=" + sessionId);
lockManager.internalUnLock(nodeIdentifier, sessionId);
}
catch (LockException e)
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-12 08:07:37 UTC (rev 576)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/IndexerCacheLoaderTest.java 2009-11-12 08:18:35 UTC (rev 577)
@@ -61,7 +61,7 @@
* @see junit.framework.TestCase#setUp()
*/
@Override
- protected void setUp() throws Exception
+ public void setUp() throws Exception
{
// TODO Auto-generated method stub
super.setUp();
Modified: jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java
===================================================================
--- jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-12 08:07:37 UTC (rev 576)
+++ jcr/branches/1.12.0-JBC/component/core/src/test/java/org/exoplatform/services/jcr/impl/storage/jbosscache/ObservationCacheLoaderTest.java 2009-11-12 08:18:35 UTC (rev 577)
@@ -80,7 +80,7 @@
private LocationFactory lf;
@Override
- protected void setUp() throws Exception
+ public void setUp() throws Exception
{
super.setUp();
loader = new ObservationCacheLoader();
@@ -551,6 +551,10 @@
{
}
+ public void addSessionInfo(String sessionId) throws RepositoryException
+ {
+ }
+
}
}
16 years, 8 months