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.message; 00018 00019 import static org.junit.Assert.assertEquals; 00020 00021 import org.ros.internal.message.definition.MessageDefinitionProviderChain; 00022 00023 import org.junit.Before; 00024 import org.junit.Test; 00025 import org.ros.internal.message.service.ServiceDefinitionResourceProvider; 00026 import org.ros.internal.message.service.ServiceDescription; 00027 import org.ros.internal.message.service.ServiceDescriptionFactory; 00028 import org.ros.internal.message.topic.TopicDefinitionResourceProvider; 00029 import org.ros.internal.message.topic.TopicDescription; 00030 import org.ros.internal.message.topic.TopicDescriptionFactory; 00031 00035 public class Md5GeneratorTest { 00036 00037 private TopicDescriptionFactory topicDescriptionFactory; 00038 private ServiceDescriptionFactory serviceDescriptionFactory; 00039 00040 @Before 00041 public void setUp() { 00042 MessageDefinitionProviderChain messageDefinitionProviderChain = 00043 new MessageDefinitionProviderChain(); 00044 messageDefinitionProviderChain 00045 .addMessageDefinitionProvider(new TopicDefinitionResourceProvider()); 00046 messageDefinitionProviderChain 00047 .addMessageDefinitionProvider(new ServiceDefinitionResourceProvider()); 00048 topicDescriptionFactory = new TopicDescriptionFactory(messageDefinitionProviderChain); 00049 serviceDescriptionFactory = new ServiceDescriptionFactory(messageDefinitionProviderChain); 00050 } 00051 00052 @Test 00053 public void testPrimitives() { 00054 TopicDescription topicDescription = 00055 topicDescriptionFactory.newFromType("rosjava_test_msgs/TestPrimitives"); 00056 assertEquals("3e70f428a22c0d26ca67f87802c8e00f", topicDescription.getMd5Checksum()); 00057 } 00058 00059 @Test 00060 public void testString() { 00061 TopicDescription topicDescription = topicDescriptionFactory.newFromType("rosjava_test_msgs/TestString"); 00062 assertEquals("334ff4377be93faa44ebc66d23d40fd3", topicDescription.getMd5Checksum()); 00063 } 00064 00065 @Test 00066 public void testHeader() { 00067 TopicDescription topicDescription = topicDescriptionFactory.newFromType("rosjava_test_msgs/TestHeader"); 00068 assertEquals("4b5a00f536da2f756ba6aebcf795a967", topicDescription.getMd5Checksum()); 00069 } 00070 00071 @Test 00072 public void testArrays() { 00073 TopicDescription topicDescription = topicDescriptionFactory.newFromType("rosjava_test_msgs/TestArrays"); 00074 assertEquals("4cc9b5e2cebe791aa3e994f5bc159eb6", topicDescription.getMd5Checksum()); 00075 } 00076 00077 @Test 00078 public void testComposite() { 00079 TopicDescription topicDescription = topicDescriptionFactory.newFromType("rosjava_test_msgs/Composite"); 00080 assertEquals("d8fb6eb869ad3956b50e8737d96dc9fa", topicDescription.getMd5Checksum()); 00081 } 00082 00083 @Test 00084 public void testOdometry() { 00085 TopicDescription topicDescription = topicDescriptionFactory.newFromType("nav_msgs/Odometry"); 00086 assertEquals("cd5e73d190d741a2f92e81eda573aca7", topicDescription.getMd5Checksum()); 00087 } 00088 00089 @Test 00090 public void testEmpty() { 00091 ServiceDescription serviceDescription = serviceDescriptionFactory.newFromType("std_srvs/Empty"); 00092 assertEquals("d41d8cd98f00b204e9800998ecf8427e", serviceDescription.getMd5Checksum()); 00093 } 00094 00095 @Test 00096 public void testAddTwoInts() { 00097 ServiceDescription serviceDescription = 00098 serviceDescriptionFactory.newFromType("rosjava_test_msgs/AddTwoInts"); 00099 assertEquals("6a2e34150c00229791cc89ff309fff21", serviceDescription.getMd5Checksum()); 00100 } 00101 00102 @Test 00103 public void testTransitiveSrv() { 00104 ServiceDescription serviceDescription = 00105 serviceDescriptionFactory.newFromType("rosjava_test_msgspy/TransitiveSrv"); 00106 assertEquals("8b7918ee2b81eaf825f4c70de011f6fa", serviceDescription.getMd5Checksum()); 00107 } 00108 }