This is an automated email from the ASF dual-hosted git repository.

bdelacretaz pushed a commit to branch SLING-10216/verify-its
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-servlets-annotations.git

commit 698707408c783a6b3dc64ead519eab5d1a37aff2
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Tue Mar 16 13:18:53 2021 +0100

    SLING-10216 - switch to verify.groovy for testing generated service 
properties
---
 src/it/annotations-it/pom.xml                      | 102 -------
 .../annotations/AnnotationsTestSupport.java        |  93 -------
 .../servlets/annotations/ServicePropertiesIT.java  | 116 --------
 .../annotations/ServletRegistrationIT.java         | 115 --------
 .../annotations-it/src/test/resources/logback.xml  |  32 ---
 src/it/annotations-it/verify.groovy                | 298 +++++++++++++++++++++
 6 files changed, 298 insertions(+), 458 deletions(-)

diff --git a/src/it/annotations-it/pom.xml b/src/it/annotations-it/pom.xml
index 6aed5a6..427fedc 100644
--- a/src/it/annotations-it/pom.xml
+++ b/src/it/annotations-it/pom.xml
@@ -90,7 +90,6 @@
             <version>${annotations.bundle.version}</version>
             <scope>provided</scope>
         </dependency>
-
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.service.component.annotations</artifactId>
@@ -108,107 +107,6 @@
             <artifactId>javax.servlet-api</artifactId>
             <scope>provided</scope>
         </dependency>
