Package org.stringtree.tract

Examples of org.stringtree.tract.MapTract


    if (page == null) {
        page = (Tract)templates.getObject("404");
    }

    if (page == null) {
        page = new MapTract("Oops, 404: ${mojasef.request.path.URI}");
        StorerHelper.put(context, HTTPConstants.RESPONSE_CODE, "404");
    }

    StringFinder result = new FetcherStringFinder(
        new FallbackFetcher(page.getUnderlyingFetcher(), context.getUnderlyingFetcher()));
View Full Code Here


        loadSpecification(context);
    }

    private void loadSpecification(StringKeeper context) {
        try {
            MapTract spec = new MapTract();
            StreamTractReader.load(spec, specfile, context);
            SpecReader.load(context, spec);
            String mountspec = spec.getContent();
            parse(mountspec, mounts, context);
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
    }
View Full Code Here

        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("A[]B");
  }

  public void testNoAppSimpleTemplateTract() throws IOException {
    templates.put("default", new MapTract("START[${this}]END"));
        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[]END");
  }
View Full Code Here

        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[]END");
  }

  public void testNoAppOverrideTemplate() throws IOException {
    context.put(Templater.TEMPLATE + ".default", new MapTract("START[${this}]END"));
        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[]END");
  }
View Full Code Here

        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[]END");
  }

  public void testNoAppAttributedTemplate() throws IOException {
    Tract tpl = new MapTract("START[${this}+${ugh}]END");
    tpl.put("ugh", "hello");
    templates.put("default", tpl);
        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[+hello]END");
  }
View Full Code Here

        assertCollected("START[+hello]END");
  }

  // FIXME add processing to tract templating to explicitly override "this"
  public void x_testNoAppThisOverrideTemplate1() throws IOException {
    Tract tpl = new MapTract("START[${this}]END");
    tpl.put("this", "hello");
    templates.put("default", tpl);
    context.put("this", "huh");
        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[huh]END");
  }
View Full Code Here

        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[huh]END");
  }

  public void testNoAppThisOverrideTemplate2() throws IOException {
    Tract tpl = new MapTract("START[${this}]END");
    tpl.put("this", "hello");
    templates.put("default", tpl);
        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[hello]END");
  }
View Full Code Here

        assertCollected("START[hello]END");
  }

  public void testThisPassThrough() throws IOException {
    context.put("this", "fkc");
    Tract tpl = new MapTract("START[${this*xx}]END");
    templates.put("default", tpl);
    templates.put("xx", ">${this}<");
        Mojasef.delegateAndExpand(collector, keeper, null, dfl);
        assertCollected("START[>fkc<]END");
  }
View Full Code Here

    assertEquals("text/html", output.responseType);
    assertEquals(40, output.responseLength);
  }
 
  public void testActiveTract() throws IOException {
    Tract tpl = new MapTract("val=${inc.get}, val=${inc.get}");
    putAndInit(tpl, "inc", new ValueIncrementer(7));
    common.put("template.thing", tpl);
    assertEquals("val=7, val=8", request("/thing"));
  }
View Full Code Here

        assertEquals(303, output.responseCode);
        assertEquals("<h2>generic 3xx</h2>Gone Fishin!", output.body);
    }
   
    public void testPageWithNoPrologueOrEpilogue() throws IOException {
        common.put("template.thing", new MapTract("hello"));
        assertEquals("hello", request("/thing"));
    }
View Full Code Here

TOP

Related Classes of org.stringtree.tract.MapTract

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.