1.1 --- a/json/src/test/java/net/java/html/json/ModelProcessorTest.java Sun Aug 02 10:03:54 2015 +0200
1.2 +++ b/json/src/test/java/net/java/html/json/ModelProcessorTest.java Wed Oct 28 19:29:17 2015 +0100
1.3 @@ -144,6 +144,68 @@
1.4 }
1.5 }
1.6
1.7 + @Test public void tooManyProperties() throws IOException {
1.8 + manyProperties(255, false, 0);
1.9 + }
1.10 +
1.11 + @Test public void tooManyArrayPropertiesIsOK() throws IOException {
1.12 + manyProperties(0, true, 300);
1.13 + }
1.14 +
1.15 + @Test public void justEnoughProperties() throws IOException {
1.16 + manyProperties(254, true, 0);
1.17 + }
1.18 +
1.19 + @Test public void justEnoughPropertiesWithArrayOne() throws IOException {
1.20 + manyProperties(253, true, 300);
1.21 + }
1.22 +
1.23 + @Test public void justEnoughPropertiesButOneArrayOne() throws IOException {
1.24 + manyProperties(254, false, 300);
1.25 + }
1.26 +
1.27 + private void manyProperties(
1.28 + int cnt, boolean constructorWithParams, int arrayCnt
1.29 + ) throws IOException {
1.30 + String html = "<html><body>"
1.31 + + "</body></html>";
1.32 + StringBuilder code = new StringBuilder();
1.33 + code.append("package x.y.z;\n"
1.34 + + "import net.java.html.json.Model;\n"
1.35 + + "import net.java.html.json.Property;\n"
1.36 + + "@Model(className=\"XModel\", properties={\n"
1.37 + );
1.38 + for (int i = 1; i <= cnt; i++) {
1.39 + code.append(" @Property(name=\"prop").append(i).append("\", ");
1.40 + code.append("type=int.class),\n");
1.41 + }
1.42 + for (int i = 1; i <= arrayCnt; i++) {
1.43 + code.append(" @Property(name=\"array").append(i).append("\", ");
1.44 + code.append("array=true, ");
1.45 + code.append("type=int.class),\n");
1.46 + }
1.47 + code.append(""
1.48 + + "})\n"
1.49 + + "class X {\n"
1.50 + + " static {\n"
1.51 + + " new XModel();\n"
1.52 + + " new XModel("
1.53 + );
1.54 + if (constructorWithParams) {
1.55 + code.append("0");
1.56 + for (int i = 1; i < cnt; i++) {
1.57 + code.append(",\n").append(i);
1.58 + }
1.59 + }
1.60 + code.append(");\n"
1.61 + + " }\n"
1.62 + + "}\n"
1.63 + );
1.64 +
1.65 + Compile c = Compile.create(html, code.toString());
1.66 + assertTrue(c.getErrors().isEmpty(), "Compiles OK: " + c.getErrors());
1.67 + }
1.68 +
1.69 @Test public void writeableComputedPropertyMissingWrite() throws IOException {
1.70 String html = "<html><body>"
1.71 + "</body></html>";