This is an automated email from the ASF dual-hosted git repository.
dulvac pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git
The following commit(s) were added to refs/heads/master by this push:
new 710b365 SLING-12309 upgrade dependencies
710b365 is described below
commit 710b365cba888753badfdb2195c8da4f28d839d3
Author: dulvac <[email protected]>
AuthorDate: Tue Apr 30 15:45:47 2024 +0200
SLING-12309 upgrade dependencies
---
pom.xml | 102 ++++++++++++++-------
.../apache/sling/hapi/client/ClientException.java | 18 ++--
.../org/apache/sling/hapi/client/Document.java | 18 ++--
.../org/apache/sling/hapi/client/HtmlClient.java | 21 ++---
.../sling/hapi/client/HtmlClientService.java | 20 ++--
.../java/org/apache/sling/hapi/client/Item.java | 20 +++-
.../java/org/apache/sling/hapi/client/Items.java | 18 ++++
.../hapi/client/forms/internal/FormValues.java | 19 ++--
.../sling/hapi/client/forms/internal/Vals.java | 22 ++---
.../hapi/client/impl/AbstractHtmlClientImpl.java | 60 +++++++-----
.../hapi/client/impl/HtmlClientServiceImpl.java | 26 +++---
.../client/impl/microdata/MicrodataDocument.java | 37 +++-----
.../client/impl/microdata/MicrodataHtmlClient.java | 22 ++---
.../org/apache/sling/hapi/client/package-info.java | 1 -
.../apache/sling/hapi/client/test/FormTest.java | 72 ++++++++-------
.../apache/sling/hapi/client/test/GetPostTest.java | 82 +++++++++--------
.../apache/sling/hapi/client/test/ItemsTest.java | 65 ++++++-------
.../hapi/client/test/util/HttpServerRule.java | 47 +++++-----
18 files changed, 375 insertions(+), 295 deletions(-)
diff --git a/pom.xml b/pom.xml
index 59a63c3..bbce80b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,59 +17,39 @@
~ 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">
+<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>
<parent>
<groupId>org.apache.sling</groupId>
- <artifactId>sling</artifactId>
- <version>30</version>
- <relativePath />
+ <artifactId>sling-bundle-parent</artifactId>
+ <version>49</version>
+ <relativePath/>
</parent>
<artifactId>org.apache.sling.hapi.client</artifactId>
- <version>1.0.1-SNAPSHOT</version>
- <packaging>bundle</packaging>
+ <version>1.0.2-SNAPSHOT</version>
<name>Apache Sling Hypermedia API client-side tools</name>
<description>Sling client-side tools for HApi</description>
<scm>
<connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git</connection>
-
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git</developerConnection>
+
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git
+ </developerConnection>
<url>https://github.com/apache/sling-org-apache-sling-hapi-client.git</url>
</scm>
<properties>
- <sling.java.version>6</sling.java.version>
+ <sling.java.version>8</sling.java.version>
</properties>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.sling</groupId>
- <artifactId>maven-sling-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Category>sling</Bundle-Category>
-
<Sling-Initial-Content>SLING-INF;overwrite=true</Sling-Initial-Content>
- <Embed-Dependency>groupId=org.jsoup</Embed-Dependency>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.5.1</version>
+ <version>4.5.13</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -87,33 +67,89 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
- <version>2.5</version>
+ <version>2.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
- <version>1.9.2</version>
+ <version>1.15.3</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
+ <version>1.7.36</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
</dependency>
<!-- test scope -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
- <version>4.5.1</version>
+ <version>4.5.13</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
+ <version>1.7.36</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <version>4.13.1</version>
+ <scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>bnd-process</id>
+ <goals>
+ <goal>bnd-process</goal>
+ </goals>
+ <configuration>
+ <bnd><![CDATA[
+Import-Package: javax.annotation;version=0.0.0,*
+-conditionalpackage: org.jsoup.*
+-includeresource: @jsoup-*.jar!/
+ ]]></bnd>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/src/main/java/org/apache/sling/hapi/client/ClientException.java
b/src/main/java/org/apache/sling/hapi/client/ClientException.java
index 9bda81e..97db159 100644
--- a/src/main/java/org/apache/sling/hapi/client/ClientException.java
+++ b/src/main/java/org/apache/sling/hapi/client/ClientException.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client;
/**
diff --git a/src/main/java/org/apache/sling/hapi/client/Document.java
b/src/main/java/org/apache/sling/hapi/client/Document.java
index 3da16ba..e7da441 100644
--- a/src/main/java/org/apache/sling/hapi/client/Document.java
+++ b/src/main/java/org/apache/sling/hapi/client/Document.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client;
/**
diff --git a/src/main/java/org/apache/sling/hapi/client/HtmlClient.java
b/src/main/java/org/apache/sling/hapi/client/HtmlClient.java
index 078f46b..50f0120 100644
--- a/src/main/java/org/apache/sling/hapi/client/HtmlClient.java
+++ b/src/main/java/org/apache/sling/hapi/client/HtmlClient.java
@@ -1,22 +1,21 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
-
+ */
package org.apache.sling.hapi.client;
import org.apache.http.HttpEntity;
@@ -41,7 +40,6 @@ public interface HtmlClient {
*/
<T extends Document> T get(String url) throws ClientException;
-
/**
* Performs a POST request.
*
@@ -68,5 +66,4 @@ public interface HtmlClient {
* @return
*/
<T extends Document> T newDocument(String html);
-
}
diff --git a/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
b/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
index fa39f28..b7326a5 100644
--- a/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
+++ b/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client;
import org.apache.http.impl.client.CloseableHttpClient;
@@ -46,4 +46,4 @@ public interface HtmlClientService {
* @return
*/
HtmlClient getClient(String baseUrl, String user, String password);
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/Item.java
b/src/main/java/org/apache/sling/hapi/client/Item.java
index 8eba400..3b8e34f 100644
--- a/src/main/java/org/apache/sling/hapi/client/Item.java
+++ b/src/main/java/org/apache/sling/hapi/client/Item.java
@@ -1,3 +1,21 @@
+/*
+ * 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.hapi.client;
/*******************************************************************************
@@ -18,9 +36,9 @@ package org.apache.sling.hapi.client;
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
+import java.util.Set;
import org.apache.http.NameValuePair;
-import java.util.Set;
/**
* An HTML item representation. This maps to an html element and contains all
the child elements.
diff --git a/src/main/java/org/apache/sling/hapi/client/Items.java
b/src/main/java/org/apache/sling/hapi/client/Items.java
index 4ccbc4d..3adce2f 100644
--- a/src/main/java/org/apache/sling/hapi/client/Items.java
+++ b/src/main/java/org/apache/sling/hapi/client/Items.java
@@ -1,3 +1,21 @@
+/*
+ * 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.hapi.client;
/*******************************************************************************
diff --git
a/src/main/java/org/apache/sling/hapi/client/forms/internal/FormValues.java
b/src/main/java/org/apache/sling/hapi/client/forms/internal/FormValues.java
index 4d894c5..ef64516 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/internal/FormValues.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/internal/FormValues.java
@@ -1,22 +1,21 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
-
+ */
package org.apache.sling.hapi.client.forms.internal;
import java.io.UnsupportedEncodingException;
diff --git
a/src/main/java/org/apache/sling/hapi/client/forms/internal/Vals.java
b/src/main/java/org/apache/sling/hapi/client/forms/internal/Vals.java
index adff0a8..5a58d4d 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/internal/Vals.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/internal/Vals.java
@@ -1,30 +1,30 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client.forms.internal;
-import org.apache.http.NameValuePair;
-
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.apache.http.NameValuePair;
+
public class Vals {
private Map<String, List<NameValuePair>> data = new LinkedHashMap<String,
List<NameValuePair>>();
diff --git
a/src/main/java/org/apache/sling/hapi/client/impl/AbstractHtmlClientImpl.java
b/src/main/java/org/apache/sling/hapi/client/impl/AbstractHtmlClientImpl.java
index 5c3444a..923de0a 100644
---
a/src/main/java/org/apache/sling/hapi/client/impl/AbstractHtmlClientImpl.java
+++
b/src/main/java/org/apache/sling/hapi/client/impl/AbstractHtmlClientImpl.java
@@ -1,23 +1,27 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client.impl;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
@@ -46,10 +50,6 @@ import org.apache.sling.hapi.client.HtmlClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
public abstract class AbstractHtmlClientImpl implements HttpClient, HtmlClient
{
protected static final Logger LOG =
LoggerFactory.getLogger(AbstractHtmlClientImpl.class);
protected CloseableHttpClient client;
@@ -61,7 +61,11 @@ public abstract class AbstractHtmlClientImpl implements
HttpClient, HtmlClient {
}
public AbstractHtmlClientImpl(String baseUrl) throws URISyntaxException {
- this(HttpClientBuilder.create().setRedirectStrategy(new
LaxRedirectStrategy()).build(), baseUrl);
+ this(
+ HttpClientBuilder.create()
+ .setRedirectStrategy(new LaxRedirectStrategy())
+ .build(),
+ baseUrl);
}
public AbstractHtmlClientImpl(String baseUrl, String user, String
password) throws URISyntaxException {
@@ -77,7 +81,6 @@ public abstract class AbstractHtmlClientImpl implements
HttpClient, HtmlClient {
.build();
}
-
@Override
public <T extends Document> T enter(String url) throws ClientException {
return get(url);
@@ -131,15 +134,14 @@ public abstract class AbstractHtmlClientImpl implements
HttpClient, HtmlClient {
@Override
public abstract <T extends Document> T newDocument(String html);
-
private URI absoluteUri(String url) throws URISyntaxException {
URI getUrl = new URI(url);
return this.baseUrl.resolve(getUrl);
}
/*
- Overrides of HttpClient methods
- */
+ Overrides of HttpClient methods
+ */
@Override
public HttpParams getParams() {
return client.getParams();
@@ -156,37 +158,49 @@ public abstract class AbstractHtmlClientImpl implements
HttpClient, HtmlClient {
}
@Override
- public HttpResponse execute(HttpUriRequest httpUriRequest, HttpContext
httpContext) throws IOException, ClientProtocolException {
+ public HttpResponse execute(HttpUriRequest httpUriRequest, HttpContext
httpContext)
+ throws IOException, ClientProtocolException {
return client.execute(httpUriRequest, httpContext);
}
@Override
- public HttpResponse execute(HttpHost httpHost, HttpRequest httpRequest)
throws IOException, ClientProtocolException {
+ public HttpResponse execute(HttpHost httpHost, HttpRequest httpRequest)
+ throws IOException, ClientProtocolException {
return client.execute(httpHost, httpRequest);
}
@Override
- public HttpResponse execute(HttpHost httpHost, HttpRequest httpRequest,
HttpContext httpContext) throws IOException, ClientProtocolException {
+ public HttpResponse execute(HttpHost httpHost, HttpRequest httpRequest,
HttpContext httpContext)
+ throws IOException, ClientProtocolException {
return client.execute(httpHost, httpRequest, httpContext);
}
@Override
- public <T> T execute(HttpUriRequest httpUriRequest, ResponseHandler<?
extends T> responseHandler) throws IOException, ClientProtocolException {
+ public <T> T execute(HttpUriRequest httpUriRequest, ResponseHandler<?
extends T> responseHandler)
+ throws IOException, ClientProtocolException {
return client.execute(httpUriRequest, responseHandler);
}
@Override
- public <T> T execute(HttpUriRequest httpUriRequest, ResponseHandler<?
extends T> responseHandler, HttpContext httpContext) throws IOException,
ClientProtocolException {
+ public <T> T execute(
+ HttpUriRequest httpUriRequest, ResponseHandler<? extends T>
responseHandler, HttpContext httpContext)
+ throws IOException, ClientProtocolException {
return client.execute(httpUriRequest, responseHandler, httpContext);
}
@Override
- public <T> T execute(HttpHost httpHost, HttpRequest httpRequest,
ResponseHandler<? extends T> responseHandler) throws IOException,
ClientProtocolException {
+ public <T> T execute(HttpHost httpHost, HttpRequest httpRequest,
ResponseHandler<? extends T> responseHandler)
+ throws IOException, ClientProtocolException {
return client.execute(httpHost, httpRequest, responseHandler);
}
@Override
- public <T> T execute(HttpHost httpHost, HttpRequest httpRequest,
ResponseHandler<? extends T> responseHandler, HttpContext httpContext) throws
IOException, ClientProtocolException {
+ public <T> T execute(
+ HttpHost httpHost,
+ HttpRequest httpRequest,
+ ResponseHandler<? extends T> responseHandler,
+ HttpContext httpContext)
+ throws IOException, ClientProtocolException {
return client.execute(httpHost, httpRequest, responseHandler,
httpContext);
}
}
diff --git
a/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
b/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
index d3f6f4b..5e9d26a 100644
--- a/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
+++ b/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
@@ -1,23 +1,25 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p/>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p/>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client.impl;
+import java.net.URISyntaxException;
+
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.sling.hapi.client.HtmlClient;
import org.apache.sling.hapi.client.HtmlClientService;
@@ -26,11 +28,7 @@ import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.net.URISyntaxException;
-
-@Component(
- service = HtmlClientService.class
-)
+@Component(service = HtmlClientService.class)
public class HtmlClientServiceImpl implements HtmlClientService {
private final Logger LOG =
LoggerFactory.getLogger(HtmlClientService.class);
diff --git
a/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java
b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java
index c60ca97..25d2082 100644
---
a/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java
+++
b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java
@@ -1,24 +1,27 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
-
+ */
package org.apache.sling.hapi.client.impl.microdata;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.*;
+
import org.apache.http.NameValuePair;
import org.apache.sling.hapi.client.*;
import org.apache.sling.hapi.client.forms.internal.FormValues;
@@ -26,10 +29,6 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-
public class MicrodataDocument implements Document {
private org.jsoup.nodes.Document jsoupDocument;
private HtmlClient client;
@@ -39,7 +38,6 @@ public class MicrodataDocument implements Document {
this.client = client;
}
-
@Override
public Items link(String rel) throws ClientException {
Item me = toItem(jsoupDocument);
@@ -106,7 +104,6 @@ public class MicrodataDocument implements Document {
return items;
}
-
private class ItemImpl implements Item {
private Element el;
@@ -153,7 +150,6 @@ public class MicrodataDocument implements Document {
return new ItemsImpl(toItems(getProxy().el.select(selector)));
}
-
/* Private methods */
private List<Item> selectProps(Element e, String name, List<Item>
items) {
@@ -181,7 +177,7 @@ public class MicrodataDocument implements Document {
}
if (c.hasAttr("itemscope")) {
- continue;
+ continue;
}
selectAllPropNames(c, items);
@@ -323,8 +319,6 @@ public class MicrodataDocument implements Document {
throw new ClientException("The item is not a form");
}
-
-
}
/**
@@ -417,5 +411,4 @@ public class MicrodataDocument implements Document {
return items.get(0).submit(values);
}
}
-
-}
\ No newline at end of file
+}
diff --git
a/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java
b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java
index c09eb3e..31171a9 100644
---
a/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java
+++
b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java
@@ -1,28 +1,28 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client.impl.microdata;
+import java.net.URISyntaxException;
+
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl;
-import java.net.URISyntaxException;
-
public class MicrodataHtmlClient extends AbstractHtmlClientImpl {
public MicrodataHtmlClient(CloseableHttpClient client, String baseUrl)
throws URISyntaxException {
diff --git a/src/main/java/org/apache/sling/hapi/client/package-info.java
b/src/main/java/org/apache/sling/hapi/client/package-info.java
index c22d105..61b61a9 100644
--- a/src/main/java/org/apache/sling/hapi/client/package-info.java
+++ b/src/main/java/org/apache/sling/hapi/client/package-info.java
@@ -16,6 +16,5 @@
* specific language governing permissions and limitations
* under the License.
******************************************************************************/
-
@org.osgi.annotation.versioning.Version("1.0.0")
package org.apache.sling.hapi.client;
diff --git a/src/test/java/org/apache/sling/hapi/client/test/FormTest.java
b/src/test/java/org/apache/sling/hapi/client/test/FormTest.java
index 9cfc73b..49a83ba 100644
--- a/src/test/java/org/apache/sling/hapi/client/test/FormTest.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/FormTest.java
@@ -1,26 +1,23 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
-
+ */
package org.apache.sling.hapi.client.test;
-import static org.hamcrest.core.IsEqual.equalTo;
-
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
@@ -45,6 +42,8 @@ import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
+import static org.hamcrest.core.IsEqual.equalTo;
+
public class FormTest {
private static final String GET_URL = "/test1";
private static final String POST_URL = "/testpost1";
@@ -56,30 +55,33 @@ public class FormTest {
@Override
protected void registerHandlers() {
- serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
- @Override
- public void handle(HttpRequest httpRequest, HttpResponse
httpResponse, HttpContext httpContext)
- throws HttpException, IOException {
- final String html =
IOUtils.toString(ItemsTest.class.getResourceAsStream("/items_forms.html"),
"UTF-8");
- HttpEntity entity = new StringEntity(html, "UTF-8");
- httpResponse.setEntity(entity);
- }
- }).registerHandler(POST_URL, new HttpRequestHandler() {
- @Override
- public void handle(HttpRequest httpRequest, HttpResponse
httpResponse, HttpContext httpContext)
- throws HttpException, IOException {
- if
(!httpRequest.getRequestLine().getMethod().equals("POST")) {
- httpResponse.setEntity(new
StringEntity(FAIL_RESPONSE));
- } else {
- httpResponse.setEntity(new StringEntity(OK_RESPONSE));
- }
- httpResponse.setStatusCode(302);
- httpResponse.setHeader("Location", GET_URL);
- }
- });
+ serverBootstrap
+ .registerHandler(GET_URL, new HttpRequestHandler() {
+ @Override
+ public void handle(HttpRequest httpRequest,
HttpResponse httpResponse, HttpContext httpContext)
+ throws HttpException, IOException {
+ final String html =
+
IOUtils.toString(ItemsTest.class.getResourceAsStream("/items_forms.html"),
"UTF-8");
+ HttpEntity entity = new StringEntity(html,
"UTF-8");
+ httpResponse.setEntity(entity);
+ }
+ })
+ .registerHandler(POST_URL, new HttpRequestHandler() {
+ @Override
+ public void handle(HttpRequest httpRequest,
HttpResponse httpResponse, HttpContext httpContext)
+ throws HttpException, IOException {
+ if
(!httpRequest.getRequestLine().getMethod().equals("POST")) {
+ httpResponse.setEntity(new
StringEntity(FAIL_RESPONSE));
+ } else {
+ httpResponse.setEntity(new
StringEntity(OK_RESPONSE));
+ }
+ httpResponse.setStatusCode(302);
+ httpResponse.setHeader("Location", GET_URL);
+ }
+ });
}
};
-
+
@Test
public void testForm() throws ClientException, URISyntaxException {
MicrodataHtmlClient client = new
MicrodataHtmlClient(httpServer.getURI().toString());
@@ -100,4 +102,4 @@ public class FormTest {
Document doc3 = form.at(1).submit(data);
Assert.assertThat(doc3.items().length(), equalTo(1));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java
b/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java
index 3f457c4..2937934 100644
--- a/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java
@@ -1,27 +1,23 @@
-
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
-
+ */
package org.apache.sling.hapi.client.test;
-import static org.hamcrest.core.StringContains.containsString;
-
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
@@ -42,6 +38,8 @@ import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
+import static org.hamcrest.core.StringContains.containsString;
+
public class GetPostTest {
private static final String GET_URL = "/test";
private static final String GET_AUTH_URL = "/testauth";
@@ -56,34 +54,40 @@ public class GetPostTest {
@Override
protected void registerHandlers() {
- serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
- @Override
- public void handle(HttpRequest httpRequest, HttpResponse
httpResponse, HttpContext httpContext)
- throws HttpException, IOException {
- httpResponse.setEntity(new StringEntity(OK_RESPONSE));
- }
- }).registerHandler(GET_AUTH_URL, new HttpRequestHandler() {
- @Override
- public void handle(HttpRequest httpRequest, HttpResponse
httpResponse, HttpContext httpContext)
- throws HttpException, IOException {
- Header[] headers = httpRequest.getHeaders("Authorization");
- if (null == headers || headers.length == 0 ||
!headers[0].getValue().equals(AUTH_STRING)) {
- httpResponse.setStatusCode(401);
- httpResponse.setHeader("WWW-Authenticate", "Basic
realm=\"TEST\"");
- } else {
- httpResponse.setEntity(new StringEntity(OK_RESPONSE));
- }
- }
- }).registerHandler(REDIRECT_URL, new HttpRequestHandler() {
- @Override
- public void handle(HttpRequest request, HttpResponse response,
HttpContext context) throws HttpException, IOException {
- response.setStatusCode(307);
- response.setHeader("Location", GET_URL);
- }
- });
+ serverBootstrap
+ .registerHandler(GET_URL, new HttpRequestHandler() {
+ @Override
+ public void handle(HttpRequest httpRequest,
HttpResponse httpResponse, HttpContext httpContext)
+ throws HttpException, IOException {
+ httpResponse.setEntity(new
StringEntity(OK_RESPONSE));
+ }
+ })
+ .registerHandler(GET_AUTH_URL, new HttpRequestHandler() {
+ @Override
+ public void handle(HttpRequest httpRequest,
HttpResponse httpResponse, HttpContext httpContext)
+ throws HttpException, IOException {
+ Header[] headers =
httpRequest.getHeaders("Authorization");
+ if (null == headers
+ || headers.length == 0
+ ||
!headers[0].getValue().equals(AUTH_STRING)) {
+ httpResponse.setStatusCode(401);
+ httpResponse.setHeader("WWW-Authenticate",
"Basic realm=\"TEST\"");
+ } else {
+ httpResponse.setEntity(new
StringEntity(OK_RESPONSE));
+ }
+ }
+ })
+ .registerHandler(REDIRECT_URL, new HttpRequestHandler() {
+ @Override
+ public void handle(HttpRequest request, HttpResponse
response, HttpContext context)
+ throws HttpException, IOException {
+ response.setStatusCode(307);
+ response.setHeader("Location", GET_URL);
+ }
+ });
}
};
-
+
@Test
public void testValidGet() throws ClientException, URISyntaxException {
MicrodataHtmlClient client = new
MicrodataHtmlClient(httpServer.getURI().toString());
diff --git a/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java
b/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java
index e43394e..92b9cee 100644
--- a/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java
@@ -1,26 +1,23 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
-
+ */
package org.apache.sling.hapi.client.test;
-import static org.hamcrest.core.IsEqual.equalTo;
-
import java.io.IOException;
import java.net.URISyntaxException;
@@ -41,6 +38,8 @@ import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
+import static org.hamcrest.core.IsEqual.equalTo;
+
public class ItemsTest {
private static final String GET_URL = "/test";
private static final String GET_LINKS_URL = "/testlinks";
@@ -50,32 +49,35 @@ public class ItemsTest {
@Override
protected void registerHandlers() throws IOException {
final String html =
IOUtils.toString(ItemsTest.class.getResourceAsStream("/items.html"), "UTF-8");
- final String htmlLinks =
IOUtils.toString(ItemsTest.class.getResourceAsStream("/items_links.html"),
"UTF-8");
- serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
- @Override
- public void handle(HttpRequest httpRequest, HttpResponse
httpResponse, HttpContext httpContext)
- throws HttpException, IOException {
- HttpEntity entity = new StringEntity(html, "UTF-8");
- httpResponse.setEntity(entity);
- }
- }).registerHandler(GET_LINKS_URL, new HttpRequestHandler() {
- @Override
- public void handle(HttpRequest httpRequest, HttpResponse
httpResponse, HttpContext httpContext)
- throws HttpException, IOException {
- HttpEntity entity = new StringEntity(htmlLinks, "UTF-8");
- httpResponse.setEntity(entity);
- }
- });
+ final String htmlLinks =
+
IOUtils.toString(ItemsTest.class.getResourceAsStream("/items_links.html"),
"UTF-8");
+ serverBootstrap
+ .registerHandler(GET_URL, new HttpRequestHandler() {
+ @Override
+ public void handle(HttpRequest httpRequest,
HttpResponse httpResponse, HttpContext httpContext)
+ throws HttpException, IOException {
+ HttpEntity entity = new StringEntity(html,
"UTF-8");
+ httpResponse.setEntity(entity);
+ }
+ })
+ .registerHandler(GET_LINKS_URL, new HttpRequestHandler() {
+ @Override
+ public void handle(HttpRequest httpRequest,
HttpResponse httpResponse, HttpContext httpContext)
+ throws HttpException, IOException {
+ HttpEntity entity = new StringEntity(htmlLinks,
"UTF-8");
+ httpResponse.setEntity(entity);
+ }
+ });
}
};
-
+
@Test
public void testItems() throws ClientException, URISyntaxException {
MicrodataHtmlClient client = new
MicrodataHtmlClient(httpServer.getURI().toString());
Document doc = client.enter(GET_URL);
Items items = doc.items();
Assert.assertThat(items.length(), equalTo(2));
- for (int i=0; i<2; i++) {
+ for (int i = 0; i < 2; i++) {
Assert.assertThat(items.at(i).prop("name").text(),
equalTo("Avatar" + i));
Assert.assertThat(items.at(i).prop("genre").text(),
equalTo("Science fiction" + i));
Assert.assertThat(items.at(i).prop("rank").number(), equalTo(i));
@@ -102,6 +104,5 @@ public class ItemsTest {
Items otherMovies = doc.link("test").follow().items();
Assert.assertThat(otherMovies.length(), equalTo(2));
-
}
-}
\ No newline at end of file
+}
diff --git
a/src/test/java/org/apache/sling/hapi/client/test/util/HttpServerRule.java
b/src/test/java/org/apache/sling/hapi/client/test/util/HttpServerRule.java
index da42c16..02cb9b5 100644
--- a/src/test/java/org/apache/sling/hapi/client/test/util/HttpServerRule.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/util/HttpServerRule.java
@@ -1,21 +1,21 @@
-/*******************************************************************************
+/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-
******************************************************************************/
+ */
package org.apache.sling.hapi.client.test.util;
import java.io.IOException;
@@ -37,25 +37,25 @@ public class HttpServerRule extends ExternalResource {
private HttpHost host;
private URI uri;
- protected ServerBootstrap serverBootstrap;
-
+ protected ServerBootstrap serverBootstrap;
+
public static enum ProtocolScheme {
http,
https;
- private ProtocolScheme() {
- }
+
+ private ProtocolScheme() {}
}
-
+
protected final ProtocolScheme protocolScheme;
public HttpServerRule() {
this(ProtocolScheme.http);
}
-
+
public HttpServerRule(ProtocolScheme protocolScheme) {
this.protocolScheme = protocolScheme;
}
-
+
@Override
protected void after() {
server.shutdown(-1, TimeUnit.SECONDS);
@@ -63,9 +63,11 @@ public class HttpServerRule extends ExternalResource {
@Override
protected void before() throws Throwable {
- final SocketConfig socketConfig =
SocketConfig.custom().setSoTimeout(5000).build();
- serverBootstrap =
ServerBootstrap.bootstrap().setSocketConfig(socketConfig).setServerInfo(ORIGIN);
- if(ProtocolScheme.https.equals(protocolScheme)) {
+ final SocketConfig socketConfig =
+ SocketConfig.custom().setSoTimeout(5000).build();
+ serverBootstrap =
+
ServerBootstrap.bootstrap().setSocketConfig(socketConfig).setServerInfo(ORIGIN);
+ if (ProtocolScheme.https.equals(protocolScheme)) {
serverBootstrap.setSslContext(SSLTestContexts.createServerSSLContext());
}
registerHandlers();
@@ -74,10 +76,9 @@ public class HttpServerRule extends ExternalResource {
host = new HttpHost("127.0.0.1", server.getLocalPort(),
protocolScheme.name());
uri = URIUtils.rewriteURI(new URI("/"), host);
}
-
- protected void registerHandlers() throws IOException {
- }
-
+
+ protected void registerHandlers() throws IOException {}
+
public URI getURI() {
return uri;
}