MessageInterfaceBuilderTest.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012 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.message;
00018 
00019 import static org.junit.Assert.assertEquals;
00020 
00021 import org.junit.Before;
00022 import org.junit.Test;
00023 import org.ros.internal.message.topic.TopicDefinitionResourceProvider;
00024 import org.ros.message.MessageDeclaration;
00025 import org.ros.message.MessageFactory;
00026 
00030 public class MessageInterfaceBuilderTest {
00031 
00032   private TopicDefinitionResourceProvider topicDefinitionResourceProvider;
00033   private MessageFactory messageFactory;
00034 
00035   @Before
00036   public void before() {
00037     topicDefinitionResourceProvider = new TopicDefinitionResourceProvider();
00038     messageFactory = new DefaultMessageFactory(topicDefinitionResourceProvider);
00039   }
00040 
00041   @Test
00042   public void testDuplicateFieldNames() {
00043     MessageInterfaceBuilder builder = new MessageInterfaceBuilder();
00044     builder.setPackageName("foo");
00045     builder.setInterfaceName("bar");
00046     builder.setMessageDeclaration(MessageDeclaration.of("foo/bar", "int32 foo\nint32 Foo"));
00047     builder.setAddConstantsAndMethods(true);
00048     String result = builder.build(messageFactory);
00049     assertEquals("package foo;\n\n"
00050         + "public interface bar extends org.ros.internal.message.Message {\n"
00051         + "  static final java.lang.String _TYPE = \"foo/bar\";\n"
00052         + "  static final java.lang.String _DEFINITION = \"int32 foo\\nint32 Foo\";\n"
00053         + "  int getFoo();\n" + "  void setFoo(int value);\n" + "}\n", result);
00054   }
00055 }


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