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

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


    }

    public void onDeny(Status status) throws Exception {
        HttpServletRequest request = status.rundata.getRequest();
        HttpServletResponse response = status.rundata.getResponse();
        URIBroker redirectURI = uriBrokerService.getURIBroker(brokerId);

        assertNotNull(redirectURI, "no URI broker found: %s", brokerId);

        StringBuffer buf = request.getRequestURL();
        String queryString = trimToNull(request.getQueryString());

        if (queryString != null) {
            buf.append('?').append(queryString);
        }

        String returnURL = buf.toString();

        response.sendRedirect(redirectURI.addQueryData(returnKey, returnURL).render());
    }
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

    private Map<String, Object> assertRequest() {
        Map<String, Object> tools = pull.getTools();
        assertEquals(4, tools.size());

        // 从pull service中直接取得
        URIBroker u1 = (URIBroker) tools.get("link2");
        URIBroker u2 = (URIBroker) tools.get("linkCharset");

        // 通过uris tool取得
        URIBrokerTool.Helper tool = (URIBrokerTool.Helper) tools.get("uris");
        URIBroker u1_2 = tool.get("link2");
        URIBroker u2_2 = tool.get("linkCharset");

        // 查看渲染结果,很明显,request已经被注入
        assertEquals("http://myuser2:mypass2@myservername2:1234/aaa/a1/bbb/ccc/ddd"
                     + "?aaa=1111&bbb=2222&ccc=3333#myreference2", u1.toString());

        assertEquals("http://localhost/", u2.toString());

        assertEquals(u1_2.toString(), u1.toString());
        assertEquals(u2_2.toString(), u2.toString());

        // 通过uri.get()方法取得broker,有cache。
        assertSame(u1_2, tool.get("link2"));
        assertSame(u2_2, tool.get("linkCharset"));
View Full Code Here

        }
    }

    @Test
    public void getURIBroker() {
        URIBroker broker = service.getURIBroker("link2");
        URIBroker parent = service.getURIBrokerInternal("link2");

        assertNotSame(parent, broker);
        assertSame(parent, broker.getParent());
        assertEquals(parent.toString(), broker.toString());

        assertNull(service.getURIBroker("notExist"));
    }
View Full Code Here

    }

    @Test
    public void init_prerendered_initialized() throws Exception {
        for (String name : service.getNames()) {
            URIBroker broker = service.getURIBrokerInternal(name);
            assertTrue(getFieldValue(broker, "initialized", Boolean.class));

            Object renderer = getFieldValue(broker, "renderer", null);
            assertTrue(invokeMethod(renderer, "isServerRendered", null, null, Boolean.class));
        }
View Full Code Here

TOP

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

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.