You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2018/01/29 19:06:52 UTC

[sling-whiteboard] branch master updated: Fixing last few rat failures

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

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 6fe58a4  Fixing last few rat failures
6fe58a4 is described below

commit 6fe58a440e7cc0a8206d93e46ee4e474ba2d3030
Author: Dan Klco <da...@gmail.com>
AuthorDate: Mon Jan 29 14:05:24 2018 -0500

    Fixing last few rat failures
---
 cms/builder/src/main/scripts/start.sh              |  16 ++
 cms/builder/src/main/scripts/stop.sh               |  15 ++
 .../apache/sling/launchpad/LaunchpadReadyRule.java | 121 --------------
 .../java/org/apache/sling/launchpad/SmokeIT.java   | 173 ---------------------
 .../org/apache/sling/launchpad/package-info.java   |  30 ----
 cms/pom.xml                                        |  11 ++
 6 files changed, 42 insertions(+), 324 deletions(-)

diff --git a/cms/builder/src/main/scripts/start.sh b/cms/builder/src/main/scripts/start.sh
index 6bff0b8..6fca4b5 100755
--- a/cms/builder/src/main/scripts/start.sh
+++ b/cms/builder/src/main/scripts/start.sh
@@ -1,5 +1,21 @@
 #!/bin/bash
 #
+# 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.
+#
+#
 # This script configures the start information for this server.
 #
 # The following variables may be used to override the defaults.
diff --git a/cms/builder/src/main/scripts/stop.sh b/cms/builder/src/main/scripts/stop.sh
index 62ae91c..1d2ae5b 100755
--- a/cms/builder/src/main/scripts/stop.sh
+++ b/cms/builder/src/main/scripts/stop.sh
@@ -1,5 +1,20 @@
 #!/bin/bash
 #
+# 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.
+#
 # This script stops the (running) application
 #
 
