Changes between Version 15 and Version 16 of MiddleWareConnection


Ignore:
Timestamp:
10/28/12 17:36:39 (7 years ago)
Author:
welberge
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MiddleWareConnection

    v15 v16  
    205205} 
    206206}}} 
     207 
     208=== Testing the created adapters === 
     209A simple way to test the adapters is by mocking up a Realizer (through a RealizerPort) and a Behavior planner (through a BMLFeedbackListener). The realizer is then connected to the RsbToBMLRealizerAdapter; the feedbacklistener to the BMLRealizerToRsbAdapter. A BML message sent from the BMLRealizerToRsbAdapter should arrive at the mocked up realizer. A feedback message sent from the RsbToBMLRealizerAdapter should arrive at the behavior planner: 
     210 
     211{{{ 
     212package asap.rsbadapters; 
     213 
     214import static org.mockito.Mockito.mock; 
     215import static org.mockito.Mockito.verify; 
     216 
     217import org.junit.After; 
     218import org.junit.Test; 
     219 
     220import asap.bml.bridge.RealizerPort; 
     221import asap.bml.feedback.BMLFeedbackListener; 
     222 
     223/** 
     224 * Integration tests for the BMLToIpaaca and IpaacaToBML adapters. 
     225 * Requires a running spread daemon. 
     226 * @author Herwin 
     227 */ 
     228public class AsaptersIntegrationTest 
     229{ 
     230    private RealizerPort mockRealizerPort = mock(RealizerPort.class); 
     231    private BMLFeedbackListener mockFeedbackListener = mock(BMLFeedbackListener.class); 
     232    private BMLRealizerToRsbAdapter bmlToRsb = new BMLRealizerToRsbAdapter(); 
     233    private RsbToBMLRealizerAdapter rsbToBML = new RsbToBMLRealizerAdapter(mockRealizerPort); 
     234     
     235    @After 
     236    public void tearDown() 
     237    { 
     238        bmlToRsb.close(); 
     239        rsbToBML.close(); 
     240    } 
     241     
     242    @Test 
     243    public void testPerformBML() throws InterruptedException 
     244    { 
     245        bmlToRsb.performBML("bmltest"); 
     246        Thread.sleep(500); 
     247        verify(mockRealizerPort).performBML("bmltest"); 
     248    } 
     249     
     250    @Test 
     251    public void testFeedback() throws InterruptedException 
     252    { 
     253        bmlToRsb.addListeners(mockFeedbackListener); 
     254        rsbToBML.feedback("bmlfeedback"); 
     255        Thread.sleep(500); 
     256        verify(mockFeedbackListener).feedback("bmlfeedback"); 
     257    } 
     258} 
     259}}}