MasterSlaveIntegrationTest.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;
00018 
00019 import static org.junit.Assert.assertEquals;
00020 import static org.junit.Assert.assertTrue;
00021 
00022 import org.junit.After;
00023 import org.junit.Before;
00024 import org.junit.Test;
00025 import org.ros.address.AdvertiseAddress;
00026 import org.ros.address.BindAddress;
00027 import org.ros.internal.node.client.MasterClient;
00028 import org.ros.internal.node.client.SlaveClient;
00029 import org.ros.internal.node.parameter.ParameterManager;
00030 import org.ros.internal.node.response.Response;
00031 import org.ros.internal.node.server.SlaveServer;
00032 import org.ros.internal.node.server.master.MasterServer;
00033 import org.ros.internal.node.service.ServiceManager;
00034 import org.ros.internal.node.topic.TopicParticipantManager;
00035 import org.ros.namespace.GraphName;
00036 
00037 import java.net.URI;
00038 import java.util.concurrent.Executors;
00039 import java.util.concurrent.ScheduledExecutorService;
00040 
00044 public class MasterSlaveIntegrationTest {
00045 
00046   private MasterServer masterServer;
00047   private MasterClient masterClient;
00048   private SlaveServer slaveServer;
00049   private SlaveClient slaveClient;
00050   private ScheduledExecutorService executorService;
00051 
00052   @Before
00053   public void setUp() {
00054     executorService = Executors.newScheduledThreadPool(10);
00055     masterServer = new MasterServer(BindAddress.newPrivate(), AdvertiseAddress.newPrivate());
00056     masterServer.start();
00057     masterClient = new MasterClient(masterServer.getUri());
00058     TopicParticipantManager topicParticipantManager = new TopicParticipantManager();
00059     ServiceManager serviceManager = new ServiceManager();
00060     ParameterManager parameterManager = new ParameterManager(executorService);
00061     slaveServer =
00062         new SlaveServer(GraphName.of("/foo"), BindAddress.newPrivate(),
00063             AdvertiseAddress.newPrivate(), BindAddress.newPrivate(), AdvertiseAddress.newPrivate(),
00064             masterClient, topicParticipantManager, serviceManager, parameterManager,
00065             executorService);
00066     slaveServer.start();
00067     slaveClient = new SlaveClient(GraphName.of("/bar"), slaveServer.getUri());
00068   }
00069 
00070   @After
00071   public void tearDown() {
00072     masterServer.shutdown();
00073     executorService.shutdown();
00074   }
00075 
00076   @Test
00077   public void testGetMasterUri() {
00078     Response<URI> response = slaveClient.getMasterUri();
00079     assertEquals(masterServer.getUri(), response.getResult());
00080   }
00081 
00082   @Test
00083   public void testGetPid() {
00084     Response<Integer> response = slaveClient.getPid();
00085     assertTrue(response.getResult() > 0);
00086   }
00087 }


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