    @Test
    public void sessionBarrierWriteError() throws Exception {

        IOFSwitch sw = createMock(IOFSwitch.class);
        setupSwitchMock(sw, dpId);
        swWriteSecondFail(sw);
        doneWithSetUp(sw);

        CompletableFuture<Optional<OFMessage>> future = null;
        try (Session session = subject.open(context, sw)) {
            future = session.write(makePacketOut(sw.getOFFactory(), 1));
        }

        try {
            future.get(1, TimeUnit.SECONDS);
            Assert.fail();
        } catch (ExecutionException e) {
            Assert.assertNotNull(e.getCause());
            Assert.assertTrue(e.getCause() instanceof SessionCloseException);
        }
    }