Tabnine Logo
XMLUtil.stringToElement
Code IndexAdd Tabnine to your IDE (free)

How to use
stringToElement
method
in
org.apache.activemq.artemis.utils.XMLUtil

Best Java code snippets using org.apache.activemq.artemis.utils.XMLUtil.stringToElement (Showing top 20 results out of 315)

origin: apache/activemq-artemis

public void parseConfiguration(final InputStream input) throws Exception {
 Reader reader = new InputStreamReader(input);
 String xml = XMLUtil.readerToString(reader);
 xml = XMLUtil.replaceSystemProps(xml);
 Element e = XMLUtil.stringToElement(xml);
 // only parse elements from <jms>
 NodeList children = e.getElementsByTagName(CONFIGURATION_SCHEMA_ROOT_ELEMENT);
 if (children.getLength() > 0) {
   parseConfiguration(children.item(0));
 }
}
origin: apache/activemq-artemis

public Configuration parseMainConfig(final InputStream input) throws Exception {
 Reader reader = new InputStreamReader(input);
 String xml = XMLUtil.readerToString(reader);
 xml = XMLUtil.replaceSystemProps(xml);
 Element e = XMLUtil.stringToElement(xml);
 SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 Schema schema = schemaFactory.newSchema(XMLUtil.findResource("schema/artemis-server.xsd"));
 Validator validator = schema.newValidator();
 try {
   validator.validate(new DOMSource(e));
 } catch (Exception ex) {
   ActiveMQServerLogger.LOGGER.error(ex.getMessage());
 }
 Configuration config = new ConfigurationImpl();
 parseMainConfig(e, config);
 return config;
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_4() throws Exception {
 String s = "<a attr1=\"val1\" attr2=\"val2\"/>";
 String s2 = "<a attr2=\"val2\" attr1=\"val1\"/>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_2() throws Exception {
 String s = "<a></a>";
 String s2 = "<a/>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_1() throws Exception {
 String s = "<a/>";
 String s2 = "<a/>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_5() throws Exception {
 String s = "<a><b/></a>";
 String s2 = "<a><b/></a>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_6() throws Exception {
 String s = "<enclosing><a attr1=\"val1\" attr2=\"val2\"/></enclosing>";
 String s2 = "<enclosing><a attr2=\"val2\" attr1=\"val1\"/></enclosing>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_8() throws Exception {
 String s = "<a><!-- some comment --><b/><!--some other comment --><c/><!-- blah --></a>";
 String s2 = "<a><b/><!--blah blah--><c/></a>";
 XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
}
origin: apache/activemq-artemis

@Test
public void testElementToString_4() throws Exception {
 String s = "<a><![CDATA[somedata]]></a>";
 Element e = XMLUtil.stringToElement(s);
 String tostring = XMLUtil.elementToString(e);
 Element convertedAgain = XMLUtil.stringToElement(tostring);
 XMLUtil.assertEquivalent(e, convertedAgain);
}
origin: apache/activemq-artemis

@Test
public void testGetTextContext_3() throws Exception {
 String document = "<blah someattribute=\"somevalue\"><a/></blah>";
 Element e = XMLUtil.stringToElement(document);
 String s = XMLUtil.getTextContent(e);
 Element subelement = XMLUtil.stringToElement(s);
 Assert.assertEquals("a", subelement.getNodeName());
}
origin: apache/activemq-artemis

@Test
public void testGetTextContext_4() throws Exception {
 String document = "<blah someattribute=\"somevalue\"><a></a></blah>";
 Element e = XMLUtil.stringToElement(document);
 String s = XMLUtil.getTextContent(e);
 Element subelement = XMLUtil.stringToElement(s);
 Assert.assertEquals("a", subelement.getNodeName());
}
origin: apache/activemq-artemis

@Test
public void testElementToString_2() throws Exception {
 String s = "<a b=\"something\"></a>";
 Element e = XMLUtil.stringToElement(s);
 String tostring = XMLUtil.elementToString(e);
 Element convertedAgain = XMLUtil.stringToElement(tostring);
 XMLUtil.assertEquivalent(e, convertedAgain);
}
origin: apache/activemq-artemis

@Test
public void testElementToString_1() throws Exception {
 String s = "<a b=\"something\">somethingelse</a>";
 Element e = XMLUtil.stringToElement(s);
 String tostring = XMLUtil.elementToString(e);
 Element convertedAgain = XMLUtil.stringToElement(tostring);
 XMLUtil.assertEquivalent(e, convertedAgain);
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_7() throws Exception {
 String s = "<a><b/><c/></a>";
 String s2 = "<a><c/><b/></a>";
 try {
   XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
   Assert.fail("this should throw exception");
 } catch (IllegalArgumentException e) {
   // OK
   e.printStackTrace();
 }
}
origin: apache/activemq-artemis

@Test
public void testEquivalent_3() throws Exception {
 String s = "<a attr1=\"val1\" attr2=\"val2\"/>";
 String s2 = "<a attr2=\"val2\"/>";
 try {
   XMLUtil.assertEquivalent(XMLUtil.stringToElement(s), XMLUtil.stringToElement(s2));
   Assert.fail("this should throw exception");
 } catch (IllegalArgumentException e) {
   // expected
 }
}
origin: apache/activemq-artemis

@Test
public void testElementToString_3() throws Exception {
 String s = "<a b=\"something\"/>";
 Element e = XMLUtil.stringToElement(s);
 String tostring = XMLUtil.elementToString(e);
 Element convertedAgain = XMLUtil.stringToElement(tostring);
 XMLUtil.assertEquivalent(e, convertedAgain);
}
origin: apache/activemq-artemis

@Test
public void testGetTextContext_5() throws Exception {
 String document = "<blah someattribute=\"somevalue\"><a><b/></a></blah>";
 Element e = XMLUtil.stringToElement(document);
 String s = XMLUtil.getTextContent(e);
 Element subelement = XMLUtil.stringToElement(s);
 Assert.assertEquals("a", subelement.getNodeName());
 NodeList nl = subelement.getChildNodes();
 // try to find <b>
 boolean found = false;
 for (int i = 0; i < nl.getLength(); i++) {
   Node n = nl.item(i);
   if ("b".equals(n.getNodeName())) {
    found = true;
   }
 }
 Assert.assertTrue(found);
}
origin: apache/activemq-artemis

/**
* test does not pass in eclipse (because it can not find artemis-configuration.xsd).
* It runs fine on the CLI with the proper env setting.
*/
@Test
public void testMinimalConfiguration() throws Exception {
 String xml = "<core xmlns='urn:activemq:core'>" + "</core>";
 Element element = XMLUtil.stringToElement(xml);
 Assert.assertNotNull(element);
 XMLUtil.validate(element, "schema/artemis-configuration.xsd");
}
origin: apache/activemq-artemis

@Test
public void testGetTextContext_2() throws Exception {
 String document = "<blah someattribute=\"somevalue\">foo</blah>";
 Element e = XMLUtil.stringToElement(document);
 Assert.assertEquals("foo", XMLUtil.getTextContent(e));
}
origin: apache/activemq-artemis

@Test
public void testGetTextContext_1() throws Exception {
 String document = "<blah>foo</blah>";
 Element e = XMLUtil.stringToElement(document);
 Assert.assertEquals("foo", XMLUtil.getTextContent(e));
}
org.apache.activemq.artemis.utilsXMLUtilstringToElement

Popular methods of XMLUtil

  • assertEquivalent
  • elementToString
  • findResource
  • getTextContent
    Note: if the content is another element or set of elements, it returns a string representation of th
  • filter
  • readerToElement
  • replaceSystemProps
  • readerToString
  • validate
  • parseBoolean
  • parseDouble
  • parseInt
  • parseDouble,
  • parseInt,
  • parseLong,
  • stripCDATA

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • putExtra (Intent)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Executors (java.util.concurrent)
    Factory and utility methods for Executor, ExecutorService, ScheduledExecutorService, ThreadFactory,
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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