Search in sources :

Example 1 with BasicAddressResolver

use of org.apache.ignite.configuration.BasicAddressResolver in project ignite by apache.

the class GridTcpSpiForwardingSelfTest method testBasicResolverMapAddress.

/**
 * @throws Exception If failed.
 */
@Test
public void testBasicResolverMapAddress() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("127.0.0.1", "127.0.0.1");
    rslvr = new BasicAddressResolver(map);
    ipFinderUseLocPorts = true;
    doTestForward();
}
Also used : HashMap(java.util.HashMap) BasicAddressResolver(org.apache.ignite.configuration.BasicAddressResolver) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 2 with BasicAddressResolver

use of org.apache.ignite.configuration.BasicAddressResolver in project ignite by apache.

the class GridTcpSpiForwardingSelfTest method testBasicResolverErrors.

/**
 * @throws Exception If failed.
 */
@Test
public void testBasicResolverErrors() throws Exception {
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            return new BasicAddressResolver(null);
        }
    }, IllegalArgumentException.class, "At least one address mapping is required.");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            return new BasicAddressResolver(new HashMap<String, String>());
        }
    }, IllegalArgumentException.class, "At least one address mapping is required.");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put("from", null);
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: from=null");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put("from", "");
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: from=");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put(null, "to");
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: null=to");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put("", "to");
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: =to");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put("from", "to:1111");
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: from=to:1111");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put("from:1111", "to");
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: from:1111=to");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put("from:1111:2222", "to:1111");
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: from:1111:2222=to:1111");
    GridTestUtils.assertThrows(log, new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Map<String, String> map = new HashMap<>();
            map.put("from:1111", "to:1111:2222");
            return new BasicAddressResolver(map);
        }
    }, IllegalArgumentException.class, "Invalid address mapping: from:1111=to:1111:2222");
}
Also used : HashMap(java.util.HashMap) BasicAddressResolver(org.apache.ignite.configuration.BasicAddressResolver) HashMap(java.util.HashMap) Map(java.util.Map) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 3 with BasicAddressResolver

use of org.apache.ignite.configuration.BasicAddressResolver in project ignite by apache.

the class GridTcpSpiForwardingSelfTest method testBasicResolverMapPorts.

/**
 * @throws Exception If failed.
 */
@Test
public void testBasicResolverMapPorts() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("127.0.0.1:" + locPort1, "127.0.0.1:" + extPort1);
    map.put("127.0.0.1:" + commLocPort1, "127.0.0.1:" + commExtPort1);
    map.put("127.0.0.1:" + locPort2, "127.0.0.1:" + extPort2);
    map.put("127.0.0.1:" + commLocPort2, "127.0.0.1:" + commExtPort2);
    rslvr = new BasicAddressResolver(map);
    doTestForward();
}
Also used : HashMap(java.util.HashMap) BasicAddressResolver(org.apache.ignite.configuration.BasicAddressResolver) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)3 BasicAddressResolver (org.apache.ignite.configuration.BasicAddressResolver)3 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)3 Test (org.junit.Test)3 Map (java.util.Map)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1