Commit e222513d authored by Dave Cridland's avatar Dave Cridland

OF-1335 Remove debuggery

parent 01d67e45
...@@ -381,35 +381,28 @@ public class XMPPPacketReader { ...@@ -381,35 +381,28 @@ public class XMPPPacketReader {
// all ancestors have the same namespace and it's a content // all ancestors have the same namespace and it's a content
// namespace. // namespace.
boolean dropNamespace = false; boolean dropNamespace = false;
System.out.println("* Processing start element {" + pp.getNamespace() + "}" + pp.getName());
if (pp.getPrefix() == null && IGNORED_NAMESPACE_ON_STANZA.contains(qname.getNamespaceURI())) { if (pp.getPrefix() == null && IGNORED_NAMESPACE_ON_STANZA.contains(qname.getNamespaceURI())) {
System.out.println("Prefix null on element " + qname.getName() + " in ns " + qname.getNamespaceURI());
// Default namespaced element which is in a content namespace, // Default namespaced element which is in a content namespace,
// so we'll drop. Example, stanzas, <message><body/></message> // so we'll drop. Example, stanzas, <message><body/></message>
dropNamespace = true; dropNamespace = true;
for (Element el = parent; el != null; el = el.getParent()) { for (Element el = parent; el != null; el = el.getParent()) {
final String defaultNS = el.getNamespaceForPrefix("").getURI(); final String defaultNS = el.getNamespaceForPrefix("").getURI();
System.out.println(" Parent defaultNS is " + defaultNS);
if (defaultNS.equals("")) { if (defaultNS.equals("")) {
// We've cleared this one already, just bail. // We've cleared this one already, just bail.
System.out.println(" --> Stop; dropNS");
break; break;
} }
if (!defaultNS.equals(qname.getNamespaceURI())) { if (!defaultNS.equals(qname.getNamespaceURI())) {
// But if there's an ancestor element, we shouldn't drop // But if there's an ancestor element, we shouldn't drop
// after all. Example: forwarded message. // after all. Example: forwarded message.
dropNamespace = false; dropNamespace = false;
System.out.println(" --> Stop; NOT dropNS");
break; break;
} }
} }
} }
if ( dropNamespace ) { if ( dropNamespace ) {
System.out.println("New element, no namespace");
newElement = df.createElement(pp.getName()); newElement = df.createElement(pp.getName());
} }
else { else {
System.out.println("New element, with namespace");
newElement = df.createElement(qname); newElement = df.createElement(qname);
} }
int nsStart = pp.getNamespaceCount(pp.getDepth() - 1); int nsStart = pp.getNamespaceCount(pp.getDepth() - 1);
...@@ -417,16 +410,13 @@ public class XMPPPacketReader { ...@@ -417,16 +410,13 @@ public class XMPPPacketReader {
for (int i = nsStart; i < nsEnd; i++) { for (int i = nsStart; i < nsEnd; i++) {
final String namespacePrefix = pp.getNamespacePrefix( i ); final String namespacePrefix = pp.getNamespacePrefix( i );
final String namespaceUri = pp.getNamespaceUri( i ); final String namespaceUri = pp.getNamespaceUri( i );
System.out.println("Considering {" + namespacePrefix + "} -> {" + namespaceUri + "}");
if ( namespacePrefix != null ) { if ( namespacePrefix != null ) {
newElement.addNamespace(namespacePrefix, namespaceUri); newElement.addNamespace(namespacePrefix, namespaceUri);
System.out.println(" Copying.");
} else if ( parent == null && IGNORED_NAMESPACE_ON_STANZA.contains( namespaceUri ) ) { } else if ( parent == null && IGNORED_NAMESPACE_ON_STANZA.contains( namespaceUri ) ) {
// Don't copy. // Don't copy.
} else if ( !(dropNamespace && namespaceUri.equals( qname.getNamespaceURI() ) ) ) { } else if ( !(dropNamespace && namespaceUri.equals( qname.getNamespaceURI() ) ) ) {
// Do not include certain default namespace on the root-element ('stream') or stanza level. This makes stanzas re-usable between, for example, c2s and s2s. // Do not include certain default namespace on the root-element ('stream') or stanza level. This makes stanzas re-usable between, for example, c2s and s2s.
newElement.addNamespace( "", namespaceUri ); newElement.addNamespace( "", namespaceUri );
System.out.println(" Copying no prefix.");
} }
} }
for (int i = 0; i < pp.getAttributeCount(); i++) { for (int i = 0; i < pp.getAttributeCount(); i++) {
......
...@@ -55,9 +55,7 @@ public class XMPPPacketReaderTest ...@@ -55,9 +55,7 @@ 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>"; 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. // Execute system under test.
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) ); final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result. // Verify result.
Assert.assertFalse( result.asXML().contains( "jabber:client" ) ); Assert.assertFalse( result.asXML().contains( "jabber:client" ) );
...@@ -78,9 +76,7 @@ public class XMPPPacketReaderTest ...@@ -78,9 +76,7 @@ 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>"; 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. // Execute system under test.
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) ); final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result. // Verify result.
Assert.assertFalse( result.asXML().contains( "jabber:client" ) ); Assert.assertFalse( result.asXML().contains( "jabber:client" ) );
...@@ -109,9 +105,7 @@ public class XMPPPacketReaderTest ...@@ -109,9 +105,7 @@ public class XMPPPacketReaderTest
" </message>" + " </message>" +
"</stream:stream>"; "</stream:stream>";
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) ); final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result. // 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.assertFalse( "'jabber:client' should not occur before 'something:else'", result.asXML().substring( 0, result.asXML().indexOf("something:else") ).contains( "jabber:client" ) );
...@@ -141,9 +135,7 @@ public class XMPPPacketReaderTest ...@@ -141,9 +135,7 @@ public class XMPPPacketReaderTest
" </message>" + " </message>" +
"</stream:stream>"; "</stream:stream>";
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) ); final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result. // 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.assertFalse( "'jabber:client' should not occur before 'something:else'", result.asXML().substring( 0, result.asXML().indexOf("something:else") ).contains( "jabber:client" ) );
...@@ -163,9 +155,7 @@ public class XMPPPacketReaderTest ...@@ -163,9 +155,7 @@ public class XMPPPacketReaderTest
" <message xmlns='jabber:client'/>" + " <message xmlns='jabber:client'/>" +
" </other>" + " </other>" +
" </message>"; " </message>";
System.out.println("** " + input);
final Document result = packetReader.read( new StringReader( input ) ); final Document result = packetReader.read( new StringReader( input ) );
System.out.println("** " + result.asXML());
// Verify result. // 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.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