@Ignore @Test public void duplicateMessageBodiesTest() throws FactoryConfigurationError, XmlPullParserException, IOException, Exception { String defaultLanguage = Stanza.getDefaultLanguage(); // message has default language, first body no language, second body default language String control = XMLBuilder.create("message") .namespace(StreamOpen.CLIENT_NAMESPACE) .a("from", "romeo@montague.lit/orchard") .a("to", "juliet@capulet.lit/balcony") .a("id", "zid615d9") .a("type", "chat") .a("xml:lang", defaultLanguage) .e("body") .t(defaultLanguage) .up() .e("body") .a("xml:lang", defaultLanguage) .t(defaultLanguage + "2") .asString(outputProperties); Message message = PacketParserUtils .parseMessage(PacketParserUtils.getParserFor(control)); assertEquals(defaultLanguage, message.getBody()); assertEquals(defaultLanguage, message.getBody(defaultLanguage)); assertEquals(1, message.getBodies().size()); assertEquals(0, message.getBodyLanguages().size()); assertXMLNotEqual(control, message.toXML(null).toString()); }
@Ignore @Test public void duplicateMessageBodiesTest2() throws FactoryConfigurationError, XmlPullParserException, IOException, Exception { String defaultLanguage = Stanza.getDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage(); // message has no language, first body no language, second body no language String control = XMLBuilder.create("message") .namespace(StreamOpen.CLIENT_NAMESPACE) .a("xml:lang", defaultLanguage) .a("from", "romeo@montague.lit/orchard") .a("to", "juliet@capulet.lit/balcony") .a("id", "zid615d9") .a("type", "chat") .e("body") .t(defaultLanguage) .up() .e("body") .t(otherLanguage) .asString(outputProperties); PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control)); }
@Test public void messageNoLanguageFirstBodyNoLanguageSecondBodyOtherTest() throws FactoryConfigurationError, XmlPullParserException, IOException, Exception { String defaultLanguage = Stanza.getDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage(); // message has no language, first body no language, second body other language String control = XMLBuilder.create("message") .namespace(StreamOpen.CLIENT_NAMESPACE) .a("from", "romeo@montague.lit/orchard") .a("to", "juliet@capulet.lit/balcony") .a("id", "zid615d9") .a("type", "chat") .e("body") // TODO change default language into something else .t(defaultLanguage) .up() .e("body") .a("xml:lang", otherLanguage) .t(otherLanguage) .asString(outputProperties); Message message = PacketParserUtils .parseMessage(PacketParserUtils.getParserFor(control)); assertEquals(defaultLanguage, message.getBody()); assertEquals(defaultLanguage, message.getBody(null)); assertEquals(otherLanguage, message.getBody(otherLanguage)); assertEquals(2, message.getBodies().size()); assertEquals(1, message.getBodyLanguages().size()); assertXMLEqual(control, message.toXML(null).toString()); }
@Test public void multipleMessageBodiesTest() throws Exception { String defaultLanguage = Stanza.getDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();
@Test public void multipleMessageSubjectsTest() throws Exception { String defaultLanguage = Stanza.getDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();
@Test public void singleMessageBodyTest() throws Exception { String defaultLanguage = Stanza.getDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();
@Test public void singleMessageSubjectTest() throws Exception { String defaultLanguage = Stanza.getDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();