[commons-geometry] branch master updated: updating examples-io module with new type names
This is an automated email from the ASF dual-hosted git repository. mattjuntunen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-geometry.git The following commit(s) were added to refs/heads/master by this push: new 0ac8384 updating examples-io module with new type names 0ac8384 is described below commit 0ac838435f594b39c415f10f933692ff458f1988 Author: Matt Juntunen AuthorDate: Tue May 5 22:17:50 2020 -0400 updating examples-io module with new type names --- .../commons/geometry/examples/io/Format3D.java | 32 +++--- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/Format3D.java b/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/Format3D.java index 67de36d..9bf58ac 100644 --- a/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/Format3D.java +++ b/commons-geometry-examples/examples-io/src/main/java/org/apache/commons/geometry/examples/io/Format3D.java @@ -30,10 +30,10 @@ import java.nio.file.Files; import org.apache.commons.geometry.core.precision.DoublePrecisionContext; import org.apache.commons.geometry.euclidean.twod.ConvexArea; -import org.apache.commons.geometry.euclidean.twod.Polyline; +import org.apache.commons.geometry.euclidean.twod.path.LinePath; import org.apache.commons.geometry.euclidean.threed.Vector3D; import org.apache.commons.geometry.euclidean.threed.BoundarySource3D; -import org.apache.commons.geometry.euclidean.threed.ConvexSubPlane; +import org.apache.commons.geometry.euclidean.threed.PlaneConvexSubset; /** * Utility class for writing out 3D scenes in various file formats. @@ -95,7 +95,7 @@ public final class Format3D { BoundarySource3D src) { // Create mesh data (vertices and facets). final Mesh mesh = new Mesh(precision); -try (Stream stream = src.boundaryStream()) { +try (Stream stream = src.boundaryStream()) { stream.forEach(mesh::add); } @@ -181,28 +181,28 @@ public final class Format3D { } /** - * Adds a plane to this mesh. + * Adds a plane subset to this mesh. * - * @param subplane Convex subplane boundary. + * @param boundary Convex plane boundary. */ -private void add(ConvexSubPlane subplane) { -if (!subplane.isEmpty()) { -if (!subplane.isFinite()) { -throw new IllegalArgumentException("Cannot add infinite subplane: " + subplane); +private void add(PlaneConvexSubset boundary) { +if (!boundary.isEmpty()) { +if (!boundary.isFinite()) { +throw new IllegalArgumentException("Cannot add infinite plane subset: " + boundary); } -final ConvexArea area = subplane.getSubspaceRegion(); -for (final Polyline boundaryPath : area.getBoundaryPaths()) { -final List subplaneVertices = subplane.getPlane() +final ConvexArea area = boundary.getSubspaceRegion(); +for (final LinePath boundaryPath : area.getBoundaryPaths()) { +final List boundaryVertices = boundary.getPlane() .toSpace(boundaryPath.getVertexSequence()); // use a triangle fan to add the path -final Vector3D p0 = subplaneVertices.get(0); -for (int i = 2; i < subplaneVertices.size(); i++) { +final Vector3D p0 = boundaryVertices.get(0); +for (int i = 2; i < boundaryVertices.size(); i++) { facets.add(new int[] { getVertexIndex(p0), -getVertexIndex(subplaneVertices.get(i - 1)), -getVertexIndex(subplaneVertices.get(i)) +getVertexIndex(boundaryVertices.get(i - 1)), +getVertexIndex(boundaryVertices.get(i)) }); } }
[commons-io] branch master updated: Use try-with-resources and format to 120 line length.
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git The following commit(s) were added to refs/heads/master by this push: new 5fbc496 Use try-with-resources and format to 120 line length. 5fbc496 is described below commit 5fbc4964bcb351cab189faaa042ac79969a66716 Author: Gary Gregory AuthorDate: Tue May 5 15:52:28 2020 -0400 Use try-with-resources and format to 120 line length. --- .../apache/commons/io/function/IOFunctionTest.java | 5 +- .../io/output/ByteArrayOutputStreamTestCase.java | 33 +++-- .../commons/io/output/ChunkedOutputStreamTest.java | 26 ++-- .../io/output/DeferredFileOutputStreamTest.java| 148 - .../apache/commons/io/output/ProxyWriterTest.java | 2 +- .../commons/io/output/WriterOutputStreamTest.java | 42 +++--- 6 files changed, 112 insertions(+), 144 deletions(-) diff --git a/src/test/java/org/apache/commons/io/function/IOFunctionTest.java b/src/test/java/org/apache/commons/io/function/IOFunctionTest.java index 5050566..34590ee 100644 --- a/src/test/java/org/apache/commons/io/function/IOFunctionTest.java +++ b/src/test/java/org/apache/commons/io/function/IOFunctionTest.java @@ -154,8 +154,9 @@ public class IOFunctionTest { @Test public void testIdentity() throws IOException { final IOFunction identityFunction = IOFunction.identity(); -final InputStream is = new ByteArrayInputStream(new byte[] { (byte)0xa, (byte)0xb, (byte)0xc}); -assertEquals(is, identityFunction.apply(is)); +try (final InputStream is = new ByteArrayInputStream(new byte[] { (byte) 0xa, (byte) 0xb, (byte) 0xc })) { +assertEquals(is, identityFunction.apply(is)); +} } private static class Holder { diff --git a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java index cda2539..e9b2aed 100644 --- a/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java +++ b/src/test/java/org/apache/commons/io/output/ByteArrayOutputStreamTestCase.java @@ -59,11 +59,10 @@ public class ByteArrayOutputStreamTestCase { baout.write(100); ref.write(100); return 1; -} else { -baout.write(DATA, 0, count); -ref.write(DATA, 0, count); -return count; } +baout.write(DATA, 0, count); +ref.write(DATA, 0, count); +return count; } private int writeData(final AbstractByteArrayOutputStream baout, @@ -180,14 +179,14 @@ public class ByteArrayOutputStreamTestCase { @ParameterizedTest(name = "[{index}] {0}") @MethodSource("toBufferedInputStreamFunctionFactories") public void testToBufferedInputStreamEmpty(final String baosName, final IOFunction toBufferedInputStreamFunction) throws IOException { -final ByteArrayInputStream bain = new ByteArrayInputStream(new byte[0]); -assertEquals(0, bain.available()); +try (final ByteArrayInputStream bain = new ByteArrayInputStream(new byte[0])) { +assertEquals(0, bain.available()); -final InputStream buffered = toBufferedInputStreamFunction.apply(bain); -assertEquals(0, buffered.available()); +try (final InputStream buffered = toBufferedInputStreamFunction.apply(bain)) { +assertEquals(0, buffered.available()); -buffered.close(); -bain.close(); +} +} } @ParameterizedTest(name = "[{index}] {0}") @@ -195,16 +194,16 @@ public class ByteArrayOutputStreamTestCase { public void testToBufferedInputStream(final String baosName, final IOFunction toBufferedInputStreamFunction) throws IOException { final byte data[] = {(byte)0xCA, (byte)0xFE, (byte)0xBA, (byte)0xBE}; -final ByteArrayInputStream bain = new ByteArrayInputStream(data); -assertEquals(data.length, bain.available()); +try (final ByteArrayInputStream bain = new ByteArrayInputStream(data)) { +assertEquals(data.length, bain.available()); -final InputStream buffered = toBufferedInputStreamFunction.apply(bain); -assertEquals(data.length, buffered.available()); +try (final InputStream buffered = toBufferedInputStreamFunction.apply(bain)) { +assertEquals(data.length, buffered.available()); -assertArrayEquals(data, IOUtils.toByteArray(buffered)); +assertArrayEquals(data, IOUtils.toByteArray(buffered)); -buffered.close(); -bain.close(); +} +} } @ParameterizedTest(name = "[{index}] {0}") diff --git a/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java b/src/test/java/org/apache/commons/io/output/ChunkedOutputStreamTest.java index
[commons-io] branch master updated: Use try-with-resources and format to 120 line length.
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git The following commit(s) were added to refs/heads/master by this push: new 06f76d5 Use try-with-resources and format to 120 line length. 06f76d5 is described below commit 06f76d5339181638a7ac69c15d32dafdf3216c47 Author: Gary Gregory AuthorDate: Tue May 5 15:51:32 2020 -0400 Use try-with-resources and format to 120 line length. --- .../commons/io/filefilter/FileFilterTestCase.java | 71 +- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java b/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java index fbf3b30..4dff42b 100644 --- a/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java +++ b/src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java @@ -1119,10 +1119,8 @@ public class FileFilterTestCase { @Test public void testMagicNumberFileFilterBytes() throws Exception { -final byte[] classFileMagicNumber = -new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE}; -final String xmlFileContent = "\n" + -"text"; +final byte[] classFileMagicNumber = new byte[] { (byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE }; +final String xmlFileContent = "\n" + "text"; final File classFileA = new File(temporaryFolder, "A.class"); final File xmlFileB = new File(temporaryFolder, "B.xml"); @@ -1130,10 +1128,10 @@ public class FileFilterTestCase { final File dir = new File(temporaryFolder, "D"); dir.mkdirs(); -final OutputStream classFileAStream = FileUtils.openOutputStream(classFileA); -IOUtils.write(classFileMagicNumber, classFileAStream); -TestUtils.generateTestData(classFileAStream, 32); -classFileAStream.close(); +try (final OutputStream classFileAStream = FileUtils.openOutputStream(classFileA)) { +IOUtils.write(classFileMagicNumber, classFileAStream); +TestUtils.generateTestData(classFileAStream, 32); +} FileUtils.write(xmlFileB, xmlFileContent, StandardCharsets.UTF_8); FileUtils.touch(emptyFile); @@ -1145,7 +1143,6 @@ public class FileFilterTestCase { assertFiltering(filter, emptyFile, false); assertFiltering(filter, dir, false); - filter = FileFilterUtils.magicNumberFileFilter(classFileMagicNumber); assertFiltering(filter, classFileA, true); @@ -1156,7 +1153,7 @@ public class FileFilterTestCase { @Test public void testMagicNumberFileFilterBytesOffset() throws Exception { -final byte[] tarMagicNumber = new byte[] {0x75, 0x73, 0x74, 0x61, 0x72}; +final byte[] tarMagicNumber = new byte[] { 0x75, 0x73, 0x74, 0x61, 0x72 }; final long tarMagicNumberOffset = 257; final File tarFileA = new File(temporaryFolder, "A.tar"); @@ -1164,29 +1161,25 @@ public class FileFilterTestCase { final File dir = new File(temporaryFolder, "D"); dir.mkdirs(); -final OutputStream tarFileAStream = FileUtils.openOutputStream(tarFileA); -TestUtils.generateTestData(tarFileAStream, tarMagicNumberOffset); -IOUtils.write(tarMagicNumber, tarFileAStream); -tarFileAStream.close(); +try (final OutputStream tarFileAStream = FileUtils.openOutputStream(tarFileA)) { +TestUtils.generateTestData(tarFileAStream, tarMagicNumberOffset); +IOUtils.write(tarMagicNumber, tarFileAStream); +} if (!randomFileB.getParentFile().exists()) { -throw new IOException("Cannot create file " + randomFileB -+ " as the parent directory does not exist"); +throw new IOException("Cannot create file " + randomFileB + " as the parent directory does not exist"); } -try (final BufferedOutputStream output = -new BufferedOutputStream(new FileOutputStream(randomFileB))) { +try (final BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(randomFileB))) { TestUtils.generateTestData(output, 2 * tarMagicNumberOffset); } -IOFileFilter filter = -new MagicNumberFileFilter(tarMagicNumber, tarMagicNumberOffset); +IOFileFilter filter = new MagicNumberFileFilter(tarMagicNumber, tarMagicNumberOffset); assertFiltering(filter, tarFileA, true); assertFiltering(filter, randomFileB, false); assertFiltering(filter, dir, false); -filter = FileFilterUtils.magicNumberFileFilter(tarMagicNumber, -tarMagicNumberOffset); +filter = FileFilterUtils.magicNumberFileFilter(tarMagicNumber, tarMagicNumberOffset); assertFiltering(filter, tarFileA, true);
[commons-io] branch master updated: Clean ups.
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git The following commit(s) were added to refs/heads/master by this push: new 8937ea3 Clean ups. 8937ea3 is described below commit 8937ea3e069cda91b4d85c89d7f8448ee0810c4f Author: Gary Gregory AuthorDate: Tue May 5 15:48:49 2020 -0400 Clean ups. --- .../FileUtilsCopyDirectoryToDirectoryTestCase.java | 29 -- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java b/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java index f913437..6d8031b 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java +++ b/src/test/java/org/apache/commons/io/FileUtilsCopyDirectoryToDirectoryTestCase.java @@ -16,18 +16,18 @@ */ package org.apache.commons.io; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.File; import java.io.IOException; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; /** - * This class ensure the correctness of {@link FileUtils#copyDirectoryToDirectory(File, File)}. - * TODO: currently does not cover happy cases + * This class ensure the correctness of {@link FileUtils#copyDirectoryToDirectory(File, File)}. TODO: currently does not + * cover happy cases * * @see FileUtils#copyDirectoryToDirectory(File, File) */ @@ -37,7 +37,8 @@ public class FileUtilsCopyDirectoryToDirectoryTestCase { public File temporaryFolder; @Test -public void copyDirectoryToDirectoryThrowsIllegalExceptionWithCorrectMessageWhenSrcDirIsNotDirectory() throws IOException { +public void copyDirectoryToDirectoryThrowsIllegalExceptionWithCorrectMessageWhenSrcDirIsNotDirectory() +throws IOException { final File srcDir = File.createTempFile("notadireotry", null, temporaryFolder); final File destDir = new File(temporaryFolder, "destinationDirectory"); destDir.mkdirs(); @@ -46,7 +47,8 @@ public class FileUtilsCopyDirectoryToDirectoryTestCase { } @Test -public void copyDirectoryToDirectoryThrowsIllegalArgumentExceptionWithCorrectMessageWhenDstDirIsNotDirectory() throws IOException { +public void copyDirectoryToDirectoryThrowsIllegalArgumentExceptionWithCorrectMessageWhenDstDirIsNotDirectory() +throws IOException { final File srcDir = new File(temporaryFolder, "sourceDirectory"); srcDir.mkdir(); final File destDir = new File(temporaryFolder, "notadirectory"); @@ -56,22 +58,23 @@ public class FileUtilsCopyDirectoryToDirectoryTestCase { } @Test -public void copyDirectoryToDirectoryThrowsNullPointerExceptionWithCorrectMessageWhenSrcDirIsNull() throws IOException { +public void copyDirectoryToDirectoryThrowsNullPointerExceptionWithCorrectMessageWhenSrcDirIsNull() { final File srcDir = null; final File destinationDirectory = new File(temporaryFolder, "destinationDirectory"); destinationDirectory.mkdir(); -assertExceptionTypeAndMessage(srcDir, destinationDirectory, NullPointerException.class, "sourceDir"); +assertExceptionTypeAndMessage(srcDir, destinationDirectory, NullPointerException.class, "sourceDir"); } @Test -public void copyDirectoryToDirectoryThrowsNullPointerExceptionWithCorrectMessageWhenDstDirIsNull() throws IOException { +public void copyDirectoryToDirectoryThrowsNullPointerExceptionWithCorrectMessageWhenDstDirIsNull() { final File srcDir = new File(temporaryFolder, "sourceDirectory"); srcDir.mkdir(); -final File destDir = null; +final File destDir = null; assertExceptionTypeAndMessage(srcDir, destDir, NullPointerException.class, "destinationDir"); } -private static void assertExceptionTypeAndMessage(final File srcDir, final File destDir, final Class expectedExceptionType, final String expectedMessage) { +private static void assertExceptionTypeAndMessage(final File srcDir, final File destDir, +final Class expectedExceptionType, final String expectedMessage) { try { FileUtils.copyDirectoryToDirectory(srcDir, destDir); } catch (final Exception e) {