Package com.oldratlee.cooma

Examples of com.oldratlee.cooma.Config


       
        Ext5NoAdaptiveMethod impl2 = ExtensionLoader.getExtensionLoader(Ext5NoAdaptiveMethod.class).getExtension("impl2") ;
        assertThat(impl2, anyOf(instanceOf(Ext5Wrapper1.class), instanceOf(Ext5Wrapper2.class)));
       
       
        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1");
        int echoCount1 = Ext5Wrapper1.echoCount.get();
        int echoCount2 = Ext5Wrapper2.echoCount.get();
        int yellCount1 = Ext5Wrapper1.yellCount.get();
        int yellCount2 = Ext5Wrapper2.yellCount.get();
       
View Full Code Here


    @Test
    public void test_getAdaptiveExtension_defaultExtension() throws Exception {
        Ext1 ext = ExtensionLoader.getExtensionLoader(Ext1.class).getAdaptiveExtension();

        Map<String, String> map = new HashMap<String, String>();
        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1");

        String echo = ext.echo(config, "haha");
        assertEquals("Ext1Impl1-echo", echo);
    }
View Full Code Here

    @Test
    public void test_getAdaptiveExtension() throws Exception {
        Ext1 ext = ExtensionLoader.getExtensionLoader(Ext1.class).getAdaptiveExtension();

        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1", "ext1", "impl2");

        String echo = ext.echo(config, "haha");
        assertEquals("Ext1Impl2-echo", echo);
    }
View Full Code Here

    @Test
    public void test_getAdaptiveExtension_customizeKey() throws Exception {
        Ext1 ext = ExtensionLoader.getExtensionLoader(Ext1.class).getAdaptiveExtension();

        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1", "key2", "impl2");

        String echo = ext.yell(config, "haha");
        assertEquals("Ext1Impl2-yell", echo);

        config = config.addConfig("key1", "impl3");
        echo = ext.yell(config, "haha");
        assertEquals("Ext1Impl3-yell", echo);
    }
View Full Code Here

    @Test
    public void test_getAdaptiveExtension_ExceptionWhenNotAdativeMethod() throws Exception {
        Ext1 ext = ExtensionLoader.getExtensionLoader(Ext1.class).getAdaptiveExtension();

       
        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1");
        try {
            ext.bang(config, 33);
            fail();
        } catch (UnsupportedOperationException expected) {
            assertThat(expected.getMessage(), containsString("method "));
View Full Code Here

   
    @Test
    public void test_getAdaptiveExtension_protocolKey() throws Exception {
        Ext3 ext = ExtensionLoader.getExtensionLoader(Ext3.class).getAdaptiveExtension();
   
        Config config = Config.fromKv("protocol", "impl3", "host", "1.2.3.4", "port", "1010", "path", "path1");

        String echo = ext.echo(config, "s");
        assertEquals("Ext3Impl3-echo", echo);
   
        config = config.addConfig("key1", "impl2");
        echo = ext.echo(config, "s");
        assertEquals("Ext3Impl2-echo", echo);
       
        String yell = ext.yell(config, "d");
        assertEquals("Ext3Impl3-yell", yell);
View Full Code Here

    @Test
    public void test_getAdaptiveExtension_lastProtocolKey() throws Exception {
        Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
       
       
        Config config = Config.fromKv("protocol", "impl1", "host", "1.2.3.4", "port", "1010", "path", "path1");

        String yell = ext.yell(config, "s");
        assertEquals("Ext2Impl1-yell", yell);
       
        config = config.addConfig("key1", "impl2");
        yell = ext.yell(config, "s");
        assertEquals("Ext2Impl2-yell", yell);
    }
View Full Code Here

    @Test
    public void test_urlHolder_getAdaptiveExtension() throws Exception {
        Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();
       
        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1", "ext2", "impl1");
       
        UrlHolder holder = new UrlHolder();
        holder.setUrl(config);
   
        String echo = ext.echo(holder, "haha");
View Full Code Here

    @Test
    public void test_urlHolder_getAdaptiveExtension_noExtension() throws Exception {
        Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();

        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1");

        UrlHolder holder = new UrlHolder();
        holder.setUrl(config);
       
        try {
            ext.echo(holder, "haha");
            fail();
        } catch (IllegalStateException expected) {
            assertThat(expected.getMessage(), containsString("Fail to get extension("));
        }
       
        config = config.addConfig("ext2", "XXX");
        holder.setUrl(config);
        try {
            ext.echo(holder, "haha");
            fail();
        } catch (IllegalStateException expected) {
View Full Code Here

    @Test
    public void test_urlHolder_getAdaptiveExtension_ExceptionWhenNotAdativeMethod() throws Exception {
        Ext2 ext = ExtensionLoader.getExtensionLoader(Ext2.class).getAdaptiveExtension();

        Config config = Config.fromKv("protocol", "p1", "host", "1.2.3.4", "port", "1010", "path", "path1");
       
        try {
            ext.bang(config, 33);
            fail();
        } catch (UnsupportedOperationException expected) {
View Full Code Here

TOP

Related Classes of com.oldratlee.cooma.Config

Copyright © 2018 www.massapicom. 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.