-
-        <!-- testing dependencies -->
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.servlets.resolver</artifactId>
-            <version>2.5.2</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.clients</artifactId>
-            <!-- for https://issues.apache.org/jira/browse/SLING-7680 -->
-            <version>1.2.1-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.rules</artifactId>
-            <version>1.0.8</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>osgi.core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.framework</artifactId>
-            <version>6.0.3</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.testing.paxexam</artifactId>
-            <version>4.0.0-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.logging</groupId>
-            <artifactId>pax-logging-api</artifactId>
-            <version>2.0.6</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.logging</groupId>
-            <artifactId>pax-logging-logback</artifactId>
-            <version>2.0.6</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam</artifactId>
-            <version>${org.ops4j.pax.exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-cm</artifactId>
-            <version>${org.ops4j.pax.exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-container-forked</artifactId>
-            <version>${org.ops4j.pax.exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-junit4</artifactId>
-            <version>${org.ops4j.pax.exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.exam</groupId>
-            <artifactId>pax-exam-link-mvn</artifactId>
-            <version>${org.ops4j.pax.exam.version}</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.ops4j.pax.url</groupId>
-            <artifactId>pax-url-wrap</artifactId>
-            <version>2.3.0</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 
 </project>
diff --git 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java
 
b/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java
deleted file mode 100644
index 8ea94ae..0000000
--- 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/AnnotationsTestSupport.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.servlets.annotations;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.sling.testing.clients.osgi.OsgiConsoleClient;
-import org.apache.sling.testing.paxexam.TestSupport;
-import org.junit.ClassRule;
-import org.junit.BeforeClass;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExamServer;
-import org.ops4j.pax.exam.options.extra.VMOption;
-
-import org.apache.sling.servlets.annotations.services.PathBoundService;
-
-import static 
org.apache.sling.testing.paxexam.SlingOptions.slingQuickstartOakTar;
-import static org.apache.sling.testing.paxexam.SlingOptions.versionResolver;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.CoreOptions.when;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-
-import java.net.URI;
-
-public class AnnotationsTestSupport extends TestSupport {
-
-    private final static int STARTUP_WAIT_SECONDS = 60;
-    protected static OsgiConsoleClient CLIENT;
-    protected static int httpPort = findFreePort();
-
-    @ClassRule
-    public static PaxExamServer serverRule = new PaxExamServer();
-
-    @Configuration
-    public Option[] configuration() throws Exception {
-        final String vmOpt = System.getProperty("pax.vm.options");
-        VMOption vmOption = null;
-        if (StringUtils.isNotEmpty(vmOpt)) {
-            vmOption = new VMOption(vmOpt);
-        }
-
-        final String jacocoOpt = System.getProperty("jacoco.command");
-        VMOption jacocoCommand = null;
-        if (StringUtils.isNotEmpty(jacocoOpt)) {
-            jacocoCommand = new VMOption(jacocoOpt);
-        }
-
-        return options(
-            when(vmOption != null).useOptions(vmOption),
-            when(jacocoCommand != null).useOptions(jacocoCommand),
-
-            // For some reason, Jetty starts first on port 8080 without this
-            
systemProperty("org.osgi.service.http.port").value(String.valueOf(httpPort)),
-
-            serverBaseConfiguration(),
-            slingQuickstartOakTar(workingDirectory(), httpPort),
-
-            testBundle("bundle.filename"),
-            
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.webconsole.plugins.ds").version(versionResolver),
-            
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").versionAsInProject(),
-            
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-logback").versionAsInProject()
-        );
-    }
-
-    @BeforeClass
-    public static void waitForSling() throws Exception {
-        final URI url = new URI(String.format("http://localhost:%d";, 
httpPort));
-        CLIENT = new OsgiConsoleClient(url, "admin", "admin");
-        CLIENT.waitExists("/", STARTUP_WAIT_SECONDS * 1000, 500);
-        CLIENT.waitComponentRegistered(PathBoundService.class.getName(), 10 * 
1000, 500);
-
-        // Verify stable status for a bit
-        for(int i=0; i < 10 ; i++) {
-            CLIENT.waitComponentRegistered(PathBoundService.class.getName(), 
1000, 100);
-            Thread.sleep(100);
-        }
-    }
-}
\ No newline at end of file
diff --git 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/ServicePropertiesIT.java
 
b/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/ServicePropertiesIT.java
deleted file mode 100644
index 70171a1..0000000
--- 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/ServicePropertiesIT.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.servlets.annotations;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.sling.servlets.annotations.services.PathBoundService;
-import 
org.apache.sling.servlets.annotations.services.PathBoundStrictAllOptionsService;
-import 
org.apache.sling.servlets.annotations.services.PathBoundStrictJustPathService;
-import org.apache.sling.testing.clients.ClientException;
-import org.apache.sling.testing.clients.util.JsonUtils;
-import org.codehaus.jackson.JsonNode;
-import org.junit.Test;
-
-/** Assuming servlet selection is tested in the servlets resolver module,
- *  it's good enough to verify that the expected OSGi service properties
- *  are set by our annotations - this is what this class does for some of
- *  our test services.
- */
-public class ServicePropertiesIT extends AnnotationsTestSupport {
-    
-    private static String componentPath(Object nameOrId) {
-        return "/system/console/components/" + nameOrId + ".json";
-    }
-
-    /** Getting service properties is not directly supported by the 
OsgiConsoleClient */
-    private List<String> getServiceProperties(String serviceName) throws 
ClientException {
-        // Need to get the component ID first, then its details
-        final List<String> result = new ArrayList<>();
-        final JsonNode idInfo = 
JsonUtils.getJsonNodeFromString(CLIENT.doGet(componentPath(serviceName)).getContent());
-        final String id = idInfo.get("data").get(0).get("id").getTextValue();
-        assertTrue("Expecting non-null component ID", !id.equals("null"));
-        final JsonNode details = 
JsonUtils.getJsonNodeFromString(CLIENT.doGet(componentPath(id)).getContent());
-        final JsonNode data = details.get("data").get(0);
-        final JsonNode props = data.get("props");
-        for(JsonNode prop : props) {
-            if("Properties".equals(prop.get("key").getTextValue())) {
-                for(JsonNode value : prop.get("value")) {
-                    result.add(value.getTextValue().replaceAll(" ", 
"").trim());
-                }
-            }
-        }
-        return result;
-    }
-
-    private void assertProperty(List<String> props, String key, String value) {
-        final String pattern = key + "=" + value;
-        assertTrue(
-            "Expecting " + pattern + " in " + props,
-            props.stream().anyMatch(line -> line.equals(pattern))
-        );
-    }
-
-    private void assertAbsentProperties(List<String> props, String ... keys) {
-        for(String key : keys) {
-            assertFalse(
-                "Expecting " + key + " to be absent in " + props,
-                props.stream().anyMatch(line -> line.startsWith(key))
-            );
-        }
-    }
-
-    @Test
-    public void testPathBoundService() throws ClientException {
-        final List<String> props = 
getServiceProperties(PathBoundService.class.getName());
-        assertProperty(props, "sling.servlet.paths", "[PathBoundServicePath]");
-        assertAbsentProperties(
-            props,
-            "sling.servlet.extensions",
-            "sling.servlet.selectors",
-            "sling.servlet.methods",
-            "sling.servlet.paths.strict"
-        );
-    }
-
-    @Test
-    public void testPathBoundStrictAllOptionsService() throws ClientException {
-        final List<String> props = 
getServiceProperties(PathBoundStrictAllOptionsService.class.getName());
-        assertProperty(props, "sling.servlet.paths.strict", "true");
-        assertProperty(props, "sling.servlet.paths", "[P1,P2]");
-        assertProperty(props, "sling.servlet.extensions", "[E1,E2]");
-        assertProperty(props, "sling.servlet.selectors", "[S1,S2]");
-        assertProperty(props, "sling.servlet.methods", "[M1,M2]");
-    }
-
-    @Test
-    public void testPathBoundStrictJustPathService() throws ClientException {
-        final List<String> props = 
getServiceProperties(PathBoundStrictJustPathService.class.getName());
-        assertProperty(props, "sling.servlet.paths.strict", "true");
-        assertProperty(props, "sling.servlet.paths", "[JustThePath]");
-        assertAbsentProperties(
-            props,
-            "sling.servlet.extensions",
-            "sling.servlet.selectors",
-            "sling.servlet.methods"
-        );
-    }
-}
diff --git 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/ServletRegistrationIT.java
 
b/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/ServletRegistrationIT.java
deleted file mode 100644
index ccdf406..0000000
--- 
a/src/it/annotations-it/src/test/java/org/apache/sling/servlets/annotations/ServletRegistrationIT.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.servlets.annotations;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Collections;
-
-import org.apache.http.entity.StringEntity;
-import org.apache.sling.testing.clients.ClientException;
-import org.junit.Test;
-
-/** Verify servlet selection based on our annotations. This duplicates
- *  some of the servlet resolver tests, see also {@link ServicePropertiesIT}
- *  for another testing method.
- */
-public class ServletRegistrationIT extends AnnotationsTestSupport {
-    
-    @Test
-    public void testPathBoundServlet() throws ClientException, 
UnsupportedEncodingException {
-        CLIENT.doGet("/bin/PathBoundServlet", 555);
-        CLIENT.doGet("/bin/PathBoundServlet.with.some.selector.and.extension", 
555);
-        
CLIENT.doGet("/bin/PathBoundServlet.with.some.selector.and.extension/suffix", 
555);
-        // other methods should work as well
-        CLIENT.doPut("/bin/PathBoundServlet", new StringEntity("some text"), 
Collections.emptyList(), 557);
-    }
-    
-    @Test
-    public void testPathBoundServletWithFilter() throws ClientException {
-        CLIENT.doGet("/bin/PathBoundServlet.html/simplefilter", 556);
-        
CLIENT.doGet("/bin/PathBoundServlet.with.some.selector.and.extension/simplefilter",
 556);
-    }
-
-    @Test
-    public void testPathBoundServletWithPrefix() throws ClientException {
-        CLIENT.doGet("/bin/PathBoundServletWithPrefix", 610);
-        
CLIENT.doGet("/bin/PathBoundServletWithPrefix.with.some.selector.and.extension",
 610);
-    }
-
-    @Test
-    public void testResourceTypeBoundServlet() throws ClientException, 
UnsupportedEncodingException {
-        CLIENT.doGet("/content/servlettest/resourceTypeBoundServlet", 560);
-        CLIENT.doGet("/content/servlettest/resourceTypeBoundServlet.html", 
560);
-        CLIENT.doGet("/content/servlettest/resourceTypeBoundServlet.json", 
560);
-        // only GET and HEAD are supposed to be working
-        CLIENT.doPut("/content/servlettest/resourceTypeBoundServlet.json", new 
StringEntity("some text"), Collections.emptyList(), 405);
-    }
-
-    @Test
-    public void testResourceTypeBoundServletWithPrefix() throws 
ClientException, UnsupportedEncodingException {
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithPrefix", 590);
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithPrefix.html", 
590);
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithPrefix.json", 
590);
-        // only GET and HEAD are supposed to be working
-        
CLIENT.doPut("/content/servlettest/resourceTypeBoundServletWithPrefix.json", 
new StringEntity("some text"), Collections.emptyList(), 405);
-    }
-
-    @Test
-    public void testResourceTypeBoundServletWithExtension() throws 
ClientException, UnsupportedEncodingException {
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithExtension", 
403); // without extension is a index listing, which is forbidden by default
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithExtension.html", 
200); // DEFAULT GET Servlet
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithExtension.ext1", 
570);
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithExtension.ext2", 
570);
-        
CLIENT.doPut("/content/servlettest/resourceTypeBoundServletWithExtension.ext2", 
new StringEntity("some text"), Collections.emptyList(), 571);
-        // extension is considered for all methods!
-        
CLIENT.doPut("/content/servlettest/resourceTypeBoundServletWithExtension.someotherext",
 new StringEntity("some text"), Collections.emptyList(), 405); // DEFAULT 
