本文整理匯總了Java中org.supercsv.cellprocessor.ift.CellProcessor.execute方法的典型用法代碼示例。如果您正苦於以下問題:Java CellProcessor.execute方法的具體用法?Java CellProcessor.execute怎麽用?Java CellProcessor.execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.supercsv.cellprocessor.ift.CellProcessor
的用法示例。
在下文中一共展示了CellProcessor.execute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: poolStringCellProcessorShouldPoolStringValues
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@SuppressWarnings({ "RedundantStringConstructorCall", "StringEquality" })
@Test
public void poolStringCellProcessorShouldPoolStringValues() throws Exception {
CellProcessor proc = new DbIpFileParser.PoolString(new StringPool());
// Construct strings explicitly to have separate instances
String input1 = new String("foo");
String input2 = new String("foo");
Assume.assumeTrue("Inputs must be different instances of equal strings, otherwise this test is useless",
input1 != input2 && input1.equals(input2));
String output1 = proc.execute(input1, dummyContext);
String output2 = proc.execute(input2, dummyContext);
assertTrue(output1 == output2);
}
示例2: parseInetAddressCellProcessorShouldParseIpv4Addresses
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void parseInetAddressCellProcessorShouldParseIpv4Addresses() throws Exception {
CellProcessor proc = new DbIpFileParser.ParseInetAddress();
InetAddress address = proc.execute("192.168.0.0", dummyContext);
assertTrue(address instanceof Inet4Address);
assertArrayEquals(new byte[] { (byte) 192, (byte) 168, 0, 0 }, address.getAddress());
}
示例3: parseInetAddressCellProcessorShouldParseIpv6Addresses
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void parseInetAddressCellProcessorShouldParseIpv6Addresses() throws Exception {
CellProcessor proc = new DbIpFileParser.ParseInetAddress();
InetAddress address = proc.execute("2001:db8:1::", dummyContext);
assertTrue(address instanceof Inet6Address);
assertArrayEquals(new byte[] { 0x20, 0x01, 0x0d, (byte) 0xb8, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 }, address.getAddress());
}
示例4: testNullInput
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testNullInput() {
for (CellProcessor p : processors) {
try {
p.execute(null, ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals(
"this processor does not accept null input - "
+ "if the column is optional then chain an Optional() processor before this one",
e.getMessage());
}
}
}
示例5: testInvalidDateWithNonLenient
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
/**
* Tests execution with an invalid date (matches format, but data invalid) and non-lenient processors (should throw
* an exception).
*/
@Test
public void testInvalidDateWithNonLenient() {
final String dodgyDate = "30/02/2012";
for( final CellProcessor cp : Arrays.asList(processor, processor3, processorChain, processorChain3) ) {
try {
cp.execute(dodgyDate, ANONYMOUS_CSVCONTEXT);
fail("should have thrown a SuperCsvCellProcessorException");
}
catch(SuperCsvCellProcessorException e) {}
}
}
示例6: testNonDurationInput
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testNonDurationInput() {
for (CellProcessor p : processors) {
try {
p.execute(123, ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals(
"the input value should be of type org.joda.time.Duration but is java.lang.Integer",
e.getMessage());
}
}
}
示例7: testWithNullNumberFormat
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
/**
* Tests execution with a invalid number format object (should throw an Exception).
*/
@Test(expected = NullPointerException.class)
public void testWithNullNumberFormat() {
final double number = 12.34;
CellProcessor invalidNumberFormatProcessor = new FmtNumber((DecimalFormat) null);
invalidNumberFormatProcessor.execute(number, ANONYMOUS_CSVCONTEXT);
}
示例8: testUnparsableString
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testUnparsableString() {
for (CellProcessor p : processors) {
try {
p.execute("not valid", ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals("Failed to parse value", e.getMessage());
}
}
}
示例9: testNonStringInput
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testNonStringInput() {
for (CellProcessor p : processors) {
try {
p.execute(123, ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals(
"the input value should be of type java.lang.String but is java.lang.Integer",
e.getMessage());
}
}
}
示例10: testInvalidDateFormat
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testInvalidDateFormat() {
final CellProcessor p = new FmtLocalTime("not valid");
try {
p.execute(LOCAL_TIME, ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals("Failed to format value as a LocalTime",
e.getMessage());
}
}
示例11: testNonIntervalInput
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testNonIntervalInput() {
for (CellProcessor p : processors) {
try {
p.execute(123, ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals(
"the input value should be of type org.joda.time.Interval but is java.lang.Integer",
e.getMessage());
}
}
}
示例12: testUnparsableString
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testUnparsableString() {
for (CellProcessor p : processors) {
try {
p.execute("not valid", ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals("Failed to parse value as a Period", e.getMessage());
}
}
}
示例13: testNonLocalDateInput
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testNonLocalDateInput() {
for (CellProcessor p : processors) {
try {
p.execute(123, ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals(
"the input value should be of type org.joda.time.LocalDate but is java.lang.Integer",
e.getMessage());
}
}
}
示例14: testInvalidDateFormat
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testInvalidDateFormat() {
final CellProcessor p = new FmtLocalDate("not valid");
try {
p.execute(LOCAL_DATE, ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals("Failed to format value as a LocalDate", e.getMessage());
}
}
示例15: testUnparsableString
import org.supercsv.cellprocessor.ift.CellProcessor; //導入方法依賴的package包/類
@Test
public void testUnparsableString() {
for (CellProcessor p : processors) {
try {
p.execute("not valid", ANONYMOUS_CSVCONTEXT);
fail("expecting SuperCsvCellProcessorException");
} catch (SuperCsvCellProcessorException e) {
assertEquals("Failed to parse value as a Duration",
e.getMessage());
}
}
}