You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by wo...@apache.org on 2011/06/03 17:33:38 UTC
svn commit: r1131075 - in /shindig/trunk: content/sampledata/
java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/
java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/
Author: woodser
Date: Fri Jun 3 15:33:37 2011
New Revision: 1131075
URL: http://svn.apache.org/viewvc?rev=1131075&view=rev
Log:
Committing patch to fix bug in XML comparison utility: https://issues.apache.org/jira/browse/SHINDIG-1545
Modified:
shindig/trunk/content/sampledata/canonicaldb.json
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/TestUtils.java
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonDelete.json
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonGroup.json
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonIds.json
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlId.xml
shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlIds.xml
Modified: shindig/trunk/content/sampledata/canonicaldb.json
URL: http://svn.apache.org/viewvc/shindig/trunk/content/sampledata/canonicaldb.json?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/content/sampledata/canonicaldb.json (original)
+++ shindig/trunk/content/sampledata/canonicaldb.json Fri Jun 3 15:33:37 2011
@@ -378,7 +378,7 @@
}
}, {
"id": "activity2",
- "published": "2011-02-10T15:04:55Z",
+ "published": "2011-03-10T15:04:55Z",
"generator": {
"url": "http://example.org/activities-app"
},
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/TestUtils.java
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/TestUtils.java?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/TestUtils.java (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/TestUtils.java Fri Jun 3 15:33:37 2011
@@ -19,7 +19,6 @@ package org.apache.shindig.social.datase
import java.io.BufferedReader;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
@@ -76,14 +75,13 @@ public class TestUtils {
return obj1Converted.equals(obj2Converted);
}
-
/**
* Tests the DOMs represented by two XML strings for equality by performing
- * a deep comparison. The two DOMs are considered equal if the paths to all
- * leaf nodes are equal and the values at such paths are equal.
+ * a deep comparison.
*
* @param xml1 represents the XML DOM to compare with xml2
* @param xml2 represents the XML DOM to compare with xml1
+ *
* return true if the represented DOMs are equal, false otherwise
*/
public static boolean xmlsEqual(String xml1, String xml2) throws Exception {
@@ -93,10 +91,10 @@ public class TestUtils {
Document doc1 = db.parse(new InputSource(new StringReader(xml1)));
Document doc2 = db.parse(new InputSource(new StringReader(xml2)));
- Map<String, String> paths1 = getLeafPaths(doc1.getDocumentElement(), "");
- Map<String, String> paths2 = getLeafPaths(doc2.getDocumentElement(), "");
-
- return paths1.equals(paths2);
+ Set<Object> childSet1 = getChildSet(doc1.getDocumentElement(), "");
+ Set<Object> childSet2 = getChildSet(doc2.getDocumentElement(), "");
+
+ return childSet1.equals(childSet2); // comparing sets does all the hard work :)
}
// ---------------------------- PRIVATE HELPERS -----------------------------
@@ -134,25 +132,23 @@ public class TestUtils {
}
/*
- * Recursive utility to map all leaf node paths to the values at each path
- * within an XML node.
+ * Recursive utility to represent an XML Document as a Set.
*
- * @param node is the root node to find all leaf paths & values for
+ * @param node is the root node to map to a Set
* @param basePath is the path to the root node
- * @return Map<String, String> is a Map of leaf paths & values for each path
+ *
+ * @return Set<Object> represents the XML Document as a Set
*/
- private static Map<String, String> getLeafPaths(Node node, String basePath) {
- Map<String, String> paths = new HashMap<String, String>();
- if (!node.hasChildNodes()) {
- if (!node.getTextContent().trim().equals("")) {
- paths.put(basePath, node.getTextContent());
- }
+ private static Set<Object> getChildSet(Node node, String basePath) {
+ Set<Object> childSet = new HashSet<Object>();
+ if (!node.hasChildNodes() && !node.getTextContent().trim().equals("")) {
+ childSet.add(basePath + ":" + node.getTextContent());
} else {
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
- paths.putAll(getLeafPaths(children.item(i), basePath + "/" + node.getNodeName()));
+ childSet.add(getChildSet(children.item(i), basePath + "/" + node.getNodeName()));
}
}
- return paths;
+ return childSet;
}
}
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomId.xml Fri Jun 3 15:33:37 2011
@@ -52,7 +52,7 @@
<provider>
<url>http://example.org/activity-stream</url>
</provider>
- <published>2011-02-10T15:04:55Z</published>
+ <published>2011-03-10T15:04:55Z</published>
<target>
<displayName>John's Photo Album</displayName>
<id>target2</id>
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryAtomIds.xml Fri Jun 3 15:33:37 2011
@@ -1,41 +1,5 @@
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:osearch="http://a9.com/-/spec/opensearch/1.1">
<entry>
- <id>activity1</id>
- <title>John posted a new blog entry</title>
- <author>
- <uri>john.doe</uri>
- <name xmlns="http://ns.opensocial.org/2008/opensocial">John Doe</name>
- </author>
- <content type="application/xml">
- <activityEntry xmlns="http://ns.opensocial.org/2008/opensocial">
- <actor>
- <displayName>John Doe</displayName>
- <id>john.doe</id>
- <image>
- <height>250</height>
- <url>http://example.org/john/image</url>
- <width>250</width>
- </image>
- <objectType>person</objectType>
- <url>http://example.org/john</url>
- </actor>
- <id>activity1</id>
- <object>
- <id>object1</id>
- <url>http://example.org/blog/2011/02/entry</url>
- </object>
- <published>2011-02-10T15:04:55Z</published>
- <target>
- <displayName>John's Blog</displayName>
- <id>target1</id>
- <objectType>blog</objectType>
- <url>http://example.org/blog/</url>
- </target>
- <verb>post</verb>
- </activityEntry>
- </content>
- </entry>
- <entry>
<id>activity2</id>
<title>John posted a new video to his album.</title>
<summary>Photo posted</summary>
@@ -85,10 +49,17 @@
<upstreamDuplicate>upstream2</upstreamDuplicate>
<url>http://example.org/album/my_fluffy_cat.jpg</url>
</object>
+ <openSocial>
+ <embed>
+ <context>1234</context>
+ <gadget>http://example.org/albumViewer.xml</gadget>
+ <url>http://example.org/album/</url>
+ </embed>
+ </openSocial>
<provider>
<url>http://example.org/activity-stream</url>
</provider>
- <published>2011-02-10T15:04:55Z</published>
+ <published>2011-03-10T15:04:55Z</published>
<target>
<displayName>John's Photo Album</displayName>
<id>target2</id>
@@ -102,13 +73,43 @@
</target>
<title>John posted a new video to his album.</title>
<verb>post</verb>
- <openSocial>
- <embed>
- <context>1234</context>
- <gadget>http://example.org/albumViewer.xml</gadget>
- <url>http://example.org/album/</url>
- </embed>
- </openSocial>
+ </activityEntry>
+ </content>
+ </entry>
+ <entry>
+ <id>activity1</id>
+ <title>John posted a new blog entry</title>
+ <author>
+ <uri>john.doe</uri>
+ <name xmlns="http://ns.opensocial.org/2008/opensocial">John Doe</name>
+ </author>
+ <content type="application/xml">
+ <activityEntry xmlns="http://ns.opensocial.org/2008/opensocial">
+ <actor>
+ <displayName>John Doe</displayName>
+ <id>john.doe</id>
+ <image>
+ <height>250</height>
+ <url>http://example.org/john/image</url>
+ <width>250</width>
+ </image>
+ <objectType>person</objectType>
+ <url>http://example.org/john</url>
+ </actor>
+ <id>activity1</id>
+ <object>
+ <id>object1</id>
+ <url>http://example.org/blog/2011/02/entry</url>
+ </object>
+ <published>2011-02-10T15:04:55Z</published>
+ <target>
+ <displayName>John's Blog</displayName>
+ <id>target1</id>
+ <objectType>blog</objectType>
+ <url>http://example.org/blog/</url>
+ </target>
+ <title>John posted a new blog entry</title>
+ <verb>post</verb>
</activityEntry>
</content>
</entry>
@@ -117,5 +118,4 @@
<osearch:itemsPerPage>2</osearch:itemsPerPage>
<author>?</author>
<link rel="rel">???</link>
-
</feed>
\ No newline at end of file
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonDelete.json
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonDelete.json?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonDelete.json (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonDelete.json Fri Jun 3 15:33:37 2011
@@ -4,7 +4,7 @@
"entry":[
{
"id": "activity2",
- "published": "2011-02-10T15:04:55Z",
+ "published": "2011-03-10T15:04:55Z",
"generator": {
"url": "http://example.org/activities-app"
},
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonGroup.json
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonGroup.json?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonGroup.json (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonGroup.json Fri Jun 3 15:33:37 2011
@@ -30,7 +30,7 @@
}
}, {
"id": "activity2",
- "published": "2011-02-10T15:04:55Z",
+ "published": "2011-03-10T15:04:55Z",
"generator": {
"url": "http://example.org/activities-app"
},
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonIds.json
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonIds.json?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonIds.json (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryJsonIds.json Fri Jun 3 15:33:37 2011
@@ -30,7 +30,7 @@
}
}, {
"id": "activity2",
- "published": "2011-02-10T15:04:55Z",
+ "published": "2011-03-10T15:04:55Z",
"generator": {
"url": "http://example.org/activities-app"
},
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlId.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlId.xml?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlId.xml (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlId.xml Fri Jun 3 15:33:37 2011
@@ -55,7 +55,7 @@
<url>http://example.org/activity-stream</url>
</provider>
- <published>2011-02-10T15:04:55Z</published>
+ <published>2011-03-10T15:04:55Z</published>
<target>
<displayName>John's Photo Album</displayName>
<id>target2</id>
Modified: shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlIds.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlIds.xml?rev=1131075&r1=1131074&r2=1131075&view=diff
==============================================================================
--- shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlIds.xml (original)
+++ shindig/trunk/java/social-api/src/test/java/org/apache/shindig/social/dataservice/integration/fixtures/ActivityEntryXmlIds.xml Fri Jun 3 15:33:37 2011
@@ -89,7 +89,7 @@
<provider>
<url>http://example.org/activity-stream</url>
</provider>
- <published>2011-02-10T15:04:55Z</published>
+ <published>2011-03-10T15:04:55Z</published>
<target>
<displayName>John's Photo Album</displayName>