You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Ashish <pa...@gmail.com> on 2009/06/02 15:11:27 UTC
[Vysper] Porting to MINA 2.0.X (Some errors)
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
Re: [Vysper] Porting to MINA 2.0.X (Some errors)
Posted by Ashish <pa...@gmail.com>.
Things seem fine. Build and all tests were successful :-)
Here are the files that I looked for changes
1. XmppIoHandlerAdapter - Changes are Fine
2. TCPEndpoint.java - Have used a slightly different approach
The code is
acceptor.setReuseAddress(true);
acceptor.bind(new InetSocketAddress(port));
and I operate mostly on SessionConfig. here is the code
SocketSessionConfig socketAcceptorConfig = acceptor.getSessionConfig();
socketAcceptorConfig.setReuseAddress(true);
On a closer look, NioSocketAcceptor doesn't set this variable from
SessionConfig. So seems my understanding is incorrect. Folks any
pointers on this?
3. MinaBackedSessionContext.java
Line 95 - close() is deprecated. Can plan to use close(boolean) implementation
4. StanzaWriterProtocolEncoder.java - Look fine. A simple suggestion
Line 58-61, the if statements are without braces, it makes it very
difficult to read the code. Though they are one line statements, use
of braces shall add to readability and avoid any future error
5. XMLStreamTokenizer.java - Looks Fine
6. XMPPProtocolCodecFactory.java - If we don't maintain any state
within decoders, we can initialize them once and return them from
getXXcoder() calls
7. ParticleDecoder.java - Looks Fine
One more thing, now that we have moved to maven build, we can remove
the lib folder, and probably log folder as well.
Will see if I can dig around a little more.
thanks
ashish
Re: [Vysper] Porting to MINA 2.0.X (Some errors)
Posted by Ashish <pa...@gmail.com>.
> Hi,
>
> Vysper/MINA2.0Mx is now in svn on a branch.
> server is still coming up and running.
>
> MINA core devs, please review if you find the time and energy.
>
> Ashish, does this go along well with you local port?
Give me sometime, in process of reviewing the changes.
Most of the porting is simple. I just got stuck at DecoderTest.
Will let you know in a while
>
> Ashish wrote:
>> 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
Re: [Vysper] Porting to MINA 2.0.X (Some errors)
Posted by Bernd Fondermann <bf...@brainlounge.de>.
Hi,
Vysper/MINA2.0Mx is now in svn on a branch.
server is still coming up and running.
MINA core devs, please review if you find the time and energy.
Ashish, does this go along well with you local port?
Thanks everyone,
Bernd
Ashish wrote:
> 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.
>