Search in sources :

Example 1 with HostAndPort

use of org.apache.logging.log4j.plugins.test.validation.HostAndPort in project logging-log4j2 by apache.

the class ValidPortValidatorTest method setUp.

@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() throws Exception {
    final PluginManager manager = new PluginManager("Test");
    manager.collectPlugins();
    plugin = (PluginType<HostAndPort>) manager.getPluginType("HostAndPort");
    assertNotNull(plugin, "Rebuild this module to ensure annotation processing has been done.");
    node = new Node(null, "HostAndPort", plugin);
    node.getAttributes().put("host", "localhost");
}
Also used : PluginManager(org.apache.logging.log4j.plugins.util.PluginManager) HostAndPort(org.apache.logging.log4j.plugins.test.validation.HostAndPort) Node(org.apache.logging.log4j.plugins.Node) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with HostAndPort

use of org.apache.logging.log4j.plugins.test.validation.HostAndPort in project logging-log4j2 by apache.

the class ValidHostValidatorTest method testLocalhost.

@Test
public void testLocalhost() throws Exception {
    node.getAttributes().put("host", "localhost");
    node.getAttributes().put("port", "1");
    final HostAndPort hostAndPort = buildPlugin();
    assertNotNull(hostAndPort);
    assertTrue(hostAndPort.isValid());
}
Also used : HostAndPort(org.apache.logging.log4j.plugins.test.validation.HostAndPort) Test(org.junit.jupiter.api.Test)

Example 3 with HostAndPort

use of org.apache.logging.log4j.plugins.test.validation.HostAndPort in project logging-log4j2 by apache.

the class ValidHostValidatorTest method setUp.

@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() throws Exception {
    final PluginManager manager = new PluginManager("Test");
    manager.collectPlugins();
    plugin = (PluginType<HostAndPort>) manager.getPluginType("HostAndPort");
    assertNotNull(plugin, "Rebuild this module to ensure annotation processing has been done.");
    node = new Node(null, "HostAndPort", plugin);
}
Also used : PluginManager(org.apache.logging.log4j.plugins.util.PluginManager) HostAndPort(org.apache.logging.log4j.plugins.test.validation.HostAndPort) Node(org.apache.logging.log4j.plugins.Node) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with HostAndPort

use of org.apache.logging.log4j.plugins.test.validation.HostAndPort in project logging-log4j2 by apache.

the class ValidHostValidatorTest method testInvalidIpAddress.

@Test
public void testInvalidIpAddress() throws Exception {
    node.getAttributes().put("host", "256.256.256.256");
    node.getAttributes().put("port", "1");
    final HostAndPort plugin = buildPlugin();
    assertNull(plugin, "Expected null, but got: " + plugin);
}
Also used : HostAndPort(org.apache.logging.log4j.plugins.test.validation.HostAndPort) Test(org.junit.jupiter.api.Test)

Aggregations

HostAndPort (org.apache.logging.log4j.plugins.test.validation.HostAndPort)4 Node (org.apache.logging.log4j.plugins.Node)2 PluginManager (org.apache.logging.log4j.plugins.util.PluginManager)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2