changeset 5037:c0298be54fa1

RT-30451: FX 8 3D: Need to validate Mesh's data size Reviewed-by: Chien Yang
author Yao Wang <yao.w.wang@oracle.com>
date Tue, 10 Sep 2013 17:40:43 -0700
parents 7c4ead19a131
children 71d0d1fde706
files modules/graphics/src/main/java/javafx/scene/shape/TriangleMesh.java modules/graphics/src/test/java/javafx/scene/shape/TriangleMeshTest.java
diffstat 2 files changed, 156 insertions(+), 266 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/javafx/scene/shape/TriangleMesh.java	Tue Sep 10 10:29:52 2013 -0700
+++ b/modules/graphics/src/main/java/javafx/scene/shape/TriangleMesh.java	Tue Sep 10 17:40:43 2013 -0700
@@ -95,20 +95,99 @@
     public static final int NUM_COMPONENTS_PER_TEXCOORD = 2;
     public static final int NUM_COMPONENTS_PER_FACE = 6;
 
-    // TODO: 3D - Need to validate the size and range of these arrays.
+    public static final int MAX_LENGTH = 65536;
+    public static final int MAX_POINTS_LENGTH = NUM_COMPONENTS_PER_POINT * MAX_LENGTH;
+    public static final int MAX_TEXCOORDS_LENGTH = NUM_COMPONENTS_PER_TEXCOORD * MAX_LENGTH;
+    public static final int MAX_FACES_LENGTH = NUM_COMPONENTS_PER_FACE * MAX_LENGTH;
+    public static final int MAX_FACESMOOTHINGGROUPS_LENGTH = MAX_LENGTH;
+
+    // TODO: 3D - Need to validate the range of these arrays.
     // A warning will be recorded to the logger and the mesh will have an empty
-    // bounds if the validation failed. (RT-30451)
+    // bounds if the validation failed. (RT-26587)
     // The values in faces must be within range and the length of points,
-    // texCoords and faces must be divisible by 3, 2 and 6 respectively.
+    // texCoords and faces.
     private final ObservableFloatArray points = FXCollections.observableFloatArray();
     private final ObservableFloatArray texCoords = FXCollections.observableFloatArray();
     private final ObservableIntegerArray faces = FXCollections.observableIntegerArray();
     private final ObservableIntegerArray faceSmoothingGroups = FXCollections.observableIntegerArray();
+
+    private final Listener pointsSyncer = new Listener<ObservableFloatArray>(points) {
+        
+        @Override
+        public void onChanged(ObservableFloatArray t, boolean sizeChanged, int from, int to) {
+            if (sizeChanged) {
+                if (t.size() > MAX_POINTS_LENGTH) {
+                    throw new IllegalArgumentException("points.length has "
+                            + "to be smaller or equal to MAX_POINTS_LENGTH.");
+                }
+                // Check that points.length is divisible by NUM_COMPONENTS_PER_POINT
+                if ((t.size() % NUM_COMPONENTS_PER_POINT) != 0) {
+                    throw new IllegalArgumentException("points.length has "
+                            + "to be divisible by NUM_COMPONENTS_PER_POINT."
+                            + " It is to store multiple x, y, and z coordinates of this mesh");
+                }
+            }
+            super.onChanged(t, sizeChanged, from, to);
+        }
+    };
+
+    private final Listener texCoordsSyncer = new Listener<ObservableFloatArray>(texCoords) {
+
+        @Override
+        public void onChanged(ObservableFloatArray t, boolean sizeChanged, int from, int to) {
+            if (sizeChanged) {
+                if (t.size() > MAX_TEXCOORDS_LENGTH) {
+                    throw new IllegalArgumentException("texCoords.length "
+                            + "has to be smaller or equal to MAX_TEXCOORDS_LENGTH.");
+                }
+                // Check that texCoords.length is divisible by NUM_COMPONENTS_PER_TEXCOORD
+                if ((t.size() % NUM_COMPONENTS_PER_TEXCOORD) != 0) {
+                    throw new IllegalArgumentException("texCoords.length "
+                            + "has to be divisible by NUM_COMPONENTS_PER_TEXCOORD."
+                            + " It is to store multiple u and v texture coordinates of this mesh");
+                }
+            }
+            super.onChanged(t, sizeChanged, from, to);
+        }
+    };
+
+    private final Listener facesSyncer = new Listener<ObservableIntegerArray>(faces) {
+
+        @Override
+        public void onChanged(ObservableIntegerArray t, boolean sizeChanged, int from, int to) {
+            if (sizeChanged) {
+                if (t.size() > MAX_FACES_LENGTH) {
+                    throw new IllegalArgumentException("faces.length has "
+                            + "to be smaller or equal to MAX_FACES_LENGTH.");
+                }
+                // Check that faces.length is divisible by NUM_COMPONENTS_PER_FACE
+                if ((t.size() % NUM_COMPONENTS_PER_FACE) != 0) {
+                    throw new IllegalArgumentException("faces.length has "
+                            + "to be divisible by NUM_COMPONENTS_PER_FACE.");
+                }
+            }
+            super.onChanged(t, sizeChanged, from, to);
+        }
+    };
     
