Author: dulvac
Date: Thu Apr 9 13:50:42 2020
New Revision: 38870
Log:
Release org.apache.sling.testing.clients-2.0.0
Added:
release/sling/CODE_OF_CONDUCT.md
release/sling/CONTRIBUTING.md
release/sling/DEPENDENCIES
release/sling/Jenkinsfile
release/sling/LICENSE
release/sling/NOTICE
release/sling/README.md
release/sling/pom.xml
release/sling/src/
release/sling/src/main/
release/sling/src/main/java/
release/sling/src/main/java/org/
release/sling/src/main/java/org/apache/
release/sling/src/main/java/org/apache/sling/
release/sling/src/main/java/org/apache/sling/testing/
release/sling/src/main/java/org/apache/sling/testing/Constants.java
release/sling/src/main/java/org/apache/sling/testing/clients/
release/sling/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
release/sling/src/main/java/org/apache/sling/testing/clients/ClientException.java
release/sling/src/main/java/org/apache/sling/testing/clients/SlingClient.java
release/sling/src/main/java/org/apache/sling/testing/clients/SlingClientConfig.java
release/sling/src/main/java/org/apache/sling/testing/clients/SlingHttpResponse.java
release/sling/src/main/java/org/apache/sling/testing/clients/SystemPropertiesConfig.java
release/sling/src/main/java/org/apache/sling/testing/clients/email/
release/sling/src/main/java/org/apache/sling/testing/clients/email/EmailMessage.java
release/sling/src/main/java/org/apache/sling/testing/clients/email/SlingEmailClient.java
release/sling/src/main/java/org/apache/sling/testing/clients/email/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/html/
release/sling/src/main/java/org/apache/sling/testing/clients/html/MicrodataClient.java
release/sling/src/main/java/org/apache/sling/testing/clients/html/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/indexing/
release/sling/src/main/java/org/apache/sling/testing/clients/indexing/IndexingClient.java
release/sling/src/main/java/org/apache/sling/testing/clients/indexing/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/instance/
release/sling/src/main/java/org/apache/sling/testing/clients/instance/InstanceConfiguration.java
release/sling/src/main/java/org/apache/sling/testing/clients/instance/InstanceSetup.java
release/sling/src/main/java/org/apache/sling/testing/clients/instance/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/DelayRequestInterceptor.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/FormBasedAuthInterceptor.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/StickyCookieHolder.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/StickyCookieInterceptor.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/StickyCookieSpec.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/TestDescriptionHolder.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/TestDescriptionInterceptor.java
release/sling/src/main/java/org/apache/sling/testing/clients/interceptors/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/Bundle.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/BundleInfo.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/BundlesInfo.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/BundlesInstaller.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/Component.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/ComponentInfo.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/ComponentsInfo.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClient.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/OsgiInstanceConfig.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/ServiceInfo.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/ServicesInfo.java
release/sling/src/main/java/org/apache/sling/testing/clients/osgi/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/query/
release/sling/src/main/java/org/apache/sling/testing/clients/query/QueryClient.java
release/sling/src/main/java/org/apache/sling/testing/clients/query/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/query/servlet/
release/sling/src/main/java/org/apache/sling/testing/clients/query/servlet/QueryServlet.java
release/sling/src/main/java/org/apache/sling/testing/clients/query/servlet/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/
release/sling/src/main/java/org/apache/sling/testing/clients/util/FormEntityBuilder.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/HttpUtils.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/InputStreamBodyWithLength.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/JsonUtils.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/PortAllocator.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/ResourceUtil.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/ServerErrorRetryStrategy.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/SlingParameter.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/TimeoutsProvider.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/URLParameterBuilder.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/UniquePaths.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/XSSUtils.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfig.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigCache.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/InstanceConfigException.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/impl/
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/impl/EmptyInstanceConfig.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/impl/InstanceConfigCacheImpl.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/impl/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/config/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/package-info.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/poller/
release/sling/src/main/java/org/apache/sling/testing/clients/util/poller/AbstractPoller.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/poller/PathPoller.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/poller/Poller.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/poller/Polling.java
release/sling/src/main/java/org/apache/sling/testing/clients/util/poller/package-info.java
release/sling/src/main/java/org/apache/sling/testing/timeouts/
release/sling/src/main/java/org/apache/sling/testing/timeouts/TimeoutsProvider.java
release/sling/src/test/
release/sling/src/test/java/
release/sling/src/test/java/org/
release/sling/src/test/java/org/apache/
release/sling/src/test/java/org/apache/sling/
release/sling/src/test/java/org/apache/sling/testing/
release/sling/src/test/java/org/apache/sling/testing/AbstractSlingClientGetPathTest.java
release/sling/src/test/java/org/apache/sling/testing/AbstractSlingClientGetServerUrlTest.java
release/sling/src/test/java/org/apache/sling/testing/AbstractSlingClientGetUrlTest.java
release/sling/src/test/java/org/apache/sling/testing/DelayRequestInterceptorTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/
release/sling/src/test/java/org/apache/sling/testing/clients/HttpServerRule.java
release/sling/src/test/java/org/apache/sling/testing/clients/SlingClientConfigTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/SlingClientDoGetJsonTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/SlingClientImportContentTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/SlingClientRetryStrategyTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/SlingClientWaitExistsTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/indexing/
release/sling/src/test/java/org/apache/sling/testing/clients/indexing/IndexingClientTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/osgi/
release/sling/src/test/java/org/apache/sling/testing/clients/osgi/ServicesInfoTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/query/
release/sling/src/test/java/org/apache/sling/testing/clients/query/QueryClientTest.java
release/sling/src/test/java/org/apache/sling/testing/clients/util/
release/sling/src/test/java/org/apache/sling/testing/clients/util/poller/
release/sling/src/test/java/org/apache/sling/testing/clients/util/poller/PollingTest.java
release/sling/src/test/java/org/apache/sling/testing/util/
release/sling/src/test/java/org/apache/sling/testing/util/ResourceUtilTest.java
release/sling/src/test/java/org/apache/sling/testing/util/UniquePathsTest.java
release/sling/src/test/java/org/apache/sling/testing/util/poller/
release/sling/src/test/java/org/apache/sling/testing/util/poller/AbstractPollerTest.java
release/sling/src/test/resources/
release/sling/src/test/resources/resource-util-test-file.txt
Added: release/sling/CODE_OF_CONDUCT.md
==============================================================================
--- release/sling/CODE_OF_CONDUCT.md (added)
+++ release/sling/CODE_OF_CONDUCT.md Thu Apr 9 13:50:42 2020
@@ -0,0 +1,22 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Apache Software Foundation Code of Conduct
+====
+
+Being an Apache project, Apache Sling adheres to the Apache Software
Foundation's [Code of
Conduct](https://www.apache.org/foundation/policies/conduct.html).
Added: release/sling/CONTRIBUTING.md
==============================================================================
--- release/sling/CONTRIBUTING.md (added)
+++ release/sling/CONTRIBUTING.md Thu Apr 9 13:50:42 2020
@@ -0,0 +1,24 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+Contributing
+====
+
+Thanks for choosing to contribute!
+
+You will find all the necessary details about how you can do this at
https://sling.apache.org/contributing.html.
Added: release/sling/DEPENDENCIES
==============================================================================
--- release/sling/DEPENDENCIES (added)
+++ release/sling/DEPENDENCIES Thu Apr 9 13:50:42 2020
@@ -0,0 +1,79 @@
+// ------------------------------------------------------------------
+// Transitive dependencies of this project determined from the
+// maven pom organized by organization.
+// ------------------------------------------------------------------
+
+Apache Sling Testing Clients
+
+
+From: 'an unknown organization'
+ - Guava: Google Core Libraries for Java
(http://code.google.com/p/guava-libraries/guava)
com.google.guava:guava:bundle:14.0.1
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - servlet-api javax.servlet:servlet-api:jar:2.4
+
+
+From: 'Bndtools' (http://bndtools.org/)
+ - bndlib (http://bnd.bndtools.org/) biz.aQute.bnd:biz.aQute.bndlib:jar:3.5.0
+ License: Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0)
+
+From: 'FasterXML' (http://fasterxml.com)
+ - Jackson (http://jackson.codehaus.org)
org.codehaus.jackson:jackson-core-asl:jar:1.5.5
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Data Mapper for Jackson (http://jackson.codehaus.org)
org.codehaus.jackson:jackson-mapper-asl:jar:1.5.5
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+
+From: 'FasterXML' (http://fasterxml.com/)
+ - Jackson-annotations (http://github.com/FasterXML/jackson)
com.fasterxml.jackson.core:jackson-annotations:bundle:2.9.10
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Jackson-core (https://github.com/FasterXML/jackson-core)
com.fasterxml.jackson.core:jackson-core:bundle:2.9.4
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - jackson-databind (http://github.com/FasterXML/jackson)
com.fasterxml.jackson.core:jackson-databind:bundle:2.9.10.1
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+
+From: 'Jonathan Hedley' (http://jonathanhedley.com/)
+ - jsoup (http://jsoup.org/) org.jsoup:jsoup:jar:1.7.2
+ License: The MIT License (http://jsoup.com/license)
+
+From: 'OPS4J - Open Participation Software for Java' (http://www.ops4j.org/)
+ - OPS4J Base - IO (http://team.ops4j.org/wiki/display/base/ops4j-base-io/)
org.ops4j.base:ops4j-base-io:bundle:1.5.0
+ License: ALv2 (http://www.apache.org/licenses/LICENSE-2.0.html)
+ - OPS4J Base - Lang
(http://team.ops4j.org/wiki/display/base/ops4j-base-lang/)
org.ops4j.base:ops4j-base-lang:bundle:1.5.0
+ License: ALv2 (http://www.apache.org/licenses/LICENSE-2.0.html)
+ - OPS4J Base - Monitors
(http://team.ops4j.org/wiki/display/base/ops4j-base-monitors/)
org.ops4j.base:ops4j-base-monitors:bundle:1.5.0
+ License: ALv2 (http://www.apache.org/licenses/LICENSE-2.0.html)
+ - OPS4J Base - Store
(http://team.ops4j.org/wiki/display/base/ops4j-base-store/)
org.ops4j.base:ops4j-base-store:bundle:1.5.0
+ License: ALv2 (http://www.apache.org/licenses/LICENSE-2.0.html)
+ - OPS4J Pax Tinybundles
(http://team.ops4j.org/wiki/display/ops4j/Tinybundles)
org.ops4j.pax.tinybundles:tinybundles:bundle:3.0.0
+ License: ALv2 (http://www.apache.org/licenses/LICENSE-2.0.html)
+
+From: 'OSGi Alliance' (http://www.osgi.org)
+ - osgi.cmpn (http://www.osgi.org) org.osgi:org.osgi.compendium:jar:5.0.0
+ License: Apache License, Version 2.0
(http://opensource.org/licenses/apache2.0.php)
+
+From: 'The Apache Software Foundation' (http://www.apache.org/)
+ - Apache Commons Codec (http://commons.apache.org/proper/commons-codec/)
commons-codec:commons-codec:jar:1.9
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Apache Commons Logging (http://commons.apache.org/proper/commons-logging/)
commons-logging:commons-logging:jar:1.2
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Commons Exec (http://commons.apache.org/exec/)
org.apache.commons:commons-exec:jar:1.1
+ License: The Apache Software License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Apache Commons Lang (http://commons.apache.org/proper/commons-lang/)
org.apache.commons:commons-lang3:jar:3.4
+ License: Apache License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Apache HttpClient (http://hc.apache.org/httpcomponents-client)
org.apache.httpcomponents:httpclient:jar:4.5
+ License: Apache License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Apache HttpCore (http://hc.apache.org/httpcomponents-core-ga)
org.apache.httpcomponents:httpcore:jar:4.4.1
+ License: Apache License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Apache HttpClient Mime (http://hc.apache.org/httpcomponents-client)
org.apache.httpcomponents:httpmime:jar:4.5
+ License: Apache License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+ - Apache Sling XSS Protection Bundle
(http://sling.apache.org/org.apache.sling.xss)
org.apache.sling:org.apache.sling.xss:bundle:1.0.4
+ License: Apache License, Version 2.0
(http://www.apache.org/licenses/LICENSE-2.0.txt)
+
+From: 'The Apache Software Foundation' (https://www.apache.org/)
+ - Apache Sling API (http://sling.apache.org/org.apache.sling.api)
org.apache.sling:org.apache.sling.api:bundle:2.16.0
+ License: Apache License, Version 2.0
(https://www.apache.org/licenses/LICENSE-2.0.txt)
+ - HApi - Sling Hypermedia API client-side tools
(http://sling.apache.org/org.apache.sling.hapi.client)
org.apache.sling:org.apache.sling.hapi.client:bundle:1.0.0
+ License: Apache License, Version 2.0
(https://www.apache.org/licenses/LICENSE-2.0.txt)
+
+
+
+
Added: release/sling/Jenkinsfile
==============================================================================
--- release/sling/Jenkinsfile (added)
+++ release/sling/Jenkinsfile Thu Apr 9 13:50:42 2020
@@ -0,0 +1,20 @@
+/**
+ * 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.
+ */
+
+slingOsgiBundleBuild()
Added: release/sling/LICENSE
==============================================================================
--- release/sling/LICENSE (added)
+++ release/sling/LICENSE Thu Apr 9 13:50:42 2020
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
Added: release/sling/NOTICE
==============================================================================
--- release/sling/NOTICE (added)
+++ release/sling/NOTICE Thu Apr 9 13:50:42 2020
@@ -0,0 +1,11 @@
+
+Apache Sling Testing Clients
+Copyright 2007-2020 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
Added: release/sling/README.md
==============================================================================
--- release/sling/README.md (added)
+++ release/sling/README.md Thu Apr 9 13:50:42 2020
@@ -0,0 +1,216 @@
+[<img
src="https://sling.apache.org/res/logos/sling.png"/>](https://sling.apache.org)
+
+ [](https://builds.apache.org/job/Sling/job/sling-org-apache-sling-testing-clients/job/master)
[](https://builds.apache.org/job/Sling/job/sling-org-apache-sling-testing-clients/job/master/test_results_analyzer/)
[](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.sling%22%20a%3A%22org.apache.sling.testing.clients%22)
[](https://www.javadoc.io/doc/org.apache.sling/org.apache.sling.testing.clients)
[](https://www.apache.org/licenses/LIC
ENSE-2.0)
[](https://github.com/apache/sling-aggregator/blob/master/docs/groups/testing.md)
+
+# Apache Sling Testing Clients
+
+This module is part of the [Apache Sling](https://sling.apache.org) project.
+
+`SlingClient` is a specialized
+[`HttpClient`](https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/HttpClient.html)
+that provides additional functionalities specific to Sling. It is designed to
be easy to use out of the box, but also fully customizable.
+This library comes with a bunch of other specialized clients (built on top of
`SlingClient`) that are ready to use.
+
+## <a name="architecture"></a> Architecture
+
+`SlingClient` implements the `HttpClient` interface, but
[deletegates](https://en.wikipedia.org/wiki/Delegation_pattern)
+this functionality to a `private final CloseableHttpClient http` field.
+The config is stored in a `private final SlingClientConfig config` field which
is immutable and may be shared across multiple clients
+(more about it in the [How to configure a SlingClient](#config) section).
+These two objects define the state of the client and are built to make the
client thread safe.
+
+`SlingClient` is designed in two layers:
+* The base `class AbstractSlingClient implements HttpClient` provides an
overlay of basic http methods such as `doGet()`,
+ `doPost()` & similar. These are meant to be full replacements of the ones in
`HttpClient` for Sling specific needs,
+ and they add specific customizations. One particularity is that they all
return `SlingHttpResponse`, an augmented `HttpResponse`.
+
+ Still, all the methods from `HttpClient` are exposed (through inheritance
and delegation) in case one needs the raw functionality.
+ Some useful methods to manipulate Sling paths and URLs have also been added
(`getUrl()`, `getPath()`).
+
+ This class encapsulates the mechanisms for extensibility (immutable config
field, delegate client field, package private constructor,
+ `adaptTo()`), but it is defined as abstract and should never be used
directly.
+
+* The main `class SlingClient extends AbstractSlingClient` is the one that
adds Sling specific methods (`createNode()`,
+ `deletePath()` etc.). It has no fields, but makes use of everything that was
defined in the super class.
+ Another main functionality defined in `SlingClient` are the mechanisms to
instantiate a SlingClient (and any other sub-class):
+
+ * constructor: `public SlingClient(URI url, String user, String password)
throws ClientException`
+
+ * builder: `public final static class Builder extends
InternalBuilder<SlingClient>` (more in [How to write a `Builder`](#builder))
+
+Any client you write should extend `SlingClient` (more in [How to extend
`SlingClient`](#extend))
+
+## <a name="instantiate"></a> How to instantiate `SlingClient`
+There are several ways to obtain a SlingClient (and sub-client) instance,
depending on the resources available:
+
+* constructor `SlingClient(URI url, String user, String password)` - handy for
obtaining a simple client from the url:
+ ```java
+ SlingClient c = new SlingClient(URI.create("localhost:8080"), "admin",
"admin");
+ ```
+
+* builder `class Builder<T extends Builder> extends HttpClientBuilder` - this
allows for more complex clients to be created, e.g.
+ with different authentication mechanism, or additional interceptors:
+ ```java
+ SlingClient c = SlingClient.Builder.create("localhost:8080", "admin",
"admin").build();
+ ```
+ This gives the possibility to customize the HttpClient (e.g. add
interceptors, change auth method) before constructing it.
+
+* `public <T extends AbstractSlingClient> T adaptTo(Class<T> clientClass)` is
the convenient method to obtain another specialized
+client form an existing one. The advantage is that the two will share the same
configuration and http handler, so they will behave
+like two different "facets" of the same client (think about the analogy of a
Web browser with multiple tabs).
+
+Although the constructor and the builder are very handy, the preferred way of
working with clients is to obtain it using one of the
+Junit Rules provided (e.g. `ExistingQuickstart`) and then call `adaptTo()`.
+
+## <a name="config"></a> How to configure `SlingClient`
+All the configs specific to `SlingClient` are stored in `private final
SlingClientConfig config` which contains fields such as
+`url`, `cookieStore` and authentication parameters. These fields can be set
only indirectly, through constructor or Builder, and only
+before constructing the client. They cannot be changed, so if you need to
change something, you must instantiate another client.
+
+`SlingClient` was designed to be immutable, so thread safe. You don't have to
worry about synchronizing it when running tests in parallel.
+Also, the immutable config is the base for the `adaptTo()` mechanism, since
the two clients can share the same config.
+
+## <a name="extend"></a> How to extend `SlingClient`
+The `SlingClient` was designed with extensibility in mind. That's why it
provides only basic functionality, leaving other specialized
+clients to implement the rest. To create a new client class (let's call it
`MyClient`), you need to:
+* extend SlingClient: `class MyClient extends SlingClient`
+* implement the two constructors:
+ * the one for simple uses:
+ ```java
+ public MyClient(URI serverUrl, String userName, String password) throws
ClientException {
+ super(serverUrl, userName, password);
+ }
+ ```
+ * the one used by `adaptTo()` (so don't forget it!):
+ ```java
+ public MyClient(CloseableHttpClient http, SlingClientConfig config) throws
ClientException {
+ super(http, config);
+ }
+ ```
+ * optionally create your `Builder`, but only if needed (more in [How to
write a `Builder`](#builder))
+
+A good example of how `SlingClient` can be extended is `OsgiConsoleClient`.
Note you can further extend the sub-clients in the same way.
+
+## <a name="builder"></a> How to write a `Builder`
+If you need to make your client customizable you will have to write your own
Builder (you were no thinking to break the immutability
+by adding a setter, right?). Below is an example of how to create the Builder
mechanism that you can take and adapt for your needs.
+In this case, we try to expose only one field `foo`, but it can be extended to
any number of fields. Although it seems complicated,
+if you follow exactly the example, you cannot fail. Trying to simplify it will
burn you (sooner or later), you have been warned!
+
+A short description of the Builder architecture would be: the
`InternalBuilder` contains all the logic while staying extensible, while
+`Builder` takes all the credit by exposing the `build()` method. Yet, the
`Builder` cannot be extended because all the sub-classes would
+return a `SlingClient` when calling `build()` (and not a subclass instance).
+
+```java
+@Immutable
+public class MyClient extends SlingClient {
+
+ private final String foo;
+
+ public MyClient(URI serverUrl, String user, String password) throws
ClientException {
+ super(serverUrl, user, password);
+ }
+
+ /**
+ * Constructor used by Builders and adaptTo(). <b>Should never be called
directly from the code.</b>
+ *
+ * @see AbstractSlingClient#AbstractSlingClient(CloseableHttpClient,
SlingClientConfig)
+ */
+ public MyClient(CloseableHttpClient http, SlingClientConfig config) throws
ClientException {
+ super(http, config);
+ }
+
+ public static abstract class InternalBuilder<T extends MyClient> extends
SlingClient.InternalBuilder<T> {
+ protected String foo;
+
+ protected InternalBuilder(URI url, String user, String password) {
+ super(url, user, password);
+ }
+
+ public InternalBuilder<T> withFoo(String foo) {
+ this.foo = foo;
+ }
+ }
+
+ public final static class Builder extends InternalBuilder<MyClient> {
+
+ private Builder(URI url, String user, String password) {
+ super(url, user, password);
+ }
+
+ @Override
+ public MyClient build() throws ClientException {
+ MyClient client = new MyClient(buildHttpClient(),
buildSlingClientConfig());
+ client.foo = this.foo;
+ return client;
+ }
+
+ public static Builder create(URI url, String user, String password) {
+ return new Builder(url, user, password);
+ }
+ }
+}
+```
+
+## FAQ
+##### How can I change the server url of an existing client?
+You don't. As described in [How to configure a `SlingClient`](#config), you
have to instantiate another client to change the config.
+
+##### How can I create a client for a server url with context path?
+The server `url` (passed in the constructor or builder) must contain all the
elements, including protocol, hostname, port and eventually
+the context path, e.g.: `http://localhost:8080/mycontextpath/`.
+The url may (or may not) contain the trailing slash. Yet, the client will
always store it with a trailing slash:
+```java
+SlingClient client = new SlingClient("http://localhost:4502/mycontextpath",
"user", "pass");
+System.out.println(client.getUrl());
+// prints http://localhost:4502/mycontextpath/
+```
+
+##### How can I customize the underlying `HttpClient`?
+The `SlingClient.Builder` directly exposes the most useful methods from
`HttpClientBuilder`, but not all of them.
+First, check if you can find it there. If you haven't found your specific
method, then the `Builder` exposes an `HttpClientBuilder` through
+`public HttpClientBuilder httpClientBuilder()` which you can use to config it.
Note that in this case you cannot chain the methods
+to build the client, so you will need to keep a reference to the
`SlingClient.Builder`:
+```java
+SlingClient.Builder builder =
SlingClient.Builder.create("http://localhost:8080", "user", "pass");
+HttpClientBuilder httpBuilder = builder.httpClientBuilder();
+httpBuilder.setProxy(myProxy);
+builder.setUser("another");
+SlingClient client = builder.build();
+```
+
+##### Why is the `Builder` pattern so complicated? Do I really need two
classes?
+Don't try to get creative here. Respect the examples provided and don't take
shortcuts, otherwise you will hurt yourself.
+
+We have tried different ways of designing the Builder. This is the best
compromise between extensibility and simplicity. The
+`HttpClientBuilder` does not offer any extensibility support, so
`SlingClient.Builder` does not extend it, it just uses it internally.
+Always remember that you don't need to create your Builder, unless you want to
add custom fields to the client.
+
+##### Why I cannot use the entity's content InputStream?
+`SlingClient#doRequest()`, `SlingClient#doGet()`, `SlingClient#doPost()` & co.
are all consuming the entity and caching it as
+String. This is by design, since there's a big risk to forget closing the
connections and to run out of sockets quickly.
+If you need the response content as InputStream (e.g. for downloading a
binary), you can use `doStreamGet()` or similar. These
+methods were written specially to not consume the entity so it's the caller's
responsibility to close it when finished. Remember to use
+them with caution and only when needed.
+
+##### Can my client use another authentication method?
+The username and password required by the constructor and builder are there
for convenience (since more than 90% of cases will use
+basic auth). But you can easily overwrite the `CredentialsProvider` in Builder
so those will be ignored. Or do anything you want with
+that `HttpClientBuilder`...
+
+##### How can I obtain the context path?
+`client.getUrl().getPath()`
+
+##### How can I obtain the "relative" url (excluding hostname and port, but
including context path)?
+`client.getUrl(path).getPath()`
+
+##### How can I remove the context path from a path?
+`client.getPath(path)`
+
+##### What if I pass an url or a path with or without context path to
`getUrl()` or `getPath()`?
+We have tried to make these methods as robust as possible. Their job is very
clear:
+* `getUrl(String path)` to transform a Sling path into a full url
+* `getPath(String url)` to transform a full url into a Sling path
+
+Any input that does not respect the contract might not work. Check
`AbstractSlingClientGetPathTest` and `AbstractSlingClientGetUrlTest`
+for an extensive list of cases that we have considered when writing these
methods.
Added: release/sling/pom.xml
==============================================================================
--- release/sling/pom.xml (added)
+++ release/sling/pom.xml Thu Apr 9 13:50:42 2020
@@ -0,0 +1,240 @@
+<?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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>34</version>
+ <relativePath />
+ </parent>
+
+ <artifactId>org.apache.sling.testing.clients</artifactId>
+ <version>2.0.0</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Sling Testing Clients</name>
+ <description>
+ Sling testing http clients and utils
+ </description>
+ <scm>
+
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git</connection>
+
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git</developerConnection>
+
<url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-testing-clients.git</url>
+ <tag>org.apache.sling.testing.clients-2.0.0</tag>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.sling.testing.clients,
+ org.apache.sling.testing.clients.html,
+ org.apache.sling.testing.clients.instance,
+ org.apache.sling.testing.clients.interceptors,
+ org.apache.sling.testing.clients.osgi,
+ org.apache.sling.testing.clients.util,
+ org.apache.sling.testing.clients.util.config,
+ org.apache.sling.testing.clients.util.poller,
+ org.apache.sling.testing.clients.*
+ </Export-Package>
+ <Import-Package>
+ org.apache.commons.exec.*; resolution:=optional,
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.22.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>3.0.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes combine.children="append">
+ <exclude>src/test/resources/**/*.txt</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-exec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>1.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpmime</artifactId>
+ <version>4.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>14.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.xss</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.tinybundles</groupId>
+ <artifactId>tinybundles</artifactId>
+ <version>3.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.hapi.client</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <!-- Used by QueryServlet on server side -->
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.16.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>5.0.0</version>
+ </dependency>
+ <!--
+ The dependency below is a duplicate of org.codehaus.jackson,
+ which was renamed to com.fasterxml.jackson.core. Yet, because of
+ package name changes, we cannot automatically switch because it would
+ cause a major change of the API. The new packages are currently needed
for
+ the query servlet, but everything should be updated at some point.
+ -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>2.9.4</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.9.10.1</version>
+ </dependency>
+
+ <!-- For tests -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-library</artifactId>
+ <version>1.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.3</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: release/sling/src/main/java/org/apache/sling/testing/Constants.java
==============================================================================
--- release/sling/src/main/java/org/apache/sling/testing/Constants.java (added)
+++ release/sling/src/main/java/org/apache/sling/testing/Constants.java Thu Apr
9 13:50:42 2020
@@ -0,0 +1,35 @@
+/*
+ * 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.testing;
+
+public class Constants {
+
+ public static final String DEFAULT_URL = "http://localhost:8080/";
+ public static final String DEFAULT_USERNAME = "admin";
+ public static final String DEFAULT_PASSWORD = "admin";
+
+ /**
+ * Handle to OSGI console
+ */
+ public static final String OSGI_CONSOLE = "/system/console";
+
+ /**
+ * General parameters and values
+ */
+ public static final String PARAMETER_CHARSET = "_charset_";
+ public static final String CHARSET_UTF8 = "utf-8";
+}
Added:
release/sling/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
==============================================================================
---
release/sling/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
(added)
+++
release/sling/src/main/java/org/apache/sling/testing/clients/AbstractSlingClient.java
Thu Apr 9 13:50:42 2020
@@ -0,0 +1,727 @@
+/*
+ * 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.testing.clients;
+
+import org.apache.http.*;
+import org.apache.http.annotation.Immutable;
+import org.apache.http.client.*;
+import org.apache.http.client.methods.*;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.protocol.HttpContext;
+import org.apache.sling.testing.clients.util.HttpUtils;
+import org.slf4j.LoggerFactory;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * The abstract base client for all implementing integration test clients.
+ */
+@Immutable
+public class AbstractSlingClient implements HttpClient, Closeable {
+
+ private final org.slf4j.Logger log = LoggerFactory.getLogger(getClass());
+
+ private final static URI slash = URI.create("/");
+
+ /**
+ * The clientId for the client, generated automatically during
instantiation of client.
+ */
+ private final String clientId;
+
+ /**
+ * The HttpClient object to which http calls are delegated.
+ * It can be shared across multiple AbstractSlingClients (by using
adaptTo())
+ */
+ private final CloseableHttpClient http;
+
+ /**
+ * A wrapper object containing the sling config for this client.
+ * It can be shared across multiple AbstractSlingClients (by using
adaptTo())
+ */
+ private final SlingClientConfig config;
+
+ /**
+ * Constructor used by Builders and adaptTo(). <b>Should never be called
directly from the code.</b>
+ *
+ * @param http http client to handle the delegated calls
+ * @param config immutable object holding the config
+ * @throws ClientException if the client could not be initialized
+ */
+ AbstractSlingClient(CloseableHttpClient http, SlingClientConfig config)
throws ClientException {
+ // Generate client ID
+ this.clientId = this.getClass() + "-" + UUID.randomUUID().toString();
+ this.http = http;
+ this.config = config;
+ }
+
+ /**
+ * Returns the unique id for this client, generated automatically during
instantiation.<br>
+ *
+ * @return client's unique id
+ */
+ protected String getClientId() {
+ return clientId;
+ }
+
+ /**
+ * <p>Base HTTP URI of the server under test. It includes the context
path, if present, and always ends with a slash</p>
+ * <p>Example: {@code http://localhost:8080/a/}</p>
+ *
+ * @return the server's URL
+ */
+ public URI getUrl() {
+ return config.getUrl();
+ }
+
+
+ /**
+ * Returns the name of the user that will be used to authenticate the
requests (by basic auth, if not replaced).
+ *
+ * @return user's name
+ */
+ public String getUser() {
+ return config.getUser();
+ }
+
+ /**
+ * Returns the password of the user that will be used to authenticate the
requests (by basic auth, if not replaced).
+ *
+ * @return user's password
+ */
+ public String getPassword() {
+ return config.getPassword();
+ }
+
+ /**
+ * <p>Gets the full URL for a given path.</p>
+ *
+ * <p>The input path is considered relative to server url path ("/" or
context path), even though it starts with a slash.
+ * The path is relativized and appended to the {@code server url}.</p>
+ *
+ * <p>Note: in the case of a server url with context path - the input path
should not contain the context path, otherwise
+ * it will be duplicated in the resulting url</p>
+ *
+ * @param path the relative path
+ * @return the absolute URI
+ * @throws IllegalArgumentException if path cannot be parsed into an URI
+ * @throws NullPointerException if path is null
+ */
+ public URI getUrl(String path) {
+ try {
+ URI pathUri = new URI(null, null, path, null);
+ URI relative = slash.relativize(pathUri);
+ return getUrl().resolve(relative);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * Creates a full URL for a given path with additional parameters. Same as
{@link #getUrl(String)}, but adds the parameters in the URI.
+ *
+ * @param path path relative to server url; can start with / but should
not include the server context path
+ * @param parameters url parameters to be added to the url. If the given
argument is {@code null}, nothing will be added to the url.
+ * If the given argument is an empty array, it will
force a "?" at the end of the url.
+ * @return full url as URI
+ * @throws IllegalArgumentException if path or parameters cannot be parsed
into an URI
+ * @throws NullPointerException if path is null
+ */
+ public URI getUrl(String path, List<NameValuePair> parameters) {
+ // add server url and path
+ URIBuilder uriBuilder = new URIBuilder(getUrl(path));
+ // add parameters
+ if (parameters != null) {
+ uriBuilder.addParameters(parameters);
+ }
+
+ try {
+ return uriBuilder.build();
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * <p>Transforms an external {@code url} into a sling path, by subtracting
the {@code server url} (incl. contextPath).
+ * The returned path will not contain the context path, so it can be used
with {@link #getUrl(String)}</p>
+ *
+ * <p>The url can be absolute (incl. hostname) or relative to root (starts
with "/").</p>
+ *
+ * <p>If the server url is not a prefix of the given url, it returns the
given url</p>
+ *
+ * <p>If the url is just a path, it returns the path (with leading slash
if not already present)</p>
+ *
+ * @param url full url
+ * @return sling path
+ */
+ public URI getPath(URI url) {
+ // special case for urls that are server urls, but without trailing
slash
+ if (url.relativize(getUrl()).equals(URI.create(""))) {
+ return slash;
+ }
+
+ URI contextPath = URI.create(getUrl().getPath());
+ URI relativeUrl = contextPath.relativize(slash.resolve(url));
+
+ if (relativeUrl.relativize(contextPath).equals(URI.create(""))) {
+ return slash;
+ }
+
+ return slash.resolve(getUrl().relativize(relativeUrl));
+ }
+
+ /**
+ * Extracts the relative sling path (to server url) from an url. Identical
to {@link AbstractSlingClient#getPath(URI)},
+ * except that it also parses the String int URI
+ *
+ * @param url string containing the full url
+ * @return relative path as URI
+ * @throws IllegalArgumentException if the parameter cannot be parsed
+ * @throws NullPointerException if url is null
+ */
+ public URI getPath(String url) {
+ try {
+ return getPath(new URI(url));
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ /**
+ * <p>Returns an instance of any class extending the AbstractSlingClient.
The new client will
+ * use the the same {@link HttpClient} and {@link SlingClientConfig} </p>
+ *
+ * @param clientClass the type of client requested, identified by its Class
+ * @param <T> any class extending the AbstractSlingClient
+ * @return instance of a class extending the AbstractSlingClient
+ * @throws ClientException if client can't be instantiated
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends AbstractSlingClient> T adaptTo(Class<T> clientClass)
throws ClientException {
+ T client;
+ try {
+ Constructor cons =
clientClass.getConstructor(CloseableHttpClient.class, SlingClientConfig.class);
+ client = (T) cons.newInstance(this.http, this.config);
+ } catch (Exception e) {
+ throw new ClientException("Could not initialize client: '" +
clientClass.getCanonicalName() + "'.", e);
+ }
+ return client;
+ }
+
+ /**
+ * Gets the value for {@code key} from the generic values
+ *
+ * @param key the key
+ * @return the value
+ */
+ public String getValue(String key) {
+ return this.config.getValues().get(key);
+ }
+
+ /**
+ * Adds the extra {@code key, value} to the generic values
+ *
+ * @param key the key for witch to add a value
+ * @param value the value
+ */
+ public void addValue(String key, String value) {
+ this.config.getValues().put(key, value);
+ }
+
+ /**
+ * Checks whether the handler has the given generic value
+ *
+ * @param key the key
+ * @return true if the value was found
+ */
+ public boolean hasValue(String key) {
+ return config.getValues().containsKey(key);
+ }
+
+ /**
+ * Returns the extra values map
+ *
+ * @return the map of values
+ */
+ public Map<String, String> getValues() {
+ return config.getValues();
+ }
+
+ /**
+ * @return the cookie store reference
+ */
+ public CookieStore getCookieStore() {
+ return config.getCookieStore();
+ }
+
+ /**
+ * @return the credentials provider
+ */
+ public CredentialsProvider getCredentialsProvider() {
+ return config.getCredsProvider();
+ }
+
+ //
+ // HTTP convenience methods
+ //
+
+ /**
+ * <p>Executes an HTTP request, WITHOUT consuming the entity in the
response. The caller is responsible for consuming the entity or
+ * closing the response's InputStream in order to release the connection.
+ * Otherwise, the client might run out of connections and will block</p>
+ *
+ * <p><b>Use this with caution and only if necessary for streaming</b>,
otherwise use the safe method
+ * {@link #doRequest(HttpUriRequest, List, int...)}</p>
+ *
+ * <p>Adds the headers and checks the response against expected status</p>
+ *
+ * @param request the request to be executed
+ * @param headers optional headers to be added to the request
+ * @param expectedStatus if passed, the response status is checked against
it/them, and has to match at least one of them
+ * @return the response, with the entity not consumed
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doStreamRequest(HttpUriRequest request,
List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ // create context from config
+ HttpClientContext context = createHttpClientContextFromConfig();
+
+ // add headers
+ if (headers != null) {
+ request.setHeaders(headers.toArray(new Header[headers.size()]));
+ }
+
+ try {
+ log.debug("request {} {}", request.getMethod(), request.getURI());
+ SlingHttpResponse response = new
SlingHttpResponse(this.execute(request, context));
+ log.debug("response {}", HttpUtils.getHttpStatus(response));
+ // Check the status and throw a ClientException if it doesn't
match expectedStatus, but close the entity before
+ if (expectedStatus != null && expectedStatus.length > 0) {
+ try {
+ HttpUtils.verifyHttpStatus(response, expectedStatus);
+ } catch (ClientException e) {
+ // catch the exception to make sure we close the entity
before re-throwing it
+ response.close();
+ throw e;
+ }
+ }
+
+ return response;
+ } catch (IOException e) {
+ throw new ClientException("Could not execute http request", e);
+ }
+ }
+
+ /**
+ * <p>Executes a raw HTTP request, WITHOUT consuming the entity in the
response. The caller is responsible for consuming the entity or
+ * closing the response's InputStream in order to release the connection.
+ * Otherwise, the client might run out of connections and will block</p>
+ *
+ * <p><b>Use this with caution and only if necessary for custom methods or
for paths that must not be encoded</b>,
+ * otherwise use the safe method {@link #doRequest(HttpUriRequest, List,
int...)}</p>
+ *
+ * <p>It behaves as {@link #doStreamRequest(HttpUriRequest, List,
int...)}, so the entity is not consumed.</p>
+ * <p>Adds the headers and checks the response against expected status</p>
+ *
+ * @param method the request to be executed
+ * @param uri the uri to be sent as it is (will not prepend the context
path)
+ * @param headers optional headers to be added to the request
+ * @param expectedStatus if passed, the response status is checked against
it/them, and has to match at least one of them
+ * @return the response, with the entity not consumed
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doRawRequest(String method, String uri,
List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ // create context from config
+ HttpClientContext context = createHttpClientContextFromConfig();
+
+ HttpHost host = new HttpHost(getUrl().getHost(), getUrl().getPort(),
getUrl().getScheme());
+ HttpRequest request = new BasicHttpRequest(method, uri);
+
+ // add headers
+ if (headers != null) {
+ request.setHeaders(headers.toArray(new Header[headers.size()]));
+ }
+
+ try {
+ log.debug("request {} {}", method, uri);
+ SlingHttpResponse response = new
SlingHttpResponse(this.execute(host, request, context));
+ log.debug("response {}", HttpUtils.getHttpStatus(response));
+ // Check the status and throw a ClientException if it doesn't
match expectedStatus, but close the entity before
+ if (expectedStatus != null && expectedStatus.length > 0) {
+ try {
+ HttpUtils.verifyHttpStatus(response, expectedStatus);
+ } catch (ClientException e) {
+ // catch the exception to make sure we close the entity
before re-throwing it
+ response.close();
+ throw e;
+ }
+ }
+
+ return response;
+ } catch (IOException e) {
+ throw new ClientException("Could not execute http request", e);
+ }
+ }
+
+ private HttpClientContext createHttpClientContextFromConfig() {
+ // create context from config
+ HttpClientContext context = HttpClientContext.create();
+
+ if (config.getCookieStore() != null) {
+ context.setCookieStore(config.getCookieStore());
+ }
+
+ if (config.getCredsProvider() != null) {
+ context.setCredentialsProvider(config.getCredsProvider());
+ }
+
+ if (config.getAuthCache() != null) {
+ context.setAuthCache(config.getAuthCache());
+ }
+
+ return context;
+ }
+
+ /**
+ * <p>Executes a GET request WITHOUT consuming the entity in the response.
The caller is responsible to close the connection.
+ * Otherwise, the client might run out of connections and will block</p>
+ *
+ * <p><b>Use this with caution and only if necessary for streaming</b>,
otherwise use the safe method
+ * {@link #doGet(String, List, List, int...)}</p>
+ *
+ * <p>Adds the given parameters and headers and checks the response
against expected status</p>
+ * @param requestPath path relative to client url
+ * @param parameters optional url parameters to be added
+ * @param headers optional headers to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity not consumed
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doStreamGet(String requestPath,
List<NameValuePair> parameters, List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ // create full uri, including server url, given path and given
parameters
+ URI uri = getUrl(requestPath, parameters);
+ // execute request
+ HttpUriRequest request = new HttpGet(uri);
+ return doStreamRequest(request, headers, expectedStatus);
+ }
+
+ /**
+ * <p>Executes a POST request WITHOUT consuming the entity in the
response. The caller is responsible to close the connection</p>
+ *
+ * <p><b>Use this with caution and only if necessary for streaming</b>,
otherwise use the safe method
+ * {@link #doPost(String, HttpEntity, List, int...)}</p>
+ *
+ * <p>Adds the headers and checks the response against expected status</p>
+ * @param requestPath path relative to client url
+ * @param entity http entity to be sent by POST
+ * @param headers optional headers to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity not consumed
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doStreamPost(String requestPath, HttpEntity
entity, List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ HttpEntityEnclosingRequestBase request = new
HttpPost(getUrl(requestPath));
+ if (entity != null) {
+ request.setEntity(entity);
+ }
+ return doStreamRequest(request, headers, expectedStatus);
+ }
+
+ /**
+ * <p>Execute an HTTP request and consumes the entity in the response. The
content is cached and can be retrieved using
+ * {@code response.getContent()}.
+ * This method is safe to use because it closes the entity so the caller
has no responsibility.</p>
+ *
+ * <p>This means the response entity SHOULD NOT BE USED to read the
content, e.g. {@code response.getEntity().getContent()}</p>
+ *
+ * @param request the request to be executed
+ * @param headers optional headers to be added to the request
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed and the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doRequest(HttpUriRequest request, List<Header>
headers, int... expectedStatus) throws ClientException {
+ SlingHttpResponse response = doStreamRequest(request, headers,
expectedStatus);
+
+ // Consume entity and cache the content so the connection is closed
+ response.getContent();
+
+ return response;
+ }
+
+ /**
+ * <p>Executes a GET request and consumes the entity in the response (so
the connection is closed immediately)
+ * The content is cached and can be retrieved using {@code
response.getContent()}.</p>
+ *
+ * <p>Adds the passed parameters and headers and checks the expected
status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param parameters optional url parameters to be added
+ * @param headers optional headers to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed amd the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doGet(String requestPath, List<NameValuePair>
parameters, List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ SlingHttpResponse response = doStreamGet(requestPath, parameters,
headers, expectedStatus);
+
+ // Consume entity and cache the content so the connection is closed
+ response.getContent();
+
+ return response;
+ }
+
+ /**
+ * <p>Executes a GET request and consumes the entity in the response (so
the connection is closed immediately)
+ * The content is cached and can be retrieved using {@code
response.getContent()}.</p>
+ *
+ * <p>Adds the passed parameters and checks the expected status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param parameters optional url parameters to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed amd the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doGet(String requestPath, List<NameValuePair>
parameters, int... expectedStatus)
+ throws ClientException {
+ return doGet(requestPath, parameters, null, expectedStatus);
+ }
+
+ /**
+ * <p>Executes a GET request and consumes the entity in the response (so
the connection is closed immediately)
+ * The content is cached and can be retrieved using {@code
response.getContent()}.</p>
+ *
+ * @param requestPath path relative to client url
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed amd the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doGet(String requestPath, int... expectedStatus)
+ throws ClientException {
+ return doGet(requestPath, null, null, expectedStatus);
+ }
+
+ /**
+ * <p>Executes a HEAD request</p>
+ *
+ * <p>Adds the passed parameters and headers and checks the expected
status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param parameters optional url parameters to be added
+ * @param headers optional headers to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doHead(String requestPath, List<NameValuePair>
parameters, List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ HttpUriRequest request = new HttpHead(getUrl(requestPath, parameters));
+ return doRequest(request, headers, expectedStatus);
+ }
+
+
+ /**
+ * <p>Executes a POST request and consumes the entity in the response. The
content is cached and be retrieved by calling
+ * {@code response.getContent()}</p>
+ *
+ * <p>Adds the passed entity and headers and checks the expected status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param entity the entity to be added to request
+ * @param headers optional headers to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed and the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doPost(String requestPath, HttpEntity entity,
List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ HttpEntityEnclosingRequestBase request = new
HttpPost(getUrl(requestPath));
+ if (entity != null) {
+ request.setEntity(entity);
+ }
+ return doRequest(request, headers, expectedStatus);
+ }
+
+ /**
+ * <p>Executes a POST request and consumes the entity in the response. The
content is cached and be retrieved by calling
+ * {@code response.getContent()}</p>
+ *
+ * <p>Adds the passed entity and checks the expected status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param entity the entity to be added to request
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed and the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doPost(String requestPath, HttpEntity entity,
int... expectedStatus)
+ throws ClientException {
+ return doPost(requestPath, entity, null, expectedStatus);
+ }
+
+ /**
+ * <p>Executes a PUT request and consumes the entity in the response. The
content is cached and be retrieved by calling
+ * {@code response.getContent()}</p>
+ *
+ * <p>Adds the passed entity and headers and checks the expected status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param entity the entity to be added to request
+ * @param headers optional url parameters to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed and the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doPut(String requestPath, HttpEntity entity,
List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ HttpEntityEnclosingRequestBase request = new
HttpPut(getUrl(requestPath));
+ if (entity != null) {
+ request.setEntity(entity);
+ }
+ return doRequest(request, headers, expectedStatus);
+ }
+
+ /**
+ * <p>Executes a PATCH request and consumes the entity in the response.
The content is cached and be retrieved by calling
+ * {@code response.getContent()}</p>
+ *
+ * <p>Adds the passed entity and headers and checks the expected status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param entity the entity to be added to request
+ * @param headers optional url parameters to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed and the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doPatch(String requestPath, HttpEntity entity,
List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ HttpEntityEnclosingRequestBase request = new
HttpPatch(getUrl(requestPath));
+ if (entity != null) {
+ request.setEntity(entity);
+ }
+ return doRequest(request, headers, expectedStatus);
+ }
+
+ /**
+ * <p>Executes a DELETE request and consumes the entity in the response.
The content is cached and be retrieved by calling
+ * {@code response.getContent()}</p>
+ *
+ * <p>Adds the passed parameters and headers and checks the expected
status</p>
+ *
+ * @param requestPath path relative to client url
+ * @param parameters optional url parameters to be added
+ * @param headers optional url parameters to be added
+ * @param expectedStatus if passed, the response status will have to match
one of them
+ * @return the response with the entity consumed and the content cached
+ * @throws ClientException if the request could not be executed
+ */
+ public SlingHttpResponse doDelete(String requestPath, List<NameValuePair>
parameters, List<Header> headers, int... expectedStatus)
+ throws ClientException {
+ HttpUriRequest request = new HttpDelete(getUrl(requestPath,
parameters));
+ return doRequest(request, headers, expectedStatus);
+ }
+
+ @Override
+ /**
+ * <p>Closes the http client and makes sure all the underlying resources,
like the connection manager, shut down </p>
+ *
+ */
+ public void close() throws IOException {
+ this.http.close();
+ }
+
+
+ //
+ // HttpClient base methods
+ //
+
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ public org.apache.http.params.HttpParams getParams() {
+ return this.http.getParams();
+ }
+
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ public org.apache.http.conn.ClientConnectionManager getConnectionManager()
{
+ return this.http.getConnectionManager();
+ }
+
+ @SuppressWarnings("DuplicateThrows")
+ public HttpResponse execute(HttpUriRequest request) throws IOException,
ClientProtocolException {
+ return this.http.execute(request);
+ }
+
+ // maybe throw UnsupportedMethodException
+ @SuppressWarnings("DuplicateThrows")
+ public CloseableHttpResponse execute(HttpUriRequest request, HttpContext
context)
+ throws IOException, ClientProtocolException {
+ return this.http.execute(request, context);
+ }
+
+ @SuppressWarnings("DuplicateThrows")
+ public HttpResponse execute(HttpHost target, HttpRequest request)
+ throws IOException, ClientProtocolException {
+ return this.http.execute(target, request);
+ }
+
+ @SuppressWarnings("DuplicateThrows")
+ public CloseableHttpResponse execute(HttpHost target, HttpRequest request,
HttpContext context)
+ throws IOException, ClientProtocolException {
+ return this.http.execute(target, request, context);
+ }
+
+ @SuppressWarnings("DuplicateThrows")
+ public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T>
responseHandler)
+ throws IOException, ClientProtocolException {
+ return this.http.execute(request, responseHandler);
+ }
+
+ @SuppressWarnings("DuplicateThrows")
+ public <T> T execute(HttpUriRequest request, ResponseHandler<? extends T>
responseHandler, HttpContext context)
+ throws IOException, ClientProtocolException {
+ return this.http.execute(request, responseHandler, context);
+ }
+
+ @SuppressWarnings("DuplicateThrows")
+ public <T> T execute(HttpHost target, HttpRequest request,
ResponseHandler<? extends T> responseHandler)
+ throws IOException, ClientProtocolException {
+ return this.http.execute(target, request, responseHandler);
+ }
+
+ @SuppressWarnings("DuplicateThrows")
+ public <T> T execute(HttpHost target, HttpRequest request,
ResponseHandler<? extends T> responseHandler, HttpContext context)
+ throws IOException, ClientProtocolException {
+ return this.http.execute(target, request, responseHandler, context);
+ }
+}