diff --git a/cms/builder/src/test/java/org/apache/sling/launchpad/LaunchpadReadyRule.java b/cms/builder/src/test/java/org/apache/sling/launchpad/LaunchpadReadyRule.java
deleted file mode 100644
index fa96fa3..0000000
--- a/cms/builder/src/test/java/org/apache/sling/launchpad/LaunchpadReadyRule.java
+++ /dev/null
@@ -1,121 +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.launchpad;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.net.ConnectException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.junit.rules.ExternalResource;
-
-public class LaunchpadReadyRule extends ExternalResource {
-
-    private static final int TRIES = 60;
-    private static final int WAIT_BETWEEN_TRIES_MILLIS = 1000;
-
-    private final List<Check> checks = new ArrayList<>();
-
-    public LaunchpadReadyRule(int launchpadPort) {
-
-        checks.add(new Check("http://localhost:" + launchpadPort + "/server/default/jcr:root"));
-        checks.add(new Check("http://localhost:" + launchpadPort + "/index.html") {
-            @Override
-            public String runCheck(HttpResponse response) throws Exception {
-                try (InputStreamReader isr = new InputStreamReader(response.getEntity().getContent());
-                        BufferedReader reader = new BufferedReader(isr)) {
-
-                    String line;
-                    while ((line = reader.readLine()) != null) {
-                        if (line.contains("Do not remove this comment, used for Launchpad integration tests")) {
-                            return null;
-                        }
-                    }
-                }
-
-                return "Did not find 'ready' marker in the response body";
-            }
-        });
-    }
-
-    @Override
-    protected void before() throws Throwable {
-
-        try (CloseableHttpClient client = HttpClients.createDefault()) {
-            for (Check check : checks) {
-                runCheck(client, check);
-            }
-        }
-    }
-
-    private void runCheck(CloseableHttpClient client, Check check) throws Exception {
-
-        String lastFailure = null;
-        HttpGet get = new HttpGet(check.getUrl());
-        
-        for (int i = 0; i < TRIES; i++) {
-            try (CloseableHttpResponse response = client.execute(get)) {
-
-                if (response.getStatusLine().getStatusCode() != 200) {
-                    lastFailure = "Status code is " + response.getStatusLine();
-                    Thread.sleep(WAIT_BETWEEN_TRIES_MILLIS);
-                    continue;
-                }
-
-                lastFailure = check.runCheck(response);
-                if (lastFailure == null) {
-                    return;
-                }
-            } catch ( ConnectException e ) {
-                lastFailure = e.getClass().getName() + " : " + e.getMessage();
-            }
-
-            Thread.sleep(WAIT_BETWEEN_TRIES_MILLIS);
-        }
-        
-        throw new RuntimeException(String.format("Launchpad not ready. Failed check for URL %s with message '%s'",
-                check.getUrl(), lastFailure));
-    }
-
-    static class Check {
-        private String url;
-
-        public Check(String url) {
-            this.url = url;
-        }
-
-        public String getUrl() {
-            return url;
-        }
-
-        /**
-         * @param response the HttpResponse
-         * @return null if check check was successful, an error description otherwise
-         * @throws Exception
-         */
-        public String runCheck(HttpResponse response) throws Exception {
-            return null;
-        }
-    }
-
-}
diff --git a/cms/builder/src/test/java/org/apache/sling/launchpad/SmokeIT.java b/cms/builder/src/test/java/org/apache/sling/launchpad/SmokeIT.java
deleted file mode 100644
index 7b3113c..0000000
--- a/cms/builder/src/test/java/org/apache/sling/launchpad/SmokeIT.java
+++ /dev/null
@@ -1,173 +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.launchpad;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.felix.utils.json.JSONParser;
-import org.apache.http.Header;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.hamcrest.CoreMatchers;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-public class SmokeIT {
-
-    private static final int LAUNCHPAD_PORT = Integer.getInteger("launchpad.http.port", 8080);
-    private static final int EXPECTED_BUNDLES_COUNT = Integer.getInteger("IT.expected.bundles.count", Integer.MAX_VALUE);
-
-    @ClassRule
-    public static LaunchpadReadyRule LAUNCHPAD = new LaunchpadReadyRule(LAUNCHPAD_PORT);
-
-    private CloseableHttpClient newClient() {
-
-        CredentialsProvider credsProvider = new BasicCredentialsProvider();
-        UsernamePasswordCredentials creds = new UsernamePasswordCredentials("admin", "admin");
-        credsProvider.setCredentials(new AuthScope("localhost", LAUNCHPAD_PORT), creds);
-
-        return HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build();
-    }
-
-    @Test
-    public void verifyAllBundlesStarted() throws Exception {
-
-        try ( CloseableHttpClient client = newClient() ) {
-
-            HttpGet get = new HttpGet("http://localhost:" + LAUNCHPAD_PORT + "/system/console/bundles.json");
-
-            try ( CloseableHttpResponse response = client.execute(get) ) {
-
-                if ( response.getStatusLine().getStatusCode() != 200 ) {
-                    fail("Unexpected status line " + response.getStatusLine());
-                }
-
-                Header contentType = response.getFirstHeader("Content-Type");
-                assertThat("Content-Type header", contentType.getValue(), CoreMatchers.startsWith("application/json"));
-
-                Map<String, Object> obj = new JSONParser(response.getEntity().getContent()).getParsed();
-
-                @SuppressWarnings("unchecked")
-                List<Object> status = (List<Object>) obj.get("s");
-
-                @SuppressWarnings("unchecked")
-                List<Object> bundles = (List<Object>) obj.get("data");
-                if(bundles.size() < EXPECTED_BUNDLES_COUNT) {
-                    fail("Expected at least " + EXPECTED_BUNDLES_COUNT + " bundles, got " + bundles.size());
-                }
-
-                BundleStatus bs = new BundleStatus(status);
-
-                if ( bs.resolvedBundles != 0 || bs.installedBundles != 0 ) {
-
-                    StringBuilder out = new StringBuilder();
-                    out.append("Expected all bundles to be active, but instead got ")
-                        .append(bs.resolvedBundles).append(" resolved bundles, ")
-                        .append(bs.installedBundles).append(" installed bundlles: ");
-
-                    for ( int i = 0 ; i < bundles.size(); i++ ) {
-                        @SuppressWarnings("unchecked")
-                        Map<String, Object> bundle = (Map<String, Object>) bundles.get(i);
-
-                        String bundleState = (String) bundle.get("state");
-                        String bundleSymbolicName = (String) bundle.get("symbolicName");
-                        String bundleVersion = (String) bundle.get("version");
-
-                        switch ( bundleState ) {
-                            case "Active":
-                            case "Fragment":
-                                continue;
-
-                            default:
-                                out.append("\n- ").append(bundleSymbolicName).append(" ").append(bundleVersion).append(" is in state " ).append(bundleState);
-                        }
-                    }
-
-                    fail(out.toString());
-                }
-            }
-        }
-    }
-
-    @Test
-    public void ensureRepositoryIsStarted() throws Exception {
-        try ( CloseableHttpClient client = newClient() ) {
-
-            HttpGet get = new HttpGet("http://localhost:" + LAUNCHPAD_PORT + "/server/default/jcr:root");
-
-            try ( CloseableHttpResponse response = client.execute(get) ) {
-
-                if ( response.getStatusLine().getStatusCode() != 200 ) {
-                    fail("Unexpected status line " + response.getStatusLine());
-                }
-
-                Header contentType = response.getFirstHeader("Content-Type");
-                assertThat("Content-Type header", contentType.getValue(), equalTo("text/xml"));
-
-                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-                dbf.setNamespaceAware(true);
-                DocumentBuilder db = dbf.newDocumentBuilder();
-                Document document = db.parse(response.getEntity().getContent());
-
-                Element docElement = document.getDocumentElement();
-                NamedNodeMap attrs = docElement.getAttributes();
-
-                Node nameAttr = attrs.getNamedItemNS("http://www.jcp.org/jcr/sv/1.0", "name");
-                assertThat("no 'name' attribute found", nameAttr, notNullValue());
-                assertThat("Invalid name attribute value", nameAttr.getNodeValue(), equalTo("jcr:root"));
-            }
-        }
-    }
-
-    static class BundleStatus {
-
-        long totalBundles;
-        long activeBundles;
-        long activeFragments;
-        long resolvedBundles;
-        long installedBundles;
-
-        public BundleStatus(List<Object> array) {
-
-            totalBundles = (Long)array.get(0);
-            activeBundles = (Long)array.get(1);
-            activeFragments = (Long)array.get(2);
-            resolvedBundles = (Long)array.get(3);
-            installedBundles = (Long)array.get(4);
-
-        }
-    }
-}
diff --git a/cms/builder/src/test/java/org/apache/sling/launchpad/package-info.java b/cms/builder/src/test/java/org/apache/sling/launchpad/package-info.java
deleted file mode 100644
index f70e5e8..0000000
--- a/cms/builder/src/test/java/org/apache/sling/launchpad/package-info.java
+++ /dev/null
@@ -1,30 +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.
- */
-/**
- * <h1>Smoke tests for the Sling Launchpad</h1>
- * 
- * <p>This package contains a minimal set of tests for the Sling launchpad. The
- * tests validate that the launchpad is correctly assembled and that there are
- * no obvious mistakes such as bundles that can't be wired. More extensive
- * tests must be placed in specific test projects.</p>
- * 
- * <p>The launchpad tests don't depend on other Sling bundles,to prevent circular
- * dependencies. As such, there is some duplication of code ( at least intent, if 
- * not implementation ) with some of the testing projects. This is another 
- * argument for keeping the tests minimal.</p>
- */
-package org.apache.sling.launchpad;
\ No newline at end of file
diff --git a/cms/pom.xml b/cms/pom.xml
index 7314f3d..49cfde1 100644
--- a/cms/pom.xml
+++ b/cms/pom.xml
@@ -1,4 +1,15 @@
 <?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.
+    -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>

-- 
To stop receiving notification emails like this one, please contact
dklco@apache.org.