Commit 01d67e45 authored by Dave Cridland's avatar Dave Cridland

OF-1335 Strip namespaces differently

parent daf92ff2
This diff is collapsed.
......@@ -55,7 +55,9 @@ public class XMPPPacketReaderTest
final String input = "<stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'><message from='juliet@example.com' to='romeo@example.net' xml:lang='en'><body>Art thou not Romeo, and a Montague?</body></message></stream:stream>";
// Execute system under test.
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result.
Assert.assertFalse( result.asXML().contains( "jabber:client" ) );
......@@ -76,7 +78,9 @@ public class XMPPPacketReaderTest
final String input = "<stream:stream to='example.com' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'><message xmlns='jabber:client' from='juliet@example.com' to='romeo@example.net' xml:lang='en'><body>Art thou not Romeo, and a Montague?</body></message></stream:stream>";
// Execute system under test.
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result.
Assert.assertFalse( result.asXML().contains( "jabber:client" ) );
......@@ -105,7 +109,9 @@ public class XMPPPacketReaderTest
" </message>" +
"</stream:stream>";
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result.
Assert.assertFalse( "'jabber:client' should not occur before 'something:else'", result.asXML().substring( 0, result.asXML().indexOf("something:else") ).contains( "jabber:client" ) );
......@@ -135,7 +141,31 @@ public class XMPPPacketReaderTest
" </message>" +
"</stream:stream>";
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result.
Assert.assertFalse( "'jabber:client' should not occur before 'something:else'", result.asXML().substring( 0, result.asXML().indexOf("something:else") ).contains( "jabber:client" ) );
Assert.assertTrue( "'jabber:client' should occur after 'something:else'", result.asXML().substring( result.asXML().indexOf("something:else") ).contains( "jabber:client" ) );
}
/**
* Check that a websocket connection woudl also work.
*/
@Test
public void testStripNamespacesForWebsocket() throws Exception
{
final String input_header = "<open xmlns='urn:ietf:params:xml:ns:xmpp-framing' to='example.com' version='1.0' />";
final Document doc_header = packetReader.read( new StringReader( input_header ) );
final String input = " <message xmlns='jabber:client'>" +
" <other xmlns='something:else'>" +
" <message xmlns='jabber:client'/>" +
" </other>" +
" </message>";
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result.
Assert.assertFalse( "'jabber:client' should not occur before 'something:else'", result.asXML().substring( 0, result.asXML().indexOf("something:else") ).contains( "jabber:client" ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment