Package org.netmelody.cieye.server.response.responder

Examples of org.netmelody.cieye.server.response.responder.FileResponder


public final class FileResponderTest {

    @Test public void
    suppliesTheCorrectMimeType() throws IOException {
        final FileResponder responder = new FileResponder("/org/netmelody/cieye/server/response/responder/test/bob.js");
        assertThat(responder.respond(null).contentType, is("text/javascript; charset=utf-8"));
    }
View Full Code Here


        assertThat(responder.respond(null).contentType, is("text/javascript; charset=utf-8"));
    }

    @Test public void
    writesTheCorrectContent() throws IOException {
        final FileResponder responder = new FileResponder("/org/netmelody/cieye/server/response/responder/test/bob.js");
        assertThat(IOUtils.toString(responder.respond(null).inputStream()), is("//hi"));
    }
View Full Code Here

    private CiEyeResponder route(Address target) {
        final String[] path = target.getPath().getSegments();
       
        if (path.length == 0) {
            return new FileResponder("/resources/welcome.html");
        }
       
        if (path.length == 1) {
            if ("mugshotconfig.html".equals(path[0])) {
                return new FileResponder("/resources/mugshotconfig.html");
            }
            if ("landscapelist.json".equals(path[0])) {
                return new LandscapeListResponder(landscapeFetcher);
            }
            if ("settingslocation.json".equals(path[0])) {
                return new SettingsLocationResponder(configurationFetcher);
            }
            if ("version.json".equals(path[0])) {
                return new CiEyeVersionResponder(configurationFetcher, updateChecker);
            }
            if ("sponsor.json".equals(path[0])) {
                return new SponsorResponder(tracker);
            }
           
            final String name = "/resources/" + path[0];
            if (null != getClass().getResource(name)) {
                return new FileResponder(name);
            }
        }
       
        if (path.length == 2) {
            if ("pictures".equals(path[0])) {
                return new PictureResponder(pictureFetcher, path[1]);
            }
           
            if ("landscapes".equals(path[0])) {
                if (!target.getPath().getPath().endsWith("/")) {
                    return new RedirectResponder(target.getPath().getPath() + "/");
                }
                return new FileResponder("/resources/cieye.html");
            }
        }
       
        if (path.length == 3) {
            if ("landscapes".equals(path[0]) && "landscapeobservation.json".equals(path[2])) {
View Full Code Here

TOP

Related Classes of org.netmelody.cieye.server.response.responder.FileResponder

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.