incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r603249 - in /incubator/sling/trunk/microsling/microsling-core/src: main/java/org/apache/sling/microsling/helpers/json/ main/java/org/apache/sling/microsling/resource/ main/java/org/apache/sling/microsling/slingservlets/ main/java/org/apach...
Date Tue, 11 Dec 2007 14:06:15 GMT
Author: bdelacretaz
Date: Tue Dec 11 06:06:13 2007
New Revision: 603249

URL: http://svn.apache.org/viewvc?rev=603249&view=rev
Log:
SLING-133 - simple default rendering of JCR Properties, makes them directly addressable by
URLs

Added:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrPropertyResource.java
  (with props)
    incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PropertyRenderingTest.java
  (with props)
Modified:
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRenderer.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRendererServlet.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/JsonRendererServlet.java
    incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/PlainTextRendererServlet.java

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/helpers/json/JsonItemWriter.java
Tue Dec 11 06:06:13 2007
@@ -66,6 +66,14 @@
         dump(node, new JSONWriter(w), 0, maxRecursionLevels);
     }
 
+    /** Dump given property in JSON */
+    public void dump(Property p, Writer w) throws JSONException, ValueFormatException, RepositoryException
{
+        final JSONWriter jw = new JSONWriter(w);
+        jw.object();
+        writeProperty(jw, 0, p);
+        jw.endObject();
+    }
+    
     /** Dump given node in JSON, optionally recursing into its child nodes */
     protected void dump(Node node, JSONWriter w, int currentRecursionLevel, int maxRecursionLevels)
     throws RepositoryException, JSONException {

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrNodeResource.java
Tue Dec 11 06:06:13 2007
@@ -58,16 +58,6 @@
     /** The relative path name of the data property of an nt:file node */
     private static final String FILE_DATA_PROP = JCR_CONTENT + "/" + JCR_DATA;
 
-    JcrNodeResource(javax.jcr.Session s,String path) throws RepositoryException {
-        node = (Node)s.getItem(path);
-        this.path = node.getPath();
-        metadata = new ResourceMetadata();
-        resourceType = getResourceTypeForNode(node);
-
-        // check for nt:file metadata
-        setMetaData(node, metadata);
-    }
-
     public JcrNodeResource(Node node) throws RepositoryException {
         this.node = node;
         this.path = node.getPath();
@@ -79,8 +69,9 @@
         setMetaData(node, metadata);
     }
 
+    @Override
     public String toString() {
-        return "JcrNodeResource, type=" + resourceType + ", path=" + path;
+        return getClass().getSimpleName() + ", type=" + resourceType + ", path=" + path;
     }
 
     public String getURI() {

Added: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrPropertyResource.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrPropertyResource.java?rev=603249&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrPropertyResource.java
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrPropertyResource.java
Tue Dec 11 06:06:13 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.sling.microsling.resource;
+
+import static org.apache.sling.api.resource.ResourceMetadata.RESOLUTION_PATH;
+
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceMetadata;
+
+/** A Resource that wraps a JCR Property */
+public class JcrPropertyResource implements Resource {
+
+    /** This empty string is currently used as the Resource type
+     *  for all Resources of this class.
+     */
+    public static final String DEFAULT_RESOURCE_TYPE = "";
+    
+    private final Property property;
+    private final String path;
+    private final ResourceMetadata metadata;
+    private final String resourceType;
+    
+    JcrPropertyResource(Property p) throws RepositoryException {
+        property = p;
+        path = p.getPath();
+        metadata = new ResourceMetadata();
+        metadata.put(RESOLUTION_PATH, path);
+        resourceType = DEFAULT_RESOURCE_TYPE;
+    }
+    
+    @Override
+    public String toString() {
+        return getClass().getSimpleName() + ", type=" + resourceType + ", path=" + path;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <Type> Type adaptTo(Class<Type> type) {
+        if (type == Property.class) {
+            return (Type) property;
+        }
+        return null;
+    }
+
+    public ResourceMetadata getResourceMetadata() {
+        return metadata;
+    }
+
+    public String getResourceType() {
+        return resourceType;
+    }
+
+    public String getURI() {
+        return path;
+    }
+}

Propchange: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrPropertyResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/JcrPropertyResource.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/resource/MicroslingResourceResolver.java
Tue Dec 11 06:06:13 2007
@@ -23,10 +23,12 @@
 import java.util.Iterator;
 import java.util.Map;
 
+import javax.jcr.Item;
 import javax.jcr.NamespaceException;
 import javax.jcr.NamespaceRegistry;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.Property;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
@@ -332,10 +334,17 @@
         }
 
         if(exists) {
-            Resource result = new JcrNodeResource(session, path);
+            Resource result = null;
+            final Item i = session.getItem(path);
+            if(i.isNode()) {
+                result = new JcrNodeResource((Node)i);
+            } else {
+                result = new JcrPropertyResource((Property)i);
+            }
+            
             result.getResourceMetadata().put(ResourceMetadata.RESOLUTION_PATH,
                 path);
-            log.info("Found Resource at path '{}'", path);
+            log.info("Found Resource " + result);
             return result;
         }
 

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/DefaultSlingServlet.java
Tue Dec 11 06:06:13 2007
@@ -25,6 +25,7 @@
 import java.util.Map;
 
 import javax.jcr.Node;
+import javax.jcr.Property;
 import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
@@ -33,7 +34,6 @@
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.servlets.HttpConstants;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
 import org.apache.sling.microsling.resource.SyntheticResourceData;
@@ -99,8 +99,8 @@
                 throw new HttpStatusCodeException(HttpServletResponse.SC_NOT_FOUND,
                         "Resource not found: " + r.getURI());
             }
-        } else if(r.adaptTo(Node.class) != null || r.adaptTo(SyntheticResourceData.class)
!= null) {
-
+            
+        } else if(canRender(r)) {
             final String contentType = req.getResponseContentType();
             final Servlet s = renderingServlets.get(contentType);
             if(s!=null) {
@@ -118,6 +118,17 @@
                 "Not implemented: resource " + req.getResource().getURI()
                 + " cannot be dumped by " + getClass().getSimpleName());
         }
