Default for keepAlive is true
authorJaroslav Tulach <jtulach@netbeans.org>
Tue, 16 Dec 2014 21:49:45 +0100
changeset 906e1291f7b7626
parent 905 6242ffbcfd16
child 907 dbd7ab3a4714
child 916 7e1929093f06
Default for keepAlive is true
boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java
boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java
boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java
     1.1 --- a/boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java	Sun Dec 14 14:36:30 2014 +0100
     1.2 +++ b/boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java	Tue Dec 16 21:49:45 2014 +0100
     1.3 @@ -527,7 +527,7 @@
     1.4                  String body;
     1.5                  boolean javacall = false;
     1.6                  boolean wait4js = true;
     1.7 -                boolean keepAlive = false;
     1.8 +                boolean keepAlive = true;
     1.9  
    1.10                  public FindInAnno() {
    1.11                      super(Opcodes.ASM4);
     2.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java	Sun Dec 14 14:36:30 2014 +0100
     2.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/JsMethods.java	Tue Dec 16 21:49:45 2014 +0100
     2.3 @@ -136,5 +136,5 @@
     2.4      }
     2.5      
     2.6      @JavaScriptBody(args = { "x" }, keepAlive = false, body = "throw 'Do not call me!'")
     2.7 -    public static native boolean checkAllowGC(Object x);
     2.8 +    public static native int checkAllowGC(Object x);
     2.9  }
     3.1 --- a/boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java	Sun Dec 14 14:36:30 2014 +0100
     3.2 +++ b/boot/src/test/java/org/netbeans/html/boot/impl/KeepAliveTest.java	Tue Dec 16 21:49:45 2014 +0100
     3.3 @@ -47,6 +47,7 @@
     3.4  import java.net.URL;
     3.5  import java.util.Collection;
     3.6  import org.netbeans.html.boot.spi.Fn;
     3.7 +import static org.testng.Assert.assertEquals;
     3.8  import static org.testng.Assert.assertFalse;
     3.9  import static org.testng.Assert.assertTrue;
    3.10  import org.testng.annotations.BeforeMethod;
    3.11 @@ -56,16 +57,16 @@
    3.12      private Class<?> jsMethods;
    3.13      @Test public void keepAliveIsSetToFalse() throws Exception {
    3.14          Closeable c = Fn.activate(this);
    3.15 -        boolean ret = (Boolean)jsMethods.getMethod("checkAllowGC", Object.class).invoke(null, this);
    3.16 +        Number ret = (Number)jsMethods.getMethod("checkAllowGC", Object.class).invoke(null, this);
    3.17          c.close();
    3.18 -        assertFalse(ret, "keepAlive returns false when the presenter is invoked");
    3.19 +        assertEquals(ret.intValue(), 0, "keepAlive is set to false");
    3.20      }    
    3.21  
    3.22 -    @Test public void keepAliveIsPropagated() throws Exception {
    3.23 +    @Test public void keepAliveIsTheDefault() throws Exception {
    3.24          Closeable c = Fn.activate(this);
    3.25 -        boolean ret = (Boolean)jsMethods.getMethod("truth").invoke(null);
    3.26 +        Number ret = (Number)jsMethods.getMethod("plus", int.class, int.class).invoke(null, 40, 2);
    3.27          c.close();
    3.28 -        assertTrue(ret, "keepAlive returns true when the presenter is invoked");
    3.29 +        assertEquals(ret.intValue(), 1, "keepAlive returns true when the presenter is invoked");
    3.30      }    
    3.31  
    3.32      @BeforeMethod
    3.33 @@ -85,7 +86,7 @@
    3.34                          res &= keepAlive[i];
    3.35                      }
    3.36                  }
    3.37 -                return res;
    3.38 +                return res ? 1 : 0;
    3.39              }
    3.40          };
    3.41      }