StringListResultFactoryTest.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2011 Google Inc.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
00015  */
00016 
00017 package org.ros.internal.node.response;
00018 
00019 import java.util.List;
00020 
00021 import junit.framework.TestCase;
00022 
00023 import org.junit.Test;
00024 
00025 import com.google.common.collect.Lists;
00026 
00030 public class StringListResultFactoryTest extends TestCase {
00031 
00032   @Test
00033   public void testEncodeAndDecode() {
00034     StringListResultFactory factory = new StringListResultFactory();
00035     List<String> expected;
00036     List<String> value;
00037 
00038     expected = Lists.newArrayList();
00039     value = factory.newFromValue(new Object[] {});
00040     assertEquals(expected, value);
00041     value = factory.newFromValue(new String[] {});
00042     assertEquals(expected, value);
00043 
00044     expected = Lists.newArrayList(new String[] { "foo" });
00045     value = factory.newFromValue(new Object[] { "foo" });
00046     assertEquals(expected, value);
00047     value = factory.newFromValue(new String[] { "foo" });
00048     assertEquals(expected, value);
00049 
00050     expected = Lists.newArrayList(new String[] { "foo", "bar" });
00051     value = factory.newFromValue(new Object[] { "foo", "bar" });
00052     assertEquals(expected, value);
00053     value = factory.newFromValue(new String[] { "foo", "bar" });
00054     assertEquals(expected, value);
00055 
00056     try {
00057       factory.newFromValue("bad");
00058       fail("should not have converted");
00059     } catch (ClassCastException e) {
00060     }
00061     try {
00062       factory.newFromValue(new Object[] { 1 });
00063       fail("should not have converted");
00064     } catch (ClassCastException e) {
00065     }
00066     try {
00067       factory.newFromValue(new Object[] { "1", 1 });
00068       fail("should not have converted");
00069     } catch (ClassCastException e) {
00070     }
00071   }
00072 }


rosjava_core
Author(s):
autogenerated on Wed Aug 26 2015 16:06:49