servlet
-    }
-
-    @Test
-    public void testResourceTypeBoundServletWithSelectors() throws 
ClientException, UnsupportedEncodingException {
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithSelectors.someext",
 404);
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithSelectors.selector1.someext",
 404);
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithSelectors.selector3.someext",
 600);
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithSelectors.selector1.selector2.someext",
 600);
-        // some non-registered selector as first selector
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithSelectors.someotherselector.selector1.selector2.someext",
 404);
-        // some non-registered selector as last selector
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithSelectors.selector1.selector2.someotherselector.someext",
 600);
-        // only GET and HEAD are supposed to be working
-        
CLIENT.doPut("/content/servlettest/resourceTypeBoundServletWithSelectors.selector3.someext",
 new StringEntity("some text"), Collections.emptyList(), 405);
-    }
-
-    @Test
-    public void testResourceTypeBoundServletWithMethods() throws 
ClientException, UnsupportedEncodingException {
-        
CLIENT.doGet("/content/servlettest/resourceTypeBoundServletWithMethods.someext",
 404); // DEFAULT Get not triggered due to weird extension
-        
CLIENT.doPut("/content/servlettest/resourceTypeBoundServletWithMethods.someext",
 new StringEntity("some text"), Collections.emptyList(), 581);
-        
CLIENT.doPost("/content/servlettest/resourceTypeBoundServletWithMethods.someext",
 new StringEntity("some text"), Collections.emptyList(), 582);
-    }
-
-    @Test
-    public void testInheritingServlets() throws ClientException {
-        
CLIENT.doGet("/content/servlettest/baseResourceTypeBoundServletWithSelectors", 
403); // no selectors passed
-        
CLIENT.doGet("/content/servlettest/baseResourceTypeBoundServletWithSelectors.someext",
 404); // no selectors passed
-        
CLIENT.doGet("/content/servlettest/baseResourceTypeBoundServletWithSelectors.sel1.someext",
 610); // matches
-        
CLIENT.doGet("/content/servlettest/baseResourceTypeBoundServletWithSelectors.sel2.someext",
 610); // matches
-        
CLIENT.doGet("/content/servlettest/inheritingResourceTypeBoundServlet", 620); 
// matches
-        
CLIENT.doGet("/content/servlettest/inheritingResourceTypeBoundServlet.someext", 
620); // matches
-        
CLIENT.doGet("/content/servlettest/inheritingResourceTypeBoundServlet.sel.someext",
 620); // matches
-        
CLIENT.doGet("/content/servlettest/inheritingResourceTypeBoundServlet.sel1.someext",
 610); // delegated to Base
-        
CLIENT.doGet("/content/servlettest/inheritingResourceTypeBoundServlet.sel2.someext",
 610); // delegated to Base
-    }
-}
\ No newline at end of file
diff --git a/src/it/annotations-it/src/test/resources/logback.xml 
b/src/it/annotations-it/src/test/resources/logback.xml
deleted file mode 100644
index a603c15..0000000
--- a/src/it/annotations-it/src/test/resources/logback.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-    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.
--->
-<configuration>
-  <appender name="file" class="ch.qos.logback.core.FileAppender">
-    <file>target/test.log</file>
-    <append>true</append>
-    <encoder>
-      <pattern>%date level=%level thread=%thread logger=%logger 
sourcefile=%file line=%line %mdc message=%msg%n</pattern>
-    </encoder>
-  </appender>
-  
-  <root level="info">
-    <appender-ref ref="file"/>
-  </root>
-</configuration>
diff --git a/src/it/annotations-it/verify.groovy 
b/src/it/annotations-it/verify.groovy
new file mode 100644
index 0000000..bf4a310
--- /dev/null
+++ b/src/it/annotations-it/verify.groovy
@@ -0,0 +1,298 @@
+/*
+ * 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.
+ */
+
+// Verify the OSGI-INF xml files generated by the bnd plugin based
+// on our annotations
+
+def INVALID_CONFIG = 'Configuration is invalid'
+
+// Utility functions
+def getXml(filename) {
+    return new XmlSlurper().parse(new File(basedir, "target/classes/OSGI-INF/" 
+ filename))
+}
+
+def assertTypedAttribute(xml, name, type, value) {
+    def errorMsg = name + " " + type + " attribute does not match " + value
+    assert(xml.property.find{ it.@name == name && it.@type == type && 
it.@value == value }) : errorMsg
+}
+
+def assertProperty(xml, name, type, String [] expected) {
+    def linesFromXml = xml.property.find{ it.@name == name && it.@type == type 
}.toString().split('\n')
+    expected.each {
+        def errorMsg = name + " " + type + " does not contain " + it
+        assert(linesFromXml.contains(it)) : errorMsg
+    }
+    assert(linesFromXml.length == expected.length)
+}
+
+def assertNoProperty(xml, String [] names) {
+    names.each {
+        def name = it
+        xml.property.find{ it.@name == name }.each {
+            assert(false) : "did not expect " + it + " for " + name
+        }
+    }
+}
+
+// The actual tests
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.services.PathBoundService.xml")
+    assertProperty(xml, 'sling.servlet.paths', 'String', 
'PathBoundServicePath')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths.strict',
+        'sling.servlet.resourceTypes',
+        'sling.servlet.resourceSuperType',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.services.PathBoundStrictAllOptionsService.xml")
+    assertProperty(xml, 'sling.servlet.paths', 'String', 'P1', 'P2')
+    assertProperty(xml, 'sling.servlet.selectors', 'String', 'S1', 'S2')
+    assertProperty(xml, 'sling.servlet.extensions', 'String', 'E1', 'E2')
+    assertProperty(xml, 'sling.servlet.methods', 'String', 'M1', 'M2')
+    assertTypedAttribute(xml, 'sling.servlet.paths.strict', 'Boolean', 'true')
+    assertNoProperty(xml,
+        'sling.servlet.resourceTypes',
+        'sling.servlet.resourceSuperType',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.services.PathBoundStrictJustPathService.xml")
+    assertProperty(xml, 'sling.servlet.paths', 'String', 'JustThePath')
+    assertTypedAttribute(xml, 'sling.servlet.paths.strict', 'Boolean', 'true')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.resourceTypes',
+        'sling.servlet.resourceSuperType',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservletfilters.SimpleServletFilter.xml")
+    assertProperty(xml, 'sling.filter.scope', 'String', 'REQUEST')
+    assertProperty(xml, 'sling.filter.pattern', 'String', '')
+    assertProperty(xml, 'sling.filter.resource.pattern', 'String', '')
+    assertProperty(xml, 'sling.filter.request.pattern', 'String', '')
+    assertProperty(xml, 'sling.filter.suffix.pattern', 'String', '')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.servlet.resourceTypes',
+        'sling.servlet.resourceSuperType',
+        'sling.servlet.selectors',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.BaseResourceTypeBoundServletWithSelectors.xml")
+    assertProperty(xml, 'sling.servlet.resourceTypes', 'String', 
'sling/testservlets/BaseResourceTypeBoundServletWithSelectors')
+    assertProperty(xml, 'sling.servlet.selectors', 'String', 'sel1', 'sel2')
+    assertTypedAttribute(xml, 'sling.servlet.resourceSuperType', 'String', 
'sling/bundle/resource')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.InheritingResourceTypeBoundServlet.xml")
+    assertProperty(xml, 'sling.servlet.resourceTypes', 'String', 
'sling/testservlets/InheritingResourceTypeBoundServlet')
+    assertTypedAttribute(xml, 'sling.servlet.resourceSuperType', 'String', 
'sling/testservlets/BaseResourceTypeBoundServletWithSelectors')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.PathBoundServlet.xml")
+    assertProperty(xml, 'sling.servlet.paths', 'String', 
'/bin/PathBoundServlet')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths.strict',
+        'sling.servlet.resourceTypes',
+        'sling.servlet.resourceSuperType',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.PathBoundServletWithPrefix.xml")
+    assertProperty(xml, 'sling.servlet.paths', 'String', 
'PathBoundServletWithPrefix')
+    assertTypedAttribute(xml, 'sling.servlet.prefix', 'String', '/bin/')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths.strict',
+        'sling.servlet.resourceTypes',
+        'sling.servlet.resourceSuperType',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.ResourceTypeBoundServlet.xml")
+    assertProperty(xml, 'sling.servlet.resourceTypes', 'String', 
'/apps/sling/testservlets/ResourceTypeBoundServlet')
+    assertTypedAttribute(xml, 'sling.servlet.resourceSuperType', 'String', 
'sling/bundle/resource')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.ResourceTypeBoundServletWithExtension.xml")
+    assertProperty(xml, 'sling.servlet.resourceTypes', 'String', 
'/apps/sling/testservlets/ResourceTypeBoundServletWithExtension')
+    assertTypedAttribute(xml, 'sling.servlet.resourceSuperType', 'String', 
'sling/bundle/resource')
+    assertProperty(xml, 'sling.servlet.extensions', 'String', 'ext1', 'ext2')
+    assertProperty(xml, 'sling.servlet.methods', 'String', 'PUT', 'GET')
+    assertNoProperty(xml,
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.ResourceTypeBoundServletWithMethods.xml")
+    assertProperty(xml, 'sling.servlet.resourceTypes', 'String', 
'/apps/sling/testservlets/ResourceTypeBoundServletWithMethods')
+    assertTypedAttribute(xml, 'sling.servlet.resourceSuperType', 'String', 
'sling/bundle/resource')
+    assertProperty(xml, 'sling.servlet.methods', 'String', 'PUT', 'POST')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.ResourceTypeBoundServletWithPrefix.xml")
+    assertProperty(xml, 'sling.servlet.resourceTypes', 'String', 
'ResourceTypeBoundServletWithPrefix')
+    assertTypedAttribute(xml, 'sling.servlet.resourceSuperType', 'String', 
'sling/bundle/resource')
+    assertTypedAttribute(xml, 'sling.servlet.prefix', 'String', 
'/apps/sling/testservlets/')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.servlet.selectors',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+
+    )
+}
+
+{
+    def 
xml=getXml("org.apache.sling.servlets.annotations.testservlets.ResourceTypeBoundServletWithSelectors.xml")
+    assertProperty(xml, 'sling.servlet.resourceTypes', 'String', 
'/apps/sling/testservlets/ResourceTypeBoundServletWithSelectors')
+    assertTypedAttribute(xml, 'sling.servlet.resourceSuperType', 'String', 
'sling/bundle/resource')
+    assertProperty(xml, 'sling.servlet.selectors', 'String', 
'selector1.selector2','selector3')
+    assertNoProperty(xml,
+        'sling.servlet.extensions',
+        'sling.servlet.methods',
+        'sling.servlet.paths',
+        'sling.servlet.paths.strict',
+        'sling.filter.scope',
+        'sling.filter.pattern',
+        'sling.filter.resource.pattern',
+        'sling.filter.request.pattern',
+        'sling.filter.suffix.pattern',
+        'sling.servlet.prefix',
+    )
+}

Reply via email to