mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-38: Add unit test for query string parser.
This commit is contained in:
@@ -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>
|
||||
|
@@ -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
|
||||
|
@@ -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"));
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user