-    private final Listener pointsSyncer = new Listener(points);
-    private final Listener texCoordsSyncer = new Listener(texCoords);
-    private final Listener facesSyncer = new Listener(faces);
-    private final Listener faceSmoothingGroupsSyncer = new Listener(faceSmoothingGroups);
+    private final Listener faceSmoothingGroupsSyncer = new Listener<ObservableIntegerArray>(faceSmoothingGroups) {
+
+        @Override
+        public void onChanged(ObservableIntegerArray t, boolean sizeChanged, int from, int to) {
+            if (sizeChanged) {
+                if (t.size() > MAX_FACESMOOTHINGGROUPS_LENGTH) {
+                    throw new IllegalArgumentException("faceSmoothingGroups.length has "
+                            + "to be smaller or equal to MAX_FACESMOOTHINGGROUPS_LENGTH.");
+                }
+                // Check that faceSmoothingGroups.length is 1/NUM_COMPONENTS_PER_FACE of faces.length
+                if (t.size() != (faces.size() / NUM_COMPONENTS_PER_FACE)) {
+                    throw new IllegalArgumentException("faceSmoothingGroups.length "
+                            + "has to be equal to (faces.length / NUM_COMPONENTS_PER_FACE).");
+                }
+            }
+            super.onChanged(t, sizeChanged, from, to);
+        }
+    };
 
     private int refCount = 1;
 
