You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by da...@apache.org on 2012/09/03 09:24:28 UTC
svn commit: r1380147 -
/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java
Author: davsclaus
Date: Mon Sep 3 07:24:27 2012
New Revision: 1380147
URL: http://svn.apache.org/viewvc?rev=1380147&view=rev
Log:
AMQ-3797: Added unit test for StringArrayEditor
Added:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java (with props)
Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java?rev=1380147&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java Mon Sep 3 07:24:27 2012
@@ -0,0 +1,72 @@
+/**
+ * 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.activemq.util;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ */
+public class StringArrayEditorTest extends TestCase {
+
+ private StringArrayEditor editor = new StringArrayEditor();
+
+ public void testConvertToStringArray() throws Exception {
+ editor.setAsText(null);
+ assertEquals(null, editor.getValue());
+ editor.setAsText("");
+ assertEquals(null, editor.getValue());
+
+ editor.setAsText("foo");
+ String[] array = (String[]) editor.getValue();
+ assertEquals(1, array.length);
+ assertEquals("foo", array[0]);
+
+ editor.setAsText("foo,bar");
+ array = (String[]) editor.getValue();
+ assertEquals(2, array.length);
+ assertEquals("foo", array[0]);
+ assertEquals("bar", array[1]);
+
+ editor.setAsText("foo,bar,baz");
+ array = (String[]) editor.getValue();
+ assertEquals("foo", array[0]);
+ assertEquals("bar", array[1]);
+ assertEquals("baz", array[2]);
+ }
+
+ public void testConvertToString() throws Exception {
+ editor.setValue(null);
+ assertEquals(null, editor.getAsText());
+
+ editor.setValue(new String[]{});
+ assertEquals(null, editor.getAsText());
+
+ editor.setValue(new String[]{""});
+ assertEquals("", editor.getAsText());
+
+ editor.setValue(new String[]{"foo"});
+ assertEquals("foo", editor.getAsText());
+
+ editor.setValue(new String[]{"foo", "bar"});
+ assertEquals("foo,bar", editor.getAsText());
+
+ editor.setValue(new String[]{"foo", "bar", "baz"});
+ assertEquals("foo,bar,baz", editor.getAsText());
+ }
+
+}
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/StringArrayEditorTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date