Commit e222513d authored by Dave Cridland's avatar Dave Cridland

OF-1335 Remove debuggery

parent 01d67e45
......@@ -381,35 +381,28 @@ public class XMPPPacketReader {
// all ancestors have the same namespace and it's a content
// namespace.
boolean dropNamespace = false;
System.out.println("* Processing start element {" + pp.getNamespace() + "}" + pp.getName());
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,
// so we'll drop. Example, stanzas, <message><body/></message>
dropNamespace = true;
for (Element el = parent; el != null; el = el.getParent()) {
final String defaultNS = el.getNamespaceForPrefix("").getURI();
System.out.println(" Parent defaultNS is " + defaultNS);
if (defaultNS.equals("")) {
// We've cleared this one already, just bail.
System.out.println(" --> Stop; dropNS");
break;
}
if (!defaultNS.equals(qname.getNamespaceURI())) {
// But if there's an ancestor element, we shouldn't drop
// after all. Example: forwarded message.
dropNamespace = false;
System.out.println(" --> Stop; NOT dropNS");
break;
}
}
}
if ( dropNamespace ) {
System.out.println("New element, no namespace");
newElement = df.createElement(pp.getName());
}
else {
System.out.println("New element, with namespace");
newElement = df.createElement(qname);
}
int nsStart = pp.getNamespaceCount(pp.getDepth() - 1);
......@@ -417,16 +410,13 @@ public class XMPPPacketReader {
for (int i = nsStart; i < nsEnd; i++) {
final String namespacePrefix = pp.getNamespacePrefix( i );
final String namespaceUri = pp.getNamespaceUri( i );
System.out.println("Considering {" + namespacePrefix + "} -> {" + namespaceUri + "}");
if ( namespacePrefix != null ) {
newElement.addNamespace(namespacePrefix, namespaceUri);
System.out.println(" Copying.");
} else if ( parent == null && IGNORED_NAMESPACE_ON_STANZA.contains( namespaceUri ) ) {
// Don't copy.
} 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.
newElement.addNamespace( "", namespaceUri );
System.out.println(" Copying no prefix.");
}
}
for (int i = 0; i < pp.getAttributeCount(); i++) {
......
......@@ -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>";
// 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" ) );
......@@ -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>";
// 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" ) );
......@@ -109,9 +105,7 @@ 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" ) );
......@@ -141,9 +135,7 @@ 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" ) );
......@@ -163,9 +155,7 @@ public class XMPPPacketReaderTest
" <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