Author: ilgrosso
Date: Mon Feb 25 15:36:47 2013
New Revision: 1449750
URL: http://svn.apache.org/r1449750
Log:
[COCOON3-77] Adding TextSerializer to pipeline components and samples / IT; skipping EncodingTextSerializer
Modified:
cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml
cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SaxPipelineTest.java
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/TextSerializer.java
cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml
Modified: cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml?rev=1449750&r1=1449749&r2=1449750&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-optional/src/main/resources/META-INF/cocoon/spring-optional/cocoon-optional-serializers.xml Mon Feb 25 15:36:47 2013
@@ -10,23 +10,28 @@
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.
- -->
+ 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.
+-->
<!-- $Id$ -->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
- <bean name="serializer:exml" class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingXMLSerializer"
- scope="prototype" />
+ <bean name="serializer:exml"
+ class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingXMLSerializer"
+ scope="prototype" />
- <bean name="serializer:exhtml" class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingXHTMLSerializer"
- scope="prototype" />
+ <bean name="serializer:exhtml"
+ class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingXHTMLSerializer"
+ scope="prototype" />
- <bean name="serializer:ehtml" class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingHTMLSerializer"
- scope="prototype" />
+ <bean name="serializer:ehtml"
+ class="org.apache.cocoon.optional.servlet.components.sax.serializers.EncodingHTMLSerializer"
+ scope="prototype" />
</beans>
Modified: cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SaxPipelineTest.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SaxPipelineTest.java?rev=1449750&r1=1449749&r2=1449750&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SaxPipelineTest.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sample-webapp/src/test/java/org/apache/cocoon/it/SaxPipelineTest.java Mon Feb 25 15:36:47 2013
@@ -16,7 +16,10 @@
*/
package org.apache.cocoon.it;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNull;
+
import org.apache.commons.httpclient.methods.HeadMethod;
import org.junit.Test;
@@ -31,9 +34,16 @@ public class SaxPipelineTest extends Coc
@Test
public void testSimplePipeline() throws Exception {
this.loadResponse("/sax-pipeline/simple");
- assertTrue(this.response.getStatusCode() == 200);
+ assertEquals(200, this.response.getStatusCode());
assertEquals("text/xml", this.response.getContentType());
- assertTrue(this.response.getContentAsString().indexOf("-//W3C//DTD XHTML 1.0 Strict//EN") == -1);
+ assertEquals(-1, this.response.getContentAsString().indexOf("-//W3C//DTD XHTML 1.0 Strict//EN"));
+ }
+
+ @Test
+ public void testSimplePipelineTxt() throws Exception {
+ this.loadResponse("/sax-pipeline/simple-txt");
+ assertEquals(200, this.response.getStatusCode());
+ assertTrue(this.response.getContentType().startsWith("text/plain"));
}
@Test
@@ -45,13 +55,13 @@ public class SaxPipelineTest extends Coc
}
/**
- * A simple pipeline that produces an XHTML 1.0 document. This implicitly tests if the
- * configuration of serializers works properly.
+ * A simple pipeline that produces an XHTML 1.0 document. This implicitly tests if the configuration of serializers
+ * works properly.
*/
@Test
public void testSimplePipelineXhtml() throws Exception {
this.loadResponse("/sax-pipeline/simple-xhtml");
- assertTrue(this.response.getStatusCode() == 200);
+ assertEquals(200, this.response.getStatusCode());
assertEquals("text/html", this.response.getContentType());
assertTrue(this.response.getContentAsString().indexOf("-//W3C//DTD XHTML 1.0 Strict//EN") > 0);
}
@@ -62,7 +72,7 @@ public class SaxPipelineTest extends Coc
@Test
public void testSimplePipelineParameterPassingToTransformer() throws Exception {
this.loadXmlPage("/sax-pipeline/simple-xml");
- assertTrue(this.response.getStatusCode() == 200);
+ assertEquals(200, this.response.getStatusCode());
assertEquals("text/xml", this.response.getContentType());
this.assertXPath("/html/body/p", "3-false");
}
@@ -73,8 +83,7 @@ public class SaxPipelineTest extends Coc
@Test
public void testSettingStatusCode() throws Exception {
this.loadResponse("/sax-pipeline/unauthorized");
- int statusCode = this.response.getStatusCode();
- assertTrue(statusCode == 401);
+ assertEquals(401, this.response.getStatusCode());
String lastModified = this.response.getResponseHeaderValue("Last-Modified");
assertNull(lastModified);
}
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html?rev=1449750&r1=1449749&r2=1449750&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/overview.html Mon Feb 25 15:36:47 2013
@@ -47,6 +47,7 @@
<li><a href="sax-pipeline/simple">SAX Pipeline</a>: Simplest possible pipeline that has a generator, transformer and serializer.</li>
<li><a href="sax-pipeline/simple-xhtml">SAX Pipeline</a>: Same as before but creates XHTML as output format.</li>
<li><a href="sax-pipeline/simple-xml">SAX Pipeline</a>: Same as before but creates XML as output format.</li>
+ <li><a href="sax-pipeline/simple-txt">SAX Pipeline</a>: Same as before but creates TXT as output format</li>
<li><a href="sax-pipeline/simple-xsd">SAX Pipeline</a>: Same as before but creates XML as output format after validating the input.</li>
<li><a href="sax-pipeline/unauthorized">Status code</a>: Set status code '401' at pipeline.</li>
</ul>
Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=1449750&r1=1449749&r2=1449750&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Mon Feb 25 15:36:47 2013
@@ -10,13 +10,13 @@
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.
- -->
+ 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.
+-->
<!-- $Id$ -->
<map:sitemap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map="http://apache.org/cocoon/sitemap"
xmlns:servlet="http://apache.org/cocoon/servlet" xmlns:controller="http://apache.org/cocoon/controller">
@@ -80,6 +80,13 @@
</map:transform>
<map:serialize type="xml" />
</map:match>
+ <map:match pattern="sax-pipeline/simple-txt">
+ <map:generate src="sax-pipeline/simple.xml" />
+ <map:transform src="sax-pipeline/simple.xslt">
+ <map:parameter name="myParam" value="3-{jexl:cocoon.request.ssf}" />
+ </map:transform>
+ <map:serialize type="txt" />
+ </map:match>
<map:match equals="sax-pipeline/simple-xsd">
<map:generate src="sax-pipeline/simple.xml" />
<map:transform type="schema" src="sax-pipeline/simple.xsd" />
@@ -387,7 +394,7 @@
<map:match equals="aggregation/xinclude-transformer">
<map:generate src="aggregation/xinclude.xml" />
<map:transform type="xinclude">
- <map:parameter name="cacheKey" value="{map:0}"/>
+ <map:parameter name="cacheKey" value="{map:0}"/>
</map:transform>
<map:serialize type="xml" />
</map:match>
Modified: cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/TextSerializer.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/TextSerializer.java?rev=1449750&r1=1449749&r2=1449750&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/TextSerializer.java (original)
+++ cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/TextSerializer.java Mon Feb 25 15:36:47 2013
@@ -41,7 +41,7 @@ public class TextSerializer extends XMLS
private boolean hadNoRootElement;
- private final static String ENCODING = "UTF-8";
+ private static final String UTF_8 = "UTF-8";
private static final String TXT = "text";
@@ -89,7 +89,7 @@ public class TextSerializer extends XMLS
@Override
public void endDocument() throws SAXException {
if (this.hadNoRootElement) {
- super.endElement("", "text", "text");
+ super.endElement("", TXT, TXT);
}
super.endDocument();
}
@@ -101,8 +101,8 @@ public class TextSerializer extends XMLS
public void characters(final char buffer[], final int start, final int len) throws SAXException {
if (!this.hasRootElement) {
this.hasRootElement = this.hadNoRootElement = true;
- LOG.warn("Encountered text before root element. Creating <text> wrapper element.");
- super.startElement("", "text", "text", XMLUtils.EMPTY_ATTRIBUTES);
+ LOG.warn("Encountered text before root element. Creating <{}> wrapper element.", TXT);
+ super.startElement("", TXT, TXT, XMLUtils.EMPTY_ATTRIBUTES);
}
super.characters(buffer, start, len);
}
@@ -114,9 +114,9 @@ public class TextSerializer extends XMLS
}
public static TextSerializer createPlainSerializer() {
- TextSerializer serializer = new TextSerializer();
- serializer.setContentType("text/plain;charset=utf-8");
- serializer.setEncoding(ENCODING);
+ final TextSerializer serializer = new TextSerializer();
+ serializer.setContentType("text/plain; charset=" + UTF_8);
+ serializer.setEncoding(UTF_8);
serializer.setMethod(TXT);
return serializer;
}
Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml?rev=1449750&r1=1449749&r2=1449750&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/resources/META-INF/cocoon/spring/cocoon-pipeline-component.xml Mon Feb 25 15:36:47 2013
@@ -10,29 +10,33 @@
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.
- -->
+ 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.
+-->
<!-- $Id$ -->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="org.apache.cocoon.sitemap.spring.PipelineComponentFactory"
- class="org.apache.cocoon.sitemap.spring.PrototypePipelineComponentFactory">
- </bean>
+ class="org.apache.cocoon.sitemap.spring.PrototypePipelineComponentFactory"/>
<bean name="serializer:xhtml" class="org.apache.cocoon.sax.component.XMLSerializer" scope="prototype"
- factory-method="createXHTMLSerializer" />
+ factory-method="createXHTMLSerializer" />
<bean name="serializer:xml" class="org.apache.cocoon.sax.component.XMLSerializer" scope="prototype"
- factory-method="createXMLSerializer" />
+ factory-method="createXMLSerializer" />
<bean name="serializer:html" class="org.apache.cocoon.sax.component.XMLSerializer" scope="prototype"
- factory-method="createHTML4Serializer" />
+ factory-method="createHTML4Serializer" />
+
+ <bean name="serializer:txt" class="org.apache.cocoon.sax.component.TextSerializer" scope="prototype"
+ factory-method="createPlainSerializer" />
<bean name="generator:url" class="org.apache.cocoon.sax.component.XMLGenerator" scope="prototype" />
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.