Here are the examples of the java api class org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser taken from open source projects.
1. FileConfiguration#parse()
Project: activemq-artemis
File: FileConfiguration.java
File: FileConfiguration.java
@Override public void parse(Element config) throws Exception { FileConfigurationParser parser = new FileConfigurationParser(); // https://jira.jboss.org/browse/HORNETQ-478 - We only want to validate AIO when // starting the server // and we don't want to do it when deploying activemq-queues.xml which uses the same parser and XML format parser.setValidateAIO(true); parser.parseMainConfig(config, this); parsed = true; }
2. FileConfigurationParserTest#testParsingClusterConnectionURIs()
Project: activemq-artemis
File: FileConfigurationParserTest.java
File: FileConfigurationParserTest.java
@Test public void testParsingClusterConnectionURIs() throws Exception { FileConfigurationParser parser = new FileConfigurationParser(); String configStr = firstPart + "<cluster-connections>\n" + " <cluster-connection-uri name=\"my-cluster\" address=\"multicast://my-discovery-group?messageLoadBalancingType=STRICT;retryInterval=333;connectorName=netty-connector;maxHops=1\"/>\n" + "</cluster-connections>\n" + lastPart; ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8)); Configuration config = parser.parseMainConfig(input); Assert.assertEquals(1, config.getClusterConfigurations().size()); Assert.assertEquals("my-discovery-group", config.getClusterConfigurations().get(0).getDiscoveryGroupName()); Assert.assertEquals(333, config.getClusterConfigurations().get(0).getRetryInterval()); }
3. WrongRoleFileConfigurationParserTest#testParsingDefaultServerConfig()
Project: activemq-artemis
File: WrongRoleFileConfigurationParserTest.java
File: WrongRoleFileConfigurationParserTest.java
/** * * * */ @Test public void testParsingDefaultServerConfig() throws Exception { FileConfigurationParser parser = new FileConfigurationParser(); ByteArrayInputStream input = new ByteArrayInputStream(configuration.getBytes(StandardCharsets.UTF_8)); parser.parseMainConfig(input); // Using the code only because I don't want a test failing just for someone editing Log text assertTrue(AssertionLoggerHandler.findText("AMQ222177", "create-durable-queue")); assertTrue(AssertionLoggerHandler.findText("AMQ222177", "delete-durable-queue")); }
4. FileConfigurationParserTest#testParsingDefaultServerConfig()
Project: activemq-artemis
File: FileConfigurationParserTest.java
File: FileConfigurationParserTest.java
@Test public void testParsingDefaultServerConfig() throws Exception { FileConfigurationParser parser = new FileConfigurationParser(); String configStr = firstPart + lastPart; ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8)); Configuration config = parser.parseMainConfig(input); String clusterPassword = config.getClusterPassword(); assertEquals(ActiveMQDefaultConfiguration.getDefaultClusterPassword(), clusterPassword); //if we add cluster-password, it should be default plain text String clusterPasswordPart = "<cluster-password>helloworld</cluster-password>"; configStr = firstPart + clusterPasswordPart + lastPart; config = parser.parseMainConfig(new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8))); assertEquals("helloworld", config.getClusterPassword()); //if we add mask, it should be able to decode correctly DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); String mask = (String) codec.encode("helloworld"); String maskPasswordPart = "<mask-password>true</mask-password>"; clusterPasswordPart = "<cluster-password>" + mask + "</cluster-password>"; configStr = firstPart + clusterPasswordPart + maskPasswordPart + lastPart; config = parser.parseMainConfig(new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8))); assertEquals("helloworld", config.getClusterPassword()); //if we change key, it should be able to decode correctly codec = new DefaultSensitiveStringCodec(); Map<String, String> prop = new HashMap<>(); prop.put("key", "newkey"); codec.init(prop); mask = (String) codec.encode("newpassword"); clusterPasswordPart = "<cluster-password>" + mask + "</cluster-password>"; String codecPart = "<password-codec>" + "org.apache.activemq.artemis.utils.DefaultSensitiveStringCodec" + ";key=newkey</password-codec>"; configStr = firstPart + clusterPasswordPart + maskPasswordPart + codecPart + lastPart; config = parser.parseMainConfig(new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8))); assertEquals("newpassword", config.getClusterPassword()); }