mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashish <paliwalash...@gmail.com>
Subject [Vysper] Porting to MINA 2.0.X (Some errors)
Date Tue, 02 Jun 2009 13:11:27 GMT
Back again with the topic. Did most of the porting on local copy, to
see how much time does it take :-)

One Observation

When using this code snippet in class XMLStreamTokenizerTestCase.java

private IoBuffer createByteBuffer() {
        return IoBuffer.allocate(0, false).setAutoExpand(true);
    }

was getting this error "Derived buffers and their parent can't be expanded."

When I changed the code to

private IoBuffer createByteBuffer() {
        return IoBuffer.allocate(1, false).setAutoExpand(true);
}

it worked fine. I guess I am missing something here



Errors

Most of the code has been ported, stuck with 2 Test Cases
Now stuck with testing the Decoder part

The test case code is below (XMLStreamTokenizerTestCase.java). Used
ProtocolCodeSession, as used in  CumulativeProtocolDecoderTest

It fails at first assert, expected is 4, but it gets 1.

public void testDecoderSimple() throws Exception {
        XMLStreamTokenizer decoder = new XMLStreamTokenizer();
        IoSession session = new ProtocolCodecSession();
        IoBuffer firstByteBuffer = createByteBuffer();
        IoBuffer secondByteBuffer = createByteBuffer();

        String stanza = StanzaWriter.XML_PROLOG + "\n\r" +
                "<stream:stream to='example.com' xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>" +
                "<trailing-stanza/>";

        firstByteBuffer.putString(stanza, CHARSET_ENCODER_UTF8).flip();

        MockProtocolDecoderOutput protocolDecoderOutput = new
MockProtocolDecoderOutput();
        decoder.decode(session, firstByteBuffer, protocolDecoderOutput);
        assertEquals(4, protocolDecoderOutput.size());

        secondByteBuffer.putString("<next></next>",
CHARSET_ENCODER_UTF8).flip();

        decoder.decode(session, secondByteBuffer, protocolDecoderOutput);
        assertEquals(5, protocolDecoderOutput.size());

        IoBuffer emptyBuffer = createByteBuffer().putString("eee",
CHARSET_ENCODER_UTF8).flip();
        decoder.decode(session, emptyBuffer, protocolDecoderOutput);
        assertEquals("plain must be terminated by <", 5,
protocolDecoderOutput.size());

        IoBuffer termBuffer = createByteBuffer().putString("<r>",
CHARSET_ENCODER_UTF8).flip();
        decoder.decode(session, termBuffer, protocolDecoderOutput);
        // eee is now terminated, but r is not balanced yet
        assertEquals("plain termination", 6, protocolDecoderOutput.size());

    }

Will continue to debug this, meanwhile any pointers are appreciated.

-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Mime
View raw message