From c8585baebc9fc35ed12a3321acf47730c967b5d3 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Tue, 24 May 2016 15:45:03 +0000
Subject: [PATCH] OPENDJ-2880 Rest2Ldap as an OAuth2 Resource Server

---
 opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/TestUtils.java |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/TestUtils.java b/opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/TestUtils.java
index f436de2..fa39d16 100644
--- a/opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/TestUtils.java
+++ b/opendj-rest2ldap/src/test/java/org/forgerock/opendj/rest2ldap/TestUtils.java
@@ -11,15 +11,18 @@
  * Header, with the fields enclosed by brackets [] replaced by your own identifying
  * information: "Portions copyright [year] [name of copyright owner]".
  *
- * Copyright 2013-2015 ForgeRock AS.
+ * Copyright 2013-2016 ForgeRock AS.
  */
 package org.forgerock.opendj.rest2ldap;
 
 import static org.forgerock.json.JsonValue.json;
 
+import java.io.IOException;
+import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.forgerock.http.util.Json;
 import org.forgerock.json.JsonPointer;
 import org.forgerock.json.JsonValue;
 import org.forgerock.json.resource.ResourceResponse;
@@ -89,6 +92,28 @@
         return result;
     }
 
+    /**
+     * Return {@link JsonValue} corresponding to the provided json blob.
+     *
+     * @param jsonStr
+     *          JSON blob.
+     * @return A {@link JsonValue} corresponding to the provided json blob.
+     */
+    public static JsonValue parseJson(final String jsonStr) throws IOException {
+        return new JsonValue(Json.readJsonLenient(new StringReader(toValidJson(jsonStr))));
+    }
+
+    /**
+     * Allows usage of single quote character in json string used in unit tests.
+     *
+     * @param jsonStr
+     *          The json string to convert to valid json.
+     * @return A Json compliant string.
+     */
+    public static String toValidJson(final String jsonStr) {
+        return jsonStr.replace("'", "\"");
+    }
+
     private TestUtils() {
         // Prevent instantiation.
     }

--
Gitblit v1.10.0