src/tutorial/tasks-filesets-properties/03-paths/src/FindTest.java [29:81]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class FindTest {

    @Rule
    public BuildFileRule rule = new BuildFileRule();

    @Rule
    public ExpectedException tried = ExpectedException.none();

    @Before
    public void setUp() {
        rule.configureProject("build.xml");
    }

    @Test
    public void testMissingFile() {
        tried.expect(BuildException.class);
        tried.expectMessage("file not set");
        Find find = new Find();
        find.execute();
    }

    @Test
    public void testMissingLocation() {
        tried.expect(BuildException.class);
        tried.expectMessage("location not set");
        Find find = new Find();
        find.setFile("ant.jar");
        find.execute();
    }

    @Test
    public void testMissingPath() {
        tried.expect(BuildException.class);
        tried.expectMessage("path not set");
        Find find = new Find();
        find.setFile("ant.jar");
        find.setLocation("location.ant-jar");
        find.execute();
    }

    @Test
    public void testFileNotPresent() {
        rule.executeTarget("testFileNotPresent");
        String result = rule.getProject().getProperty("location.ant-jar");
        assertNull("Property set to wrong value.", result);
    }

    @Test
    public void testFilePresent() {
        rule.executeTarget("testFilePresent");
        String result = rule.getProject().getProperty("location.ant-jar");
        assertNotNull("Property not set.", result);
        assertTrue("Wrong file found.", result.endsWith("ant.jar"));
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/tutorial/tasks-filesets-properties/final/src/FindTest.java [32:84]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class FindTest {

    @Rule
    public BuildFileRule rule = new BuildFileRule();

    @Rule
    public ExpectedException tried = ExpectedException.none();

    @Before
    public void setUp() {
        rule.configureProject("build.xml");
    }

    @Test
    public void testMissingFile() {
        tried.expect(BuildException.class);
        tried.expectMessage("file not set");
        Find find = new Find();
        find.execute();
    }

    @Test
    public void testMissingLocation() {
        tried.expect(BuildException.class);
        tried.expectMessage("location not set");
        Find find = new Find();
        find.setFile("ant.jar");
        find.execute();
    }

    @Test
    public void testMissingPath() {
        tried.expect(BuildException.class);
        tried.expectMessage("path not set");
        Find find = new Find();
        find.setFile("ant.jar");
        find.setLocation("location.ant-jar");
        find.execute();
    }

    @Test
    public void testFileNotPresent() {
        rule.executeTarget("testFileNotPresent");
        String result = rule.getProject().getProperty("location.ant-jar");
        assertNull("Property set to wrong value.", result);
    }

    @Test
    public void testFilePresent() {
        rule.executeTarget("testFilePresent");
        String result = rule.getProject().getProperty("location.ant-jar");
        assertNotNull("Property not set.", result);
        assertTrue("Wrong file found.", result.endsWith("ant.jar"));
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



