Examples of EngineGroup


Examples of net.paoding.rose.web.impl.mapping.EngineGroup

            return "def";
        }
    };

    public void testGetPost() {
        EngineGroup engineGroup = new EngineGroupImpl();
        engineGroup.addEngine(ReqMethod.GET, new LinkedEngine(null, getEngine, null));
        engineGroup.addEngine(ReqMethod.POST, new LinkedEngine(null, postEngine, null));

        assertSame(getEngine, engineGroup.getEngines(ReqMethod.GET)[0].getTarget());
        assertSame(postEngine, engineGroup.getEngines(ReqMethod.POST)[0].getTarget());

        String msg = "not allowed method should return engines with length is zero";
        assertEquals(msg, 0, engineGroup.getEngines(ReqMethod.PUT).length);
        assertEquals(msg, 0, engineGroup.getEngines(ReqMethod.DELETE).length);
        assertEquals(msg, 0, engineGroup.getEngines(ReqMethod.OPTIONS).length);

        assertEquals("[GET, POST]", engineGroup.toString());
    }
View Full Code Here

Examples of net.paoding.rose.web.impl.mapping.EngineGroup

        assertEquals("[GET, POST]", engineGroup.toString());
    }

    public void testNotOverrideByAll() {
        EngineGroup engineGroup = new EngineGroupImpl();
        engineGroup.addEngine(ReqMethod.GET, new LinkedEngine(null, getEngine, null));
        engineGroup.addEngine(ReqMethod.ALL, new LinkedEngine(null, defEngine, null));
        engineGroup.addEngine(ReqMethod.POST, new LinkedEngine(null, postEngine, null));

        assertSame(getEngine, engineGroup.getEngines(ReqMethod.GET)[0].getTarget());
        assertSame(defEngine, engineGroup.getEngines(ReqMethod.GET)[1].getTarget());
        assertSame(defEngine, engineGroup.getEngines(ReqMethod.POST)[0].getTarget());
        assertSame(postEngine, engineGroup.getEngines(ReqMethod.POST)[1].getTarget());

        assertSame(defEngine, engineGroup.getEngines(ReqMethod.PUT)[0].getTarget());
        assertSame(defEngine, engineGroup.getEngines(ReqMethod.DELETE)[0].getTarget());

        assertEquals("[GET, POST, DELETE, PUT, HEAD, OPTIONS, TRACE]", engineGroup.toString());
    }
View Full Code Here

Examples of net.paoding.rose.web.impl.mapping.EngineGroup

            // not rose uri
            return ("@404: <br>not rose uri: '" + testUri + "'");
        }

        final MatchResult lastMatched = matchResults.get(matchResults.size() - 1);
        final EngineGroup leafEngineGroup = lastMatched.getMappingNode().getLeafEngines();
        final LinkedEngine leafEngine = select(leafEngineGroup.getEngines(testMethod), inv
                .getRequest());
        if (leafEngine == null) {
            if (leafEngineGroup.size() == 0) {
                // not rose uri
                return ("@404: <br>not rose uri, not exits leaf engines for it: '" + testUri + "'");

            } else {
                // 405 Method Not Allowed
                StringBuilder allow = new StringBuilder();
                final String gap = ", ";

                for (ReqMethod m : leafEngineGroup.getAllowedMethods()) {
                    allow.append(m.toString()).append(gap);
                }
                if (allow.length() > 0) {
                    allow.setLength(allow.length() - gap.length());
                }
View Full Code Here

Examples of net.paoding.rose.web.impl.mapping.EngineGroup

     * @param sb
     */
    private void printNode(final MappingNode node, String prefix, StringBuilder sb) {
        sb.append("<node path=\"").append(prefix + node.getMappingPath()).append("\">");
        //
        EngineGroup leaf = node.getLeafEngines();
        if (leaf.size() > 0) {
            for (ReqMethod method : leaf.getAllowedMethods()) {
                for (LinkedEngine engine : leaf.getEngines(method)) {
                    ActionEngine action = (ActionEngine) engine.getTarget();
                    Method m = action.getMethod();
                    Class<?> cc = action.getControllerClass();
                    String rm = method.toString();
                    sb.append("<allowed ");
View Full Code Here

Examples of net.paoding.rose.web.impl.mapping.EngineGroup

            path = "ROOT";
        }
        sb.append(path).append("\n");
        //
        tab += gap;
        EngineGroup leaf = node.getLeafEngines();
        if (leaf.size() > 0) {
            for (ReqMethod method : leaf.getAllowedMethods()) {
                for (LinkedEngine engine : leaf.getEngines(method)) {
                    ActionEngine action = (ActionEngine) engine.getTarget();
                    Method m = action.getMethod();
                    Class<?> cc = action.getControllerClass();
                    sb.append(tab);
                    sb.append(method + "=\"" + cc.getSimpleName() + "#" + m.getName() + "\" ");
View Full Code Here

Examples of net.paoding.rose.web.impl.mapping.EngineGroup

            }
            return false;
        }

        final MatchResult lastMatched = matchResults.get(matchResults.size() - 1);
        final EngineGroup leafEngineGroup = lastMatched.getMappingNode().getLeafEngines();
        if (leafEngineGroup.size() == 0) {
            // not rose uri
            if (debugEnabled) {
                logger.debug("not rose uri, not exits leaf engines for it: '" + this.path.getUri()
                        + "'");
            }
            return false;

        }
        final LinkedEngine leafEngine = select(leafEngineGroup.getEngines(path.getMethod()));
        if (leafEngine == null) {
            // 405 Method Not Allowed
            /*
             * The method specified in the Request-Line is not allowed for the
             * resource identified by the Request-URI. The response MUST include an
             * Allow header containing a list of valid methods for the requested
             * resource.
             */
            StringBuilder allow = new StringBuilder();
            final String gap = ", ";

            for (ReqMethod method : leafEngineGroup.getAllowedMethods()) {
                allow.append(method.toString()).append(gap);
            }
            if (allow.length() > 0) {
                allow.setLength(allow.length() - gap.length());
            }
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.