You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:36:36 UTC

[sling-org-apache-sling-hapi-client] annotated tag org.apache.sling.hapi.client-1.0.0 created (now f7f4961)

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

rombert pushed a change to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git.


      at f7f4961  (tag)
 tagging 5aa1a49fb4787844c590fbc896bc7355744c7e88 (commit)
      by Andrei Dulvac
      on Wed Aug 10 14:52:28 2016 +0000

- Log -----------------------------------------------------------------
org.apache.sling.hapi.client-1.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 01c6607  SLING-5136 - HApi microdata client, contributed by Andrei Dulvac, thanks!
     new 6d11d9f  SLING-5136 - HApi microdata client, improved tests contributed by Andrei Dulvac, thanks!
     new 55c08ba  SLING-5136 - use a JUnit Rule to setup the HTTP server
     new 0a194f8  SLING-5136 - move test classes to Sling packages
     new 7bb773c  SLING-5136 - use numeric localhost address, the string might not work in some environments
     new 24ff60e  SLING-5390 - Allow HApi microdata client to fitler links and forms - contributed by Andrei Dulvac, thanks!
     new 746dab3  hapi: add license headers to test resources
     new acfb221  @trivial removed unused imports
     new 27a1a4d  [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
     new fbafc34  trivial: cleaner pom
     new 5587698  [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
     new a163fbc  [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0
     new 65b582d  [maven-release-plugin] prepare for next development iteration
     new 313573a  SLING-5880 [hapi client] Make org.apache.sling.hapi.client into a bundle
     new 024a306  [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
     new 3224683  [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0
     new 0aec769  [maven-release-plugin] prepare for next development iteration
     new b1f1fc4  SLING-5880 Fixed service interface
     new 962b976  SLING-5880 made forms package private
     new 2a0fbf9  Update to latest parent pom, clean up pom, use OSGi annotations
     new 00f59ab  SLING-5880 made forms package internal
     new e3448b7  reverted hapi release
     new 07089a1  [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
     new 5aa1a49  [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0

The 24 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-hapi-client] 15/24: [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 024a30612b5ab60bfff100e23fb641880b9fb79f
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Tue Aug 9 12:51:45 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755601 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index c4e0735..fc2f3a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.hapi.client-1.0.0</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 02/24: SLING-5136 - HApi microdata client, improved tests contributed by Andrei Dulvac, thanks!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 6d11d9f8624afefd7a26784fb9b8d11c8cd54acc
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Oct 13 11:05:58 2015 +0000

    SLING-5136 - HApi microdata client, improved tests contributed by Andrei Dulvac, thanks!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1708328 13f79535-47bb-0310-9956-ffa450edef68
---
 src/test/java/FormTest.java      | 23 +++++++-------
 src/test/java/GetPostTest.java   | 26 +++++++++-------
 src/test/java/ItemsTest.java     | 23 +++++++-------
 src/test/java/util/TestBase.java | 67 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 104 insertions(+), 35 deletions(-)

diff --git a/src/test/java/FormTest.java b/src/test/java/FormTest.java
index 3c9424d..c179b9b 100644
--- a/src/test/java/FormTest.java
+++ b/src/test/java/FormTest.java
@@ -21,7 +21,6 @@ import org.apache.commons.io.IOUtils;
 import org.apache.http.*;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -30,9 +29,9 @@ import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import util.TestBase;
 
 import java.io.IOException;
 import java.net.URI;
@@ -43,7 +42,7 @@ import java.util.List;
 import static org.hamcrest.core.IsEqual.equalTo;
 
 
-public class FormTest extends LocalServerTestBase {
+public class FormTest extends TestBase {
     public static final String GET_URL = "/test1";
     public static final String POST_URL = "/testpost1";
     public static final String OK_RESPONSE = "TEST_OK";
@@ -51,18 +50,18 @@ public class FormTest extends LocalServerTestBase {
 
     public static String html;
 
-    private HttpHost host;
-    private URI uri;
+    private static HttpHost host;
+    private static URI uri;
 
     @BeforeClass
-    public static void setUpClass() throws IOException {
+    public static void setUp() throws Exception {
         FormTest.html = IOUtils.toString(ItemsTest.class.getResourceAsStream("items_forms.html"), "UTF-8");
+        setupServer();
     }
 
-    @Before
-    public void setup() throws Exception {
-        super.setUp();
-        this.serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
+    public static void setupServer() throws Exception {
+        TestBase.setUp();
+        serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
             @Override
             public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext)
                     throws HttpException, IOException {
@@ -84,8 +83,8 @@ public class FormTest extends LocalServerTestBase {
         });
 
         // start server
-        this.host = this.start();
-        this.uri = URIUtils.rewriteURI(new URI("/"), host);
+        host = TestBase.start();
+        uri = URIUtils.rewriteURI(new URI("/"), host);
     }
 
     @Test
diff --git a/src/test/java/GetPostTest.java b/src/test/java/GetPostTest.java
index e45b8b1..23589b6 100644
--- a/src/test/java/GetPostTest.java
+++ b/src/test/java/GetPostTest.java
@@ -21,7 +21,6 @@
 import org.apache.http.*;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.sling.hapi.client.ClientException;
@@ -29,8 +28,9 @@ import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
 import org.hamcrest.core.StringContains;
 import org.junit.Assert;
-import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
+import util.TestBase;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -39,7 +39,7 @@ import java.net.URISyntaxException;
 
 import static org.hamcrest.core.StringContains.containsString;
 
-public class GetPostTest extends LocalServerTestBase {
+public class GetPostTest extends TestBase {
     public static final String GET_URL = "/test";
     public static final String GET_AUTH_URL = "/testauth";
     public static final String OK_RESPONSE = "TEST_OK";
@@ -50,13 +50,17 @@ public class GetPostTest extends LocalServerTestBase {
     private static final String REDIRECT_URL = "/test_redirect";
 
 
-    private HttpHost host;
-    private URI uri;
+    private static HttpHost host;
+    private static URI uri;
 
-    @Before
-    public void setup() throws Exception {
-        super.setUp();
-        this.serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
+    @BeforeClass
+    public static void setUp() throws Exception {
+        setupServer();
+    }
+
+    public static void setupServer() throws Exception {
+        TestBase.setUp();
+        serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
             @Override
             public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext)
                     throws HttpException, IOException {
@@ -83,8 +87,8 @@ public class GetPostTest extends LocalServerTestBase {
         });
 
         // start server
-        this.host = this.start();
-        this.uri = URIUtils.rewriteURI(new URI("/"), host);
+        host = TestBase.start();
+        uri = URIUtils.rewriteURI(new URI("/"), host);
     }
 
     @Test
diff --git a/src/test/java/ItemsTest.java b/src/test/java/ItemsTest.java
index 9e0b962..7c09f45 100644
--- a/src/test/java/ItemsTest.java
+++ b/src/test/java/ItemsTest.java
@@ -21,7 +21,6 @@ import org.apache.commons.io.IOUtils;
 import org.apache.http.*;
 import org.apache.http.client.utils.URIUtils;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.localserver.LocalServerTestBase;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.sling.hapi.client.ClientException;
@@ -29,9 +28,9 @@ import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
 import org.junit.Assert;
-import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import util.TestBase;
 
 import java.io.IOException;
 import java.net.URI;
@@ -40,7 +39,7 @@ import java.net.URISyntaxException;
 import static org.hamcrest.core.IsEqual.equalTo;
 
 
-public class ItemsTest extends LocalServerTestBase {
+public class ItemsTest extends TestBase {
     public static final String GET_URL = "/test";
     public static final String GET_LINKS_URL = "/testlinks";
     public static final String OK_RESPONSE = "TEST_OK";
@@ -49,19 +48,19 @@ public class ItemsTest extends LocalServerTestBase {
     public static String html;
     public static String htmlLinks;
 
-    private HttpHost host;
-    private URI uri;
+    private static HttpHost host;
+    private static URI uri;
 
     @BeforeClass
-    public static void setUpClass() throws IOException {
+    public static void setUp() throws Exception {
         ItemsTest.html = IOUtils.toString(ItemsTest.class.getResourceAsStream("items.html"), "UTF-8");
         ItemsTest.htmlLinks = IOUtils.toString(ItemsTest.class.getResourceAsStream("items_links.html"), "UTF-8");
+        setupServer();
     }
 
-    @Before
-    public void setup() throws Exception {
-        super.setUp();
-        this.serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
+    public static void setupServer() throws Exception {
+        TestBase.setUp();
+        serverBootstrap.registerHandler(GET_URL, new HttpRequestHandler() {
             @Override
             public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext)
                     throws HttpException, IOException {
@@ -78,8 +77,8 @@ public class ItemsTest extends LocalServerTestBase {
         });
 
         // start server
-        this.host = this.start();
-        this.uri = URIUtils.rewriteURI(new URI("/"), host);
+        host = TestBase.start();
+        uri = URIUtils.rewriteURI(new URI("/"), host);
     }
 
     @Test
diff --git a/src/test/java/util/TestBase.java b/src/test/java/util/TestBase.java
new file mode 100644
index 0000000..d1dbc25
--- /dev/null
+++ b/src/test/java/util/TestBase.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 util;
+
+import org.apache.http.HttpHost;
+import org.apache.http.config.SocketConfig;
+import org.apache.http.impl.bootstrap.HttpServer;
+import org.apache.http.impl.bootstrap.ServerBootstrap;
+import org.apache.http.localserver.SSLTestContexts;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import java.util.concurrent.TimeUnit;
+
+public abstract class TestBase {
+    public static final String ORIGIN = "TEST/1.1";
+    protected static TestBase.ProtocolScheme scheme = TestBase.ProtocolScheme.http;
+    protected static ServerBootstrap serverBootstrap;
+    protected static HttpServer server;
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(5000).build();
+        serverBootstrap = ServerBootstrap.bootstrap().setSocketConfig(socketConfig).setServerInfo("TEST/1.1");
+        if(scheme.equals(TestBase.ProtocolScheme.https)) {
+            serverBootstrap.setSslContext(SSLTestContexts.createServerSSLContext());
+        }
+    }
+
+    @AfterClass
+    public static void shutDown() throws Exception {
+        if(server != null) {
+            server.shutdown(-1, TimeUnit.SECONDS);
+        }
+
+    }
+
+    public static HttpHost start() throws Exception {
+        server = serverBootstrap.create();
+        server.start();
+        return new HttpHost("localhost", server.getLocalPort(), scheme.name());
+    }
+
+    public static enum ProtocolScheme {
+        http,
+        https;
+
+        private ProtocolScheme() {
+        }
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 08/24: @trivial removed unused imports

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit acfb221f831523b203913e29d5575903bcfef649
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Thu Jun 16 12:32:08 2016 +0000

    @trivial removed unused imports
    
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1748702 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java  | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
index e71df99..22539df 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
+++ b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
@@ -19,9 +19,7 @@
 
 package org.apache.sling.hapi.client.microdata;
 
-import org.apache.http.HttpEntity;
 import org.apache.http.NameValuePair;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
 import org.apache.sling.hapi.client.*;
 import org.apache.sling.hapi.client.forms.FormValues;
 import org.jsoup.Jsoup;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 13/24: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 65b582d50a557b66bd6b4f06cf979183e963dd51
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Jul 13 15:27:43 2016 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1752446 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 08c85c8..249f1ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.hapi.client-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 16/24: [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 3224683bd07d99b7cc848bcd4165436d1e9047f8
Merge: a163fbc 024a306
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Tue Aug 9 12:51:58 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0@1755602 13f79535-47bb-0310-9956-ffa450edef68

 pom.xml                                            | 31 +++++++-
 ...odataHtmlClient.java => HtmlClientService.java} | 31 ++------
 .../package-info.java}                             | 31 ++------
 .../hapi/client/impl/HtmlClientServiceImpl.java    | 82 ++++++++++++++++++++++
 .../{ => impl}/microdata/MicrodataDocument.java    |  2 +-
 .../{ => impl}/microdata/MicrodataHtmlClient.java  |  2 +-
 .../MicrodataHtmlClient.java => package-info.java} | 31 ++------
 .../apache/sling/hapi/client/test/FormTest.java    |  2 +-
 .../apache/sling/hapi/client/test/GetPostTest.java |  2 +-
 .../apache/sling/hapi/client/test/ItemsTest.java   |  2 +-
 10 files changed, 130 insertions(+), 86 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 23/24: [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 07089a1f8828d6e4ffa03f5dedb2f522f5e4496f
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Aug 10 14:52:15 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755761 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 608fd8c..881bff8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.hapi.client-1.0.0</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 17/24: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 0aec7694e50d0091cbe805068a0e072d3ba8fc09
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Tue Aug 9 12:52:00 2016 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755603 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index fc2f3a6..2bc1c2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.hapi.client-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 19/24: SLING-5880 made forms package private

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 962b976cf6dd7f6eba12d87a91822c17c72539dc
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Aug 10 12:39:52 2016 +0000

    SLING-5880 made forms package private
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755732 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                                 | 1 -
 .../java/org/apache/sling/hapi/client/forms/{ => impl}/FormValues.java  | 2 +-
 src/main/java/org/apache/sling/hapi/client/forms/{ => impl}/Vals.java   | 2 +-
 .../org/apache/sling/hapi/client/forms/{ => impl}/package-info.java     | 2 +-
 .../org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java  | 2 +-
 5 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 58c22b9..2bc1c2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,7 +61,6 @@
                 <configuration>
                     <instructions>
                         <Bundle-Category>sling</Bundle-Category>
-                        <Private-Package>org.apache.sling.hapi.client.forms</Private-Package>
                         <Sling-Initial-Content>SLING-INF;overwrite=true</Sling-Initial-Content>
                         <Embed-Dependency>groupId=org.jsoup</Embed-Dependency>
                     </instructions>
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/FormValues.java b/src/main/java/org/apache/sling/hapi/client/forms/impl/FormValues.java
similarity index 98%
rename from src/main/java/org/apache/sling/hapi/client/forms/FormValues.java
rename to src/main/java/org/apache/sling/hapi/client/forms/impl/FormValues.java
index 9a12cb1..c8811ac 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/FormValues.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/impl/FormValues.java
@@ -17,7 +17,7 @@
  * under the License.
  ******************************************************************************/
 
-package org.apache.sling.hapi.client.forms;
+package org.apache.sling.hapi.client.forms.impl;
 
 import java.io.UnsupportedEncodingException;
 
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/Vals.java b/src/main/java/org/apache/sling/hapi/client/forms/impl/Vals.java
similarity index 97%
rename from src/main/java/org/apache/sling/hapi/client/forms/Vals.java
rename to src/main/java/org/apache/sling/hapi/client/forms/impl/Vals.java
index 9e728a6..13f9454 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/Vals.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/impl/Vals.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  ******************************************************************************/
-package org.apache.sling.hapi.client.forms;
+package org.apache.sling.hapi.client.forms.impl;
 
 import org.apache.http.NameValuePair;
 
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/package-info.java b/src/main/java/org/apache/sling/hapi/client/forms/impl/package-info.java
similarity index 95%
rename from src/main/java/org/apache/sling/hapi/client/forms/package-info.java
rename to src/main/java/org/apache/sling/hapi/client/forms/impl/package-info.java
index 8003994..05b7d76 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/package-info.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/impl/package-info.java
@@ -18,6 +18,6 @@
  ******************************************************************************/
 
 @Version("1.0.0")
-package org.apache.sling.hapi.client.forms;
+package org.apache.sling.hapi.client.forms.impl;
 
 import aQute.bnd.annotation.Version;
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 248887d..84c9645 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
@@ -21,7 +21,7 @@ package org.apache.sling.hapi.client.impl.microdata;
 
 import org.apache.http.NameValuePair;
 import org.apache.sling.hapi.client.*;
-import org.apache.sling.hapi.client.forms.FormValues;
+import org.apache.sling.hapi.client.forms.impl.FormValues;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 20/24: Update to latest parent pom, clean up pom, use OSGi annotations

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 2a0fbf9fc4a457a87a5737aae09ae3650ac0ff24
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 10 12:48:46 2016 +0000

    Update to latest parent pom, clean up pom, use OSGi annotations
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755735 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                      | 10 +++++-----
 src/main/java/org/apache/sling/hapi/client/package-info.java |  4 +---
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2bc1c2d..c89f338 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>26</version>
+        <version>28</version>
         <relativePath />
     </parent>
 
@@ -74,21 +74,25 @@
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpclient</artifactId>
             <version>4.5.1</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpmime</artifactId>
             <version>4.5</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
             <version>2.5</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>2.5</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.jsoup</groupId>
@@ -98,7 +102,6 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.7.21</version>
         </dependency>
         <!-- test scope -->
         <dependency>
@@ -111,13 +114,10 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
-            <version>1.7.21</version>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <scope>test</scope>
         </dependency>
     </dependencies>
 </project>
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 c15121e..c22d105 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
@@ -17,7 +17,5 @@
  * under the License.
  ******************************************************************************/
 
-@Version("1.0.0")
+@org.osgi.annotation.versioning.Version("1.0.0")
 package org.apache.sling.hapi.client;
-
-import aQute.bnd.annotation.Version;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 11/24: [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 5587698f6716312baf55c5e5f7ae4213f5aa5ecb
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Jul 13 15:27:28 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1752444 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index e9d7e20..08c85c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.hapi.client-1.0.0</url>
     </scm>
 
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 04/24: SLING-5136 - move test classes to Sling packages

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 0a194f851afab6b43978f560698c48712c6d23fb
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Oct 13 11:55:28 2015 +0000

    SLING-5136 - move test classes to Sling packages
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1708359 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/{ => org/apache/sling/hapi/client/test}/FormTest.java   | 7 ++++---
 .../{ => org/apache/sling/hapi/client/test}/GetPostTest.java     | 5 +++--
 .../java/{ => org/apache/sling/hapi/client/test}/ItemsTest.java  | 9 +++++----
 .../apache/sling/hapi/client/test}/util/HttpServerRule.java      | 2 +-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/test/java/FormTest.java b/src/test/java/org/apache/sling/hapi/client/test/FormTest.java
similarity index 96%
rename from src/test/java/FormTest.java
rename to src/test/java/org/apache/sling/hapi/client/test/FormTest.java
index e13c20f..5d9b675 100644
--- a/src/test/java/FormTest.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/FormTest.java
@@ -17,6 +17,8 @@
  * under the License.
  ******************************************************************************/
 
+package org.apache.sling.hapi.client.test;
+
 import static org.hamcrest.core.IsEqual.equalTo;
 
 import java.io.IOException;
@@ -38,12 +40,11 @@ import org.apache.sling.hapi.client.ClientException;
 import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.apache.sling.hapi.client.test.util.HttpServerRule;
 import org.junit.Assert;
 import org.junit.ClassRule;
 import org.junit.Test;
 
-import util.HttpServerRule;
-
 public class FormTest {
     private static final String GET_URL = "/test1";
     private static final String POST_URL = "/testpost1";
@@ -59,7 +60,7 @@ public class FormTest {
                 @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"); 
+                    final String html = IOUtils.toString(ItemsTest.class.getResourceAsStream("/items_forms.html"), "UTF-8"); 
                     HttpEntity entity = new StringEntity(html, "UTF-8");
                     httpResponse.setEntity(entity);
                 }
diff --git a/src/test/java/GetPostTest.java b/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java
similarity index 97%
rename from src/test/java/GetPostTest.java
rename to src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java
index 5b13112..4e9b158 100644
--- a/src/test/java/GetPostTest.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/GetPostTest.java
@@ -18,6 +18,8 @@
  * under the License.
  ******************************************************************************/
 
+package org.apache.sling.hapi.client.test;
+
 import static org.hamcrest.core.StringContains.containsString;
 
 import java.io.IOException;
@@ -34,13 +36,12 @@ import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.sling.hapi.client.ClientException;
 import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.apache.sling.hapi.client.test.util.HttpServerRule;
 import org.hamcrest.core.StringContains;
 import org.junit.Assert;
 import org.junit.ClassRule;
 import org.junit.Test;
 
-import util.HttpServerRule;
-
 public class GetPostTest {
     private static final String GET_URL = "/test";
     private static final String GET_AUTH_URL = "/testauth";
diff --git a/src/test/java/ItemsTest.java b/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java
similarity index 95%
rename from src/test/java/ItemsTest.java
rename to src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java
index 8ab5453..66561db 100644
--- a/src/test/java/ItemsTest.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/ItemsTest.java
@@ -17,6 +17,8 @@
  * under the License.
  ******************************************************************************/
 
+package org.apache.sling.hapi.client.test;
+
 import static org.hamcrest.core.IsEqual.equalTo;
 
 import java.io.IOException;
@@ -34,12 +36,11 @@ import org.apache.sling.hapi.client.ClientException;
 import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.apache.sling.hapi.client.test.util.HttpServerRule;
 import org.junit.Assert;
 import org.junit.ClassRule;
 import org.junit.Test;
 
-import util.HttpServerRule;
-
 public class ItemsTest {
     private static final String GET_URL = "/test";
     private static final String GET_LINKS_URL = "/testlinks";
@@ -48,8 +49,8 @@ public class ItemsTest {
     public static final HttpServerRule httpServer = new HttpServerRule() {
         @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");
+            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)
diff --git a/src/test/java/util/HttpServerRule.java b/src/test/java/org/apache/sling/hapi/client/test/util/HttpServerRule.java
similarity index 98%
rename from src/test/java/util/HttpServerRule.java
rename to src/test/java/org/apache/sling/hapi/client/test/util/HttpServerRule.java
index 0822ae4..4e1b069 100644
--- a/src/test/java/util/HttpServerRule.java
+++ b/src/test/java/org/apache/sling/hapi/client/test/util/HttpServerRule.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  ******************************************************************************/
-package util;
+package org.apache.sling.hapi.client.test.util;
 
 import java.io.IOException;
 import java.net.URI;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 12/24: [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit a163fbcf4566d560cd66be128311eeb3c23ca3f1
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Jul 13 15:27:41 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0@1752445 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 10/24: trivial: cleaner pom

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit fbafc34b280b439bf6ba82a66174b705c1d0fedf
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Jul 13 15:26:00 2016 +0000

    trivial: cleaner pom
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1752443 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/pom.xml b/pom.xml
index ac70daf..e9d7e20 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,22 +23,26 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>20</version>
+        <version>26</version>
         <relativePath />
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.0-SNAPSHOT</version>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
 
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/client</url>
+    </scm>
+
     <properties>
         <sling.java.version>6</sling.java.version>
     </properties>
 
-    <build>
-    </build>
 
     <dependencies>
         <dependency>
@@ -54,12 +58,12 @@
         <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
-            <version>2.4</version>
+            <version>2.5</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.commons</groupId>
+            <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
-            <version>1.3.2</version>
+            <version>2.5</version>
         </dependency>
         <dependency>
             <groupId>org.jsoup</groupId>
@@ -88,15 +92,7 @@
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
-            <version>4.12</version>
             <scope>test</scope>
         </dependency>
     </dependencies>
-
-
-  <scm>
-    <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</connection>
-    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</developerConnection>
-    <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.hapi.client-1.0.0</url>
-  </scm>
 </project>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 18/24: SLING-5880 Fixed service interface

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit b1f1fc445f08f7c887328386b6c2186fd6a58f4b
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Aug 10 11:38:38 2016 +0000

    SLING-5880 Fixed service interface
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755727 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  1 +
 .../org/apache/sling/hapi/client/Document.java     | 30 +++++++++++++++++++++-
 .../sling/hapi/client/HtmlClientService.java       | 26 +++++++++++++++++++
 .../java/org/apache/sling/hapi/client/Item.java    | 15 ++++++-----
 .../hapi/client/impl/HtmlClientServiceImpl.java    |  4 ++-
 5 files changed, 67 insertions(+), 9 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2bc1c2d..58c22b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,6 +61,7 @@
                 <configuration>
                     <instructions>
                         <Bundle-Category>sling</Bundle-Category>
+                        <Private-Package>org.apache.sling.hapi.client.forms</Private-Package>
                         <Sling-Initial-Content>SLING-INF;overwrite=true</Sling-Initial-Content>
                         <Embed-Dependency>groupId=org.jsoup</Embed-Dependency>
                     </instructions>
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 9344e5d..3da16ba 100644
--- a/src/main/java/org/apache/sling/hapi/client/Document.java
+++ b/src/main/java/org/apache/sling/hapi/client/Document.java
@@ -19,11 +19,39 @@
 package org.apache.sling.hapi.client;
 
 /**
- * An HTML document representation
+ * A hapi representation of an HTML document, backed by HTML markup.
+ * The Document provides a structure, accessible through the {@link #item(String)} and {@link #items()} methods
+ * and a way to use the hypermedia controls through the {@link #link(String)} and {@link #form(String)} methods
  */
 public interface Document {
+    /**
+     * Get all the {@link Document}'s link items. These Items should normally be backed by HTML <i>anchors</i> and <i>links</i>.
+     * @param rel An identifier that groups all the <i>link</i> Items for this Document
+     * @return all the link Items for this Document, that have the given relation
+     * @throws ClientException
+     */
     Items link(String rel) throws ClientException;
+
+    /**
+     * Get all the {@link Document}'s form items. These Items should normally be backed by the HTML <i>form</i> element
+     * @param rel An identifier that groups all the <i>form</i> Items for this Document
+     * @return all the form Items for this Document, that have the given relation
+     * @throws ClientException
+     */
     Items form(String rel) throws ClientException;
+
+    /**
+     * Get all the {@link Document}'s items. These Items are backed by any HTML element
+     * @param rel An identifier that groups all the Items for this Document
+     * @return all the Items for this Document, that have the given relation
+     * @throws ClientException
+     */
     Items item(String rel) throws ClientException;
+
+    /**
+     * Get all the {@link Document}'s items. These Items are backed by any HTML element
+     * @return all the Items for this Document
+     * @throws ClientException
+     */
     Items items() throws ClientException;
 }
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 bedf01d..fa39f28 100644
--- a/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
+++ b/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
@@ -18,6 +18,32 @@
  ******************************************************************************/
 package org.apache.sling.hapi.client;
 
+import org.apache.http.impl.client.CloseableHttpClient;
+
 public interface HtmlClientService {
 
+    /**
+     * Get an HtmlClient that internally uses a CloseableHttpClient
+     * @param client the inner {@link CloseableHttpClient}. The client should take care of any timeouts, authentication, pre/post
+     *               processing, etc.
+     * @param baseUrl The address prefix to all the http requests (e.g. http://localhost:8080/myapp/)
+     * @return
+     */
+    HtmlClient getClient(CloseableHttpClient client, String baseUrl);
+
+    /**
+     * Get an HtmlClient.
+     * @param baseUrl The address prefix to all the http requests (e.g. http://localhost:8080/myapp/)
+     * @return
+     */
+    HtmlClient getClient(String baseUrl);
+
+    /**
+     * Get an HtmlClient that uses BasicAuth for all requests
+     * @param baseUrl The address prefix to all the http requests (e.g. http://localhost:8080/myapp/)
+     * @param user The username for BasicAuth
+     * @param password The password for BasicAuth
+     * @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 fa74107..8eba400 100644
--- a/src/main/java/org/apache/sling/hapi/client/Item.java
+++ b/src/main/java/org/apache/sling/hapi/client/Item.java
@@ -20,21 +20,22 @@ package org.apache.sling.hapi.client;
  ******************************************************************************/
 
 import org.apache.http.NameValuePair;
-
-import java.util.List;
 import java.util.Set;
 
 /**
- *
+ * An HTML item representation. This maps to an html element and contains all the child elements.
+ * The child <i>semantic</i> elements (properties, links, forms) and the Item's metadata (src, href, value)
+ * are accessible through the dedicated methods
  */
 public interface Item {
     /**
-     * Returns the property of the item having the given name.
+     * Returns the property of the item having the given name. The property is a child Item.
      */
     Items prop(String name) throws ClientException;
 
     /**
-     * Return a List of all the properties of this item
+     * Return a List of all the properties of this item.
+     * The returned Strings are names that can be used for {@link #prop(String)}
      */
     Set<String> props() throws ClientException;
 
@@ -81,12 +82,12 @@ public interface Item {
     String src();
 
     /**
-     * Follow a hyperlink and get a new {@see Document} representation
+     * Follow a hyperlink and get a new {@link Document} representation
      */
     Document follow() throws ClientException;
 
     /**
-     * Submits this form item and returns a new {@see Document} representation
+     * Submits this form item and returns a new {@link Document} representation
      */
     Document submit(Iterable<NameValuePair> data) throws ClientException;
 }
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 a684d1d..623c47d 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
@@ -32,7 +32,6 @@ import java.net.URISyntaxException;
 @Component(metatype = false)
 @Service(value = HtmlClientService.class)
 public class HtmlClientServiceImpl implements HtmlClientService {
-
     private final Logger LOG = LoggerFactory.getLogger(HtmlClientService.class);
 
     /**
@@ -41,6 +40,7 @@ public class HtmlClientServiceImpl implements HtmlClientService {
      * @param baseUrl the base URL as String
      * @return the HtmlClient or null if there was an error
      */
+    @Override
     public HtmlClient getClient(CloseableHttpClient client, String baseUrl) {
         try {
             return new MicrodataHtmlClient(client, baseUrl);
@@ -55,6 +55,7 @@ public class HtmlClientServiceImpl implements HtmlClientService {
      * @param baseUrl the base URL as String
      * @return the HtmlClient or null if there was an error
      */
+    @Override
     public HtmlClient getClient(String baseUrl) {
         try {
             return new MicrodataHtmlClient(baseUrl);
@@ -71,6 +72,7 @@ public class HtmlClientServiceImpl implements HtmlClientService {
      * @param password the password to be used for basic auth
      * @return the HtmlClient or null if there was an error
      */
+    @Override
     public HtmlClient getClient(String baseUrl, String user, String password) {
         try {
             return new MicrodataHtmlClient(baseUrl, user, password);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 01/24: SLING-5136 - HApi microdata client, contributed by Andrei Dulvac, thanks!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 01c66077c21f293a2fbb37ec19c194c174e18e30
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Oct 13 08:56:08 2015 +0000

    SLING-5136 - HApi microdata client, contributed by Andrei Dulvac, thanks!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1708306 13f79535-47bb-0310-9956-ffa450edef68
---
 .gitignore                                         |  15 +
 pom.xml                                            |  97 +++++
 .../apache/sling/hapi/client/ClientException.java  |  32 ++
 .../org/apache/sling/hapi/client/Document.java     |  29 ++
 .../org/apache/sling/hapi/client/HtmlClient.java   |  72 ++++
 .../java/org/apache/sling/hapi/client/Item.java    |  82 +++++
 .../java/org/apache/sling/hapi/client/Items.java   |  35 ++
 .../apache/sling/hapi/client/forms/FormValues.java | 116 ++++++
 .../org/apache/sling/hapi/client/forms/Vals.java   |  60 ++++
 .../hapi/client/impl/AbstractHtmlClientImpl.java   | 192 ++++++++++
 .../hapi/client/microdata/MicrodataDocument.java   | 399 +++++++++++++++++++++
 .../hapi/client/microdata/MicrodataHtmlClient.java |  44 +++
 src/test/java/FormTest.java                        | 114 ++++++
 src/test/java/GetPostTest.java                     | 111 ++++++
 src/test/java/ItemsTest.java                       | 121 +++++++
 src/test/resources/items.html                      |  24 ++
 src/test/resources/items_forms.html                |  28 ++
 src/test/resources/items_links.html                |  20 ++
 18 files changed, 1591 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..518c151
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,15 @@
+target/
+.project
+.classpath
+.settings/
+/sling/
+derby.log
+*.iml
+*.ipr
+*.iws
+coverage.em
+coverage.ec
+coverage/
+.DS_Store
+.idea/
+bundles/extensions/models/integration-tests/sling
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..9d95953
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+~ Licensed to the Apache Software Foundation (ASF) under one
+~ or more contributor license agreements. See the NOTICE file
+~ distributed with this work for additional information
+~ regarding copyright ownership. The ASF licenses this file
+~ to you under the Apache License, Version 2.0 (the
+~ "License"); you may not use this file except in compliance
+~ with the License. You may obtain a copy of the License at
+~
+~ http://www.apache.org/licenses/LICENSE-2.0
+~
+~ Unless required by applicable law or agreed to in writing,
+~ software distributed under the License is distributed on an
+~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~ KIND, either express or implied. See the License for the
+~ specific language governing permissions and limitations
+~ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>20</version>
+        <relativePath/>
+    </parent>
+
+    <artifactId>org.apache.sling.hapi.client</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+
+    <name>HApi - Sling Hypermedia API client-side tools</name>
+    <description>Sling client-side tools for HApi</description>
+
+    <properties>
+        <sling.java.version>6</sling.java.version>
+    </properties>
+
+    <build>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpmime</artifactId>
+            <version>4.5</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jsoup</groupId>
+            <artifactId>jsoup</artifactId>
+            <version>1.8.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.12</version>
+        </dependency>
+        <!-- test scope -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.1</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>1.7.12</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</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
new file mode 100644
index 0000000..9bda81e
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/ClientException.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+/**
+ * An HTTP client exception
+ */
+public class ClientException extends Exception {
+    public ClientException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ClientException(String message) {
+        super(message);
+    }
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/Document.java b/src/main/java/org/apache/sling/hapi/client/Document.java
new file mode 100644
index 0000000..9344e5d
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/Document.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+/**
+ * An HTML document representation
+ */
+public interface Document {
+    Items link(String rel) throws ClientException;
+    Items form(String rel) throws ClientException;
+    Items item(String rel) throws ClientException;
+    Items items() throws ClientException;
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/HtmlClient.java b/src/main/java/org/apache/sling/hapi/client/HtmlClient.java
new file mode 100644
index 0000000..078f46b
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/HtmlClient.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+import org.apache.http.HttpEntity;
+
+public interface HtmlClient {
+
+    /**
+     * Enters a url and return a Document
+     *
+     * @param url
+     * @return
+     * @throws ClientException
+     */
+    <T extends Document> T enter(String url) throws ClientException;
+
+    /**
+     * Performs a GET request and returns a Document
+     *
+     * @param url the URL String to perform an HTTP GET on
+     * @return
+     * @throws ClientException
+     */
+    <T extends Document> T get(String url) throws ClientException;
+
+
+    /**
+     * Performs a POST request.
+     *
+     * @param url    the URL String to perform an HTTP post on
+     * @param entity data to post
+     * @return
+     * @throws ClientException
+     */
+    <T extends Document> T post(String url, HttpEntity entity) throws ClientException;
+
+    /**
+     * Performs a DELETE request and returns a Document
+     *
+     * @param url the URL String to perform an HTTP DELETE on
+     * @return
+     * @throws ClientException
+     */
+    <T extends Document> T delete(String url) throws ClientException;
+
+    /**
+     * Method to create a new Document representation from an HTML content String
+     * @param html
+     * @param <T>
+     * @return
+     */
+    <T extends Document> T newDocument(String html);
+
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/Item.java b/src/main/java/org/apache/sling/hapi/client/Item.java
new file mode 100644
index 0000000..f1d8865
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/Item.java
@@ -0,0 +1,82 @@
+package org.apache.sling.hapi.client;
+
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ ******************************************************************************/
+
+import org.apache.http.NameValuePair;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ *
+ */
+public interface Item {
+    /**
+     * Returns the property of the item having the given name.
+     */
+    Items prop(String name) throws ClientException;
+
+    /**
+     * Return a List of all the properties of this item
+     */
+    Set<String> props() throws ClientException;
+
+    /**
+     * Returns the child links that have the given relation
+     */
+    Items link(String rel) throws ClientException;
+
+    /**
+     * Returns the child forms that have the given relation
+     */
+    Items form(String rel) throws ClientException;
+
+    /**
+     * Returns the text value of the property.
+     */
+    String text() throws ClientException;
+
+    /**
+     * Returns he boolean value of the property
+     */
+    boolean bool() throws ClientException;
+
+    int number() throws ClientException;
+
+    /**
+     * Returns the href value of the property. This only makes sense for hyperlinks (&lt;a&gt; or &lt;link&gt;).
+     */
+    String href();
+
+    /**
+     * Returns the <i>src</i> value of the property.
+     */
+    String src();
+
+    /**
+     * Follow a hyperlink and get a new {@see Document} representation
+     */
+    Document follow() throws ClientException;
+
+    /**
+     * Submits this form item and returns a new {@see Document} representation
+     */
+    Document submit(Iterable<NameValuePair> data) throws ClientException;
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/Items.java b/src/main/java/org/apache/sling/hapi/client/Items.java
new file mode 100644
index 0000000..4ccbc4d
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/Items.java
@@ -0,0 +1,35 @@
+package org.apache.sling.hapi.client;
+
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ ******************************************************************************/
+
+/**
+ * A composite object representing items in a {@see Document}
+ */
+public interface Items extends Iterable<Item>, Item {
+    /**
+     * Returns the item at one index
+     */
+    Item at(int index) throws IndexOutOfBoundsException;
+
+    /**
+     * Returns the amount of items contained in this collection.
+     */
+    int length();
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/FormValues.java b/src/main/java/org/apache/sling/hapi/client/forms/FormValues.java
new file mode 100644
index 0000000..9a12cb1
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/forms/FormValues.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.forms;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.client.entity.UrlEncodedFormEntity;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.message.BasicNameValuePair;
+import org.jsoup.nodes.Element;
+
+/**
+ *
+ */
+public class FormValues {
+    private Element form;
+
+    private Iterable<NameValuePair> values;
+
+    private Vals list = new Vals();
+
+    public FormValues(Element form, Iterable<NameValuePair> values) {
+        this.form = form;
+        this.values = values;
+
+        build();
+        resolve();
+    }
+
+    /**
+     * @return
+     * {@see http://www.w3.org/TR/html5/forms.html#constructing-the-form-data-set}
+     */
+    private FormValues build() {
+        for (Element input : form.select("button, input, select, textarea")) {
+            String type = input.attr("type");
+
+            if (input.hasAttr("disabled")) continue;
+            if (input.tagName().equalsIgnoreCase("button") && !type.equals("submit")) continue;
+            if (input.tagName().equalsIgnoreCase("input") && (type.equals("button") || type.equals("reset"))) continue;
+            if (type.equals("checkbox") && input.hasAttr("checked")) continue;
+            if (type.equals("radio") && input.hasAttr("checked")) continue;
+            if (!type.equals("image") && input.attr("name").length() == 0) continue;
+            if (input.parents().is("datalist")) continue;
+
+            if (type.equals("image") || type.equals("file")) continue; // don't support files for now
+            String name = input.attr("name");
+
+            if (input.tagName().equalsIgnoreCase("select")) {
+                for (Element o : input.select("option[selected]")) {
+                    if (o.hasAttr("disabled")) continue;
+                    list.add(name, new BasicNameValuePair(name, o.val()));
+                }
+            } else if (type.equals("checkbox") || type.equals("radio")) {
+                String value = input.hasAttr("value") ? input.val() : "on";
+                list.add(name, new BasicNameValuePair(name, value));
+            } else {
+                list.add(name, new BasicNameValuePair(name, input.val()));
+            }
+        }
+        return this;
+    }
+
+    private FormValues resolve() {
+        for (NameValuePair o : values) {
+            if (list.has(o.getName())) {
+                list.set(o);
+            } else {
+                // for now just set the value even if the form doesn't have a submittable input for the name.
+                // this is to support custom field that generate input dynamically
+                list.set(o);
+            }
+        }
+        return this;
+    }
+
+    public String toString() {
+        return URLEncodedUtils.format(list.flatten(), "UTF-8");
+    }
+
+    public HttpEntity toUrlEncodedEntity() {
+        try {
+            return new UrlEncodedFormEntity(list.flatten(), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public HttpEntity toMultipartEntity() {
+        MultipartEntityBuilder eb = MultipartEntityBuilder.create();
+        for (NameValuePair p : list.flatten()) {
+            eb.addTextBody(p.getName(), p.getValue());
+        }
+        return eb.build();
+    }
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/Vals.java b/src/main/java/org/apache/sling/hapi/client/forms/Vals.java
new file mode 100644
index 0000000..9e728a6
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/forms/Vals.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.forms;
+
+import org.apache.http.NameValuePair;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+public class Vals {
+    private Map<String, List<NameValuePair>> data = new LinkedHashMap<String, List<NameValuePair>>();
+
+    public void add(String name, NameValuePair pair) {
+        if (data.containsKey(name)) {
+            data.get(name).add(pair);
+        } else {
+            ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
+            list.add(pair);
+            data.put(name, list);
+        }
+    }
+
+    public boolean has(String name) {
+        return data.containsKey(name);
+    }
+
+    public void set(NameValuePair pair) {
+        ArrayList<NameValuePair> list = new ArrayList<NameValuePair>();
+        list.add(pair);
+        data.put(pair.getName(), list);
+    }
+
+    public List<? extends NameValuePair> flatten() {
+        List<NameValuePair> result = new ArrayList<NameValuePair>();
+
+        for (List<NameValuePair> c : data.values()) {
+            result.addAll(c);
+        }
+
+        return result;
+    }
+}
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
new file mode 100644
index 0000000..5c3444a
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/impl/AbstractHtmlClientImpl.java
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * 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.impl;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.LaxRedirectStrategy;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.util.EntityUtils;
+import org.apache.sling.hapi.client.ClientException;
+import org.apache.sling.hapi.client.Document;
+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;
+    protected URI baseUrl;
+
+    public AbstractHtmlClientImpl(CloseableHttpClient client, String baseUrl) throws URISyntaxException {
+        this.client = client;
+        this.baseUrl = new URI(baseUrl);
+    }
+
+    public AbstractHtmlClientImpl(String baseUrl) throws URISyntaxException {
+        this(HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategy()).build(), baseUrl);
+    }
+
+    public AbstractHtmlClientImpl(String baseUrl, String user, String password) throws URISyntaxException {
+        this.baseUrl = new URI(baseUrl);
+        HttpHost targetHost = URIUtils.extractHost(this.baseUrl);
+        BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
+        credsProvider.setCredentials(
+                new AuthScope(targetHost.getHostName(), targetHost.getPort()),
+                new UsernamePasswordCredentials(user, password));
+        this.client = HttpClientBuilder.create()
+                .setDefaultCredentialsProvider(credsProvider)
+                .setRedirectStrategy(new LaxRedirectStrategy())
+                .build();
+    }
+
+
+    @Override
+    public <T extends Document> T enter(String url) throws ClientException {
+        return get(url);
+    }
+
+    @Override
+    public <T extends Document> T get(String url) throws ClientException {
+        try {
+            URI absoluteUri = absoluteUri(url);
+            LOG.info("GET " + absoluteUri);
+            HttpResponse response = this.execute(new HttpGet(absoluteUri));
+            return newDocument(EntityUtils.toString(response.getEntity()));
+
+        } catch (URISyntaxException e) {
+            throw new ClientException("Invalid get url " + url, e);
+        } catch (Exception e) {
+            throw new ClientException("Could not execute GET request", e);
+        }
+    }
+
+    @Override
+    public <T extends Document> T post(String url, HttpEntity entity) throws ClientException {
+        try {
+            URI absoluteUri = absoluteUri(url);
+            LOG.info("POST " + absoluteUri);
+            HttpPost post = new HttpPost(absoluteUri);
+            post.setEntity(entity);
+            HttpResponse response = this.execute(post);
+            return newDocument(EntityUtils.toString(response.getEntity()));
+        } catch (URISyntaxException e) {
+            throw new ClientException("Invalid post url " + url, e);
+        } catch (Exception e) {
+            throw new ClientException("Could not execute POST request", e);
+        }
+    }
+
+    @Override
+    public <T extends Document> T delete(String url) throws ClientException {
+        try {
+            URI absoluteUri = absoluteUri(url);
+            LOG.info("DELETE " + absoluteUri);
+            HttpResponse response = this.execute(new HttpDelete(absoluteUri));
+            return newDocument(response.getEntity().toString());
+        } catch (URISyntaxException e) {
+            throw new ClientException("Invalid post url " + url, e);
+        } catch (Exception e) {
+            throw new ClientException("Could not execute DELETE request", e);
+        }
+    }
+
+    @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
+     */
+    @Override
+    public HttpParams getParams() {
+        return client.getParams();
+    }
+
+    @Override
+    public ClientConnectionManager getConnectionManager() {
+        return client.getConnectionManager();
+    }
+
+    @Override
+    public HttpResponse execute(HttpUriRequest httpUriRequest) throws IOException, ClientProtocolException {
+        return client.execute(httpUriRequest);
+    }
+
+    @Override
+    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 {
+        return client.execute(httpHost, httpRequest);
+    }
+
+    @Override
+    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 {
+        return client.execute(httpUriRequest, responseHandler);
+    }
+
+    @Override
+    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 {
+        return client.execute(httpHost, httpRequest, responseHandler);
+    }
+
+    @Override
+    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/microdata/MicrodataDocument.java b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
new file mode 100644
index 0000000..2f6ee91
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
@@ -0,0 +1,399 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.microdata;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.NameValuePair;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.sling.hapi.client.*;
+import org.apache.sling.hapi.client.forms.FormValues;
+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;
+
+    public MicrodataDocument(String html, HtmlClient client, String baseUrl) {
+        this.jsoupDocument = Jsoup.parse(html, baseUrl);
+        this.client = client;
+    }
+
+
+    @Override
+    public Items link(String rel) throws ClientException {
+        Item me = toItem(jsoupDocument);
+        return me.link(rel);
+    }
+
+    @Override
+    public Items form(String rel) throws ClientException {
+        Item me = toItem(jsoupDocument);
+        return me.form(rel);
+    }
+
+    @Override
+    public Items item(String rel) {
+        List<Item> items = new ArrayList<Item>();
+
+        for (Item i : items()) {
+            if (((ItemImpl) i).el.hasClass(rel)) {
+                items.add(i);
+            }
+        }
+
+        return new ItemsImpl(items);
+    }
+
+    @Override
+    public Items items() {
+        return new ItemsImpl(selectItems(jsoupDocument, new ArrayList<Item>()));
+    }
+
+    @Override
+    public String toString() {
+        return this.jsoupDocument.toString();
+    }
+
+    private String toClass(String name) {
+        return "." + name;
+    }
+
+    private List<Item> toItems(Elements el) {
+        List<Item> items = new ArrayList<Item>();
+
+        for (Element e : el) {
+            items.add(toItem(e));
+        }
+
+        return items;
+    }
+
+    private Item toItem(Element el) {
+        return new ItemImpl(el, this);
+    }
+
+    private List<Item> selectItems(Element e, List<Item> items) {
+        if (e.hasAttr("itemscope") && !e.hasAttr("itemprop")) {
+            items.add(new ItemImpl(e, this));
+            return items;
+        }
+
+        for (Element c : e.children()) {
+            selectItems(c, items);
+        }
+
+        return items;
+    }
+
+
+    private class ItemImpl implements Item {
+
+        private Element el;
+        private MicrodataDocument document;
+        private ItemImpl followed;
+
+        public ItemImpl(Element element, MicrodataDocument document) {
+            if (element == null) throw new NullPointerException("element is mandatory");
+            this.el = element;
+            this.document = document;
+        }
+
+        @Override
+        public Items prop(String name) throws ClientException {
+            return new ItemsImpl(selectProps(getProxy().el, name, new ArrayList<Item>()));
+        }
+
+        @Override
+        public Set<String> props() throws ClientException {
+            return selectAllPropNames(getProxy().el, new HashSet<String>());
+        }
+
+        @Override
+        public Items link(String rel) throws ClientException {
+            return new ItemsImpl(toItems(getProxy().el.select("link[rel=" + rel + "], a[rel=" + rel + "]")));
+        }
+
+        @Override
+        public Items form(String rel) throws ClientException {
+            return new ItemsImpl(toItems(getProxy().el.select("form[data-rel=" + rel + "]")));
+        }
+
+
+        /* Private methods */
+
+        private List<Item> selectProps(Element e, String name, List<Item> items) {
+            for (Element c : e.children()) {
+                if (c.hasAttr("itemprop")) {
+                    if (c.attr("itemprop").equals(name)) {
+                        items.add(new ItemImpl(c, document));
+                    }
+
+                    if (c.hasAttr("itemscope")) {
+                        continue;
+                    }
+                }
+
+                selectProps(c, name, items);
+            }
+
+            return items;
+        }
+
+        private Set<String> selectAllPropNames(Element e, Set<String> items) {
+            for (Element c : e.children()) {
+                if (c.hasAttr("itemprop")) {
+                    items.add(c.attr("itemprop"));
+                }
+
+                if (c.hasAttr("itemscope")) {
+                        continue;
+                }
+
+                selectAllPropNames(c, items);
+            }
+            return items;
+        }
+
+        private ItemImpl getProxy() throws ClientException {
+            if (el.tagName().equalsIgnoreCase("a") && el.hasAttr("href")) {
+                if (followed == null) {
+                    followed = follow(el, document);
+                }
+                return followed;
+            }
+
+            return this;
+        }
+
+        private ItemImpl follow(Element el, MicrodataDocument doc) throws ClientException {
+            if (el.hasAttr("itemscope")) {
+                return new ItemImpl(el, doc);
+            }
+
+            if (el.tagName().equalsIgnoreCase("a") && el.hasAttr("href")) {
+                String href = el.attr("href");
+
+                if (href.startsWith("#")) {
+                    Element first = el.ownerDocument().select(href).first();
+                    return first == null ? null : follow(first, doc);
+                }
+
+                String absHref = el.attr("abs:href");
+                MicrodataDocument d = (MicrodataDocument) doc.client.get(absHref);
+
+                try {
+                    URI uri = new URI(absHref);
+
+                    String fragment = uri.getRawFragment();
+                    if (fragment != null) {
+                        Element e = d.jsoupDocument.getElementById(fragment);
+                        return e == null ? null : follow(e, d);
+                    }
+                } catch (URISyntaxException ex) {
+                    throw new ClientException("Error parsing URI: " + absHref, ex);
+                }
+
+                ItemsImpl items = (ItemsImpl) d.items();
+
+                if (items.length() == 1) {
+                    return (ItemImpl) items.at(0);
+                }
+
+                throw new ClientException("Unable determine item: " + absHref);
+            }
+
+            return new ItemImpl(el, doc);
+        }
+
+        @Override
+        public String text() throws ClientException {
+            // resolve element
+            Element el = getProxy().el;
+
+            // if it's a meta, get the value of the content attr
+            if (el.tagName().equalsIgnoreCase("meta") && el.hasAttr("content")) {
+                return el.attr("content");
+            }
+
+            // else, get the text value using jsoup
+            return getProxy().el.text();
+        }
+
+        @Override
+        public boolean bool() throws ClientException {
+            return Boolean.parseBoolean(text());
+        }
+
+        @Override
+        public int number() throws ClientException {
+            return Integer.parseInt(text());
+        }
+
+        @Override
+        public String href() {
+            return el.attr("href");
+        }
+
+        @Override
+        public String src() {
+            return el.attr("src");
+        }
+
+        @Override
+        public Document follow() throws ClientException {
+            if ((el.tagName().equalsIgnoreCase("a") || el.tagName().equalsIgnoreCase("link")) && el.hasAttr("href")) {
+                String href = el.attr("href");
+
+                if (href.startsWith("#")) {
+                    return document;
+                }
+
+                return document.client.enter(el.attr("abs:href"));
+            }
+
+            throw new ClientException("Unable to follow: " + el.toString());
+        }
+
+        @Override
+        public Document submit(Iterable<NameValuePair> values) throws ClientException {
+            if (el.tagName().equalsIgnoreCase("form")) {
+                String action = el.attr("abs:action");
+                if (action.length() == 0) {
+                    action = el.baseUri();
+                }
+
+                String method = el.attr("method");
+
+                if (method.length() == 0 || method.equalsIgnoreCase("get")) {
+                    FormValues query = new FormValues(el, values);
+                    String url = action + (action.contains("?") ? "?" : "&") + query.toString();
+                    return document.client.enter(url);
+                }
+
+                if (method.equalsIgnoreCase("post")) {
+                    String enctype = el.attr("enctype");
+
+                    FormValues v = new FormValues(el, values);
+                    if (enctype.length() == 0 || enctype.equalsIgnoreCase("application/x-www-form-urlencoded")) {
+                        return document.client.post(action, v.toUrlEncodedEntity());
+                    } else if (enctype.equalsIgnoreCase("multipart/form-data")) {
+                        return document.client.post(action, v.toMultipartEntity());
+                    }
+
+                    throw new ClientException("Unsupported form enctype: " + enctype);
+                }
+
+                throw new ClientException("Unsupported form method: " + method);
+            }
+
+            throw new ClientException("The item is not a form");
+        }
+
+
+    }
+
+    /**
+     * Items impl for microdata
+     */
+    private class ItemsImpl implements Items {
+        private List<Item> items;
+
+        public ItemsImpl(List<Item> items) {
+            this.items = items;
+        }
+
+        @Override
+        public Iterator<Item> iterator() {
+            return items.iterator();
+        }
+
+        @Override
+        public Item at(int index) {
+            return items.get(index);
+        }
+
+        @Override
+        public int length() {
+            return items.size();
+        }
+
+        @Override
+        public Items prop(String name) throws ClientException {
+            return items.get(0).prop(name);
+        }
+
+        @Override
+        public Set<String> props() throws ClientException {
+            return items.get(0).props();
+        }
+
+        @Override
+        public Items link(String rel) throws ClientException {
+            return items.get(0).link(rel);
+        }
+
+        @Override
+        public Items form(String rel) throws ClientException {
+            return items.get(0).form(rel);
+        }
+
+        @Override
+        public String text() throws ClientException {
+            return items.get(0).text();
+        }
+
+        @Override
+        public boolean bool() throws ClientException {
+            return items.get(0).bool();
+        }
+
+        @Override
+        public int number() throws ClientException {
+            return items.get(0).number();
+        }
+
+        @Override
+        public String href() {
+            return items.get(0).href();
+        }
+
+        @Override
+        public String src() {
+            return items.get(0).src();
+        }
+
+        @Override
+        public Document follow() throws ClientException {
+            return items.get(0).follow();
+        }
+
+        @Override
+        public Document submit(Iterable<NameValuePair> values) throws ClientException {
+            return items.get(0).submit(values);
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
new file mode 100644
index 0000000..807067a
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.microdata;
+
+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 {
+        super(client, baseUrl);
+    }
+
+    public MicrodataHtmlClient(String baseUrl) throws URISyntaxException {
+        super(baseUrl);
+    }
+
+    public MicrodataHtmlClient(String baseUrl, String user, String password) throws URISyntaxException {
+        super(baseUrl, user, password);
+    }
+
+    @Override
+    public MicrodataDocument newDocument(String html) {
+        return new MicrodataDocument(html, this, this.baseUrl.toString());
+    }
+}
diff --git a/src/test/java/FormTest.java b/src/test/java/FormTest.java
new file mode 100644
index 0000000..3c9424d
--- /dev/null
+++ b/src/test/java/FormTest.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ ******************************************************************************/
+
+import org.apache.commons.io.IOUtils;
+import org.apache.http.*;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.localserver.LocalServerTestBase;
+import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.sling.hapi.client.ClientException;
+import org.apache.sling.hapi.client.Document;
+import org.apache.sling.hapi.client.Items;
+import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+
+
+public class FormTest extends LocalServerTestBase {
+    public static final String GET_URL = "/test1";
+    public static final String POST_URL = "/testpost1";
+    public static final String OK_RESPONSE = "TEST_OK";
+    public static final String FAIL_RESPONSE = "TEST_FAIL";
+
+    public static String html;
+
+    private HttpHost host;
+    private URI uri;
+
+    @BeforeClass
+    public static void setUpClass() throws IOException {
+        FormTest.html = IOUtils.toString(ItemsTest.class.getResourceAsStream("items_forms.html"), "UTF-8");
+    }
+
+    @Before
+    public void setup() throws Exception {
+        super.setUp();
+        this.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(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);
+            }
+        });
+
+        // start server
+        this.host = this.start();
+        this.uri = URIUtils.rewriteURI(new URI("/"), host);
+    }
+
+    @Test
+    public void testForm() throws ClientException, URISyntaxException {
+        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString());
+        Document doc = client.enter(GET_URL);
+        Items items = doc.items();
+        Assert.assertThat(items.length(), equalTo(1));
+        Items form = doc.form("test");
+        Assert.assertThat(form.length(), equalTo(2));
+
+        List<NameValuePair> data = new ArrayList<NameValuePair>();
+        data.add(new BasicNameValuePair("f1", "val1"));
+
+        // url encode enctype
+        Document doc2 = form.at(0).submit(data);
+        Assert.assertThat(doc2.items().length(), equalTo(1));
+
+        // the multipart enctype
+        Document doc3 = form.at(1).submit(data);
+        Assert.assertThat(doc3.items().length(), equalTo(1));
+
+
+
+    }
+}
diff --git a/src/test/java/GetPostTest.java b/src/test/java/GetPostTest.java
new file mode 100644
index 0000000..e45b8b1
--- /dev/null
+++ b/src/test/java/GetPostTest.java
@@ -0,0 +1,111 @@
+
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ ******************************************************************************/
+
+import org.apache.http.*;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.localserver.LocalServerTestBase;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.sling.hapi.client.ClientException;
+import org.apache.sling.hapi.client.Document;
+import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.hamcrest.core.StringContains;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.hamcrest.core.StringContains.containsString;
+
+public class GetPostTest extends LocalServerTestBase {
+    public static final String GET_URL = "/test";
+    public static final String GET_AUTH_URL = "/testauth";
+    public static final String OK_RESPONSE = "TEST_OK";
+    public static final String FAIL_RESPONSE = "TEST_FAIL";
+    public static final String USER = "admin";
+    private static final String PASSWORD = "admin";
+    private static final String AUTH_STRING = "Basic YWRtaW46YWRtaW4=";
+    private static final String REDIRECT_URL = "/test_redirect";
+
+
+    private HttpHost host;
+    private URI uri;
+
+    @Before
+    public void setup() throws Exception {
+        super.setUp();
+        this.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);
+            }
+        });
+
+        // start server
+        this.host = this.start();
+        this.uri = URIUtils.rewriteURI(new URI("/"), host);
+    }
+
+    @Test
+    public void testValidGet() throws ClientException, URISyntaxException {
+        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString());
+        Document doc = client.get(GET_URL);
+        Assert.assertThat("GET request failed", doc.toString(), new StringContains(OK_RESPONSE));
+    }
+
+    @Test
+    public void testValidAuthGet() throws ClientException, URISyntaxException {
+        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString(), USER, PASSWORD);
+        Document doc = client.get(GET_AUTH_URL);
+        Assert.assertThat("GET request failed with basic auth", doc.toString(), containsString(OK_RESPONSE));
+    }
+
+    @Test
+    public void testRedirect() throws ClientException, URISyntaxException, UnsupportedEncodingException {
+        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString(), USER, PASSWORD);
+        Document doc = client.post(REDIRECT_URL, new StringEntity("test"));
+        Assert.assertThat("POST request failed to redirect", doc.toString(), containsString(OK_RESPONSE));
+    }
+
+}
diff --git a/src/test/java/ItemsTest.java b/src/test/java/ItemsTest.java
new file mode 100644
index 0000000..9e0b962
--- /dev/null
+++ b/src/test/java/ItemsTest.java
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ ******************************************************************************/
+
+import org.apache.commons.io.IOUtils;
+import org.apache.http.*;
+import org.apache.http.client.utils.URIUtils;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.localserver.LocalServerTestBase;
+import org.apache.http.protocol.HttpContext;
+import org.apache.http.protocol.HttpRequestHandler;
+import org.apache.sling.hapi.client.ClientException;
+import org.apache.sling.hapi.client.Document;
+import org.apache.sling.hapi.client.Items;
+import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.hamcrest.core.IsEqual.equalTo;
+
+
+public class ItemsTest extends LocalServerTestBase {
+    public static final String GET_URL = "/test";
+    public static final String GET_LINKS_URL = "/testlinks";
+    public static final String OK_RESPONSE = "TEST_OK";
+    public static final String FAIL_RESPONSE = "TEST_FAIL";
+
+    public static String html;
+    public static String htmlLinks;
+
+    private HttpHost host;
+    private URI uri;
+
+    @BeforeClass
+    public static void setUpClass() throws IOException {
+        ItemsTest.html = IOUtils.toString(ItemsTest.class.getResourceAsStream("items.html"), "UTF-8");
+        ItemsTest.htmlLinks = IOUtils.toString(ItemsTest.class.getResourceAsStream("items_links.html"), "UTF-8");
+    }
+
+    @Before
+    public void setup() throws Exception {
+        super.setUp();
+        this.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);
+            }
+        });
+
+        // start server
+        this.host = this.start();
+        this.uri = URIUtils.rewriteURI(new URI("/"), host);
+    }
+
+    @Test
+    public void testItems() throws ClientException, URISyntaxException {
+        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString());
+        Document doc = client.enter(GET_URL);
+        Items items = doc.items();
+        Assert.assertThat(items.length(), equalTo(2));
+        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));
+            Assert.assertThat(items.at(i).prop("director").prop("name").text(), equalTo("James Cameron" + i));
+            Assert.assertThat(items.at(i).prop("director").prop("birthDate").text(), equalTo("August 16, 1954 - " + i));
+        }
+    }
+
+    @Test
+    public void testItemsLinks() throws ClientException, URISyntaxException {
+        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString());
+        Document doc = client.enter(GET_LINKS_URL);
+        Items items = doc.items();
+        Assert.assertThat(items.length(), equalTo(1));
+        Assert.assertThat(items.prop("name").text(), equalTo("Avatar"));
+        Assert.assertThat(items.prop("genre").text(), equalTo("Science fiction"));
+        Assert.assertThat(items.prop("rank").number(), equalTo(2));
+        Assert.assertThat(items.prop("director").prop("name").text(), equalTo("James Cameron"));
+        Assert.assertThat(items.prop("director").prop("birthDate").text(), equalTo("August 16, 1954"));
+
+        Assert.assertThat(doc.link("test").length(), equalTo(2));
+        Assert.assertThat(doc.items().link("test").length(), equalTo(1));
+        Assert.assertThat(doc.items().prop("director").link("test").length(), equalTo(1));
+
+        Items otherMovies = doc.link("test").follow().items();
+        Assert.assertThat(otherMovies.length(), equalTo(2));
+
+    }
+
+}
diff --git a/src/test/resources/items.html b/src/test/resources/items.html
new file mode 100644
index 0000000..abe5d78
--- /dev/null
+++ b/src/test/resources/items.html
@@ -0,0 +1,24 @@
+<html>
+<head>
+</head>
+</html>
+<body>
+<div itemscope itemtype ="http://schema.org/Movie">
+    <h1 itemprop="name">Avatar0</h1>
+    <div itemprop="director" itemscope itemtype="http://schema.org/Person">
+        Director: <span itemprop="name" itemscope itemtype="text">James Cameron0</span>
+        (born <span itemprop="birthDate" itemscope itemtype="text">August 16, 1954 - 0</span>)
+    </div>
+    <span itemprop="genre" itemscope itemtype="text">Science fiction0</span>
+    <span itemprop="rank" itemscope="true" itemtype="number">0</span>
+</div>
+<div itemscope itemtype ="http://schema.org/Movie">
+    <h1 itemprop="name">Avatar1</h1>
+    <div itemprop="director" itemscope itemtype="http://schema.org/Person">
+        Director: <span itemprop="name">James Cameron1</span> (born <span itemprop="birthDate">August 16, 1954 - 1</span>)
+    </div>
+    <span itemprop="genre">Science fiction1</span>
+    <span itemprop="rank">1</span>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/src/test/resources/items_forms.html b/src/test/resources/items_forms.html
new file mode 100644
index 0000000..fd14eb1
--- /dev/null
+++ b/src/test/resources/items_forms.html
@@ -0,0 +1,28 @@
+<html>
+<head>
+</head>
+</html>
+<body>
+<div itemscope itemtype ="http://schema.org/Movie">
+    <h1 itemprop="name">Avatar</h1>
+    <div itemprop="director" itemscope itemtype="http://schema.org/Person">
+        Director: <span itemprop="name" itemscope itemtype="text">James Cameron</span>
+        (born <span itemprop="birthDate" itemscope itemtype="text">August 16, 1954</span>)
+        <p>Also directed: <a rel="test" href="/test">test</a></p>
+    </div>
+    <span itemprop="genre" itemscope itemtype="text">Science fiction</span>
+    <span itemprop="rank" itemscope="true" itemtype="number">2</span>
+</div>
+<div>
+    <form data-rel="test" action="/testpost1" method="post">
+        <input type="text" name="f1" value="default1">
+        <textarea name="f2">val2</textarea>
+    </form>
+
+    <form data-rel="test" action="/testpost1" method="post" enctype="multipart/form-data">
+        <input type="text" name="f1" value="default1">
+        <textarea name="f2">val2</textarea>
+    </form>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/src/test/resources/items_links.html b/src/test/resources/items_links.html
new file mode 100644
index 0000000..1586116
--- /dev/null
+++ b/src/test/resources/items_links.html
@@ -0,0 +1,20 @@
+<html>
+<head>
+</head>
+</html>
+<body>
+<div itemscope itemtype ="http://schema.org/Movie">
+    <h1 itemprop="name">Avatar</h1>
+    <div itemprop="director" itemscope itemtype="http://schema.org/Person">
+        Director: <span itemprop="name" itemscope itemtype="text">James Cameron</span>
+        (born <span itemprop="birthDate" itemscope itemtype="text">August 16, 1954</span>)
+        <p>Also directed: <a rel="test" href="/test">test</a></p>
+    </div>
+    <span itemprop="genre" itemscope itemtype="text">Science fiction</span>
+    <span itemprop="rank" itemscope="true" itemtype="number">2</span>
+</div>
+<div>
+    <a rel="test" href="/test">test</a>
+</div>
+</body>
+</html>
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 07/24: hapi: add license headers to test resources

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 746dab306b8a0954cc8555ddbe3f17e216c49192
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Wed Jan 27 13:42:59 2016 +0000

    hapi: add license headers to test resources
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1727051 13f79535-47bb-0310-9956-ffa450edef68
---
 src/test/resources/items.html       | 20 +++++++++++++++++++-
 src/test/resources/items_forms.html | 20 +++++++++++++++++++-
 src/test/resources/items_links.html | 20 +++++++++++++++++++-
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/src/test/resources/items.html b/src/test/resources/items.html
index abe5d78..7650bd9 100644
--- a/src/test/resources/items.html
+++ b/src/test/resources/items.html
@@ -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.
+-->
 <html>
 <head>
 </head>
@@ -21,4 +39,4 @@
     <span itemprop="rank">1</span>
 </div>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/src/test/resources/items_forms.html b/src/test/resources/items_forms.html
index fd14eb1..e9e52d7 100644
--- a/src/test/resources/items_forms.html
+++ b/src/test/resources/items_forms.html
@@ -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.
+-->
 <html>
 <head>
 </head>
@@ -25,4 +43,4 @@
     </form>
 </div>
 </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/src/test/resources/items_links.html b/src/test/resources/items_links.html
index 1586116..f318962 100644
--- a/src/test/resources/items_links.html
+++ b/src/test/resources/items_links.html
@@ -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.
+-->
 <html>
 <head>
 </head>
@@ -17,4 +35,4 @@
     <a rel="test" href="/test">test</a>
 </div>
 </body>
-</html>
\ No newline at end of file
+</html>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 14/24: SLING-5880 [hapi client] Make org.apache.sling.hapi.client into a bundle

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 313573a41ccb19edc144687220863f0d6c718792
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Tue Aug 9 07:47:02 2016 +0000

    SLING-5880 [hapi client] Make org.apache.sling.hapi.client into a bundle
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755563 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            | 33 +++++++--
 ...odataHtmlClient.java => HtmlClientService.java} | 31 ++------
 .../package-info.java}                             | 31 ++------
 .../hapi/client/impl/HtmlClientServiceImpl.java    | 82 ++++++++++++++++++++++
 .../{ => impl}/microdata/MicrodataDocument.java    |  2 +-
 .../{ => impl}/microdata/MicrodataHtmlClient.java  |  2 +-
 .../MicrodataHtmlClient.java => package-info.java} | 31 ++------
 .../apache/sling/hapi/client/test/FormTest.java    |  2 +-
 .../apache/sling/hapi/client/test/GetPostTest.java |  2 +-
 .../apache/sling/hapi/client/test/ItemsTest.java   |  2 +-
 10 files changed, 131 insertions(+), 87 deletions(-)

diff --git a/pom.xml b/pom.xml
index 249f1ac..c4e0735 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,8 @@
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
@@ -43,6 +44,30 @@
         <sling.java.version>6</sling.java.version>
     </properties>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <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>
@@ -68,12 +93,12 @@
         <dependency>
             <groupId>org.jsoup</groupId>
             <artifactId>jsoup</artifactId>
-            <version>1.8.3</version>
+            <version>1.9.2</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
-            <version>1.7.12</version>
+            <version>1.7.21</version>
         </dependency>
         <!-- test scope -->
         <dependency>
@@ -86,7 +111,7 @@
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
-            <version>1.7.12</version>
+            <version>1.7.21</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
similarity index 53%
copy from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
copy to src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
index 807067a..bedf01d 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
+++ b/src/main/java/org/apache/sling/hapi/client/HtmlClientService.java
@@ -6,9 +6,9 @@
  * 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>
+ * <p/>
  * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ * <p/>
  * 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
@@ -16,29 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  ******************************************************************************/
-package org.apache.sling.hapi.client.microdata;
+package org.apache.sling.hapi.client;
 
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl;
+public interface HtmlClientService {
 
-import java.net.URISyntaxException;
-
-public class MicrodataHtmlClient extends AbstractHtmlClientImpl {
-
-    public MicrodataHtmlClient(CloseableHttpClient client, String baseUrl) throws URISyntaxException {
-        super(client, baseUrl);
-    }
-
-    public MicrodataHtmlClient(String baseUrl) throws URISyntaxException {
-        super(baseUrl);
-    }
-
-    public MicrodataHtmlClient(String baseUrl, String user, String password) throws URISyntaxException {
-        super(baseUrl, user, password);
-    }
-
-    @Override
-    public MicrodataDocument newDocument(String html) {
-        return new MicrodataDocument(html, this, this.baseUrl.toString());
-    }
-}
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/forms/package-info.java
similarity index 53%
copy from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
copy to src/main/java/org/apache/sling/hapi/client/forms/package-info.java
index 807067a..8003994 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/package-info.java
@@ -6,9 +6,9 @@
  * 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>
+ *
  * 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
@@ -16,29 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  ******************************************************************************/
-package org.apache.sling.hapi.client.microdata;
 
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl;
+@Version("1.0.0")
+package org.apache.sling.hapi.client.forms;
 
-import java.net.URISyntaxException;
-
-public class MicrodataHtmlClient extends AbstractHtmlClientImpl {
-
-    public MicrodataHtmlClient(CloseableHttpClient client, String baseUrl) throws URISyntaxException {
-        super(client, baseUrl);
-    }
-
-    public MicrodataHtmlClient(String baseUrl) throws URISyntaxException {
-        super(baseUrl);
-    }
-
-    public MicrodataHtmlClient(String baseUrl, String user, String password) throws URISyntaxException {
-        super(baseUrl, user, password);
-    }
-
-    @Override
-    public MicrodataDocument newDocument(String html) {
-        return new MicrodataDocument(html, this, this.baseUrl.toString());
-    }
-}
+import aQute.bnd.annotation.Version;
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
new file mode 100644
index 0000000..a684d1d
--- /dev/null
+++ b/src/main/java/org/apache/sling/hapi/client/impl/HtmlClientServiceImpl.java
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.impl;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.sling.hapi.client.HtmlClient;
+import org.apache.sling.hapi.client.HtmlClientService;
+import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URISyntaxException;
+
+@Component(metatype = false)
+@Service(value = HtmlClientService.class)
+public class HtmlClientServiceImpl implements HtmlClientService {
+
+    private final Logger LOG = LoggerFactory.getLogger(HtmlClientService.class);
+
+    /**
+     * Get the HtmlClient
+     * @param client The inner http client
+     * @param baseUrl the base URL as String
+     * @return the HtmlClient or null if there was an error
+     */
+    public HtmlClient getClient(CloseableHttpClient client, String baseUrl) {
+        try {
+            return new MicrodataHtmlClient(client, baseUrl);
+        } catch (URISyntaxException e) {
+            LOG.error("Cannot instantiate client", e);
+            return null;
+        }
+    }
+
+    /**
+     * {@see HtmlClient}
+     * @param baseUrl the base URL as String
+     * @return the HtmlClient or null if there was an error
+     */
+    public HtmlClient getClient(String baseUrl) {
+        try {
+            return new MicrodataHtmlClient(baseUrl);
+        } catch (URISyntaxException e) {
+            LOG.error("Cannot instantiate client", e);
+            return null;
+        }
+    }
+
+    /**
+     * {@see HtmlClient}
+     * @param baseUrl the base URL as String
+     * @param user the username to be used for basic auth
+     * @param password the password to be used for basic auth
+     * @return the HtmlClient or null if there was an error
+     */
+    public HtmlClient getClient(String baseUrl, String user, String password) {
+        try {
+            return new MicrodataHtmlClient(baseUrl, user, password);
+        } catch (URISyntaxException e) {
+            LOG.error("Cannot instantiate client", e);
+            return null;
+        }
+    }
+}
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java
similarity index 99%
rename from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
rename to src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java
index 22539df..248887d 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
+++ b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java
@@ -17,7 +17,7 @@
  * under the License.
  ******************************************************************************/
 
-package org.apache.sling.hapi.client.microdata;
+package org.apache.sling.hapi.client.impl.microdata;
 
 import org.apache.http.NameValuePair;
 import org.apache.sling.hapi.client.*;
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java
similarity index 97%
copy from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
copy to src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java
index 807067a..c09eb3e 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
+++ b/src/main/java/org/apache/sling/hapi/client/impl/microdata/MicrodataHtmlClient.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  ******************************************************************************/
-package org.apache.sling.hapi.client.microdata;
+package org.apache.sling.hapi.client.impl.microdata;
 
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl;
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java b/src/main/java/org/apache/sling/hapi/client/package-info.java
similarity index 53%
rename from src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
rename to src/main/java/org/apache/sling/hapi/client/package-info.java
index 807067a..c15121e 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataHtmlClient.java
+++ b/src/main/java/org/apache/sling/hapi/client/package-info.java
@@ -6,9 +6,9 @@
  * 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>
+ *
  * 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
@@ -16,29 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  ******************************************************************************/
-package org.apache.sling.hapi.client.microdata;
 
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.sling.hapi.client.impl.AbstractHtmlClientImpl;
+@Version("1.0.0")
+package org.apache.sling.hapi.client;
 
-import java.net.URISyntaxException;
-
-public class MicrodataHtmlClient extends AbstractHtmlClientImpl {
-
-    public MicrodataHtmlClient(CloseableHttpClient client, String baseUrl) throws URISyntaxException {
-        super(client, baseUrl);
-    }
-
-    public MicrodataHtmlClient(String baseUrl) throws URISyntaxException {
-        super(baseUrl);
-    }
-
-    public MicrodataHtmlClient(String baseUrl, String user, String password) throws URISyntaxException {
-        super(baseUrl, user, password);
-    }
-
-    @Override
-    public MicrodataDocument newDocument(String html) {
-        return new MicrodataDocument(html, this, this.baseUrl.toString());
-    }
-}
+import aQute.bnd.annotation.Version;
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 5d9b675..9cfc73b 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
@@ -39,7 +39,7 @@ import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.sling.hapi.client.ClientException;
 import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
-import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient;
 import org.apache.sling.hapi.client.test.util.HttpServerRule;
 import org.junit.Assert;
 import org.junit.ClassRule;
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 4e9b158..3f457c4 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
@@ -35,7 +35,7 @@ import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.sling.hapi.client.ClientException;
 import org.apache.sling.hapi.client.Document;
-import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient;
 import org.apache.sling.hapi.client.test.util.HttpServerRule;
 import org.hamcrest.core.StringContains;
 import org.junit.Assert;
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 66561db..e43394e 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
@@ -35,7 +35,7 @@ import org.apache.http.protocol.HttpRequestHandler;
 import org.apache.sling.hapi.client.ClientException;
 import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
-import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
+import org.apache.sling.hapi.client.impl.microdata.MicrodataHtmlClient;
 import org.apache.sling.hapi.client.test.util.HttpServerRule;
 import org.junit.Assert;
 import org.junit.ClassRule;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 22/24: reverted hapi release

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit e3448b7720843d42234c93baca66d7a283bb2ab8
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Aug 10 14:50:39 2016 +0000

    reverted hapi release
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755760 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  2 +-
 .../hapi/client/forms/internal/package-info.java   | 23 ----------------------
 2 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/pom.xml b/pom.xml
index c89f338..608fd8c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.0-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/internal/package-info.java b/src/main/java/org/apache/sling/hapi/client/forms/internal/package-info.java
deleted file mode 100644
index c63c9d0..0000000
--- a/src/main/java/org/apache/sling/hapi/client/forms/internal/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- ******************************************************************************/
-
-@Version("1.0.0")
-package org.apache.sling.hapi.client.forms.internal;
-
-import aQute.bnd.annotation.Version;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 05/24: SLING-5136 - use numeric localhost address, the string might not work in some environments

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 7bb773c563c65f08d06634ec2b7d8bd55db74ed1
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Oct 13 12:00:41 2015 +0000

    SLING-5136 - use numeric localhost address, the string might not work in some environments
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1708360 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/hapi/client/test/util/HttpServerRule.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 4e1b069..da42c16 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
@@ -71,7 +71,7 @@ public class HttpServerRule extends ExternalResource {
         registerHandlers();
         server = serverBootstrap.create();
         server.start();
-        host = new HttpHost("localhost", server.getLocalPort(), protocolScheme.name());
+        host = new HttpHost("127.0.0.1", server.getLocalPort(), protocolScheme.name());
         uri = URIUtils.rewriteURI(new URI("/"), host);
     }
     

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 09/24: [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 27a1a4d5a63d19128da2c59fd2737e8f9ae2d5e3
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Jul 13 14:23:16 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.hapi.client-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1752436 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9d95953..ac70daf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,19 +17,18 @@
 ~ 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>20</version>
-        <relativePath/>
+        <relativePath />
     </parent>
 
     <artifactId>org.apache.sling.hapi.client</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
 
     <name>HApi - Sling Hypermedia API client-side tools</name>
     <description>Sling client-side tools for HApi</description>
@@ -94,4 +93,10 @@
         </dependency>
     </dependencies>
 
+
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0</developerConnection>
+    <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.hapi.client-1.0.0</url>
+  </scm>
 </project>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 21/24: SLING-5880 made forms package internal

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 00f59abbe9e966865fe8eadee8f8b8af263f9d41
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Aug 10 14:30:13 2016 +0000

    SLING-5880 made forms package internal
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1755756 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/hapi/client/forms/{impl => internal}/FormValues.java   | 2 +-
 .../org/apache/sling/hapi/client/forms/{impl => internal}/Vals.java     | 2 +-
 .../apache/sling/hapi/client/forms/{impl => internal}/package-info.java | 2 +-
 .../org/apache/sling/hapi/client/impl/microdata/MicrodataDocument.java  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/hapi/client/forms/impl/FormValues.java b/src/main/java/org/apache/sling/hapi/client/forms/internal/FormValues.java
similarity index 98%
rename from src/main/java/org/apache/sling/hapi/client/forms/impl/FormValues.java
rename to src/main/java/org/apache/sling/hapi/client/forms/internal/FormValues.java
index c8811ac..4d894c5 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/impl/FormValues.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/internal/FormValues.java
@@ -17,7 +17,7 @@
  * under the License.
  ******************************************************************************/
 
-package org.apache.sling.hapi.client.forms.impl;
+package org.apache.sling.hapi.client.forms.internal;
 
 import java.io.UnsupportedEncodingException;
 
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/impl/Vals.java b/src/main/java/org/apache/sling/hapi/client/forms/internal/Vals.java
similarity index 97%
rename from src/main/java/org/apache/sling/hapi/client/forms/impl/Vals.java
rename to src/main/java/org/apache/sling/hapi/client/forms/internal/Vals.java
index 13f9454..adff0a8 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/impl/Vals.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/internal/Vals.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  ******************************************************************************/
-package org.apache.sling.hapi.client.forms.impl;
+package org.apache.sling.hapi.client.forms.internal;
 
 import org.apache.http.NameValuePair;
 
diff --git a/src/main/java/org/apache/sling/hapi/client/forms/impl/package-info.java b/src/main/java/org/apache/sling/hapi/client/forms/internal/package-info.java
similarity index 95%
rename from src/main/java/org/apache/sling/hapi/client/forms/impl/package-info.java
rename to src/main/java/org/apache/sling/hapi/client/forms/internal/package-info.java
index 05b7d76..c63c9d0 100644
--- a/src/main/java/org/apache/sling/hapi/client/forms/impl/package-info.java
+++ b/src/main/java/org/apache/sling/hapi/client/forms/internal/package-info.java
@@ -18,6 +18,6 @@
  ******************************************************************************/
 
 @Version("1.0.0")
-package org.apache.sling.hapi.client.forms.impl;
+package org.apache.sling.hapi.client.forms.internal;
 
 import aQute.bnd.annotation.Version;
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 84c9645..c60ca97 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
@@ -21,7 +21,7 @@ package org.apache.sling.hapi.client.impl.microdata;
 
 import org.apache.http.NameValuePair;
 import org.apache.sling.hapi.client.*;
-import org.apache.sling.hapi.client.forms.impl.FormValues;
+import org.apache.sling.hapi.client.forms.internal.FormValues;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 06/24: SLING-5390 - Allow HApi microdata client to fitler links and forms - contributed by Andrei Dulvac, thanks!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 24ff60ea046e7b8984364ef369f15bb59e3d5c12
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Dec 18 13:27:21 2015 +0000

    SLING-5390 - Allow HApi microdata client to fitler links and forms - contributed by Andrei Dulvac, thanks!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1720780 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/hapi/client/Item.java    | 10 ++++++++
 .../hapi/client/microdata/MicrodataDocument.java   | 28 ++++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)

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 f1d8865..fa74107 100644
--- a/src/main/java/org/apache/sling/hapi/client/Item.java
+++ b/src/main/java/org/apache/sling/hapi/client/Item.java
@@ -44,11 +44,21 @@ public interface Item {
     Items link(String rel) throws ClientException;
 
     /**
+     * Returns all the child links
+     */
+    Items link() throws ClientException;
+
+    /**
      * Returns the child forms that have the given relation
      */
     Items form(String rel) throws ClientException;
 
     /**
+     * Returns all the child forms
+     */
+    Items form() throws ClientException;
+
+    /**
      * Returns the text value of the property.
      */
     String text() throws ClientException;
diff --git a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
index 2f6ee91..e71df99 100644
--- a/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
+++ b/src/main/java/org/apache/sling/hapi/client/microdata/MicrodataDocument.java
@@ -133,12 +133,26 @@ public class MicrodataDocument implements Document {
 
         @Override
         public Items link(String rel) throws ClientException {
-            return new ItemsImpl(toItems(getProxy().el.select("link[rel=" + rel + "], a[rel=" + rel + "]")));
+            String selector = "link[rel=" + rel + "], a[rel=" + rel + "], link" + toClass(rel) + ", a" + toClass(rel);
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
+        }
+
+        @Override
+        public Items link() throws ClientException {
+            String selector = "link, a";
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
         }
 
         @Override
         public Items form(String rel) throws ClientException {
-            return new ItemsImpl(toItems(getProxy().el.select("form[data-rel=" + rel + "]")));
+            String selector = "form[data-rel=" + rel + "], form" + toClass(rel);
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
+        }
+
+        @Override
+        public Items form() throws ClientException {
+            String selector = "form";
+            return new ItemsImpl(toItems(getProxy().el.select(selector)));
         }
 
 
@@ -356,11 +370,21 @@ public class MicrodataDocument implements Document {
         }
 
         @Override
+        public Items link() throws ClientException {
+            return items.get(0).link();
+        }
+
+        @Override
         public Items form(String rel) throws ClientException {
             return items.get(0).form(rel);
         }
 
         @Override
+        public Items form() throws ClientException {
+            return items.get(0).form();
+        }
+
+        @Override
         public String text() throws ClientException {
             return items.get(0).text();
         }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 03/24: SLING-5136 - use a JUnit Rule to setup the HTTP server

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 55c08baed620dc3647907f8a1f56727750dfd529
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Oct 13 11:50:44 2015 +0000

    SLING-5136 - use a JUnit Rule to setup the HTTP server
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/hapi/client@1708357 13f79535-47bb-0310-9956-ffa450edef68
---
 src/test/java/FormTest.java                        | 113 ++++++++++-----------
 src/test/java/GetPostTest.java                     | 109 +++++++++-----------
 src/test/java/ItemsTest.java                       | 100 ++++++++----------
 .../util/{TestBase.java => HttpServerRule.java}    |  75 ++++++++------
 4 files changed, 190 insertions(+), 207 deletions(-)

diff --git a/src/test/java/FormTest.java b/src/test/java/FormTest.java
index c179b9b..e13c20f 100644
--- a/src/test/java/FormTest.java
+++ b/src/test/java/FormTest.java
@@ -17,9 +17,19 @@
  * under the License.
  ******************************************************************************/
 
+import static org.hamcrest.core.IsEqual.equalTo;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.commons.io.IOUtils;
-import org.apache.http.*;
-import org.apache.http.client.utils.URIUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.NameValuePair;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.message.BasicNameValuePair;
 import org.apache.http.protocol.HttpContext;
@@ -29,67 +39,49 @@ import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
 import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
-import util.TestBase;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.core.IsEqual.equalTo;
 
-
-public class FormTest extends TestBase {
-    public static final String GET_URL = "/test1";
-    public static final String POST_URL = "/testpost1";
-    public static final String OK_RESPONSE = "TEST_OK";
-    public static final String FAIL_RESPONSE = "TEST_FAIL";
-
-    public static String html;
-
-    private static HttpHost host;
-    private static URI uri;
-
-    @BeforeClass
-    public static void setUp() throws Exception {
-        FormTest.html = IOUtils.toString(ItemsTest.class.getResourceAsStream("items_forms.html"), "UTF-8");
-        setupServer();
-    }
-
-    public static void setupServer() throws Exception {
-        TestBase.setUp();
-        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(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));
+import util.HttpServerRule;
+
+public class FormTest {
+    private static final String GET_URL = "/test1";
+    private static final String POST_URL = "/testpost1";
+    private static final String OK_RESPONSE = "TEST_OK";
+    private static final String FAIL_RESPONSE = "TEST_FAIL";
+
+    @ClassRule
+    public static final HttpServerRule httpServer = new HttpServerRule() {
+
+        @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);
                 }
-                httpResponse.setStatusCode(302);
-                httpResponse.setHeader("Location", GET_URL);
-            }
-        });
-
-        // start server
-        host = TestBase.start();
-        uri = URIUtils.rewriteURI(new URI("/"), host);
-    }
-
+            }).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(uri.toString());
+        MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString());
         Document doc = client.enter(GET_URL);
         Items items = doc.items();
         Assert.assertThat(items.length(), equalTo(1));
@@ -106,8 +98,5 @@ public class FormTest extends TestBase {
         // the multipart enctype
         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/GetPostTest.java b/src/test/java/GetPostTest.java
index 23589b6..5b13112 100644
--- a/src/test/java/GetPostTest.java
+++ b/src/test/java/GetPostTest.java
@@ -18,8 +18,16 @@
  * under the License.
  ******************************************************************************/
 
-import org.apache.http.*;
-import org.apache.http.client.utils.URIUtils;
+import static org.hamcrest.core.StringContains.containsString;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URISyntaxException;
+
+import org.apache.http.Header;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -28,88 +36,71 @@ import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
 import org.hamcrest.core.StringContains;
 import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
-import util.TestBase;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
 
-import static org.hamcrest.core.StringContains.containsString;
+import util.HttpServerRule;
 
-public class GetPostTest extends TestBase {
-    public static final String GET_URL = "/test";
-    public static final String GET_AUTH_URL = "/testauth";
-    public static final String OK_RESPONSE = "TEST_OK";
-    public static final String FAIL_RESPONSE = "TEST_FAIL";
-    public static final String USER = "admin";
+public class GetPostTest {
+    private static final String GET_URL = "/test";
+    private static final String GET_AUTH_URL = "/testauth";
+    private static final String OK_RESPONSE = "TEST_OK";
+    private static final String USER = "admin";
     private static final String PASSWORD = "admin";
     private static final String AUTH_STRING = "Basic YWRtaW46YWRtaW4=";
     private static final String REDIRECT_URL = "/test_redirect";
 
+    @ClassRule
+    public static final HttpServerRule httpServer = new HttpServerRule() {
 
-    private static HttpHost host;
-    private static URI uri;
-
-    @BeforeClass
-    public static void setUp() throws Exception {
-        setupServer();
-    }
-
-    public static void setupServer() throws Exception {
-        TestBase.setUp();
-        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 {
+        @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(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);
-            }
-        });
-
-        // start server
-        host = TestBase.start();
-        uri = URIUtils.rewriteURI(new URI("/"), host);
-    }
-
+            }).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(uri.toString());
+        MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString());
         Document doc = client.get(GET_URL);
         Assert.assertThat("GET request failed", doc.toString(), new StringContains(OK_RESPONSE));
     }
 
     @Test
     public void testValidAuthGet() throws ClientException, URISyntaxException {
-        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString(), USER, PASSWORD);
+        MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString(), USER, PASSWORD);
         Document doc = client.get(GET_AUTH_URL);
         Assert.assertThat("GET request failed with basic auth", doc.toString(), containsString(OK_RESPONSE));
     }
 
     @Test
     public void testRedirect() throws ClientException, URISyntaxException, UnsupportedEncodingException {
-        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString(), USER, PASSWORD);
+        MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString());
         Document doc = client.post(REDIRECT_URL, new StringEntity("test"));
         Assert.assertThat("POST request failed to redirect", doc.toString(), containsString(OK_RESPONSE));
     }
-
 }
diff --git a/src/test/java/ItemsTest.java b/src/test/java/ItemsTest.java
index 7c09f45..8ab5453 100644
--- a/src/test/java/ItemsTest.java
+++ b/src/test/java/ItemsTest.java
@@ -17,9 +17,16 @@
  * under the License.
  ******************************************************************************/
 
+import static org.hamcrest.core.IsEqual.equalTo;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
 import org.apache.commons.io.IOUtils;
-import org.apache.http.*;
-import org.apache.http.client.utils.URIUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.protocol.HttpRequestHandler;
@@ -28,62 +35,42 @@ import org.apache.sling.hapi.client.Document;
 import org.apache.sling.hapi.client.Items;
 import org.apache.sling.hapi.client.microdata.MicrodataHtmlClient;
 import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
-import util.TestBase;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-
-
-public class ItemsTest extends TestBase {
-    public static final String GET_URL = "/test";
-    public static final String GET_LINKS_URL = "/testlinks";
-    public static final String OK_RESPONSE = "TEST_OK";
-    public static final String FAIL_RESPONSE = "TEST_FAIL";
-
-    public static String html;
-    public static String htmlLinks;
-
-    private static HttpHost host;
-    private static URI uri;
-
-    @BeforeClass
-    public static void setUp() throws Exception {
-        ItemsTest.html = IOUtils.toString(ItemsTest.class.getResourceAsStream("items.html"), "UTF-8");
-        ItemsTest.htmlLinks = IOUtils.toString(ItemsTest.class.getResourceAsStream("items_links.html"), "UTF-8");
-        setupServer();
-    }
-
-    public static void setupServer() throws Exception {
-        TestBase.setUp();
-        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);
-            }
-        });
-
-        // start server
-        host = TestBase.start();
-        uri = URIUtils.rewriteURI(new URI("/"), host);
-    }
 
+import util.HttpServerRule;
+
+public class ItemsTest {
+    private static final String GET_URL = "/test";
+    private static final String GET_LINKS_URL = "/testlinks";
+
+    @ClassRule
+    public static final HttpServerRule httpServer = new HttpServerRule() {
+        @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);
+                }
+            });
+        }
+    };
+    
     @Test
     public void testItems() throws ClientException, URISyntaxException {
-        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString());
+        MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString());
         Document doc = client.enter(GET_URL);
         Items items = doc.items();
         Assert.assertThat(items.length(), equalTo(2));
@@ -98,7 +85,7 @@ public class ItemsTest extends TestBase {
 
     @Test
     public void testItemsLinks() throws ClientException, URISyntaxException {
-        MicrodataHtmlClient client = new MicrodataHtmlClient(uri.toString());
+        MicrodataHtmlClient client = new MicrodataHtmlClient(httpServer.getURI().toString());
         Document doc = client.enter(GET_LINKS_URL);
         Items items = doc.items();
         Assert.assertThat(items.length(), equalTo(1));
@@ -116,5 +103,4 @@ public class ItemsTest extends TestBase {
         Assert.assertThat(otherMovies.length(), equalTo(2));
 
     }
-
-}
+}
\ No newline at end of file
diff --git a/src/test/java/util/TestBase.java b/src/test/java/util/HttpServerRule.java
similarity index 57%
rename from src/test/java/util/TestBase.java
rename to src/test/java/util/HttpServerRule.java
index d1dbc25..0822ae4 100644
--- a/src/test/java/util/TestBase.java
+++ b/src/test/java/util/HttpServerRule.java
@@ -18,50 +18,67 @@
  ******************************************************************************/
 package util;
 
+import java.io.IOException;
+import java.net.URI;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.http.HttpHost;
+import org.apache.http.client.utils.URIUtils;
 import org.apache.http.config.SocketConfig;
 import org.apache.http.impl.bootstrap.HttpServer;
 import org.apache.http.impl.bootstrap.ServerBootstrap;
 import org.apache.http.localserver.SSLTestContexts;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-
-import java.util.concurrent.TimeUnit;
+import org.junit.rules.ExternalResource;
 
-public abstract class TestBase {
+/** JUnit Rule that starts an HTTP server */
+public class HttpServerRule extends ExternalResource {
     public static final String ORIGIN = "TEST/1.1";
-    protected static TestBase.ProtocolScheme scheme = TestBase.ProtocolScheme.http;
-    protected static ServerBootstrap serverBootstrap;
-    protected static HttpServer server;
+    private HttpServer server;
+    private HttpHost host;
+    private URI uri;
 
-    @BeforeClass
-    public static void setUp() throws Exception {
-        SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(5000).build();
-        serverBootstrap = ServerBootstrap.bootstrap().setSocketConfig(socketConfig).setServerInfo("TEST/1.1");
-        if(scheme.equals(TestBase.ProtocolScheme.https)) {
-            serverBootstrap.setSslContext(SSLTestContexts.createServerSSLContext());
+    protected ServerBootstrap serverBootstrap; 
+    
+    public static enum ProtocolScheme {
+        http,
+        https;
+        private ProtocolScheme() {
         }
     }
+    
+    protected final ProtocolScheme protocolScheme;
 
-    @AfterClass
-    public static void shutDown() throws Exception {
-        if(server != null) {
-            server.shutdown(-1, TimeUnit.SECONDS);
-        }
-
+    public HttpServerRule() {
+        this(ProtocolScheme.http);
+    }
+    
+    public HttpServerRule(ProtocolScheme protocolScheme) {
+        this.protocolScheme = protocolScheme;
+    }
+    
+    @Override
+    protected void after() {
+        server.shutdown(-1, TimeUnit.SECONDS);
     }
 
-    public static HttpHost start() throws Exception {
+    @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)) {
+            serverBootstrap.setSslContext(SSLTestContexts.createServerSSLContext());
+        }
+        registerHandlers();
         server = serverBootstrap.create();
         server.start();
-        return new HttpHost("localhost", server.getLocalPort(), scheme.name());
+        host = new HttpHost("localhost", server.getLocalPort(), protocolScheme.name());
+        uri = URIUtils.rewriteURI(new URI("/"), host);
     }
-
-    public static enum ProtocolScheme {
-        http,
-        https;
-
-        private ProtocolScheme() {
-        }
+    
+    protected void registerHandlers() throws IOException {
+    }
+    
+    public URI getURI() {
+        return uri;
     }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-hapi-client] 24/24: [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.hapi.client-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi-client.git

commit 5aa1a49fb4787844c590fbc896bc7355744c7e88
Merge: 3224683 07089a1
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Wed Aug 10 14:52:28 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.hapi.client-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.hapi.client-1.0.0@1755762 13f79535-47bb-0310-9956-ffa450edef68

 pom.xml                                            | 10 ++++----
 .../org/apache/sling/hapi/client/Document.java     | 30 +++++++++++++++++++++-
 .../sling/hapi/client/HtmlClientService.java       | 26 +++++++++++++++++++
 .../java/org/apache/sling/hapi/client/Item.java    | 15 ++++++-----
 .../client/forms/{ => internal}/FormValues.java    |  2 +-
 .../hapi/client/forms/{ => internal}/Vals.java     |  2 +-
 .../sling/hapi/client/forms/package-info.java      | 23 -----------------
 .../hapi/client/impl/HtmlClientServiceImpl.java    |  4 ++-
 .../client/impl/microdata/MicrodataDocument.java   |  2 +-
 .../org/apache/sling/hapi/client/package-info.java |  4 +--
 10 files changed, 75 insertions(+), 43 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.