Author: ggregory Date: Wed Mar 20 05:24:27 2013 New Revision: 1458639 URL: http://svn.apache.org/r1458639 Log: Sort members in AB order.
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java?rev=1458639&r1=1458638&r2=1458639&view=diff ============================================================================== --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java (original) +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java Wed Mar 20 05:24:27 2013 @@ -45,123 +45,120 @@ public class CSVFormatBuilderTest { } @Test - public void testDelimiter() { - assertEquals('?', builder.withDelimiter('?').build().getDelimiter()); + public void testCommentStart() { + assertEquals('?', builder.withCommentStart('?').build().getCommentStart().charValue()); } - @Test(expected = IllegalArgumentException.class) - public void testNewFormatLFThrowsException() { - CSVFormat.newBuilder(LF); + @Test + public void testCopiedFormatIsEqualToOriginal() { + final CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build(); + assertEquals(RFC4180, copyOfRCF4180); } - @Test(expected = IllegalArgumentException.class) - public void testNewFormatCRThrowsException() { - CSVFormat.newBuilder(CR); + @Test + public void testCopiedFormatWithChanges() { + final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build(); + assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter()); } - @Test(expected = IllegalArgumentException.class) - public void testWithDelimiterLFThrowsException() { - builder.withDelimiter(LF).build(); + @Test + public void testDelimiter() { + assertEquals('?', builder.withDelimiter('?').build().getDelimiter()); } @Test(expected = IllegalStateException.class) - public void testDelimiterSameAsEscapeThrowsException() { - builder.withDelimiter('!').withEscape('!').build(); + public void testDelimiterSameAsCommentStartThrowsException() { + builder.withDelimiter('!').withCommentStart('!').build(); } @Test(expected = IllegalStateException.class) - public void testDelimiterSameAsCommentStartThrowsException() { - builder.withDelimiter('!').withCommentStart('!').build(); + public void testDelimiterSameAsEscapeThrowsException() { + builder.withDelimiter('!').withEscape('!').build(); } @Test - public void testQuoteChar() { - assertEquals('?', builder.withQuoteChar('?').build().getQuoteChar().charValue()); + public void testEscape() { + assertEquals('?', builder.withEscape('?').build().getEscape().charValue()); } @Test(expected = IllegalStateException.class) - public void testQuoteCharSameAsCommentStartThrowsException() { - builder.withQuoteChar('!').withCommentStart('!').build(); + public void testEscapeSameAsCommentStartThrowsException() { + builder.withEscape('!').withCommentStart('!').build(); } @Test(expected = IllegalStateException.class) - public void testQuoteCharSameAsCommentStartThrowsExceptionForWrapperType() { + public void testEscapeSameAsCommentStartThrowsExceptionForWrapperType() { // Cannot assume that callers won't use different Character objects - builder.withQuoteChar(new Character('!')).withCommentStart('!').build(); - } - - @Test(expected = IllegalStateException.class) - public void testQuoteCharSameAsDelimiterThrowsException() { - builder.withQuoteChar('!').withDelimiter('!').build(); + builder.withEscape(new Character('!')).withCommentStart(new Character('!')).build(); } - @Test(expected = IllegalArgumentException.class) - public void testWithQuoteLFThrowsException() { - builder.withQuoteChar(LF).build(); + @Test + public void testHeaderReferenceCannotEscape() { + final String[] header = new String[]{"one", "tow", "three"}; + builder.withHeader(header); + + final CSVFormat firstFormat = builder.build(); + final CSVFormat secondFormat = builder.build(); + assertNotSame(header, firstFormat.getHeader()); + assertNotSame(firstFormat, secondFormat.getHeader()); } @Test - public void testQuotePolicy() { - assertEquals(Quote.ALL, builder.withQuotePolicy(Quote.ALL).build().getQuotePolicy()); - } - - @Test(expected = IllegalStateException.class) - public void testQuotePolicyNoneWithoutEscapeThrowsException() { - CSVFormat.newBuilder('!').withQuotePolicy(Quote.NONE).build(); + public void testIgnoreEmptyLines() { + assertFalse(builder.withIgnoreEmptyLines(false).build().getIgnoreEmptyLines()); } @Test - public void testCommentStart() { - assertEquals('?', builder.withCommentStart('?').build().getCommentStart().charValue()); + public void testIgnoreSurroundingSpaces() { + assertFalse(builder.withIgnoreSurroundingSpaces(false).build().getIgnoreSurroundingSpaces()); } @Test(expected = IllegalArgumentException.class) - public void testWithCommentStartCRThrowsException() { - builder.withCommentStart(CR).build(); + public void testNewFormatCRThrowsException() { + CSVFormat.newBuilder(CR); } - @Test - public void testRecoardSeparator() { - assertEquals("?", builder.withRecordSeparator("?").build().getRecordSeparator()); + @Test(expected = IllegalArgumentException.class) + public void testNewFormatLFThrowsException() { + CSVFormat.newBuilder(LF); } @Test - public void testEscape() { - assertEquals('?', builder.withEscape('?').build().getEscape().charValue()); + public void testQuoteChar() { + assertEquals('?', builder.withQuoteChar('?').build().getQuoteChar().charValue()); } - @Test(expected = IllegalArgumentException.class) - public void testWithEscapeCRThrowsExceptions() { - builder.withEscape(CR).build(); + @Test(expected = IllegalStateException.class) + public void testQuoteCharSameAsCommentStartThrowsException() { + builder.withQuoteChar('!').withCommentStart('!').build(); } - + @Test(expected = IllegalStateException.class) - public void testEscapeSameAsCommentStartThrowsException() { - builder.withEscape('!').withCommentStart('!').build(); + public void testQuoteCharSameAsCommentStartThrowsExceptionForWrapperType() { + // Cannot assume that callers won't use different Character objects + builder.withQuoteChar(new Character('!')).withCommentStart('!').build(); } @Test(expected = IllegalStateException.class) - public void testEscapeSameAsCommentStartThrowsExceptionForWrapperType() { - // Cannot assume that callers won't use different Character objects - builder.withEscape(new Character('!')).withCommentStart(new Character('!')).build(); + public void testQuoteCharSameAsDelimiterThrowsException() { + builder.withQuoteChar('!').withDelimiter('!').build(); } @Test - public void testIgnoreSurroundingSpaces() { - assertFalse(builder.withIgnoreSurroundingSpaces(false).build().getIgnoreSurroundingSpaces()); + public void testQuotePolicy() { + assertEquals(Quote.ALL, builder.withQuotePolicy(Quote.ALL).build().getQuotePolicy()); } - - @Test - public void testIgnoreEmptyLines() { - assertFalse(builder.withIgnoreEmptyLines(false).build().getIgnoreEmptyLines()); + + @Test(expected = IllegalStateException.class) + public void testQuotePolicyNoneWithoutEscapeThrowsException() { + CSVFormat.newBuilder('!').withQuotePolicy(Quote.NONE).build(); } - + @Test - public void testCopiedFormatIsEqualToOriginal() { - final CSVFormat copyOfRCF4180 = CSVFormat.newBuilder(RFC4180).build(); - assertEquals(RFC4180, copyOfRCF4180); + public void testRecoardSeparator() { + assertEquals("?", builder.withRecordSeparator("?").build().getRecordSeparator()); } - + @Test public void testRFC4180() { assertEquals(null, RFC4180.getCommentStart()); @@ -172,21 +169,24 @@ public class CSVFormatBuilderTest { assertEquals(null, RFC4180.getQuotePolicy()); assertEquals("\r\n", RFC4180.getRecordSeparator()); } + + @Test(expected = IllegalArgumentException.class) + public void testWithCommentStartCRThrowsException() { + builder.withCommentStart(CR).build(); + } - @Test - public void testCopiedFormatWithChanges() { - final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build(); - assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter()); + @Test(expected = IllegalArgumentException.class) + public void testWithDelimiterLFThrowsException() { + builder.withDelimiter(LF).build(); + } + + @Test(expected = IllegalArgumentException.class) + public void testWithEscapeCRThrowsExceptions() { + builder.withEscape(CR).build(); } - @Test - public void testHeaderReferenceCannotEscape() { - final String[] header = new String[]{"one", "tow", "three"}; - builder.withHeader(header); - - final CSVFormat firstFormat = builder.build(); - final CSVFormat secondFormat = builder.build(); - assertNotSame(header, firstFormat.getHeader()); - assertNotSame(firstFormat, secondFormat.getHeader()); + @Test(expected = IllegalArgumentException.class) + public void testWithQuoteLFThrowsException() { + builder.withQuoteChar(LF).build(); } }