@Test public final void testLoadArrayIndexIODataError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPairType> f = loader.loadArrayIndexBuffers( () -> { throw new UncheckedIOException(new IOException("IO failure")); }, (data) -> Long.valueOf(23L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> Long.valueOf(42L), JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
/** * Construct an update that will replace all of the data in {@code buffer}. * * @param buffer The buffer * @param <T> The precise type of buffer * * @return An update */ public static <T extends JCGLBufferWritableType> JCGLBufferUpdateType<T> newUpdateReplacingAll(final T buffer) { NullCheck.notNull(buffer); return JCGLBufferUpdates.newUpdateReplacingRange(buffer, buffer.getRange()); }
@Test public final void testLoadArrayIndexIOArraySizeError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPair> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> Long.valueOf(42L), JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
/** * Construct an update that will replace all of the data in {@code buffer}. * * @param buffer The buffer * @param <T> The precise type of buffer * * @return An update */ public static <T extends JCGLBufferWritableType> JCGLBufferUpdateType<T> newUpdateReplacingAll(final T buffer) { NullCheck.notNull(buffer, "Buffer"); return newUpdateReplacingRange(buffer, buffer.byteRange()); }
@Test public final void testLoadArrayIndexIOArraySizeError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPairType> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> Long.valueOf(42L), JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testBufferUpdateOutOfRange() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); this.expected.expect(RangeCheckException.class); JCGLBufferUpdates.newUpdateReplacingRange( a, new UnsignedRangeInclusiveL(0L, 200L)); } }
@Test public final void testLoadArrayIndexIOIndexSizeError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPairType> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> Long.valueOf(42L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testBufferUpdateOutOfRange() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); this.expected.expect(RangeCheckException.class); JCGLBufferUpdates.newUpdateReplacingRange( a, new UnsignedRangeInclusiveL(0L, 200L)); } }
@Test public final void testLoadArrayIndexIOIndexSizeError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPair> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> Long.valueOf(42L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testLoadArrayIndexIOArrayUpdateError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPair> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> Long.valueOf(42L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testLoadArrayIndexIODataError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPair> f = loader.loadArrayIndexBuffers( () -> { throw new UncheckedIOException(new IOException("IO failure")); }, (data) -> Long.valueOf(23L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> Long.valueOf(42L), JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testLoadArrayIndexIOArrayUpdateError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPairType> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> Long.valueOf(42L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> { throw new UncheckedIOException(new IOException("IO failure")); }, JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> JCGLBufferUpdates.newUpdateReplacingAll(index) ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testLoadArrayIndexIOIndexUpdateError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPairType> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> Long.valueOf(42L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> Long.valueOf(42L), JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> { throw new UncheckedIOException(new IOException("IO failure")); } ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testLoadArrayIndexIOIndexUpdateError() throws Exception { final JCGLAsyncResourceLoaderType loader = this.getLoader("main"); final CompletableFuture<JCGLAsyncBufferPair> f = loader.loadArrayIndexBuffers( () -> "Hello", (data) -> Long.valueOf(42L), JCGLUsageHint.USAGE_STATIC_DRAW, (data) -> Long.valueOf(42L), JCGLUnsignedType.TYPE_UNSIGNED_INT, JCGLUsageHint.USAGE_STATIC_DRAW, (data, array) -> JCGLBufferUpdates.newUpdateReplacingAll(array), (data, index) -> { throw new UncheckedIOException(new IOException("IO failure")); } ); this.expected.expect(ExecutionException.class); this.expected.expectMessage("IO failure"); f.get(30L, TimeUnit.SECONDS); }
@Test public final void testArrayRead() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); final ByteBuffer b = u.data(); for (int index = 0; index < 100; ++index) { b.put(index, (byte) 0x50); } ga.arrayBufferUpdate(u); final ByteBuffer e = ga.arrayBufferRead(a, size -> ByteBuffer.allocateDirect((int) size)); for (int index = 0; index < 100; ++index) { final long bv = (long) b.get(index); final long ev = (long) e.get(index); Assert.assertEquals("index " + index, bv, ev); } }
@Test public final void testArrayRead() { final JCGLArrayBuffersType ga = this.getArrayBuffers("main"); final JCGLArrayBufferType a = ga.arrayBufferAllocate(100L, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLArrayBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(a); final ByteBuffer b = u.getData(); for (int index = 0; index < 100; ++index) { b.put(index, (byte) 0x50); } ga.arrayBufferUpdate(u); final ByteBuffer e = ga.arrayBufferRead(a, size -> ByteBuffer.allocateDirect((int) size)); for (int index = 0; index < 100; ++index) { final long bv = (long) b.get(index); final long ev = (long) e.get(index); Assert.assertEquals("index " + index, bv, ev); } }
@Test public final void testIndexRead() { final Interfaces ii = this.getIndexBuffers("main"); final JCGLIndexBuffersType gi = ii.getIndexBuffers(); final JCGLIndexBufferType i = gi.indexBufferAllocate( 100L, JCGLUnsignedType.TYPE_UNSIGNED_BYTE, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLIndexBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(i); final ByteBuffer b = u.getData(); for (int index = 0; index < 100; ++index) { b.put(index, (byte) 0x50); } gi.indexBufferUpdate(u); final ByteBuffer e = gi.indexBufferRead(i, size -> ByteBuffer.allocateDirect((int) size)); for (int index = 0; index < 100; ++index) { Assert.assertEquals((long) b.get(index), (long) e.get(index)); } }
JCGLBufferUpdates.newUpdateReplacingAll(ib); final IntBuffer i = u.getData().asIntBuffer(); JCGLBufferUpdates.newUpdateReplacingAll(ab);
JCGLBufferUpdates.newUpdateReplacingAll(ib); final IntBuffer i = u.data().asIntBuffer(); JCGLBufferUpdates.newUpdateReplacingAll(ab);
@Test public final void testIndexRead() { final Interfaces ii = this.getIndexBuffers("main"); final JCGLIndexBuffersType gi = ii.getIndexBuffers(); final JCGLIndexBufferType i = gi.indexBufferAllocate( 100L, JCGLUnsignedType.TYPE_UNSIGNED_BYTE, JCGLUsageHint.USAGE_STATIC_DRAW); final JCGLBufferUpdateType<JCGLIndexBufferType> u = JCGLBufferUpdates.newUpdateReplacingAll(i); final ByteBuffer b = u.data(); for (int index = 0; index < 100; ++index) { b.put(index, (byte) 0x50); } gi.indexBufferUpdate(u); final ByteBuffer e = gi.indexBufferRead(i, size -> ByteBuffer.allocateDirect((int) size)); for (int index = 0; index < 100; ++index) { Assert.assertEquals((long) b.get(index), (long) e.get(index)); } }