Source:
<code>public void testValidation() { FlatFileItemWriterProperties properties = new FlatFileItemWriterProperties(); properties.setFormatted(true); properties.setDelimited(true); FlatFileItemWriterAutoConfiguration configuration = new FlatFileItemWriterAutoConfiguration( properties); try { configuration.itemWriter(); } catch (IllegalStateException ise) { assertThat(ise.getMessage()).isEqualTo( "An output file must be either delimited or formatted or a custom " + "LineAggregator must be provided. Your current configuration specifies both delimited and formatted"); } catch (Exception e) { fail("Incorrect exception thrown", e); } <START> <END> properties.setFormatted(true); properties.setDelimited(false); ReflectionTestUtils.setField(configuration, "lineAggregator", new PassThroughLineAggregator<>()); try { configuration.itemWriter(); } catch (IllegalStateException ise) { assertThat(ise.getMessage()) .isEqualTo("A LineAggregator must be configured if the " + "output is not formatted or delimited"); } catch (Exception e) { fail("Incorrect exception thrown", e); } properties.setFormatted(false); properties.setDelimited(true); try { configuration.itemWriter(); } catch (IllegalStateException ise) { assertThat(ise.getMessage()) .isEqualTo("A LineAggregator must be configured if the " + "output is not formatted or delimited"); } catch (Exception e) { fail("Incorrect exception thrown", e); } }</code><technical_language>test for success. If success fail test</technical_language>

Target:
public void testValidation() { FlatFileItemWriterProperties properties = new FlatFileItemWriterProperties(); properties.setFormatted(true); properties.setDelimited(true); FlatFileItemWriterAutoConfiguration configuration = new FlatFileItemWriterAutoConfiguration( properties); try { configuration.itemWriter(); fail("Exception should have been thrown when both formatted and delimited are selected"); } catch (IllegalStateException ise) { assertThat(ise.getMessage()).isEqualTo( "An output file must be either delimited or formatted or a custom " + "LineAggregator must be provided. Your current configuration specifies both delimited and formatted"); } catch (Exception e) { fail("Incorrect exception thrown", e); } properties.setFormatted(true); properties.setDelimited(false); ReflectionTestUtils.setField(configuration, "lineAggregator", new PassThroughLineAggregator<>()); try { configuration.itemWriter(); fail("Exception should have been thrown when a LineAggregator and one of the autocreated options are selected"); } catch (IllegalStateException ise) { assertThat(ise.getMessage()) .isEqualTo("A LineAggregator must be configured if the " + "output is not formatted or delimited"); } catch (Exception e) { fail("Incorrect exception thrown", e); } properties.setFormatted(false); properties.setDelimited(true); try { configuration.itemWriter(); fail("Exception should have been thrown when a LineAggregator and one of the autocreated options are selected"); } catch (IllegalStateException ise) { assertThat(ise.getMessage()) .isEqualTo("A LineAggregator must be configured if the " + "output is not formatted or delimited"); } catch (Exception e) { fail("Incorrect exception thrown", e); } }