Skip to content
Browse files

Implemented: Add unit tests for ‘UtilHttp#getPathInfoOnlyParameterMap’


git-svn-id: 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jul 19, 2019
1 parent d972375 commit b1f0137d19cddcbb2ef3bdc7259b9da5962ecaea
Showing with 64 additions and 0 deletions.
  1. +64 −0 framework/base/src/test/java/org/apache/ofbiz/base/util/
@@ -0,0 +1,64 @@
* 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
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
package org.apache.ofbiz.base.util;

import static org.apache.ofbiz.base.util.UtilHttp.getPathInfoOnlyParameterMap;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.Matchers.hasEntry;
import static org.junit.Assert.assertThat;

import java.util.Arrays;
import java.util.Map;

import org.hamcrest.Matchers;
import org.junit.Test;

public class UtilHttpTest {

public void basicGetPathInfoOnlyParameterMap() {
assertThat(getPathInfoOnlyParameterMap("/~foo=1/~bar=2", null, false),
allOf(hasEntry("foo", "1"), hasEntry("bar", "2")));

assertThat(getPathInfoOnlyParameterMap("/~foo=1/~foo=2", null, false),
hasEntry("foo", Arrays.asList("1", "2")));

assertThat(getPathInfoOnlyParameterMap("/~foo=1/~foo=2/~foo=3/", null, false),
hasEntry("foo", Arrays.asList("1", "2", "3")));

assertThat(getPathInfoOnlyParameterMap("/~foo=1/~bar=2/~foo=3/", null, false),
hasEntry("foo", Arrays.asList("1", "3")),
hasEntry("bar", "2")));

public void emptyGetPathInfoOnlyParameterMap() {
assertThat(getPathInfoOnlyParameterMap(null, null, false), is(anEmptyMap()));

public void filteredGetPathInfoOnlyParameterMap() {
assertThat(getPathInfoOnlyParameterMap("/~foo=1/~bar=2", UtilMisc.toSet("foo"), false),
allOf(not(hasEntry("foo", "1")), hasEntry("bar", "2")));

assertThat(getPathInfoOnlyParameterMap("/~foo=1/~bar=2", UtilMisc.toSet("foo"), true),
allOf(hasEntry("foo", "1"), not(hasEntry("bar", "2"))));

0 comments on commit b1f0137

Please sign in to comment.
You can’t perform that action at this time.