cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1235338 - in /cxf/dosgi/trunk/dsw/cxf-dsw/src: main/java/org/apache/cxf/dosgi/dsw/service/Utils.java test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
Date Tue, 24 Jan 2012 16:36:12 GMT
Author: sergeyb
Date: Tue Jan 24 16:36:12 2012
New Revision: 1235338

URL: http://svn.apache.org/viewvc?rev=1235338&view=rev
Log:
[DOSGI-108] Checking string properties for multiple values

Modified:
    cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
    cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java?rev=1235338&r1=1235337&r2=1235338&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/Utils.java
Tue Jan 24 16:36:12 2012
@@ -40,9 +40,15 @@ public class Utils {
 
         if (object instanceof String) {
             String s = (String)object;
-            String[] ret = new String[1];
-            ret[0] = s;
-            return ret;
+            String[] values = s.split(",");
+            List<String> list = new ArrayList<String>();
+            for (String val : values) {
+            	String actualValue = val.trim();
+            	if (actualValue.length() > 0) {
+            		list.add(actualValue);
+            	}
+            }
+            return list.toArray(new String[0]);
         }
 
         if (object instanceof String[]) {

Modified: cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java?rev=1235338&r1=1235337&r2=1235338&view=diff
==============================================================================
--- cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
(original)
+++ cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/UtilsTest.java
Tue Jan 24 16:36:12 2012
@@ -18,23 +18,27 @@
  */
 package org.apache.cxf.dosgi.dsw.service;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
 import java.util.Properties;
 
-import org.osgi.framework.Constants;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
 import org.junit.Test;
+import org.osgi.framework.Constants;
 
 public class UtilsTest {
 
+	@Test
+	public void testSplitString() {
+		String[] values = Utils.normalizeStringPlus("1, 2");
+		assertEquals(2, values.length);
+		assertEquals(values[0], "1");
+		assertEquals(values[1], "2");
+	}
+	
     @Test
     public void testNormalizeStringPlus() {
 



Mime
View raw message