Package com.alibaba.citrus.service.uribroker.uri

Examples of com.alibaba.citrus.service.uribroker.uri.URIBroker$BaseURI


    }

    @Test
    public void init_request() {
        for (String name : service.getNames()) {
            URIBroker broker = service.getURIBrokerInternal(name);
            HttpServletRequest requestProxy = getFieldValue(broker, "request", HttpServletRequest.class);

            assertNotNull(requestProxy);
            assertTrue(requestProxy instanceof ProxyTargetFactory);
            assertSame(request, ((ProxyTargetFactory) requestProxy).getObject());
View Full Code Here


import org.junit.Test;

public class InterceptorForkTests {
    @Test
    public void test() {
        URIBroker u1 = new GenericURIBroker();
        u1.setServerURI("http://localhost:8080/");
        u1.setInterceptors(Collections.<URIBrokerInterceptor>singletonList(new MyInterceptor()));

        u1 = u1.fork();

        assertEquals(true, u1.isAutoReset());
        assertEquals("http://localhost:8080/", u1.toString());
        assertEquals("http://localhost:8080/?test=webx3", u1.render());

        // u1.toString以后,interceptor不被执行。
        u1.toString(); // http://localhost:8080/
        URIBroker u2 = u1.fork();

        assertEquals("http://localhost:8080/", u2.toString());
        assertEquals("http://localhost:8080/?test=webx3", u2.render());
        assertEquals("http://localhost:8080/", u2.toString());
    }
View Full Code Here

        ApplicationContext factory = new XmlApplicationContext(new FileSystemResource(new File(srcdir,
                                                                                               "services-uris.xml")));

        URIBrokerService uris = (URIBrokerService) factory.getBean("uris");

        URIBroker link1 = uris.getURIBroker("link1");
        assertEquals("http://taobao.com/hello", link1.toString());

        TurbineURIBroker link2 = (TurbineURIBroker) uris.getURIBroker("link2");
        assertSame(factory.getBean("mappingRuleService"), link2.getMappingRuleService());
        assertEquals("http://taobao.com/mycontext/myservlet/mycomponent/my_target.htm?action=myAction",
                     link2.toString());
View Full Code Here

        ApplicationContext factory = new XmlApplicationContext(new FileSystemResource(new File(srcdir,
                                                                                               "services-uris-no-mappings.xml")));

        URIBrokerService uris = (URIBrokerService) factory.getBean("uris");

        URIBroker link1 = uris.getURIBroker("link1");
        assertEquals("http://taobao.com/hello", link1.toString());

        TurbineURIBroker link2 = (TurbineURIBroker) uris.getURIBroker("link2");
        assertNull(link2.getMappingRuleService());
        assertEquals("http://taobao.com/mycontext/myservlet/mycomponent/my_target.vm?action=myAction", link2.toString());
View Full Code Here

    @Test
    public void not_requestAware() {
        service = (URIBrokerServiceImpl) factory.getBean("not-requestAware");

        for (String name : service.getNames()) {
            URIBroker uri = service.getURIBroker(name);

            if ("link-request".equals(name)) {
                assertEquals("http://localhost/", uri.render());
            } else {
                assertEquals("http:///", uri.render());
                assertEquals("http://www.alibaba.com:9999/", uri.setServerName("www.alibaba.com").setServerPort(9999)
                                                                .render());
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void standalone() {
        URIBroker broker = (URIBroker) factory.getBean("standalone_uri");
        assertEquals("http://www.taobao.com/hello", broker.toString());
    }
View Full Code Here

    @Test
    public void noCharset() {
        service = (URIBrokerServiceImpl) factory.getBean("noDefaultCharset");

        URIBroker link1 = service.getURIBroker("a");
        assertEquals(null, link1.getCharset());
        assertEquals("http://localhost/?name=%E4%B8%AD%E5%9B%BD", link1.addQueryData("name", "中国").render()); // from context

        URIBroker link2 = service.getURIBroker("b");
        assertEquals("GBK", link2.getCharset());
        assertEquals("http://localhost/?name=%D6%D0%B9%FA", link2.addQueryData("name", "中国").render());
    }
View Full Code Here

    @Test
    public void defaultCharset() {
        service = (URIBrokerServiceImpl) factory.getBean("withDefaultCharset");

        URIBroker link1 = service.getURIBroker("x");
        assertEquals("UTF-8", link1.getCharset());
        assertEquals("http://localhost/?name=%E4%B8%AD%E5%9B%BD", link1.addQueryData("name", "中国").render());

        URIBroker link2 = service.getURIBroker("y");
        assertEquals("GBK", link2.getCharset());
        assertEquals("http://localhost/?name=%D6%D0%B9%FA", link2.addQueryData("name", "中国").render());
    }
View Full Code Here

    @Test
    public void uriBean() {
        service = (URIBrokerServiceImpl) factory.getBean("uri_bean");

        URIBroker bean = service.getURIBroker("mybean");
        assertEquals("https://myserver/aa/bb/cc", bean.render());
    }
View Full Code Here

        assertEquals(importedNames, names);

        // check uris
        for (String name : names) {
            URIBroker uri = service.getURIBroker(name);
            URIBroker importedUri = imported.getURIBroker(name);

            if (uri != null) {
                uri = uri.getParent();
                assertFalse(uri.isAutoReset());
            }

            if (importedUri != null) {
                importedUri = importedUri.getParent();
                assertFalse(importedUri.isAutoReset());
            }

            if ("link2".equals(name)) {
                assertEquals("http:///", uri.toString());
                assertEquals(
                        "http://myuser2:mypass2@myservername2:1234/aaa/a1/bbb/ccc/ddd?aaa=1111&bbb=2222&ccc=3333#myreference2",
                        importedUri.toString());
            } else if ("newlink".equals(name)) {
                assertEquals("http://www.taobao.com/newlink", uri.toString());
                assertNull(importedUri);
            } else {
                assertNotNull(uri);
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.uribroker.uri.URIBroker$BaseURI

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.