Tabnine Logo
TestUtils.getMessageParser
Code IndexAdd Tabnine to your IDE (free)

How to use
getMessageParser
method
in
org.jivesoftware.smack.test.util.TestUtils

Best Java code snippets using org.jivesoftware.smack.test.util.TestUtils.getMessageParser (Showing top 3 results out of 315)

origin: igniterealtime/Smack

  @Test
  public void headersInMessageTest() throws Exception {
    // @formatter:off
    final String messageStanza =
     "<message xmlns='jabber:client' from='romeo@shakespeare.lit/orchard' to='juliet@capulet.com' type='chat'>" +
      "<body>Wherefore are thou?!?</body>" +
      "<headers xmlns='http://jabber.org/protocol/shim'>" +
       "<header name='Urgency'>high</header>" +
      "</headers>" +
     "</message>";
    // @formatter:on
    XmlPullParser parser = TestUtils.getMessageParser(messageStanza);
    Message message = PacketParserUtils.parseMessage(parser);
    HeadersExtension headers = HeadersExtension.from(message);
    Header header = headers.getHeaders().get(0);
    assertEquals("Urgency", header.getName());
    assertEquals("high", header.getValue());
  }
}
origin: igniterealtime/Smack

@Test
public void consumeUnparsedInput() throws Exception {
  final String MESSAGE_EXCEPTION_ELEMENT =
          "<" + ThrowException.ELEMENT + " xmlns='" + ThrowException.NAMESPACE + "'>" +
            "<nothingInHere>" +
            "</nothingInHere>" +
          "</" + ThrowException.ELEMENT + ">";
  XmlPullParser parser = TestUtils.getMessageParser(
      "<message from='user@server.example' to='francisco@denmark.lit' id='foo'>" +
        MESSAGE_EXCEPTION_ELEMENT +
        EXTENSION2 +
      "</message>");
  int parserDepth = parser.getDepth();
  CharSequence content = null;
  try {
    PacketParserUtils.parseMessage(parser);
  } catch (Exception e) {
    content = PacketParserUtils.parseContentDepth(parser, parserDepth, false);
  }
  assertThat(MESSAGE_EXCEPTION_ELEMENT + EXTENSION2 + "</message>", equalsCharSequence(content));
}
origin: igniterealtime/Smack

/**
 * RFC6121 5.2.3 explicitly disallows mixed content in <body/> elements. Make sure that we throw
 * an exception if we encounter such an element.
 *
 * @throws Exception
 */
@Test(expected = XmlPullParserException.class)
public void invalidMessageBodyContainingTagTest() throws Exception {
  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", "en")
    .e("body")
      .a("xmlns", "http://www.w3.org/1999/xhtml")
      .e("span")
        .a("style", "font-weight: bold;")
        .t("Bad Message Body")
    .asString(outputProperties);
  Message message = PacketParserUtils.parseMessage(TestUtils.getMessageParser(control));
  fail("Should throw exception. Instead got message: " + message.toXML(null).toString());
}
org.jivesoftware.smack.test.utilTestUtilsgetMessageParser

Popular methods of TestUtils

  • getParser
  • parseExtensionElement
  • getIQParser

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now