You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2018/06/03 19:06:03 UTC
[28/50] guacamole-client git commit: GUACAMOLE-38: Add unit test for
query string parser.
GUACAMOLE-38: Add unit test for query string parser.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/aabc871d
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/aabc871d
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/aabc871d
Branch: refs/heads/staging/1.0.0
Commit: aabc871d7d05c4db1f4e3906e6a8c93b0fc9a30b
Parents: 1011845
Author: Nick Couchman <vn...@apache.org>
Authored: Thu Apr 19 08:55:24 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Fri Jun 1 13:40:52 2018 -0400
----------------------------------------------------------------------
extensions/guacamole-auth-quickconnect/pom.xml | 8 ++++
.../auth/quickconnect/utility/QCParser.java | 2 +-
.../auth/quickconnect/utility/QCParserTest.java | 49 ++++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/aabc871d/extensions/guacamole-auth-quickconnect/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-quickconnect/pom.xml b/extensions/guacamole-auth-quickconnect/pom.xml
index e8d0440..b2fd922 100644
--- a/extensions/guacamole-auth-quickconnect/pom.xml
+++ b/extensions/guacamole-auth-quickconnect/pom.xml
@@ -193,6 +193,14 @@
<scope>provided</scope>
</dependency>
+ <!-- JUnit -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/aabc871d/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java
index 4924619..c8e954a 100644
--- a/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java
+++ b/extensions/guacamole-auth-quickconnect/src/main/java/org/apache/guacamole/auth/quickconnect/utility/QCParser.java
@@ -167,7 +167,7 @@ public class QCParser {
* @throws UnsupportedEncodingException
* If Java lacks UTF-8 support.
*/
- private static Map<String, String> parseQueryString(String queryStr)
+ public static Map<String, String> parseQueryString(String queryStr)
throws UnsupportedEncodingException {
// Split the query string into the pairs
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/aabc871d/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java
new file mode 100644
index 0000000..5567ea3
--- /dev/null
+++ b/extensions/guacamole-auth-quickconnect/src/test/java/org/apache/guacamole/auth/quickconnect/utility/QCParserTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.guacamole.auth.quickconnect.utility;
+
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Class to test methods in the QCParser utility class.
+ */
+public class QCParserTest {
+
+ /**
+ * Verify that the parseQueryString() method functions as designed.
+ */
+ @Test
+ public void testParseQueryString() throws UnsupportedEncodingException {
+
+ final String queryString = "param1=value1¶m2=value2=3¶m3=value%3D3¶m4=value%264";
+ Map<String, String> queryMap = QCParser.parseQueryString(queryString);
+
+ assertEquals("value1", queryMap.get("param1"));
+ assertEquals("value2=3", queryMap.get("param2"));
+ assertEquals("value=3", queryMap.get("param3"));
+ assertEquals("value&4", queryMap.get("param4"));
+
+ }
+
+}