Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 18344 invoked from network); 1 Nov 2007 13:32:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Nov 2007 13:32:34 -0000 Received: (qmail 97528 invoked by uid 500); 1 Nov 2007 13:30:38 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 97500 invoked by uid 500); 1 Nov 2007 13:30:38 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 97491 invoked by uid 99); 1 Nov 2007 13:30:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2007 06:30:38 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2007 13:31:05 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 736D61A984D; Thu, 1 Nov 2007 06:30:26 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071101133026.736D61A984D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 listChildren(Resource parent) { + return null; + } + + public Iterator> 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 --%> + + + ESP template +

<%= resource.item.text %>

+ + 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 --%> + + + FreeMarker template +

${resource.getItem().getProperty("text").getString()}

+ + 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(""); +out.println("Raw javascript template"); +out.println("

" + resource.item.text + "

"); +out.print(""); 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 @@ + + + + Velocity template +

$resource.getItem().getProperty("text").getString()

+ + 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 @@ + + +This is testfile.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