Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Improved: Inline ‘StringUtil#toMap’
(OFBIZ-11014) ‘StringUtil#toMap’ was only used in the ‘CollectionConverters.StringToMap’ converter so in order to clean ‘StringUtil’ it seems better to inline it. The corresponding tests has been adapted to check ‘CollectionConverters.StringToMap#convert’ behavior instead. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862228 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
with
56 additions
and 47 deletions.
- +8 −3 framework/base/src/main/java/org/apache/ofbiz/base/conversion/CollectionConverters.java
- +0 −27 framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java
- +48 −0 framework/base/src/test/java/org/apache/ofbiz/base/conversion/CollectionConvertersTest.java
- +0 −17 framework/base/src/test/java/org/apache/ofbiz/base/util/StringUtilTests.java
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.ofbiz.base.conversion; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.ofbiz.base.util.UtilMisc; | ||
import org.junit.Test; | ||
|
||
public class CollectionConvertersTest { | ||
|
||
@Test | ||
public void testToMap() throws ConversionException { | ||
Converter<String, Map<String, String>> cvt = new CollectionConverters.StringToMap(); | ||
for (String s: new String[] {"", "{", "}", "}{"}) { | ||
ConversionException caught = null; | ||
try { | ||
cvt.convert(s); | ||
} catch (ConversionException e) { | ||
caught = e; | ||
} finally { | ||
assertNotNull("bad(" + s + ")", caught); | ||
} | ||
} | ||
assertEquals("single", UtilMisc.toMap("1", "one"), cvt.convert("{1=one}")); | ||
assertEquals("double", UtilMisc.toMap("2", "two", "1", "one"), cvt.convert("{1=one, 2=two}")); | ||
assertEquals("double-space", UtilMisc.toMap("2", "two ", " 1", "one"), cvt.convert("{ 1=one, 2=two }")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -83,23 +83,6 @@ public void testStrToMap() { | ||
StringUtil.strToMap(" 1 = one | 2 = two ", true)); | ||
} | ||
|
||
@Test | ||
public void testToList() { | ||
for (String s: new String[] {"", "[", "]", "]["}) { | ||