/** * @param output * @return * @throws XmlPullParserException * @throws IOException */ private static XmlPullParser getParser(String output) throws XmlPullParserException, IOException { return TestUtils.getParser(output, "validate"); } }
public void waitAndReset() { waitUntilInvocationOrTimeout(); reset(); }
public static <EE extends ExtensionElement> EE parseExtensionElement(String elementString) throws Exception { return parseExtensionElement(getParser(elementString)); }
@BeforeClass @AfterClass public static void deletePath() { FileTestUtil.deleteDirectory(storagePath); }
public static void assertSimilar(CharSequence expected, CharSequence actual) throws SAXException, IOException { assertXmlSimilar(expected, actual); }
/** * Reset the lists of added, deleted or updated items. */ @Override public synchronized void reset() { super.reset(); addressesAdded.clear(); addressesDeleted.clear(); addressesUpdated.clear(); } }
@Override public void processStanza(Stanza packet) throws NotConnectedException { reportInvoked(); }
@Factory public static Matcher<CharSequence> equalsCharSequence(CharSequence charSequence) { return new CharSequenceEquals(charSequence); } }
@Override public byte[] encode(byte[] input, int offset, int len) { String string = encodeToString(input, offset, len); try { return string.getBytes(StringUtils.USASCII); } catch (UnsupportedEncodingException e) { throw new AssertionError(e); } } });
private void processServerMessage(Stanza incomingChat) { TestChatServer chatServer = new TestChatServer(incomingChat, dc); chatServer.start(); try { chatServer.join(); } catch (InterruptedException e) { throw new AssertionError(e); } waitListener.waitAndReset(); }
public static XmlPullParser getIQParser(String stanza) { return getParser(stanza, "iq"); }
@AfterClass @BeforeClass public static void deleteDirs() { FileTestUtil.deleteDirectory(basePath); } }
public static XmlPullParser getPresenceParser(String stanza) { return getParser(stanza, "presence"); }
@AfterClass @BeforeClass public static void deleteDirs() { FileTestUtil.deleteDirectory(basePath); } }
public static XmlPullParser getMessageParser(String stanza) { return getParser(stanza, "message"); }
public static XmlPullParser getParser(String string) { return getParser(string, null); }
public static XmlPullParser getParser(String string, String startTag) { return getParser(new StringReader(string), startTag); }
@Test(expected = XmlPullParserException.class) public void unknownMoodValueExceptionTest() throws Exception { String xml = "<mood xmlns='http://jabber.org/protocol/mood'>" + "<unknown/>" + "</mood>"; XmlPullParser parser = TestUtils.getParser(xml); MoodElement element = MoodProvider.INSTANCE.parse(parser); } }
@Test(expected = IllegalArgumentException.class) public void emptyPreKeysShouldFailTest() throws Exception { String s = "<bundle xmlns='eu.siacs.conversations.axolotl'><signedPreKeyPublic signedPreKeyId='1'>BU4bJ18+rqbSnBblZU8pR/s+impyhoL9AJssJIE59fZb</signedPreKeyPublic><signedPreKeySignature>MaQtv7ySqHpPr0gkVtMp4KmWC61Hnfs5a7/cKEhrX8n12evGdkg4fNf3Q/ufgmJu5dnup9pkTA1pj00dTbtXjw==</signedPreKeySignature><identityKey>BWO0QOem1YXIJuT61cxXpG/mKlvISDwZxQJHW2/7eVki</identityKey><prekeys></prekeys></bundle>"; XmlPullParser parser = TestUtils.getParser(s); new OmemoBundleVAxolotlProvider().parse(parser); }
@Test(expected = IllegalArgumentException.class) public void missingPreKeysShouldAlsoFailTest() throws Exception { String s = "<bundle xmlns='eu.siacs.conversations.axolotl'><signedPreKeyPublic signedPreKeyId='1'>BU4bJ18+rqbSnBblZU8pR/s+impyhoL9AJssJIE59fZb</signedPreKeyPublic><signedPreKeySignature>MaQtv7ySqHpPr0gkVtMp4KmWC61Hnfs5a7/cKEhrX8n12evGdkg4fNf3Q/ufgmJu5dnup9pkTA1pj00dTbtXjw==</signedPreKeySignature><identityKey>BWO0QOem1YXIJuT61cxXpG/mKlvISDwZxQJHW2/7eVki</identityKey></bundle>"; XmlPullParser parser = TestUtils.getParser(s); new OmemoBundleVAxolotlProvider().parse(parser); } }