Search in sources :

Example 6 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class ClientToMemberDiscoveryTest method setup.

@Before
public void setup() {
    String serverXmlFileName = "hazelcast-multicast-plugin.xml";
    String clientXmlFileName = "hazelcast-client-multicast-plugin.xml";
    InputStream xmlResource = MulticastDiscoveryStrategy.class.getClassLoader().getResourceAsStream(serverXmlFileName);
    serverConfig = new XmlConfigBuilder(xmlResource).build();
    InputStream xmlClientResource = MulticastDiscoveryStrategy.class.getClassLoader().getResourceAsStream(clientXmlFileName);
    clientConfig = new XmlClientConfigBuilder(xmlClientResource).build();
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) XmlClientConfigBuilder(com.hazelcast.client.config.XmlClientConfigBuilder) InputStream(java.io.InputStream) MulticastDiscoveryStrategy(com.hazelcast.spi.discovery.multicast.MulticastDiscoveryStrategy) Before(org.junit.Before)

Example 7 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class HazelcastServerCachingProvider method getConfig.

private Config getConfig(URL configURL, ClassLoader theClassLoader, String instanceName) throws IOException {
    Config config = new XmlConfigBuilder(configURL).build();
    config.setClassLoader(theClassLoader);
    if (instanceName != null) {
        // If instance name is specified via properties use it
        // even though instance name is specified in the config.
        config.setInstanceName(instanceName);
    } else if (config.getInstanceName() == null) {
        // Use config url as instance name if instance name is not specified.
        config.setInstanceName(configURL.toString());
    }
    return config;
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Config(com.hazelcast.config.Config)

Example 8 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class CachePartitionLostListenerConfigTest method cacheConfigXmlTest.

@Test
public void cacheConfigXmlTest() throws IOException {
    String cacheName = "cacheWithPartitionLostListener";
    Config config = new XmlConfigBuilder(configUrl).build();
    CacheSimpleConfig cacheConfig = config.getCacheConfig(cacheName);
    List<CachePartitionLostListenerConfig> configs = cacheConfig.getPartitionLostListenerConfigs();
    assertEquals(1, configs.size());
    assertEquals("DummyCachePartitionLostListenerImpl", configs.get(0).getClassName());
}
Also used : CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) Config(com.hazelcast.config.Config) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class DiscoverySpiTest method testNodeFilter_from_xml.

@Test
public void testNodeFilter_from_xml() throws Exception {
    String xmlFileName = "test-hazelcast-discovery-spi.xml";
    InputStream xmlResource = DiscoverySpiTest.class.getClassLoader().getResourceAsStream(xmlFileName);
    Config config = new XmlConfigBuilder(xmlResource).build();
    JoinConfig joinConfig = config.getNetworkConfig().getJoin();
    DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
    Address address = new Address("localhost", 5701);
    DiscoveryServiceSettings settings = buildDiscoveryServiceSettings(address, discoveryConfig, DiscoveryMode.Client);
    DiscoveryServiceProvider provider = new DefaultDiscoveryServiceProvider();
    DiscoveryService discoveryService = provider.newDiscoveryService(settings);
    discoveryService.start();
    discoveryService.discoverNodes();
    discoveryService.destroy();
    Field nodeFilterField = DefaultDiscoveryService.class.getDeclaredField("nodeFilter");
    nodeFilterField.setAccessible(true);
    TestNodeFilter nodeFilter = (TestNodeFilter) nodeFilterField.get(discoveryService);
    assertEquals(4, nodeFilter.getNodes().size());
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) Address(com.hazelcast.nio.Address) InetAddress(java.net.InetAddress) InputStream(java.io.InputStream) AwsConfig(com.hazelcast.config.AwsConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) MulticastConfig(com.hazelcast.config.MulticastConfig) JoinConfig(com.hazelcast.config.JoinConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) TcpIpConfig(com.hazelcast.config.TcpIpConfig) InterfacesConfig(com.hazelcast.config.InterfacesConfig) DiscoveryServiceSettings(com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings) DiscoveryServiceProvider(com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) Field(java.lang.reflect.Field) DefaultDiscoveryServiceProvider(com.hazelcast.spi.discovery.impl.DefaultDiscoveryServiceProvider) JoinConfig(com.hazelcast.config.JoinConfig) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) DiscoveryService(com.hazelcast.spi.discovery.integration.DiscoveryService) DefaultDiscoveryService(com.hazelcast.spi.discovery.impl.DefaultDiscoveryService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 10 with XmlConfigBuilder

use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.

the class MemberToMemberDiscoveryTest method setUp.

@Before
public void setUp() {
    String xmlFileName = "hazelcast-multicast-plugin.xml";
    InputStream xmlResource = MulticastDiscoveryStrategy.class.getClassLoader().getResourceAsStream(xmlFileName);
    config = new XmlConfigBuilder(xmlResource).build();
    System.setProperty(TestEnvironment.HAZELCAST_TEST_USE_NETWORK, "true");
    System.setProperty("java.net.preferIPv4Stack", "true");
}
Also used : XmlConfigBuilder(com.hazelcast.config.XmlConfigBuilder) InputStream(java.io.InputStream) Before(org.junit.Before)

Aggregations

XmlConfigBuilder (com.hazelcast.config.XmlConfigBuilder)25 Config (com.hazelcast.config.Config)20 Test (org.junit.Test)10 InputStream (java.io.InputStream)9 QuickTest (com.hazelcast.test.annotation.QuickTest)8 MapConfig (com.hazelcast.config.MapConfig)7 JoinConfig (com.hazelcast.config.JoinConfig)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 URL (java.net.URL)6 MapStoreConfig (com.hazelcast.config.MapStoreConfig)5 MulticastConfig (com.hazelcast.config.MulticastConfig)5 TcpIpConfig (com.hazelcast.config.TcpIpConfig)5 AwsConfig (com.hazelcast.config.AwsConfig)4 DiscoveryConfig (com.hazelcast.config.DiscoveryConfig)4 DiscoveryStrategyConfig (com.hazelcast.config.DiscoveryStrategyConfig)4 InterfacesConfig (com.hazelcast.config.InterfacesConfig)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 ClientConfig (com.hazelcast.client.config.ClientConfig)2 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)2