Package clojure.lang

Examples of clojure.lang.IFn$DLLLD


  @Test
  public void testSimpleHandler1() {
    RT.var("clojure.core", "require").invoke(Symbol.create("nginx.clojure.compojure-fns-for-test"));
//    System.out.println("rq cl :" + rq.getClass().getClassLoader());
    final IFn  fn = (IFn)RT.var("nginx.clojure.compojure-fns-for-test", "simple-handler").fn();
    for (int i = 0; i < 2; i++) {
      final Map<String,Object> resp = new HashMap<String, Object>();
      System.out.println("test at i=" + i);
      Coroutine cr = new Coroutine(new Runnable() {
        @Override
        public void run() throws SuspendExecution {
          resp.putAll((Map)fn.invoke());
        }
      });
      cr.resume();
      Assert.assertEquals(0, resp.size());
      System.out.println("before resume");
View Full Code Here


  @Test
  public void testSimpleHandler11() {
    System.out.println("do test testSimpleHandler11");
    RT.var("clojure.core", "require").invoke(Symbol.create("nginx.clojure.compojure-fns-for-test"));
//    System.out.println("rq cl :" + rq.getClass().getClassLoader());
    final IFn  fn = (IFn)RT.var("nginx.clojure.compojure-fns-for-test", "simple-handler").fn();
    final Map<String,Object> resp = new HashMap<String, Object>();
    Coroutine cr = new Coroutine(new Runnable() {
      @Override
      public void run() throws SuspendExecution {
        resp.putAll((Map)fn.invoke());
      }
    });
    cr.resume();
    Assert.assertEquals(0, resp.size());
    System.out.println("before resume");
View Full Code Here

  @Test
  public void testSimpleHandler2() {
    RT.var("clojure.core", "require").invoke(Symbol.create("nginx.clojure.compojure-fns-for-test"));
//    System.out.println("rq cl :" + rq.getClass().getClassLoader());
   
    IFn  fn = (IFn)RT.var("nginx.clojure.compojure-fns-for-test", "simple-selfresume-handler").fn();
    MyRunner myrunner = new MyRunner(fn, "just a test");
    Coroutine cr = new Coroutine(myrunner);
    cr.resume();
    Assert.assertEquals(0, myrunner.response.size());
    try {
View Full Code Here

             "(use \'[compojure.core])" +
             "(use \'[nginx.clojure.coroutine-socket-handlers-for-test])" +
             "(context \"/coroutineSocketAndCompojure\" [] coroutine-socket-test-handler)" +
//             "coroutine-socket-test-handler" +
           ")";
    IFn fn = (IFn)RT.var("clojure.core", "eval").invoke(RT.var("clojure.core","read-string").invoke(code));
    //{:uri "/simple", :scheme :http, :request-method :get, :headers {}}
    PersistentArrayMap request = new PersistentArrayMap(new Object[] {
        RT.keyword(null, "uri"), "/coroutineSocketAndCompojure/simple"
//        RT.keyword(null, "uri"), "/simple"
          ,RT.keyword(null, "scheme"), RT.keyword(null, "http")
View Full Code Here

             "(context \"/coroutineSocketAndCompojure\" [] coroutine-socket-test-handler)" +
//             "coroutine-socket-test-handler" +
           ")";
//    final IFn fn = (IFn)RT.var("clojure.core", "eval").invoke(RT.var("clojure.core","read-string").invoke(code));
   
    final IFn fn = new AFn() {
      @Override
      public Object invoke(Object req)  {
        final Coroutine co = Coroutine.getActiveCoroutine();
        Thread selfresume = new Thread() {
          public void run() {
View Full Code Here

             "(use \'[compojure.core])" +
             "(use \'[nginx.clojure.coroutine-socket-handlers-for-test])" +
//             "(context \"/coroutineSocketAndCompojure\" [] coroutine-socket-test-handler)" +
             "coroutine-socket-test-handler" +
           ")";
    IFn fn = (IFn)RT.var("clojure.core", "eval").invoke(RT.var("clojure.core","read-string").invoke(code));
    //{:uri "/simple", :scheme :http, :request-method :get, :headers {}}
    PersistentArrayMap request = new PersistentArrayMap(new Object[] {
//        RT.keyword(null, "uri"), "/coroutineSocketAndCompojure/simple"
        RT.keyword(null, "uri"), "/simple"
          ,RT.keyword(null, "scheme"), RT.keyword(null, "http")
View Full Code Here

  @Test
  public void testSimpleHandler32() {
    RT.var("clojure.core", "require").invoke(Symbol.create("nginx.clojure.coroutine-socket-handlers-for-test"));
//    System.out.println("rq cl :" + rq.getClass().getClassLoader());
   
    IFn  fn = (IFn)RT.var("nginx.clojure.coroutine-socket-handlers-for-test", "simple-handler").fn();
//    String code = "(do " +
//             "(use \'[compojure.core])" +
//             "(use \'[nginx.clojure.coroutine-socket-handlers-for-test])" +
////             "(context \"/coroutineSocketAndCompojure\" [] coroutine-socket-test-handler)" +
//             "coroutine-socket-test-handler" +
View Full Code Here

 
 
  @Test
  public void testSimpleHandler4() {
 
    IFn fn = new AFn() {
      @Override
      public Object invoke(Object arg1) throws SuspendExecution {
        System.out.println("before");
        final Coroutine cr = Coroutine.getActiveCoroutine();
        new Thread() {
View Full Code Here

    initialize(fn);
  }

  @Override
  public void prepare(FlowProcess fp, OperationCall call) {
    IFn fn = Util.deserializeFn(serializedFn);

    Boolean isPrepared =
        (Boolean) Util.bootSimpleFn("cascalog.logic.def", "prepared?").invoke(fn);

    if (isPrepared.booleanValue()) {
      Object res = fn.invoke(fp, call);

      if(res instanceof Map) {
        Map resmap = (Map) res;
        this.fn = (IFn) resmap.get(Keyword.intern("operate"));
        this.cleanupFn = (IFn) resmap.get(Keyword.intern("cleanup"));
View Full Code Here

        Assert.assertSame(v1, v2);
    }

    @Test
    public void testEvalAllowsRefs() {
        IFn obj = (IFn) ClojureIteratorUtils.eval(
                "(require '[clojure.string :as string])" +
                        "(fn [s] (string/upper-case s))"
        );

        String s = (String) obj.invoke("a");
        Assert.assertEquals("A", s);
    }
View Full Code Here

TOP

Related Classes of clojure.lang.IFn$DLLLD

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.