incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r590999 [5/5] - in /incubator/sling/trunk/microsling: ./ microsling-core/ microsling-core/src/ microsling-core/src/main/ microsling-core/src/main/java/ microsling-core/src/main/java/org/ microsling-core/src/main/java/org/apache/ microsling-...
Date Thu, 01 Nov 2007 13:30:08 GMT
Added: incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/services/MicroslingServiceLocatorTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/services/MicroslingServiceLocatorTest.java?rev=590999&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/services/MicroslingServiceLocatorTest.java
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/java/org/apache/sling/microsling/services/MicroslingServiceLocatorTest.java
Thu Nov  1 06:30:00 2007
@@ -0,0 +1,105 @@
+/*
+ * 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.services;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletRequest;
+
+import junit.framework.TestCase;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.services.InvalidServiceFilterSyntaxException;
+import org.apache.sling.api.services.ServiceLocator;
+import org.apache.sling.api.services.ServiceNotAvailableException;
+
+public class MicroslingServiceLocatorTest extends TestCase {
+    private ServiceLocator serviceLocator;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        MicroslingServiceLocator sl = new MicroslingServiceLocator();
+        sl.registerService(ResourceResolver.class, new ResourceResolver() {
+
+            public Iterator<Resource> findResources(String query,
+                    String language) {
+                return null;
+            }
+
+            public Resource getResource(String path) {
+                return null;
+            }
+
+            public Resource getResource(Resource base, String path) {
+                return null;
+            }
+
+            public Iterator<Resource> listChildren(Resource parent) {
+                return null;
+            }
+
+            public Iterator<Map<String, Object>> queryResources(String query,
+                    String language) {
+                return null;
+            }
+
+            public Resource resolve(ServletRequest request) {
+                return null;
+            }
+
+        });
+        serviceLocator = sl;
+    }
+
+    public void testServiceFound() {
+        final Object svc = serviceLocator.getService(ResourceResolver.class);
+        assertNotNull(svc);
+        assertTrue(svc instanceof ResourceResolver);
+    }
+
+    public void testServiceNotFound() {
+        final Object svc = serviceLocator.getService(Iterator.class);
+        assertNull(svc);
+    }
+
+    public void testRequiredServiceFound() throws ServiceNotAvailableException {
+        final Object svc = serviceLocator.getRequiredService(ResourceResolver.class);
+        assertNotNull(svc);
+        assertTrue(svc instanceof ResourceResolver);
+    }
+
+    public void testRequiredServiceNotFound() {
+        try {
+            serviceLocator.getRequiredService(Iterator.class);
+            fail("Expected Exception when service is not found");
+        } catch (ServiceNotAvailableException sna) {
+            // fine - as expected
+        }
+    }
+
+    public void testGetServices() throws InvalidServiceFilterSyntaxException {
+        final Object[] svc = serviceLocator.getServices(ResourceResolver.class,
+            null);
+        assertNotNull(svc);
+        assertEquals(1, svc.length);
+        assertTrue(svc[0] instanceof ResourceResolver);
+    }
+}

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

Added: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.esp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.esp?rev=590999&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.esp
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.esp
Thu Nov  1 06:30:00 2007
@@ -0,0 +1,7 @@
+<%-- used by ScriptedRenderingTest --%>
+<html>
+	<body>
+		ESP template
+		<p><%= resource.item.text %></p>
+	</body>
+</html>

Added: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ftl
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ftl?rev=590999&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ftl
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.ftl
Thu Nov  1 06:30:00 2007
@@ -0,0 +1,7 @@
+<%-- used by ScriptedRenderingTest --%>
+<html>
+	<body>
+		FreeMarker template
+		<p><span>${resource.getItem().getProperty("text").getString()}</span></p>
+	</body>
+</html>

Added: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.js
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.js?rev=590999&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.js
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.js
Thu Nov  1 06:30:00 2007
@@ -0,0 +1,5 @@
+// Used by ScriptedRenderingTest
+out.println("<html><body>");
+out.println("Raw javascript template");
+out.println("<p><em>" + resource.item.text + "</em></p>");
+out.print("</body></html>");

Propchange: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.vlt
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.vlt?rev=590999&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.vlt
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/rendering-test.vlt
Thu Nov  1 06:30:00 2007
@@ -0,0 +1,7 @@
+<!-- Used by ScriptedRenderingTest -->
+<html>
+	<body>
+		Velocity template
+		<p><b>$resource.getItem().getProperty("text").getString()</b></p>
+	</body>
+</html>

Added: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.html?rev=590999&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.html
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.html
Thu Nov  1 06:30:00 2007
@@ -0,0 +1,5 @@
+<html>
+<body>
+This is <em>testfile.html</em>.
+</body>
+</html>
\ No newline at end of file

Propchange: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.txt
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.txt?rev=590999&view=auto
==============================================================================
--- incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.txt
(added)
+++ incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.txt
Thu Nov  1 06:30:00 2007
@@ -0,0 +1 @@
+This is just some text in an ASCII file.
\ No newline at end of file

Propchange: incubator/sling/trunk/microsling/microsling-core/src/test/resources/integration-test/testfile.txt
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message