Examples of IBatisNamespaceRule


Examples of com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceRule

                List<Set<IRoutingRule<IBatisRoutingFact, List<String>>>> ruleSequence = setUpRuleSequenceContainerIfNecessary(
                        router, namespace);

                if (StringUtils.isEmpty(shardingExpression)) {

                    ruleSequence.get(3).add(new IBatisNamespaceRule(namespace, destinations));
                } else {
                    IBatisNamespaceShardingRule insr = new IBatisNamespaceShardingRule(namespace,
                            destinations, shardingExpression);
                    if (MapUtils.isNotEmpty(functionsMap)) {
                        insr.setFunctionMap(functionsMap);
View Full Code Here

Examples of com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceRule

                        "'namespace' and 'sqlAction' are alternatives, can't guess which one to use if both of them are provided.");
            }

            if (StringUtils.isNotEmpty(namespace)) {
                if (StringUtils.isEmpty(shardingExpression)) {
                    namespaceRules.add(new IBatisNamespaceRule(namespace, destinations));
                } else {
                    IBatisNamespaceShardingRule insr = new IBatisNamespaceShardingRule(namespace,
                            destinations, shardingExpression);
                    if (MapUtils.isNotEmpty(getFunctionsMap())) {
                        insr.setFunctionMap(getFunctionsMap());
View Full Code Here

Examples of com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceRule

import com.alibaba.cobar.client.support.utils.CollectionUtils;

@Test
public class IBatisNamespaceRuleTest{
    public void testNamespaceRuleNormally() {
        IBatisNamespaceRule rule = new IBatisNamespaceRule("com.alibaba.cobar.client.entity.Tweet",
                "p1, p2");
        List<String> shardIds = rule.action();
        assertNotNull(shardIds);
        assertEquals(2, shardIds.size());

        IBatisRoutingFact fact = new IBatisRoutingFact(
                "com.alibaba.cobar.client.entity.Tweet.update", null);
        assertTrue(rule.isDefinedAt(fact));
        fact = new IBatisRoutingFact("com.alibaba.cobar.client.entity.Tweet.delete", null);
        assertTrue(rule.isDefinedAt(fact));
        fact = new IBatisRoutingFact("com.alibaba.cobar.client.entity.Twet.delete", null);
        assertFalse(rule.isDefinedAt(fact));
    }
View Full Code Here

Examples of com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceRule

        fact = new IBatisRoutingFact("com.alibaba.cobar.client.entity.Twet.delete", null);
        assertFalse(rule.isDefinedAt(fact));
    }

    public void testNamespaceRuleNormallyWithCustomActionPatternSeparator() {
        IBatisNamespaceRule rule = new IBatisNamespaceRule("com.alibaba.cobar.client.entity.Tweet",
                "p1, p2");
        rule.setActionPatternSeparator(";");
        List<String> shards = rule.action();
        assertTrue(CollectionUtils.isNotEmpty(shards));
        assertEquals(1, shards.size());

        rule = new IBatisNamespaceRule("com.alibaba.cobar.client.entity.Tweet", "p1; p2");
        rule.setActionPatternSeparator(";");
        shards = null;
        shards = rule.action();
        assertTrue(CollectionUtils.isNotEmpty(shards));
        assertEquals(2, shards.size());

        IBatisRoutingFact fact = new IBatisRoutingFact(
                "com.alibaba.cobar.client.entity.Tweet.update", null);
        assertTrue(rule.isDefinedAt(fact));
        fact = new IBatisRoutingFact("com.alibaba.cobar.client.entity.Tweet.delete", null);
        assertTrue(rule.isDefinedAt(fact));
        fact = new IBatisRoutingFact("com.alibaba.cobar.client.entity.Twet.delete", null);
        assertFalse(rule.isDefinedAt(fact));
    }
View Full Code Here

Examples of com.alibaba.cobar.client.router.rules.ibatis.IBatisNamespaceRule

        assertFalse(rule.isDefinedAt(fact));
    }

    public void testNamespaceRuleAbnormally() {
        try {
            new IBatisNamespaceRule("", "");
            fail();
        } catch (IllegalArgumentException e) {
            // pass
        }

        try {
            new IBatisNamespaceRule("", null);
            fail();
        } catch (IllegalArgumentException e) {
            // pass
        }

        try {
            new IBatisNamespaceRule(null, "");
            fail();
        } catch (IllegalArgumentException e) {
            // pass
        }

        try {
            new IBatisNamespaceRule(null, null);
            fail();
        } catch (IllegalArgumentException e) {
            // pass
        }

        IBatisNamespaceRule rule = new IBatisNamespaceRule("com.alibaba.cobar.client.entity.Tweet",
                "p1, p2");
        try {
            rule.setActionPatternSeparator(null);
        } catch (IllegalArgumentException e) {
            // pass
        }

        try {
            rule.isDefinedAt(null);
            fail();
        } catch (IllegalArgumentException e) {
            // pass
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.