+    }
+    
+    /** True if our rendering servlets can render Resource r */
+    protected boolean canRender(Resource r) {
+        return 
+            r!=null && 
+            (
+                    r.adaptTo(Node.class) != null 
+                    || r.adaptTo(Property.class) != null
+                    || r.adaptTo(SyntheticResourceData.class) != null
+            );
     }
 
     @Override

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRenderer.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRenderer.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRenderer.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRenderer.java
Tue Dec 11 06:06:13 2007
@@ -23,6 +23,7 @@
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.microsling.resource.SyntheticResourceData;
@@ -46,6 +47,10 @@
     public void render(PrintWriter pw, Resource r, SyntheticResourceData data) {
         pw.println("<h1>SyntheticResourceData</h1>");
         pw.println("<p>" + data.toString() + "</p>");
+    }
+
+    public void render(PrintWriter pw, Resource r, Property p) throws RepositoryException
{
+        pw.print(p.getValue().getString());
     }
 
     protected void dump(PrintWriter pw, Resource r, Property p) throws RepositoryException
{

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRendererServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRendererServlet.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRendererServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/DefaultHtmlRendererServlet.java
Tue Dec 11 06:06:13 2007
@@ -20,6 +20,7 @@
 import java.io.PrintWriter;
 
 import javax.jcr.Node;
+import javax.jcr.Property;
 import javax.jcr.RepositoryException;
 import javax.servlet.ServletException;
 
@@ -53,18 +54,24 @@
         final PrintWriter pw = resp.getWriter();
         
         final Node node = r.adaptTo(Node.class);
-        final SyntheticResourceData srd = r.adaptTo(SyntheticResourceData.class); 
-        if(srd != null) {
-            renderer.render(pw, r, srd);
-        } else {
-            try {
+        final SyntheticResourceData srd = r.adaptTo(SyntheticResourceData.class);
+        final Property p = r.adaptTo(Property.class);
+        
+        try {
+            if(srd != null) {
+                renderer.render(pw, r, srd);
+            } else if(node!=null) {
                 pw.println("<html><body>");
                 renderer.render(pw, r, node);
                 pw.println("</body></html>");
-            } catch (RepositoryException re) {
-                throw new ServletException("Cannot dump contents of "
-                    + req.getResource().getURI(), re);
+            } else {
+                // for properties, we just output the String value
+                renderer.render(pw, r, p);
             }
+        
+        } catch (RepositoryException re) {
+            throw new ServletException("Cannot dump contents of "
+                + req.getResource().getURI(), re);
         }
     }
 }

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/JsonRendererServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/JsonRendererServlet.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/JsonRendererServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/JsonRendererServlet.java
Tue Dec 11 06:06:13 2007
@@ -19,7 +19,9 @@
 import java.io.IOException;
 
 import javax.jcr.Node;
+import javax.jcr.Property;
 import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
@@ -65,11 +67,26 @@
             throw new HttpStatusCodeException(HttpServletResponse.SC_NOT_FOUND, "No data
to dump");
         }
         
+        // Do we have a SyntheticResourceData?
         if(r.adaptTo(SyntheticResourceData.class) != null) {
             renderSyntheticResource(req, resp);
             return;
         }
         
+        // Do we have a Property?
+        final Property p = r.adaptTo(Property.class);
+        if(p!=null) {
+            try {
+                renderProperty(p, resp);
+            } catch(JSONException je) {
+                reportException(je);
+            } catch(RepositoryException re) {
+                reportException(re);
+            }
+            return;
+        }
+        
+        // Do we have a Node?
         final Node n = r.adaptTo(Node.class);
         if(n == null) {
             throw new HttpStatusCodeException(
@@ -98,6 +115,12 @@
         } catch(RepositoryException re) {
             reportException(re);
         }
+    }
+    
+    /** Render a Property by dumping its String value */ 
+    private void renderProperty(Property p, SlingHttpServletResponse resp) throws JSONException,
RepositoryException, IOException {
+        resp.setContentType(responseContentType);
+        new JsonItemWriter(null).dump(p, resp.getWriter());
     }
 
     /** Render synthetic resources as empty JSON objects */ 

Modified: incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/PlainTextRendererServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/PlainTextRendererServlet.java?rev=603249&r1=603248&r2=603249&view=diff
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/PlainTextRendererServlet.java
(original)
+++ incubator/sling/trunk/microsling/microsling-core/src/main/java/org/apache/sling/microsling/slingservlets/renderers/PlainTextRendererServlet.java
Tue Dec 11 06:06:13 2007
@@ -55,14 +55,28 @@
             return;
         }
         
