public void testDisconnectAfterReadResultsInNewKey() throws Exception {
		InetAddress loopBack = InetAddress.getByName("127.0.0.1");
		InetSocketAddress clientAddr = new InetSocketAddress(loopBack, 0);		
		InetSocketAddress serverAddr = new InetSocketAddress(loopBack, 0);
		
		server.configureBlocking(false);
		server.socket().bind(serverAddr);
		client.socket().bind(clientAddr);
		
		server.register(selector, SelectionKey.OP_ACCEPT);
		
		new PollingThread2().start();
		
		SocketAddress addr = server.socket().getLocalSocketAddress();
		client.connect(addr);
		
		log.info("configure client non-blocking");
		client.configureBlocking(false);
		//client.register(selector, SelectionKey.OP_READ);
		
//		Thread.sleep(2000);
		log.info("write data to server");
		ByteBuffer b = ByteBuffer.allocate(10);
		b.putChar('d');
		b.putChar('e');
		b.flip();
		log.info("write bytes");
		int i = client.write(b);
		log.info("wrote bytes="+i);
		
		synchronized(client) {
			log.info("waiting for server to tell us received data from read");
			if(!receivedWrite)
				client.wait();
		}
		
		client.close();
		
		synchronized(client) {
			log.info("close done, notify server");			
			closeHappened = true;
			client.notify();
		}

		log.info("sleeping");
		//will block forever when bug is fixed.....
//		synchronized(lastLock) {
//			if(!isThreadDone)
//				lastLock.wait();
//		}
		log.info("result="+result);

		Thread.sleep(5000);	
		log.info("test done");
	}