This is an automated email from the ASF dual-hosted git repository. dulvac pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git
commit 9f6c0010053a23256ddee21663c66fd4a23f8ac3 Author: Marc Pfaff <[email protected]> AuthorDate: Tue Dec 7 14:42:51 2021 +0100 SLING-10974 - update jackson dependencies - remove all usage of org.codehaus.jackson packages --- pom.xml | 57 ++++--- .../apache/sling/testing/clients/SlingClient.java | 19 ++- .../testing/clients/email/SlingEmailClient.java | 172 ++++++++++----------- .../sling/testing/clients/email/package-info.java | 2 +- .../sling/testing/clients/html/package-info.java | 2 +- .../sling/testing/clients/osgi/BundleInfo.java | 32 ++-- .../sling/testing/clients/osgi/BundlesInfo.java | 48 +++--- .../sling/testing/clients/osgi/ComponentInfo.java | 16 +- .../sling/testing/clients/osgi/ComponentsInfo.java | 15 +- .../testing/clients/osgi/OsgiConsoleClient.java | 62 ++++---- .../sling/testing/clients/osgi/ServiceInfo.java | 16 +- .../sling/testing/clients/osgi/ServicesInfo.java | 27 ++-- .../sling/testing/clients/osgi/package-info.java | 2 +- .../apache/sling/testing/clients/package-info.java | 2 +- .../sling/testing/clients/query/QueryClient.java | 4 +- .../sling/testing/clients/util/JsonUtils.java | 7 +- .../sling/testing/clients/util/package-info.java | 2 +- .../clients/SlingClientConstructorTest.java | 9 -- .../testing/clients/SlingClientDoGetJsonTest.java | 8 +- .../clients/SlingClientImportContentTest.java | 5 +- .../clients/osgi/OsgiConsoleClientTest.java | 30 ++-- .../testing/clients/query/QueryClientTest.java | 22 +-- 22 files changed, 283 insertions(+), 276 deletions(-) diff --git a/pom.xml b/pom.xml index eae85d0..5f79e61 100644 --- a/pom.xml +++ b/pom.xml @@ -17,18 +17,19 @@ specific language governing permissions and limitations under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.sling</groupId> <artifactId>sling-bundle-parent</artifactId> <version>41</version> - <relativePath /> + <relativePath/> </parent> <artifactId>org.apache.sling.testing.clients</artifactId> - <version>2.0.13-SNAPSHOT</version> + <version>3.0.0-SNAPSHOT</version> <name>Apache Sling Testing Clients</name> <description> @@ -36,11 +37,12 @@ </description> <scm> <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git</connection> - <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git</developerConnection> + <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-clients.git + </developerConnection> <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-testing-clients.git</url> <tag>HEAD</tag> </scm> - + <build> <plugins> <plugin> @@ -71,7 +73,7 @@ <artifactId>apache-rat-plugin</artifactId> <configuration> <excludes combine.children="append"> - <exclude>src/test/resources/**/*.txt</exclude> + <exclude>src/test/resources/**/*.txt</exclude> </excludes> </configuration> </plugin> @@ -92,15 +94,26 @@ <artifactId>commons-exec</artifactId> <version>1.1</version> </dependency> + <!-- <dependency>--> + <!-- <groupId>org.codehaus.jackson</groupId>--> + <!-- <artifactId>jackson-core-asl</artifactId>--> + <!-- <version>1.5.5</version>--> + <!-- </dependency>--> + <!-- <dependency>--> + <!-- <groupId>org.codehaus.jackson</groupId>--> + <!-- <artifactId>jackson-mapper-asl</artifactId>--> + <!-- <version>1.5.5</version>--> + <!-- </dependency>--> <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-core-asl</artifactId> - <version>1.5.5</version> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + <version>2.13.0</version> </dependency> + <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-mapper-asl</artifactId> - <version>1.5.5</version> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.13.0</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> @@ -176,16 +189,16 @@ cause a major change of the API. The new packages are currently needed for the query servlet, but everything should be updated at some point. --> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-core</artifactId> - <version>2.9.4</version> - </dependency> - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - <version>2.9.10.1</version> - </dependency> +<!-- <dependency>--> +<!-- <groupId>com.fasterxml.jackson.core</groupId>--> +<!-- <artifactId>jackson-core</artifactId>--> +<!-- <version>2.9.4</version>--> +<!-- </dependency>--> +<!-- <dependency>--> +<!-- <groupId>com.fasterxml.jackson.core</groupId>--> +<!-- <artifactId>jackson-databind</artifactId>--> +<!-- <version>2.9.10.1</version>--> +<!-- </dependency>--> <!-- For tests --> <dependency> diff --git a/src/main/java/org/apache/sling/testing/clients/SlingClient.java b/src/main/java/org/apache/sling/testing/clients/SlingClient.java index 59b8484..4002afe 100644 --- a/src/main/java/org/apache/sling/testing/clients/SlingClient.java +++ b/src/main/java/org/apache/sling/testing/clients/SlingClient.java @@ -28,6 +28,7 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpRequestInterceptor; @@ -54,7 +55,7 @@ import org.apache.sling.testing.clients.util.ServerErrorRetryStrategy; import org.apache.sling.testing.clients.util.poller.AbstractPoller; import org.apache.sling.testing.clients.util.poller.Polling; import org.apache.sling.testing.timeouts.TimeoutsProvider; -import org.codehaus.jackson.JsonNode; + /** * <p>The Base class for all Integration Test Clients. It provides generic methods to send HTTP requests to a server. </p> @@ -356,13 +357,13 @@ public class SlingClient extends AbstractSlingClient { } /** - * Returns the JSON content of a node already mapped to a {@link org.codehaus.jackson.JsonNode}.<br> + * Returns the JSON content of a node already mapped to a {@link com.fasterxml.jackson.databind.JsonNode}.<br> * Waits max 10 seconds for the node to be created. * * @deprecated use {@link #waitExists(String, long, long)} and {@link #doGetJson(String, int, int...)} instead * @param path the path to the content node * @param depth the number of levels to go down the tree, -1 for infinity - * @return a {@link org.codehaus.jackson.JsonNode} mapping to the requested content node. + * @return a {@link com.fasterxml.jackson.databind.JsonNode} mapping to the requested content node. * @throws ClientException if something fails during request/response processing * @throws InterruptedException to mark this operation as "waiting" */ @@ -372,7 +373,7 @@ public class SlingClient extends AbstractSlingClient { } /** - * Returns JSON format of a content node already mapped to a {@link org.codehaus.jackson.JsonNode}. + * Returns JSON format of a content node already mapped to a {@link com.fasterxml.jackson.databind.JsonNode}. * * @deprecated use {@link #waitExists(String, long, long)} and {@link #doGetJson(String, int, int...)} instead * @param path the path to the content node @@ -381,7 +382,7 @@ public class SlingClient extends AbstractSlingClient { * @param retryNumber number of retries before throwing an exception * @param expectedStatus list of allowed HTTP Status to be returned. If not set, * http status 200 (OK) is assumed. - * @return a {@link org.codehaus.jackson.JsonNode} mapping to the requested content node. + * @return a {@link com.fasterxml.jackson.databind.JsonNode} mapping to the requested content node. * @throws ClientException if something fails during request/response cycle * @throws InterruptedException to mark this operation as "waiting" */ @@ -407,13 +408,13 @@ public class SlingClient extends AbstractSlingClient { } /** - * Returns the {@link org.codehaus.jackson.JsonNode} object corresponding to a content node. + * Returns the {@link com.fasterxml.jackson.databind.JsonNode} object corresponding to a content node. * * @param path the path to the content node * @param depth the number of levels to go down the tree, -1 for infinity * @param expectedStatus list of allowed HTTP Status to be returned. If not set, 200 (OK) is assumed. * - * @return a {@link org.codehaus.jackson.JsonNode} mapping to the requested content node. + * @return a {@link com.fasterxml.jackson.databind.JsonNode} mapping to the requested content node. * @throws ClientException if the path does not exist or something fails during request/response cycle * @since 1.1.0 */ @@ -598,7 +599,9 @@ public class SlingClient extends AbstractSlingClient { return null; } - return uuidNode.getValueAsText(); + //TODO write test to ensure uuidNode.asText() == uuidNode.getValueAsText(), to avoid regression + //return uuidNode.getValueAsText(); + return uuidNode.asText(); } @Override diff --git a/src/main/java/org/apache/sling/testing/clients/email/SlingEmailClient.java b/src/main/java/org/apache/sling/testing/clients/email/SlingEmailClient.java index a41c72f..8a235e9 100644 --- a/src/main/java/org/apache/sling/testing/clients/email/SlingEmailClient.java +++ b/src/main/java/org/apache/sling/testing/clients/email/SlingEmailClient.java @@ -18,15 +18,8 @@ */ package org.apache.sling.testing.clients.email; -import static org.apache.http.HttpStatus.SC_NO_CONTENT; -import static org.apache.http.HttpStatus.SC_OK; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.http.Header; import org.apache.http.NameValuePair; import org.apache.http.impl.client.CloseableHttpClient; @@ -34,90 +27,97 @@ import org.apache.sling.testing.clients.ClientException; import org.apache.sling.testing.clients.SlingClient; import org.apache.sling.testing.clients.SlingClientConfig; import org.apache.sling.testing.clients.SlingHttpResponse; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import static org.apache.http.HttpStatus.SC_NO_CONTENT; +import static org.apache.http.HttpStatus.SC_OK; /** - * Accesses email stored by a mock SMTP server deployed to Sling + * Accesses email stored by a mock SMTP server deployed to Sling * * <p>Requires that the <code>org.apache.sling.testing.email</code> bundle is deployed.</p> */ public final class SlingEmailClient extends SlingClient { - /** - * The well-known path under which the EmailServlet is deployed - */ - private static final String EMAIL_SERVLET_PATH = "/system/sling/testing/email"; - - /** - * The well-known property name of the email body contents - */ - private static final String PN_CONTENT = "-Content-"; - - - private final ObjectMapper mapper = new ObjectMapper(); - - public SlingEmailClient(CloseableHttpClient http, SlingClientConfig config) throws ClientException { - super(http, config); - } - - /** - * Retrieves the actual bind port of the SMTP server - * - * @return the port value - * @throws ClientException in case of any errors - */ - public int getBindPort() throws ClientException { + /** + * The well-known path under which the EmailServlet is deployed + */ + private static final String EMAIL_SERVLET_PATH = "/system/sling/testing/email"; + + /** + * The well-known property name of the email body contents + */ + private static final String PN_CONTENT = "-Content-"; + + + private final ObjectMapper mapper = new ObjectMapper(); + + public SlingEmailClient(CloseableHttpClient http, SlingClientConfig config) throws ClientException { + super(http, config); + } + + /** + * Retrieves the actual bind port of the SMTP server + * + * @return the port value + * @throws ClientException in case of any errors + */ + public int getBindPort() throws ClientException { try { - SlingHttpResponse mockEmailConfig = doGet(EMAIL_SERVLET_PATH + "/config", SC_OK); - - JsonNode configNode = mapper.readTree(mockEmailConfig.getContent()); - return configNode.get("bindPort").getIntValue(); - } catch (IOException e) { - throw new ClientException("Failed retrieving configuration", e); - } - } - - /** - * Retrieves the list of mail messages currently stored - * - * @return the list of messages, possibly empty - * @throws ClientException in case of any errors - */ - public List<EmailMessage> getMessages() throws ClientException { - List<EmailMessage> emails = new ArrayList<>(); - + SlingHttpResponse mockEmailConfig = doGet(EMAIL_SERVLET_PATH + "/config", SC_OK); + + JsonNode configNode = mapper.readTree(mockEmailConfig.getContent()); + return configNode.get("bindPort").intValue(); + } catch (IOException e) { + throw new ClientException("Failed retrieving configuration", e); + } + } + + /** + * Retrieves the list of mail messages currently stored + * + * @return the list of messages, possibly empty + * @throws ClientException in case of any errors + */ + public List<EmailMessage> getMessages() throws ClientException { + List<EmailMessage> emails = new ArrayList<>(); + try { - SlingHttpResponse response = doGet(EMAIL_SERVLET_PATH + "/messages", SC_OK); - JsonNode messages = mapper.readTree(response.getContent()); - for ( JsonNode emailNode : messages.get("messages") ) { - EmailMessage msg = new EmailMessage(emailNode.get(PN_CONTENT).getTextValue()); - Iterator<String> fieldNames = emailNode.getFieldNames(); - while ( fieldNames.hasNext() ) { - String fieldName = fieldNames.next(); - if ( fieldName.equals(PN_CONTENT) ) { - continue; - } - msg.addHeader(fieldName, emailNode.get(fieldName).getTextValue()); - } - - emails.add(msg); - } - } catch (IOException e) { - throw new ClientException("Failed retrieving email messages", e); - } - - - return emails; - } - - /** - * Deletes all mail messages currently stored - * - * @throws ClientException in case of any errors - */ - public void deleteMessages() throws ClientException { - doDelete(EMAIL_SERVLET_PATH, Collections.<NameValuePair>emptyList(), - Collections.<Header> emptyList(), SC_NO_CONTENT); - } + SlingHttpResponse response = doGet(EMAIL_SERVLET_PATH + "/messages", SC_OK); + JsonNode messages = mapper.readTree(response.getContent()); + for (JsonNode emailNode : messages.get("messages")) { + EmailMessage msg = new EmailMessage(emailNode.get(PN_CONTENT).textValue()); + Iterator<String> fieldNames = emailNode.fieldNames(); + while (fieldNames.hasNext()) { + String fieldName = fieldNames.next(); + if (fieldName.equals(PN_CONTENT)) { + continue; + } + msg.addHeader(fieldName, emailNode.get(fieldName).textValue()); + } + + emails.add(msg); + } + } catch (IOException e) { + throw new ClientException("Failed retrieving email messages", e); + } + + + return emails; + } + + /** + * Deletes all mail messages currently stored + * + * @throws ClientException in case of any errors + */ + public void deleteMessages() throws ClientException { + doDelete(EMAIL_SERVLET_PATH, Collections.<NameValuePair>emptyList(), + Collections.<Header>emptyList(), SC_NO_CONTENT); + } } diff --git a/src/main/java/org/apache/sling/testing/clients/email/package-info.java b/src/main/java/org/apache/sling/testing/clients/email/package-info.java index 01de7b2..fd7b7a0 100644 --- a/src/main/java/org/apache/sling/testing/clients/email/package-info.java +++ b/src/main/java/org/apache/sling/testing/clients/email/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("1.3.0") +@Version("2.0.0") package org.apache.sling.testing.clients.email; import org.osgi.annotation.versioning.Version; diff --git a/src/main/java/org/apache/sling/testing/clients/html/package-info.java b/src/main/java/org/apache/sling/testing/clients/html/package-info.java index 2723070..bf17816 100644 --- a/src/main/java/org/apache/sling/testing/clients/html/package-info.java +++ b/src/main/java/org/apache/sling/testing/clients/html/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("2.4.0") +@Version("3.0.0") package org.apache.sling.testing.clients.html; import org.osgi.annotation.versioning.Version; diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/BundleInfo.java b/src/main/java/org/apache/sling/testing/clients/osgi/BundleInfo.java index 33cdd22..1d8d0b5 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/BundleInfo.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/BundleInfo.java @@ -17,8 +17,8 @@ package org.apache.sling.testing.clients.osgi; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.sling.testing.clients.ClientException; -import org.codehaus.jackson.JsonNode; import java.util.HashMap; import java.util.Iterator; @@ -29,13 +29,13 @@ public class BundleInfo { private JsonNode bundle; public BundleInfo(JsonNode root) throws ClientException { - if(root.get("id") != null) { - if(root.get("id") == null) { + if (root.get("id") != null) { + if (root.get("id") == null) { throw new ClientException("No Bundle Info returned"); } bundle = root; } else { - if(root.get("data") == null && root.get("data").size() < 1) { + if (root.get("data") == null && root.get("data").size() < 1) { throw new ClientException("No Bundle Info returned"); } bundle = root.get("data").get(0); @@ -46,51 +46,51 @@ public class BundleInfo { * @return the bundle identifier */ public int getId() { - return bundle.get("id").getIntValue(); + return bundle.get("id").intValue(); } /** * @return the bundle name */ public String getName() { - return bundle.get("name").getTextValue(); + return bundle.get("name").textValue(); } /** * @return the bundle version */ public String getVersion() { - return bundle.get("version").getTextValue(); + return bundle.get("version").textValue(); } /** * Returns the indicator if the bundle is a fragment - * + * * @return {@code true} if bundle is a fragment, {@code false} otherwise. */ public boolean isFragment() { - return bundle.get("fragment").getBooleanValue(); + return bundle.get("fragment").booleanValue(); } /** * @return the bundle current state */ public Bundle.Status getStatus() { - return Bundle.Status.value(bundle.get("state").getTextValue()); + return Bundle.Status.value(bundle.get("state").textValue()); } /** * @return the bundle symbolic name */ public String getSymbolicName() { - return bundle.get("symbolicName").getTextValue(); + return bundle.get("symbolicName").textValue(); } /** * @return the category of the bundle */ public String getCategory() { - return bundle.get("category").getTextValue(); + return bundle.get("category").textValue(); } /** @@ -111,11 +111,11 @@ public class BundleInfo { JsonNode props = bundle.get("props"); Map<String, String> entries = new HashMap<String, String>(); - if(props != null) { - Iterator<JsonNode> it = props.getElements(); - while(it.hasNext()) { + if (props != null) { + Iterator<JsonNode> it = props.elements(); + while (it.hasNext()) { JsonNode n = it.next(); - entries.put(n.get("key").getTextValue(), n.get("value").getTextValue()); + entries.put(n.get("key").textValue(), n.get("value").textValue()); } } return entries; diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/BundlesInfo.java b/src/main/java/org/apache/sling/testing/clients/osgi/BundlesInfo.java index b99fbf5..eb47093 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/BundlesInfo.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/BundlesInfo.java @@ -17,8 +17,8 @@ package org.apache.sling.testing.clients.osgi; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.sling.testing.clients.ClientException; -import org.codehaus.jackson.JsonNode; import java.util.Iterator; @@ -33,16 +33,16 @@ public class BundlesInfo { /** * The only constructor. - * + * * @param root the root JSON node of the bundles info. * @throws ClientException if the json does not contain the proper info */ public BundlesInfo(JsonNode root) throws ClientException { this.root = root; // some simple sanity checks - if(root.get("s") == null) + if (root.get("s") == null) throw new ClientException("No Status Info returned!"); - if(root.get("s").size() != 5) + if (root.get("s").size() != 5) throw new ClientException("Wrong number of status numbers listed!"); status = root.get("s"); } @@ -52,16 +52,16 @@ public class BundlesInfo { * @throws ClientException if the request cannot be completed */ public String getStatusMessage() throws ClientException { - if(root.get("status") == null) + if (root.get("status") == null) throw new ClientException("No Status message returned!"); - return root.get("status").getValueAsText(); + return root.get("status").asText(); } /** * @return total number of bundles. */ public int getTotalNumOfBundles() { - return Integer.parseInt(status.get(0).getValueAsText()); + return Integer.parseInt(status.get(0).asText()); } /** @@ -72,21 +72,21 @@ public class BundlesInfo { */ public int getNumBundlesByStatus(Bundle.Status status) { int index = -1; - switch(status) { - case ACTIVE: - index = 1; - break; - case FRAGMENT: - index = 2; - break; - case RESOLVED: - index = 3; - break; - case INSTALLED: - index = 4; - break; + switch (status) { + case ACTIVE: + index = 1; + break; + case FRAGMENT: + index = 2; + break; + case RESOLVED: + index = 3; + break; + case INSTALLED: + index = 4; + break; } - return Integer.parseInt(this.status.get(index).getValueAsText()); + return Integer.parseInt(this.status.get(index).asText()); } /** @@ -126,11 +126,11 @@ public class BundlesInfo { } private JsonNode findBy(String key, String value) { - Iterator<JsonNode> nodes = root.get("data").getElements(); - while(nodes.hasNext()) { + Iterator<JsonNode> nodes = root.get("data").elements(); + while (nodes.hasNext()) { JsonNode node = nodes.next(); if ((null != node.get(key)) && (node.get(key).isValueNode())) { - final String valueNode = node.get(key).getTextValue(); + final String valueNode = node.get(key).textValue(); if (valueNode.equals(value)) { return node; } diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/ComponentInfo.java b/src/main/java/org/apache/sling/testing/clients/osgi/ComponentInfo.java index 32ed94c..50b7e9d 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/ComponentInfo.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/ComponentInfo.java @@ -17,21 +17,21 @@ package org.apache.sling.testing.clients.osgi; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.sling.testing.clients.ClientException; -import org.codehaus.jackson.JsonNode; public class ComponentInfo { private JsonNode component; public ComponentInfo(JsonNode root) throws ClientException { - if(root.get("id") != null) { - if(root.get("id") == null) { + if (root.get("id") != null) { + if (root.get("id") == null) { throw new ClientException("No Component Info returned"); } component = root; } else { - if(root.get("data") == null && root.get("data").size() < 1) { + if (root.get("data") == null && root.get("data").size() < 1) { throw new ClientException("No Component Info returned"); } component = root.get("data").get(0); @@ -42,28 +42,28 @@ public class ComponentInfo { * @return the component identifier */ public int getId() { - return component.get("id").getIntValue(); + return component.get("id").intValue(); } /** * @return the component name */ public String getName() { - return component.get("name").getTextValue(); + return component.get("name").textValue(); } /** * @return the component status */ public Component.Status getStatus() { - return Component.Status.value(component.get("state").getTextValue()); + return Component.Status.value(component.get("state").textValue()); } /** * @return the component persistent identifier */ public String getPid() { - return component.get("pid").getTextValue(); + return component.get("pid").textValue(); } } diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/ComponentsInfo.java b/src/main/java/org/apache/sling/testing/clients/osgi/ComponentsInfo.java index 49b7b14..9770cc1 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/ComponentsInfo.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/ComponentsInfo.java @@ -17,11 +17,12 @@ package org.apache.sling.testing.clients.osgi; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.sling.testing.clients.ClientException; -import org.codehaus.jackson.JsonNode; import java.util.Iterator; + /** * Thin wrapper around the list of components */ @@ -31,7 +32,7 @@ public class ComponentsInfo { /** * The only constructor. - * + * * @param rootNode the root JSON node of the components info. * @throws ClientException if the info cannot be retrieved */ @@ -44,9 +45,9 @@ public class ComponentsInfo { * @throws ClientException if the info cannot be retrieved */ public int getNumberOfInstalledComponents() throws ClientException { - if(root.get("status") == null) + if (root.get("status") == null) throw new ClientException("Number of installed Components not defined!"); - return Integer.parseInt(root.get("status").getValueAsText()); + return Integer.parseInt(root.get("status").asText()); } /** @@ -80,11 +81,11 @@ public class ComponentsInfo { } private JsonNode findBy(String key, String value) { - Iterator<JsonNode> nodes = root.get("data").getElements(); - while(nodes.hasNext()) { + Iterator<JsonNode> nodes = root.get("data").elements(); + while (nodes.hasNext()) { JsonNode node = nodes.next(); if ((null != node.get(key)) && (node.get(key).isValueNode())) { - final String valueNode = node.get(key).getTextValue(); + final String valueNode = node.get(key).textValue(); if (valueNode.equals(value)) { return node; } diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClient.java b/src/main/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClient.java index b5119c9..b3fdfea 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClient.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClient.java @@ -17,23 +17,7 @@ package org.apache.sling.testing.clients.osgi; -import static org.apache.http.HttpStatus.SC_MOVED_TEMPORARILY; -import static org.apache.http.HttpStatus.SC_OK; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeoutException; -import java.util.jar.JarInputStream; -import java.util.jar.Manifest; - +import com.fasterxml.jackson.databind.JsonNode; import org.apache.http.Header; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; @@ -46,11 +30,27 @@ import org.apache.sling.testing.clients.util.HttpUtils; import org.apache.sling.testing.clients.util.JsonUtils; import org.apache.sling.testing.clients.util.poller.PathPoller; import org.apache.sling.testing.clients.util.poller.Polling; -import org.codehaus.jackson.JsonNode; import org.osgi.framework.Constants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeoutException; +import java.util.jar.JarInputStream; +import java.util.jar.Manifest; + +import static org.apache.http.HttpStatus.SC_MOVED_TEMPORARILY; +import static org.apache.http.HttpStatus.SC_OK; + /** * A client that wraps the Felix OSGi Web Console REST API calls. * @see <a href=http://felix.apache.org/documentation/subprojects/apache-felix-web-console/web-console-restful-api.html> @@ -294,19 +294,19 @@ public class OsgiConsoleClient extends SlingClient { if(rootNode.get("properties") == null) return props; JsonNode properties = rootNode.get("properties"); - for(Iterator<String> it = properties.getFieldNames(); it.hasNext();) { + for(Iterator<String> it = properties.fieldNames(); it.hasNext();) { String propName = it.next(); JsonNode value = properties.get(propName).get("value"); if(value != null) { - props.put(propName, value.getValueAsText()); + props.put(propName, value.asText()); continue; } value = properties.get(propName).get("values"); if(value != null) { - Iterator<JsonNode> iter = value.getElements(); + Iterator<JsonNode> iter = value.elements(); List<String> list = new ArrayList<String>(); while(iter.hasNext()) { - list.add(iter.next().getValueAsText()); + list.add(iter.next().asText()); } props.put(propName, list.toArray(new String[list.size()])); } @@ -345,22 +345,22 @@ public class OsgiConsoleClient extends SlingClient { // go through the properties final JsonNode propertiesNode = rootNode.get("properties"); if ( propertiesNode != null ) { - for(Iterator<String> it = propertiesNode.getFieldNames(); it.hasNext();) { + for(Iterator<String> it = propertiesNode.fieldNames(); it.hasNext();) { final String propName = it.next(); final JsonNode propNode = propertiesNode.get(propName); - final boolean isSet = propNode.get("is_set").getBooleanValue(); + final boolean isSet = propNode.get("is_set").booleanValue(); if ( isSet ) { JsonNode value = propNode.get("value"); if (value != null) { - result.put(propName, value.getValueAsText()); + result.put(propName, value.asText()); } else { value = propNode.get("values"); if (value != null) { - final Iterator<JsonNode> iter = value.getElements(); + final Iterator<JsonNode> iter = value.elements(); List<String> list = new ArrayList<String>(); while(iter.hasNext()) { - list.add(iter.next().getValueAsText()); + list.add(iter.next().asText()); } result.put(propName, list.toArray(new String[list.size()])); } @@ -727,7 +727,7 @@ public class OsgiConsoleClient extends SlingClient { throw new ClientException("Cannot get id from bundle json"); } - return idNode.getLongValue(); + return idNode.longValue(); } /** @@ -744,7 +744,7 @@ public class OsgiConsoleClient extends SlingClient { throw new ClientException("Cannot get version from bundle json"); } - return versionNode.getTextValue(); + return versionNode.textValue(); } /** @@ -761,7 +761,7 @@ public class OsgiConsoleClient extends SlingClient { throw new ClientException("Cannot get state from bundle json"); } - return stateNode.getTextValue(); + return stateNode.textValue(); } /** @@ -874,7 +874,7 @@ public class OsgiConsoleClient extends SlingClient { throw new ClientException(path + " does not provide '" + JSON_KEY_DATA + "' element, JSON content=" + content); } - Iterator<JsonNode> data = root.get(JSON_KEY_DATA).getElements(); + Iterator<JsonNode> data = root.get(JSON_KEY_DATA).elements(); if (!data.hasNext()) { throw new ClientException(path + "." + JSON_KEY_DATA + " is empty, JSON content=" + content); } diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/ServiceInfo.java b/src/main/java/org/apache/sling/testing/clients/osgi/ServiceInfo.java index 2d703d8..6fcb050 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/ServiceInfo.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/ServiceInfo.java @@ -17,10 +17,10 @@ package org.apache.sling.testing.clients.osgi; -import java.util.List; - +import com.fasterxml.jackson.databind.JsonNode; import org.apache.sling.testing.clients.ClientException; -import org.codehaus.jackson.JsonNode; + +import java.util.List; public class ServiceInfo { @@ -41,7 +41,7 @@ public class ServiceInfo { * @return the service identifier */ public int getId() { - return Integer.parseInt(service.get("id").getValueAsText()); + return Integer.parseInt(service.get("id").asText()); } /** @@ -49,25 +49,25 @@ public class ServiceInfo { */ public List<String> getTypes() { // this is not a proper JSON array (https://issues.apache.org/jira/browse/FELIX-5762) - return ServicesInfo.splitPseudoJsonValueArray(service.get("types").getTextValue()); + return ServicesInfo.splitPseudoJsonValueArray(service.get("types").textValue()); } public String getPid() { - return service.get("pid").getTextValue(); + return service.get("pid").textValue(); } /** * @return the bundle id of the bundle exposing the service */ public int getBundleId() { - return service.get("bundleId").getIntValue(); + return service.get("bundleId").intValue(); } /** * @return the bundle symbolic name of bundle implementing the service */ public String getBundleSymbolicName() { - return service.get("bundleSymbolicName").getTextValue(); + return service.get("bundleSymbolicName").textValue(); } } diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/ServicesInfo.java b/src/main/java/org/apache/sling/testing/clients/osgi/ServicesInfo.java index 8ec3bbd..ce25aed 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/ServicesInfo.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/ServicesInfo.java @@ -17,8 +17,8 @@ package org.apache.sling.testing.clients.osgi; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.sling.testing.clients.ClientException; -import org.codehaus.jackson.JsonNode; import java.util.Arrays; import java.util.Collection; @@ -36,16 +36,16 @@ public class ServicesInfo { /** * The only constructor. - * + * * @param root the root JSON node of the bundles info. * @throws ClientException if the json does not contain the proper info */ public ServicesInfo(JsonNode root) throws ClientException { this.root = root; // some simple sanity checks - if(root.get("status") == null) + if (root.get("status") == null) throw new ClientException("No Status returned!"); - if(root.get("serviceCount") == null) + if (root.get("serviceCount") == null) throw new ClientException("No serviceCount returned!"); } @@ -53,7 +53,7 @@ public class ServicesInfo { * @return total number of bundles. */ public int getTotalNumOfServices() { - return root.get("serviceCount").getIntValue(); + return root.get("serviceCount").intValue(); } /** @@ -96,14 +96,14 @@ public class ServicesInfo { private List<JsonNode> findAllContainingValueInArray(String key, String value) { return findBy(key, value, false, true); } - + private List<JsonNode> findBy(String key, String value, boolean onlyReturnFirstMatch, boolean arrayContainingMatch) { - Iterator<JsonNode> nodes = root.get("data").getElements(); + Iterator<JsonNode> nodes = root.get("data").elements(); List<JsonNode> results = new LinkedList<>(); - while(nodes.hasNext()) { + while (nodes.hasNext()) { JsonNode node = nodes.next(); if ((null != node.get(key)) && (node.get(key).isValueNode())) { - final String valueNode = node.get(key).getTextValue(); + final String valueNode = node.get(key).textValue(); if (arrayContainingMatch) { if (splitPseudoJsonValueArray(valueNode).contains(value)) { results.add(node); @@ -121,10 +121,11 @@ public class ServicesInfo { /** * Array values are not returned as proper JSON array for Apache Felix. * Therefore we need this dedicated split method, which extracts the individual values from this "pseudo" JSON array. - * Example value: + * Example value: * <pre> * [java.lang.Runnable, org.apache.sling.event.impl.jobs.queues.QueueManager, org.osgi.service.event.EventHandler] * </pre> + * * @param value the value to split * @return the list of the individual values in the given array. * @see <a href="https://issues.apache.org/jira/browse/FELIX-5762">FELIX-5762</a> @@ -133,9 +134,9 @@ public class ServicesInfo { // is this an array? if (value.startsWith("[") && value.length() >= 2) { // strip of first and last character - String pureArrayValues = value.substring(1, value.length() - 1); - String[] resultArray = pureArrayValues.split(", |,"); - return Arrays.asList(resultArray); + String pureArrayValues = value.substring(1, value.length() - 1); + String[] resultArray = pureArrayValues.split(", |,"); + return Arrays.asList(resultArray); } return Collections.singletonList(value); } diff --git a/src/main/java/org/apache/sling/testing/clients/osgi/package-info.java b/src/main/java/org/apache/sling/testing/clients/osgi/package-info.java index 7d0e647..efa5e41 100644 --- a/src/main/java/org/apache/sling/testing/clients/osgi/package-info.java +++ b/src/main/java/org/apache/sling/testing/clients/osgi/package-info.java @@ -19,7 +19,7 @@ /** * OSGI testing tools. */ -@Version("2.1.0") +@Version("3.0.0") package org.apache.sling.testing.clients.osgi; import org.osgi.annotation.versioning.Version; diff --git a/src/main/java/org/apache/sling/testing/clients/package-info.java b/src/main/java/org/apache/sling/testing/clients/package-info.java index 8b3a108..ab6987a 100644 --- a/src/main/java/org/apache/sling/testing/clients/package-info.java +++ b/src/main/java/org/apache/sling/testing/clients/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("2.4.0") +@Version("3.0.0") package org.apache.sling.testing.clients; import org.osgi.annotation.versioning.Version; diff --git a/src/main/java/org/apache/sling/testing/clients/query/QueryClient.java b/src/main/java/org/apache/sling/testing/clients/query/QueryClient.java index bfad020..f81eaee 100644 --- a/src/main/java/org/apache/sling/testing/clients/query/QueryClient.java +++ b/src/main/java/org/apache/sling/testing/clients/query/QueryClient.java @@ -16,6 +16,7 @@ */ package org.apache.sling.testing.clients.query; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.http.NameValuePair; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.sling.testing.clients.ClientException; @@ -26,7 +27,6 @@ import org.apache.sling.testing.clients.osgi.OsgiConsoleClient; import org.apache.sling.testing.clients.query.servlet.QueryServlet; import org.apache.sling.testing.clients.util.JsonUtils; import org.apache.sling.testing.clients.util.URLParameterBuilder; -import org.codehaus.jackson.JsonNode; import org.ops4j.pax.tinybundles.core.TinyBundles; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -133,7 +133,7 @@ public class QueryClient extends SlingClient { * @throws InterruptedException to mark that this method blocks */ public long doCount(final String query, final QueryType type) throws ClientException, InterruptedException { - return doQuery(query, type, false, false).get("total").getLongValue(); + return doQuery(query, type, false, false).get("total").longValue(); } /** diff --git a/src/main/java/org/apache/sling/testing/clients/util/JsonUtils.java b/src/main/java/org/apache/sling/testing/clients/util/JsonUtils.java index e64ac8d..6007f96 100644 --- a/src/main/java/org/apache/sling/testing/clients/util/JsonUtils.java +++ b/src/main/java/org/apache/sling/testing/clients/util/JsonUtils.java @@ -16,10 +16,9 @@ */ package org.apache.sling.testing.clients.util; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.sling.testing.clients.ClientException; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.JsonProcessingException; -import org.codehaus.jackson.map.ObjectMapper; import java.io.IOException; @@ -35,8 +34,6 @@ public class JsonUtils { try { ObjectMapper mapper = new ObjectMapper(); return mapper.readTree(jsonString); - } catch (JsonProcessingException e) { - throw new ClientException("Could not read json file.", e); } catch (IOException e) { throw new ClientException("Could not read json node.", e); } diff --git a/src/main/java/org/apache/sling/testing/clients/util/package-info.java b/src/main/java/org/apache/sling/testing/clients/util/package-info.java index 1b6436d..5c5d2ae 100644 --- a/src/main/java/org/apache/sling/testing/clients/util/package-info.java +++ b/src/main/java/org/apache/sling/testing/clients/util/package-info.java @@ -17,7 +17,7 @@ * under the License. */ -@Version("2.0.0") +@Version("3.0.0") package org.apache.sling.testing.clients.util; import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java b/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java index 4ae3caf..076c78b 100644 --- a/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java +++ b/src/test/java/org/apache/sling/testing/clients/SlingClientConstructorTest.java @@ -16,17 +16,8 @@ */ package org.apache.sling.testing.clients; -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; -import org.codehaus.jackson.JsonNode; -import org.junit.ClassRule; import org.junit.Test; -import java.io.IOException; import java.net.URI; import static org.junit.Assert.assertEquals; diff --git a/src/test/java/org/apache/sling/testing/clients/SlingClientDoGetJsonTest.java b/src/test/java/org/apache/sling/testing/clients/SlingClientDoGetJsonTest.java index 6eeba23..dd7d621 100644 --- a/src/test/java/org/apache/sling/testing/clients/SlingClientDoGetJsonTest.java +++ b/src/test/java/org/apache/sling/testing/clients/SlingClientDoGetJsonTest.java @@ -16,19 +16,19 @@ */ package org.apache.sling.testing.clients; +import com.fasterxml.jackson.databind.JsonNode; 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; -import org.codehaus.jackson.JsonNode; import org.junit.ClassRule; import org.junit.Test; import java.io.IOException; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; public class SlingClientDoGetJsonTest { private static final String GET_JSON_PATH = "/test/json/resource"; @@ -59,13 +59,13 @@ public class SlingClientDoGetJsonTest { public void testDoGetJson() throws Exception { SlingClient c = new SlingClient(httpServer.getURI(), "user", "pass"); JsonNode res = c.doGetJson(GET_JSON_PATH, 1, 200); - assertEquals("admin-json", res.get("jcr:createdBy").getTextValue()); + assertEquals("admin-json", res.get("jcr:createdBy").textValue()); } @Test public void testDoGetJsonInfinity() throws Exception { SlingClient c = new SlingClient(httpServer.getURI(), "user", "pass"); JsonNode res = c.doGetJson(GET_JSON_PATH, -1, 200); - assertEquals("admin-infinity", res.get("jcr:createdBy").getTextValue()); + assertEquals("admin-infinity", res.get("jcr:createdBy").textValue()); } } diff --git a/src/test/java/org/apache/sling/testing/clients/SlingClientImportContentTest.java b/src/test/java/org/apache/sling/testing/clients/SlingClientImportContentTest.java index 7ad5938..5ebc66a 100644 --- a/src/test/java/org/apache/sling/testing/clients/SlingClientImportContentTest.java +++ b/src/test/java/org/apache/sling/testing/clients/SlingClientImportContentTest.java @@ -16,14 +16,14 @@ */ package org.apache.sling.testing.clients; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; import org.apache.commons.io.IOUtils; import org.apache.http.*; import org.apache.http.client.utils.URLEncodedUtils; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; -import org.codehaus.jackson.node.JsonNodeFactory; -import org.codehaus.jackson.node.ObjectNode; import org.junit.ClassRule; import org.junit.Test; import org.slf4j.Logger; @@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.List; diff --git a/src/test/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClientTest.java b/src/test/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClientTest.java index 289323f..72db37f 100644 --- a/src/test/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClientTest.java +++ b/src/test/java/org/apache/sling/testing/clients/osgi/OsgiConsoleClientTest.java @@ -16,25 +16,26 @@ */ package org.apache.sling.testing.clients.osgi; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.util.Map; - +import com.fasterxml.jackson.databind.JsonNode; import org.apache.sling.testing.clients.ClientException; import org.apache.sling.testing.clients.util.JsonUtils; -import org.codehaus.jackson.JsonNode; import org.junit.Test; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + public class OsgiConsoleClientTest { - @Test public void testExtractOSGiConfigurationNoConfig() throws ClientException { + @Test + public void testExtractOSGiConfigurationNoConfig() throws ClientException { final String jsonResult = "{\"pid\":\"org.apache.sling.Factory\"," + "\"title\":\"Factory\"," + "\"description\":\"A factory\"," + "\"properties\":{" - + "\"prop\":{\"name\":\"Prop\",\"optional\":false,\"is_set\":false,\"type\":1,\"values\":[\"a\",\"b\"]," - + "\"description\":\"A property\"}}}"; + + "\"prop\":{\"name\":\"Prop\",\"optional\":false,\"is_set\":false,\"type\":1,\"values\":[\"a\",\"b\"]," + + "\"description\":\"A property\"}}}"; final JsonNode rootNode = JsonUtils.getJsonNodeFromString(jsonResult); @@ -42,15 +43,16 @@ public class OsgiConsoleClientTest { assertNull(OsgiConsoleClient.extractOSGiConfiguration(rootNode)); } - @Test public void testExtractOSGiConfiguration() throws ClientException { + @Test + public void testExtractOSGiConfiguration() throws ClientException { final String jsonResult = "{\"pid\":\"org.apache.sling.Factory\"," + "\"title\":\"Factory\"," + "\"description\":\"A factory\"," + "\"properties\":{" - + "\"propset\":{\"name\":\"Prop\",\"optional\":false,\"is_set\":true,\"type\":1,\"value\":\"a\"," - + "\"description\":\"A property\"}," - + "\"prop\":{\"name\":\"Prop\",\"optional\":false,\"is_set\":false,\"type\":1,\"values\":[\"a\",\"b\"]," - + "\"description\":\"A property\"}" + + "\"propset\":{\"name\":\"Prop\",\"optional\":false,\"is_set\":true,\"type\":1,\"value\":\"a\"," + + "\"description\":\"A property\"}," + + "\"prop\":{\"name\":\"Prop\",\"optional\":false,\"is_set\":false,\"type\":1,\"values\":[\"a\",\"b\"]," + + "\"description\":\"A property\"}" + "},\"bundleLocation\":\"\",\"bundle_location\":null,\"service_location\":\"\"}"; final JsonNode rootNode = JsonUtils.getJsonNodeFromString(jsonResult); diff --git a/src/test/java/org/apache/sling/testing/clients/query/QueryClientTest.java b/src/test/java/org/apache/sling/testing/clients/query/QueryClientTest.java index 8e8d6f5..001572f 100644 --- a/src/test/java/org/apache/sling/testing/clients/query/QueryClientTest.java +++ b/src/test/java/org/apache/sling/testing/clients/query/QueryClientTest.java @@ -16,6 +16,7 @@ */ package org.apache.sling.testing.clients.query; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.http.HttpException; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; @@ -27,7 +28,6 @@ import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; import org.apache.sling.testing.clients.ClientException; import org.apache.sling.testing.clients.HttpServerRule; -import org.codehaus.jackson.JsonNode; import org.junit.Assert; import org.junit.ClassRule; import org.junit.Test; @@ -77,15 +77,15 @@ public class QueryClientTest { serverBootstrap.registerHandler(QUERY_PATH, new HttpRequestHandler() { @Override public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { - List<NameValuePair> parameters = URLEncodedUtils.parse( - request.getRequestLine().getUri(), Charset.defaultCharset()); - - for (NameValuePair parameter : parameters) { - if (parameter.getName().equals("explain") && !parameter.getValue().equals("false")) { - response.setEntity(new StringEntity(EXPLAIN_RESPONSE)); - return; - } + List<NameValuePair> parameters = URLEncodedUtils.parse( + request.getRequestLine().getUri(), Charset.defaultCharset()); + + for (NameValuePair parameter : parameters) { + if (parameter.getName().equals("explain") && !parameter.getValue().equals("false")) { + response.setEntity(new StringEntity(EXPLAIN_RESPONSE)); + return; } + } response.setEntity(new StringEntity(QUERY_RESPONSE)); } @@ -116,7 +116,7 @@ public class QueryClientTest { serverBootstrap.registerHandler(BUNDLE_PATH, new HttpRequestHandler() { @Override public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { - response.setStatusCode(200); + response.setStatusCode(200); } }); } @@ -141,7 +141,7 @@ public class QueryClientTest { // JsonNode response = client.doQuery("SELECT * FROM [cq:Tag] WHERE ISDESCENDANTNODE([/etc/])", QueryClient.QueryType.SQL2); LOG.info(response.toString()); - Assert.assertNotEquals(0, response.get("total").getLongValue()); + Assert.assertNotEquals(0, response.get("total").longValue()); } @Test