-        final Node node = r.adaptTo(Node.class);
         resp.setContentType(responseContentType);
         final PrintWriter pw = resp.getWriter();
         try {
-            dump(pw, r, node);
+            renderItem(pw, r);
         } catch (RepositoryException re) {
-            throw new ServletException("Cannot dump contents of "
-                + req.getResource().getURI(), re);
+            throw new ServletException("Exception while rendering Resource " + req.getResource(),
re);
+        }
+    }
+    
+    /** Render a Node or Property  */
+    private void renderItem(PrintWriter pw, Resource r) throws ServletException, RepositoryException
{
+        Node n = null;
+        Property p = null;
+        
+        if ( (n = r.adaptTo(Node.class)) != null) {
+            dump(pw, r, n);
+            
+        } else if( (p = r.adaptTo(Property.class)) != null) {
+            dump(pw, r, p);
+            
+        } else {
+            throw new ServletException("Resource " + r + " does not adapt to a Node or a
Property");
         }
     }
 
@@ -81,22 +95,21 @@
         pw.println("\n** Node properties **");
         for (PropertyIterator pi = n.getProperties(); pi.hasNext();) {
             final Property p = pi.nextProperty();
-            printPropertyValue(pw, p);
+            printPropertyValue(pw, p, true);
+            pw.println();
         }
     }
 
     protected void dump(PrintWriter pw, Resource r, Property p) throws RepositoryException
{
-        pw.println("** Property dumped by " + getClass().getSimpleName() + "**");
-        pw.println("Property path:" + p.getPath());
-        pw.println("Resource metadata: " + r.getResourceMetadata());
-
-        printPropertyValue(pw, p);
+        printPropertyValue(pw, p, false);
     }
 
-    protected void printPropertyValue(PrintWriter pw, Property p)
+    protected void printPropertyValue(PrintWriter pw, Property p, boolean includeName)
             throws RepositoryException {
 
-        pw.print(p.getName() + ": ");
+        if(includeName) {
+            pw.print(p.getName() + ": ");
+        }
 
         if (p.getDefinition().isMultiple()) {
             Value[] values = p.getValues();
@@ -107,9 +120,9 @@
                 }
                 pw.print(values[i].getString());
             }
-            pw.println(']');
+            pw.print(']');
         } else {
-            pw.println(p.getValue().getString());
+            pw.print(p.getValue().getString());
         }
     }
 }

Added: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PropertyRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PropertyRenderingTest.java?rev=603249&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PropertyRenderingTest.java
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PropertyRenderingTest.java
Tue Dec 11 06:06:13 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.sling.microsling.integration;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Test the rendering of JCR Properties, directly addressed by URLs.
+ *  See SLING-133
+ */
+public class PropertyRenderingTest extends RenderingTestBase {
+
+    private String slingResourceType;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set test values
+        testText = "This is a test " + System.currentTimeMillis();
+        slingResourceType = getClass().getName();
+
+        // create the test node, under a path that's specific to this class to allow collisions
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + System.currentTimeMillis()
+ "/*";
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("sling:resourceType", slingResourceType);
+        props.put("text", testText);
+        displayUrl = testClient.createNode(url, props);
+    }
+
+    public void testNodeAccess() throws IOException {
+        final String json = getContent(displayUrl + ".json", CONTENT_TYPE_JSON);
+        assertJavascript(testText, json, "out.println(data.text)");
+    }
+    
+    public void testTextJson() throws IOException {
+        final String json = getContent(displayUrl + "/text.json", CONTENT_TYPE_JSON);
+        assertEquals("{\"text\":\"" + testText + "\"}",json);
+    }
+
+    public void testTextHtml() throws IOException {
+        final String data = getContent(displayUrl + "/text.html", CONTENT_TYPE_HTML);
+        assertEquals(testText, data);
+    }
+    
+    public void testTextTxt() throws IOException {
+        final String data = getContent(displayUrl + "/text.txt", CONTENT_TYPE_PLAIN);
+        assertEquals(testText, data);
+    }
+    
+    public void testTextNoExt() throws IOException {
+        final String data = getContent(displayUrl + "/text", CONTENT_TYPE_PLAIN);
+        assertEquals(testText, data);
+    }
+    
+    public void testResourceTypeNoExt() throws IOException {
+        final String data = getContent(displayUrl + "/sling:resourceType", CONTENT_TYPE_PLAIN);
+        assertEquals(slingResourceType, data);
+    }
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PropertyRenderingTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/integration/PropertyRenderingTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message