@Test
public void testAddSwitch() throws Exception {

    controller.activeSwitches = new ConcurrentHashMap<Long, IOFSwitch>();
    //OFSwitchImpl oldsw = createMock(OFSwitchImpl.class);
    OFSwitchImpl oldsw = new OFSwitchImpl();
    OFFeaturesReply featuresReply = new OFFeaturesReply();
    featuresReply.setDatapathId(0L);
    featuresReply.setPorts(new ArrayList<OFPhysicalPort>());
    oldsw.setFeaturesReply(featuresReply);
    //expect(oldsw.getId()).andReturn(0L).anyTimes();
    //expect(oldsw.asyncRemoveSwitchLock()).andReturn(rwlock.writeLock()).anyTimes();
    //oldsw.setConnected(false);
    //expect(oldsw.getStringId()).andReturn("00:00:00:00:00:00:00").anyTimes();
    Channel channel = createNiceMock(Channel.class);
    //expect(oldsw.getChannel()).andReturn(channel);
    oldsw.setChannel(channel);
    expect(channel.close()).andReturn(null);
    IOFSwitch newsw = createMock(IOFSwitch.class);
    expect(newsw.getId()).andReturn(0L).anyTimes();
    expect(newsw.getStringId()).andReturn("00:00:00:00:00:00:00").anyTimes();
    expect(newsw.getConnectedSince()).andReturn(new Date());
    Channel channel2 = createMock(Channel.class);
    expect(newsw.getChannel()).andReturn(channel2);
    expect(channel2.getRemoteAddress()).andReturn(null);
    expect(newsw.getPorts()).andReturn(new ArrayList<OFPhysicalPort>());
    expect(newsw.getCapabilities()).andReturn(0).anyTimes();
    expect(newsw.getBuffers()).andReturn(0).anyTimes();
    expect(newsw.getTables()).andReturn((byte)0).anyTimes();
    expect(newsw.getActions()).andReturn(0).anyTimes();
    controller.activeSwitches.put(0L, oldsw);
    replay(newsw, channel, channel2);
    controller.addSwitch(newsw);
    verify(newsw, channel, channel2);
}