--- a/modules/graphics/src/test/java/javafx/scene/shape/TriangleMeshTest.java	Tue Sep 10 10:29:52 2013 -0700
+++ b/modules/graphics/src/test/java/javafx/scene/shape/TriangleMeshTest.java	Tue Sep 10 17:40:43 2013 -0700
@@ -31,7 +31,7 @@
 public class TriangleMeshTest {
 
     /**
-     * Test of setFaceSmoothingGroups method, of class TriangleMesh.
+     * Test of setting faceSmoothingGroups, of class TriangleMesh.
      */
     @Test
     public void testSetFaceSmoothingGroups_intArr() {
@@ -43,10 +43,12 @@
         instance.getFaceSmoothingGroups().setAll(faceSmoothingGroups);
         assertTrue(instance.getFaceSmoothingGroups().size() == faceSmoothingGroups.length);
         assertArrayEquals(faceSmoothingGroups, instance.getFaceSmoothingGroups().toArray(null));
+        assertEquals(instance.getFaces().size() / TriangleMesh.NUM_COMPONENTS_PER_FACE,
+                instance.getFaceSmoothingGroups().size());
     }
 
     /**
-     * Test of setFaceSmoothingGroups method, of class TriangleMesh.
+     * Test of setting faceSmoothingGroups with arguments, of class TriangleMesh.
      */
     @Test
     public void testSetFaceSmoothingGroups_4args() {
@@ -63,174 +65,77 @@
         instance.getFaceSmoothingGroups().setAll(faceSmoothingGroups);
         instance.getFaceSmoothingGroups().set(index, setterArray, start, length);
         assertArrayEquals(setterArray, instance.getFaceSmoothingGroups().toArray(index, expected, length));
+        assertEquals(instance.getFaces().size() / TriangleMesh.NUM_COMPONENTS_PER_FACE,
+                instance.getFaceSmoothingGroups().size());
     }
 
     /**
-     * Test faceSmoothingGroups with illegal value of setFaceSmoothingGroups
-     * method, of class TriangleMesh.
+     * Test of setting faceSmoothingGroups with illegal array length, of class TriangleMesh.
      */
-    @Test (expected=ArrayIndexOutOfBoundsException.class)
-    public void testSetFaceSmoothingGroups_4argsValueOutOfRange() {
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetFaceSmoothingGroups_IllegalLength() {
         int divX = 10;
         int divY = 10;
         TriangleMesh instance = buildTriangleMesh(divX, divY);
-        int[] faceSmoothingGroups = new int[divX * divY * 2];
+        int smLength = divX * divY * 2;
+        int[] faceSmoothingGroups = new int[smLength];
         Arrays.fill(faceSmoothingGroups, 1);
-        int[] setterArray = new int[]{2, 0, -1};
-        int index = 0;
-        int start = 0;
-        int length = setterArray.length;
-        instance.getFaceSmoothingGroups().set(index, setterArray, start, length); // expect IllegalArgumentException
-        // faceSmoothingGroups should not change
-        assertArrayEquals(faceSmoothingGroups, instance.getFaceSmoothingGroups().toArray(null));
+        instance.getFaceSmoothingGroups().setAll(faceSmoothingGroups);
+        int[] setterArray = new int[smLength + 1]; // IllegalLength
+        instance.getFaceSmoothingGroups().setAll(setterArray); // expect IllegalArgumentException
     }
 
     /**
-     * Test setFaceSmoothingGroups with illegal value of setFaceSmoothingGroups
-     * method, of class TriangleMesh.
+     * Test of setting faceSmoothingGroups with oversized array, of class TriangleMesh.
      */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetFaceSmoothingGroups_4argsIllegalArgument() {
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetFaceSmoothingGroups_OversizedArr() {
         int divX = 10;
         int divY = 10;
         TriangleMesh instance = buildTriangleMesh(divX, divY);
-        int[] faceSmoothingGroups = new int[divX * divY * 2];
+        int smLength = divX * divY * 2;
+        int[] faceSmoothingGroups = new int[smLength];
         Arrays.fill(faceSmoothingGroups, 1);
         instance.getFaceSmoothingGroups().setAll(faceSmoothingGroups);
-        int[] setterArray = new int[]{2, 0, 1};
-        int index = 0;
-        int start = 0;
-        instance.getFaceSmoothingGroups().set(index, setterArray, start, -1); // expect IllegalArgumentException
-        // faceSmoothingGroups should not change
-        assertArrayEquals(faceSmoothingGroups, instance.getFaceSmoothingGroups().toArray(null));
+        int[] setterArray = new int[smLength + 1]; // IllegalLength
+        instance.getFaceSmoothingGroups().setAll(setterArray); // expect IllegalArgumentException
     }
 
     /**
-     * Test setFaceSmoothingGroups with illegal value of setFaceSmoothingGroups
-     * method, of class TriangleMesh.
+     * Test of setting faces with arguments, of class TriangleMesh.
      */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetFaceSmoothingGroups_4argsIndexOutOfRange() {
+    @Test (expected = IllegalArgumentException.class)
+    public void testSetFaces_4args() {
+        int faceSmoothingGroups[] = new int[TriangleMesh.MAX_FACESMOOTHINGGROUPS_LENGTH + 1]; // Oversized
+        TriangleMesh triangleMesh = new TriangleMesh();
+        triangleMesh.getFaceSmoothingGroups().setAll(faceSmoothingGroups); // expect IllegalArgumentException
+    }
+
+    /**
+     * Test of setting faces with illegal array length, of class TriangleMesh.
+     */
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetFaces_IllegalLength() {
         int divX = 10;
         int divY = 10;
         TriangleMesh instance = buildTriangleMesh(divX, divY);
-        int[] faceSmoothingGroups = new int[divX * divY * 2];
-        Arrays.fill(faceSmoothingGroups, 1);
-        int[] setterArray = new int[]{2, 0, 1};
-        int start = 0;
-        int length = setterArray.length;
-        instance.getFaceSmoothingGroups().setAll(faceSmoothingGroups);
-        instance.getFaceSmoothingGroups().set(198, setterArray, start, length); // expect ArrayIndexOutOfBoundsException
-        // faceSmoothingGroups should not change
-        assertArrayEquals(faceSmoothingGroups, instance.getFaceSmoothingGroups().toArray(null));
+        int faces[] = new int[instance.getFaces().size() + 1]; // IllegalLength
+        int[] expecteds = instance.getFaces().toArray(null);
+        instance.getFaces().setAll(faces); // expect IllegalArgumentException
     }
 
     /**
-     * Test setFaceSmoothingGroups with illegal value of setFaceSmoothingGroups
-     * method, of class TriangleMesh.
+     * Test of setting faces with oversized array, of class TriangleMesh.
      */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetFaceSmoothingGroups_4argsStartOutOfRange() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY);
-        int[] faceSmoothingGroups = new int[divX * divY * 2];
-        Arrays.fill(faceSmoothingGroups, 1);
-        int[] setterArray = new int[]{2, 0, 1};
-        int index = 0;
-        int length = setterArray.length;
-        instance.getFaceSmoothingGroups().setAll(faceSmoothingGroups);
-        instance.getFaceSmoothingGroups().set(index, setterArray, 2, length); // expect IllegalArgumentException
-        // faceSmoothingGroups should not change
-        assertArrayEquals(faceSmoothingGroups, instance.getFaceSmoothingGroups().toArray(null));
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetFaces_OversizedArr() {
+        int faces[] = new int[TriangleMesh.MAX_FACES_LENGTH + 6]; // Oversized
+        TriangleMesh triangleMesh = new TriangleMesh();
+        triangleMesh.getFaces().setAll(faces); // expect IllegalArgumentException
     }
 
     /**
-     * Test of setFaces method, of class TriangleMesh.
-     */
-    @Test
-    public void testSetFaces_4args() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 1200 faces
-        int faces[] = {
-            0, 0, 2, 2, 1, 1,
-            2, 2, 3, 3, 1, 1,
-            4, 0, 5, 1, 6, 2,
-            6, 2, 5, 1, 7, 3,
-            0, 0, 1, 1, 4, 2,
-            4, 2, 1, 1, 5, 3,
-            2, 0, 6, 2, 3, 1,
-            3, 1, 6, 2, 7, 3,
-            0, 0, 4, 1, 2, 2,
-            2, 2, 4, 1, 6, 3,
-            1, 0, 3, 1, 5, 2,
-            5, 2, 3, 1, 7, 3,};
-        int index = 6;
-        int start = 0;
-        int length = faces.length;
-        instance.getFaces().set(index, faces, start, length);
-        int[] expected = new int[faces.length];
-        assertArrayEquals(instance.getFaces().toArray(index, expected, length), faces);
-    }
-
-    /**
-     * Test setFaces with illegal value of setFaceSmoothingGroups method, of
-     * class TriangleMesh.
-     */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetFaces_4argsIllegalArgument() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 1200 faces
-        int faces[] = {0, 0, 2, 2, 1, 1,};
-        int[] expecteds = instance.getFaces().toArray(null);
-        int length = faces.length;
-        instance.getFaces().set(-1, faces, -1, length);
-        // faces should not change
-        assertArrayEquals(expecteds, instance.getFaces().toArray(null));
-    }
-
-    /**
-     * Test setFaces with index argument out of range of setFaceSmoothingGroups
-     * method, of class TriangleMesh.
-     */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetFaces_4argsIndexOutOfRange() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 1200 faces
-        int faces[] = {0, 0, 2, 2, 1, 1,};
-        int[] expecteds = instance.getFaces().toArray(null);
-        int start = 0;
-        int length = faces.length;
-        instance.getFaces().set(1200, faces, start, length);
-        // faces should not change
-        assertArrayEquals(expecteds, instance.getFaces().toArray(null));
-    }
-
-    /**
-     * Test setFaces with start argument out of range of setFaceSmoothingGroups
-     * method, of class TriangleMesh.
-     */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetFaces_4argsStartOutOfRange() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 1200 faces
-        int faces[] = {
-            0, 0, 2, 2, 1, 1,
-            2, 2, 3, 3, 1, 1,};
-        int[] expecteds = instance.getFaces().toArray(null);
-        int index = 6;
-        int length = faces.length;
-        instance.getFaces().set(index, faces, 1, length);
-        // faces should not change
-        assertArrayEquals(expecteds, instance.getFaces().toArray(null));
-    }
-
-    /**
-     * Test of setTexCoords method, of class TriangleMesh.
+     * Test of setting texCoords with arguments, of class TriangleMesh.
      */
     @Test
     public void testsetTexCoords_4args() {
@@ -250,75 +155,35 @@
     }
 
     /**
-     * Test setTexCoords with illegal value of setTexCoordsmoothingGroups
-     * method, of class TriangleMesh.
+     * Test of setting faces with illegal array length, of class TriangleMesh.
      */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testsetTexCoords_4argsIllegalArgument() {
+    @Test(expected = IllegalArgumentException.class)
+    public void testsetTexCoords_IllegalLength() {
         int divX = 10;
         int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 242 texCoords
-        float texCoords[] = {0, 0,
-                             0, 1,
-                             1, 0,
-                             1, 1};
-        float[] expecteds = instance.getTexCoords().toArray(null);
-        int length = texCoords.length;
-        instance.getTexCoords().set(-1, texCoords, -1, length);
-        // texCoords should not change
-        assertArrayEquals(instance.getTexCoords().toArray(null), expecteds, 1e-3f);
+        TriangleMesh instance = buildTriangleMesh(divX, divY);
+        float texCoords[] = new float[instance.getTexCoords().size() + 1]; // IllegalLength
+        instance.getTexCoords().setAll(texCoords); // expect IllegalArgumentException
     }
 
     /**
-     * Test setTexCoords with index argument out of range of
-     * setTexCoordsmoothingGroups method, of class TriangleMesh.
+     * Test of setting texCoords with oversized array, of class TriangleMesh.
      */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testsetTexCoords_4argsIndexOutOfRange() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 242 texCoords
-        float texCoords[] = {0, 0,
-                             0, 1,
-                             1, 0,
-                             1, 1};
-        float[] expecteds = instance.getTexCoords().toArray(null);
-        int start = 0;
-        int length = texCoords.length;
-        instance.getTexCoords().set(240, texCoords, start, length);
-        // texCoords should not change
-        assertArrayEquals(instance.getTexCoords().toArray(null), expecteds, 1e-3f);
+    @Test(expected = IllegalArgumentException.class)
+    public void testsetTexCoords_OversizedArr() {
+        int texCoords[] = new int[TriangleMesh.MAX_TEXCOORDS_LENGTH + 2]; // Oversized
+        TriangleMesh triangleMesh = new TriangleMesh();
+        triangleMesh.getFaces().setAll(texCoords); // expect IllegalArgumentException
     }
 
     /**
-     * Test setTexCoords with start argument out of range of
-     * setTexCoordsmoothingGroups method, of class TriangleMesh.
-     */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testsetTexCoords_4argsStartOutOfRange() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 242 texCoords
-        float texCoords[] = {0, 0,
-                             0, 1,
-                             1, 0,
-                             1, 1};
-        float[] expecteds = instance.getTexCoords().toArray(null);
-        int index = 2;
-        int length = texCoords.length;
-        instance.getTexCoords().set(index, texCoords, 1, length);
-        // texCoords should not change
-        assertArrayEquals(instance.getTexCoords().toArray(null), expecteds, 1e-3f);
-    }
-
-    /**
-     * Test of setPoints method, of class TriangleMesh.
+     * Test of setting points with arguments, of class TriangleMesh.
      */
     @Test
     public void testSetPoints_4args() {
         int divX = 10;
         int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 121 points
+        TriangleMesh instance = buildTriangleMesh(divX, divY);
         float points[] = {
             1, 1, 1,
             1, 1, -1,
@@ -337,80 +202,26 @@
     }
 
     /**
-     * Test setPoints with illegal value of setPointsmoothingGroups method, of
-     * class TriangleMesh.
+     * Test of setting points with illegal array length, of class TriangleMesh.
      */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetPoints_4argsIllegalArgument() {
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetPoints_IllegalLength() {
         int divX = 10;
         int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 121 points
-        float points[] = {
-            1, 1, 1,
-            1, 1, -1,
-            1, -1, 1,
-            1, -1, -1,
-            -1, 1, 1,
-            -1, 1, -1,
-            -1, -1, 1,
-            -1, -1, -1,};
+        TriangleMesh instance = buildTriangleMesh(divX, divY);
+        float points[] = new float[instance.getPoints().size() - 2]; // IllegalLength
         float[] expecteds = instance.getPoints().toArray(null);
-        int length = points.length;
-        instance.getPoints().set(-1, points, -1, length);
-        // points should not change
-        assertArrayEquals(instance.getPoints().toArray(null), expecteds, 1e-3f);
+        instance.getPoints().setAll(points); // expect IllegalArgumentException
     }
 
     /**
-     * Test setPoints with index argument out of range of
-     * setPointsmoothingGroups method, of class TriangleMesh.
+     * Test of setting points with oversized array, of class TriangleMesh.
      */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetPoints_4argsIndexOutOfRange() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 121 points
-        float points[] = {
-            1, 1, 1,
-            1, 1, -1,
-            1, -1, 1,
-            1, -1, -1,
-            -1, 1, 1,
-            -1, 1, -1,
-            -1, -1, 1,
-            -1, -1, -1,};
-        float[] expecteds = instance.getPoints().toArray(null);
-        int start = 0;
-        int length = points.length;
-        instance.getPoints().set(120 * 3, points, start, length);
-        // points should not change
-        assertArrayEquals(instance.getPoints().toArray(null), expecteds, 1e-3f);
-    }
-
-    /**
-     * Test setPoints with start argument out of range of
-     * setPointsmoothingGroups method, of class TriangleMesh.
-     */
-    @Test(expected = ArrayIndexOutOfBoundsException.class)
-    public void testSetPoints_4argsStartOutOfRange() {
-        int divX = 10;
-        int divY = 10;
-        TriangleMesh instance = buildTriangleMesh(divX, divY); // 121 points
-        float points[] = {
-            1, 1, 1,
-            1, 1, -1,
-            1, -1, 1,
-            1, -1, -1,
-            -1, 1, 1,
-            -1, 1, -1,
-            -1, -1, 1,
-            -1, -1, -1,};
-        float[] expecteds = instance.getPoints().toArray(null);
-        int index = 3;
-        int length = points.length;
-        instance.getPoints().set(index, points, 1, length);
-        // points should not change
-        assertArrayEquals(instance.getPoints().toArray(null), expecteds, 1e-3f);
+    @Test(expected = IllegalArgumentException.class)
+    public void testSetPoints_OversizedArr() {
+        float points[] = new float[TriangleMesh.MAX_POINTS_LENGTH + 3]; // Oversized
+        TriangleMesh triangleMesh = new TriangleMesh();
+        triangleMesh.getPoints().setAll(points); // expect IllegalArgumentException
     }
 
     TriangleMesh buildTriangleMesh(int subDivX, int subDivY) {