You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2010/10/31 20:09:02 UTC

svn commit: r1029457 - in /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test: java/org/apache/clerezza/rdf/stable/serializer/ resources/org/apache/clerezza/rdf/stable/serializer/

Author: reto
Date: Sun Oct 31 19:09:02 2010
New Revision: 1029457

URL: http://svn.apache.org/viewvc?rev=1029457&view=rev
Log:
CLEREZZA-345: added test showing problem (failing when uncommenting assert statement)

Added:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/java/org/apache/clerezza/rdf/stable/serializer/DocumentationStabilityTest.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/resources/org/apache/clerezza/rdf/stable/serializer/documentation-example.nt

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/java/org/apache/clerezza/rdf/stable/serializer/DocumentationStabilityTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/java/org/apache/clerezza/rdf/stable/serializer/DocumentationStabilityTest.java?rev=1029457&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/java/org/apache/clerezza/rdf/stable/serializer/DocumentationStabilityTest.java (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/java/org/apache/clerezza/rdf/stable/serializer/DocumentationStabilityTest.java Sun Oct 31 19:09:02 2010
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.clerezza.rdf.stable.serializer;
+
+import java.io.ByteArrayOutputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class DocumentationStabilityTest {
+	
+	@Test
+	public void RDFTestCases() throws Exception {
+		
+		Parser parser = Parser.getInstance();
+		Graph tc1 = parser.parse(
+				getClass().getResourceAsStream("documentation-example.nt"), SupportedFormat.N_TRIPLE);
+		final Set<String> lines1 = serializeToLines(tc1);
+		TripleCollection tc2 = new SimpleMGraph();
+		tc2.addAll(tc1);
+		//add <bundle:///intro> <http://clerezza.org/2009/08/documentation#after> <bundle://org.apache.clerezza.platform.documentation/intro> .
+		tc2.add(new TripleImpl(new UriRef("bundle:///intro"), 
+				new UriRef("http://clerezza.org/2009/08/documentation#after"), 
+				new UriRef("bundle://org.apache.clerezza.platform.documentation/intro")));
+		final Set<String> lines2 = serializeToLines(tc2);
+		lines2.removeAll(lines1);
+		//TODO: the following fails, fix:
+		//Assert.assertEquals(1, lines2.size());
+	}
+	
+	private Set<String> serializeToLines(TripleCollection tc) throws UnsupportedEncodingException {
+		StableSerializerProvider ssp = new StableSerializerProvider();
+		final ByteArrayOutputStream os1 = new ByteArrayOutputStream();
+		ssp.serialize(os1, tc, SupportedFormat.N_TRIPLE);
+		return new HashSet<String>(Arrays.asList(new String(os1.toByteArray(), "utf-8").split("\n")));
+		
+	}
+
+}

Added: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/resources/org/apache/clerezza/rdf/stable/serializer/documentation-example.nt
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/resources/org/apache/clerezza/rdf/stable/serializer/documentation-example.nt?rev=1029457&view=auto
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/resources/org/apache/clerezza/rdf/stable/serializer/documentation-example.nt (added)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.rdf.stable.serializer/src/test/resources/org/apache/clerezza/rdf/stable/serializer/documentation-example.nt Sun Oct 31 19:09:02 2010
@@ -0,0 +1,25 @@
+<bundle:///intro-content-el/0> <http://discobits.org/ontology#infoBit> "The documentation viewer provides access to the documentation (provided by the different modules) at <a xmlns=\"http://www.w3.org/1999/xhtml\" href=\"/documentation\">/documentation</a>."^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
+<bundle:///intro-content-el/0> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
+<bundle:///intro-content-el/1> <http://discobits.org/ontology#infoBit> "The documentation is ordered so that the after properties http://clerezza.org/2009/08/documentation#after are satisfied. When the documentation is written with the discobits editor such a property is typically set by adding something like the folleowing in the RDF editing mode to the xml element representing the resource: &lt;after xmlns=\"http://clerezza.org/2009/08/documentation#\" rdf:resource=\"bundle://org.apache.clerezza.platform.content/discobits-editor\"/ /&gt;"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
+<bundle:///intro-content-el/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
+<bundle:///intro-content> <http://discobits.org/ontology#contains> _:1e27a3b4f21eada7ec61fd7c55f2bd221 . 
+<bundle:///intro-content> <http://discobits.org/ontology#contains> _:86e4309edd82a6d415338546caff2d551 . 
+<bundle:///intro-content> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#OrderedContent> .
+<bundle:///intro-title> <http://discobits.org/ontology#infoBit> "Documentation Viewer"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
+<bundle:///intro-title> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
+<bundle:///intro> <http://clerezza.org/2009/08/documentation#after> <bundle://org.apache.clerezza.platform.content/discobits-editor> .
+<bundle:///intro> <http://discobits.org/ontology#contains> _:cc06f094ff0d735a332291b856b0d4ae1 . 
+<bundle:///intro> <http://discobits.org/ontology#contains> _:ccd6d577f99d82c53d5323fdbe4b6ba31 . 
+<bundle:///intro> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#TitledContent> .
+_:1e27a3b4f21eada7ec61fd7c55f2bd221 <http://discobits.org/ontology#holds> <bundle:///intro-content-el/0> . 
+_:1e27a3b4f21eada7ec61fd7c55f2bd221 <http://discobits.org/ontology#pos> "0" . 
+_:1e27a3b4f21eada7ec61fd7c55f2bd221 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> . 
+_:86e4309edd82a6d415338546caff2d551 <http://discobits.org/ontology#holds> <bundle:///intro-content-el/1> . 
+_:86e4309edd82a6d415338546caff2d551 <http://discobits.org/ontology#pos> "1" . 
+_:86e4309edd82a6d415338546caff2d551 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> . 
+_:cc06f094ff0d735a332291b856b0d4ae1 <http://discobits.org/ontology#holds> <bundle:///intro-content> . 
+_:cc06f094ff0d735a332291b856b0d4ae1 <http://discobits.org/ontology#pos> "1" . 
+_:cc06f094ff0d735a332291b856b0d4ae1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> . 
+_:ccd6d577f99d82c53d5323fdbe4b6ba31 <http://discobits.org/ontology#holds> <bundle:///intro-title> . 
+_:ccd6d577f99d82c53d5323fdbe4b6ba31 <http://discobits.org/ontology#pos> "0" . 
+_:ccd6d577f99d82c53d5323fdbe4b6ba31 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .