public int fireSelector(MyKey key, String expected, String expected2, boolean isSpecial) throws Exception {
        client1.oldConnect(null);
        mockSunsChannel.expect("connect");
        
        ByteBuffer b = ByteBuffer.allocate(1000);        
        HELPER.putString(b, expected);
        HELPER.doneFillingBuffer(b);
        int remain1 = b.remaining();
        
        mockSelect.addReturnValue("createRegistrationListener", mockRegListener);
        mockSunsChannel.addBehavior("write", new NoReadByteBuffer2(0));
        client1.oldWrite(b, (OperationCallback)mockWriteHandler);
        mockSunsChannel.expect("write");
        
        b = ByteBuffer.allocate(50);
        int remain2 = b.remaining();
        HELPER.putString(b, expected2);
        HELPER.doneFillingBuffer(b);
        client1.oldWrite(b, (OperationCallback)mockWriteHandler);
        
        mockSunsChannel.expect(MockObject.NONE);
        
        mockSelect.setDefaultReturnValue("getKeyFromChannel", key);
        
        String[] methodNames = new String[] { "getKeyFromChannel", "register" };
        CalledMethod[] methods = mockSelect.expect(methodNames);
        Object attachment = methods[1].getAllParams()[2];
        key.attach(attachment);

        Set<SelectionKey> set = new HashSet<SelectionKey>();
        set.add(key);
        mockSelect.addReturnValue("select", 1);
        mockSelect.addReturnValue("selectedKeys", set);
        
        mockSunsChannel.addBehavior("write", new NoReadByteBuffer2(remain1));
        if(isSpecial)
        	mockSunsChannel.addBehavior("write", new NoReadByteBuffer2(1));
        else
        	mockSunsChannel.addBehavior("write", new NoReadByteBuffer2(remain2));
        //now, simlute the jdk selector going off....
        listener.selectorFired();     
        
        return remain2;
    }