javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/ModelTest.java
branchmodel
changeset 500 f9e80d48e9b4
parent 499 af027874f93e
child 505 4198be34b516
     1.1 --- a/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/ModelTest.java	Mon Jan 21 10:06:42 2013 +0100
     1.2 +++ b/javaquery/api/src/test/java/org/apidesign/bck2brwsr/htmlpage/ModelTest.java	Mon Jan 21 11:55:27 2013 +0100
     1.3 @@ -65,11 +65,40 @@
     1.4          assertTrue(my.mutated.contains("unrelated"), "Its name is unrelated");
     1.5      }
     1.6      
     1.7 +    @Test public void computedPropertyCannotWriteToModel() {
     1.8 +        try {
     1.9 +            String res = Model.getNotAllowedWrite();
    1.10 +            fail("We should not be allowed to write to the model: " + res);
    1.11 +        } catch (IllegalStateException ex) {
    1.12 +            // OK, we can't read
    1.13 +        }
    1.14 +    }
    1.15 +
    1.16 +    @Test public void computedPropertyCannotReadToModel() {
    1.17 +        try {
    1.18 +            String res = Model.getNotAllowedRead();
    1.19 +            fail("We should not be allowed to read from the model: " + res);
    1.20 +        } catch (IllegalStateException ex) {
    1.21 +            // OK, we can't read
    1.22 +        }
    1.23 +    }
    1.24 +    
    1.25      @ComputedProperty
    1.26      static int powerValue(int value) {
    1.27          return value * value;
    1.28      }
    1.29      
    1.30 +    @ComputedProperty
    1.31 +    static String notAllowedRead() {
    1.32 +        return "Not allowed callback: " + Model.getUnrelated();
    1.33 +    }
    1.34 +
    1.35 +    @ComputedProperty
    1.36 +    static String notAllowedWrite() {
    1.37 +        Model.setUnrelated(11);
    1.38 +        return "Not allowed callback!";
    1.39 +    }
    1.40 +    
    1.41      static class MockKnockout extends Knockout {
    1.42          List<String> mutated = new ArrayList<String>();
    1.43