0) {
- if (delimiter==null) {
+ if (!foundFiles.isEmpty()) {
+ if (delimiter == null) {
// only the first
- rv = (String)foundFiles.elementAt(0);
+ rv = foundFiles.get(0);
} else {
// create list
- StringBuffer list = new StringBuffer();
- for(Iterator it=foundFiles.iterator(); it.hasNext(); ) {
- list.append(it.next());
- if (it.hasNext()) list.append(delimiter);
+ StringBuilder list = new StringBuilder();
+ for (String file : foundFiles) {
+ if (list.length() > 0) list.append(delimiter);
+ list.append(file);
}
rv = list.toString();
}
}
- if (rv!=null)
+ if (rv != null)
getProject().setNewProperty(location, rv);
}
diff --git a/src/tutorial/tasks-filesets-properties/04-lists/src/FindTest.java b/src/tutorial/tasks-filesets-properties/04-lists/src/FindTest.java
index 54c7fc2b3..836325f67 100644
--- a/src/tutorial/tasks-filesets-properties/04-lists/src/FindTest.java
+++ b/src/tutorial/tasks-filesets-properties/04-lists/src/FindTest.java
@@ -1,78 +1,92 @@
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.taskdefs.Property;
-import java.io.File;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
-public class FindTest extends BuildFileTest {
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
- public FindTest(String name) {
- super(name);
- }
+public class FindTest {
+
+ @Rule
+ public BuildFileRule rule = new BuildFileRule();
+ @Rule
+ public ExpectedException tried = ExpectedException.none();
+
+ @Before
public void setUp() {
- configureProject("build.xml");
+ rule.configureProject("build.xml");
}
+ @Test
public void testMissingFile() {
+ tried.expect(BuildException.class);
+ tried.expectMessage("file not set");
Find find = new Find();
- try {
- find.execute();
- fail("No 'no-file'-exception thrown.");
- } catch (Exception e) {
- // exception expected
- String expected = "file not set";
- assertEquals("Wrong exception message.", expected, e.getMessage());
- }
+ find.execute();
}
+ @Test
public void testMissingLocation() {
+ tried.expect(BuildException.class);
+ tried.expectMessage("location not set");
Find find = new Find();
find.setFile("ant.jar");
- try {
- find.execute();
- fail("No 'no-location'-exception thrown.");
- } catch (Exception e) {
- // exception expected
- String expected = "location not set";
- assertEquals("Wrong exception message.", expected, e.getMessage());
- }
+ 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");
- try {
- find.execute();
- fail("No 'no-fileset'-exception thrown.");
- } catch (Exception e) {
- // exception expected
- String expected = "path not set";
- assertEquals("Wrong exception message.", expected, e.getMessage());
- }
+ find.execute();
}
+ @Test
public void testFileNotPresent() {
- executeTarget("testFileNotPresent");
- String result = getProject().getProperty("location.ant-jar");
+ rule.executeTarget("testFileNotPresent");
+ String result = rule.getProject().getProperty("location.ant-jar");
assertNull("Property set to wrong value.", result);
}
public void testFilePresent() {
- executeTarget("testFilePresent");
- String result = getProject().getProperty("location.ant-jar");
+ rule.executeTarget("testFilePresent");
+ String result = rule.getProject().getProperty("location.ant-jar");
assertNotNull("Property not set.", result);
assertTrue("Wrong file found.", result.endsWith("ant.jar"));
}
public void testMultipleFiles() {
- executeTarget("testMultipleFiles");
- String result = getProject().getProperty("location.test");
+ rule.executeTarget("testMultipleFiles");
+ String result = rule.getProject().getProperty("location.test");
assertNotNull("Property not set.", result);
- assertTrue("Only one file found.", result.indexOf(";") > -1);
+ assertTrue("Only one file found.", result.contains(";"));
//assertTrue("Wrong file found.", result.endsWith("ant.jar"));
}
-
}
diff --git a/src/tutorial/tasks-filesets-properties/final/build.xml b/src/tutorial/tasks-filesets-properties/final/build.xml
index 39c18a2d6..ee695df8c 100644
--- a/src/tutorial/tasks-filesets-properties/final/build.xml
+++ b/src/tutorial/tasks-filesets-properties/final/build.xml
@@ -1,4 +1,20 @@
-
+
+
@@ -29,15 +45,14 @@
-
+
-
-
+
@@ -118,7 +133,6 @@
-
@@ -155,8 +169,6 @@
-
+ description="Runs unit tests and creates a report"/>
diff --git a/src/tutorial/tasks-filesets-properties/final/find.html b/src/tutorial/tasks-filesets-properties/final/find.html
index 7f781a618..c37200c6a 100644
--- a/src/tutorial/tasks-filesets-properties/final/find.html
+++ b/src/tutorial/tasks-filesets-properties/final/find.html
@@ -1,3 +1,19 @@
+
@@ -7,9 +23,9 @@
-
+Find
Description
-Searchs in a given path for a file and returns the absolute to it as property.
+
Searches in a given path for a file and returns the absolute to it as property.
If delimiter is set this task returns all found locations.
Parameters
diff --git a/src/tutorial/tasks-filesets-properties/final/src/Find.java b/src/tutorial/tasks-filesets-properties/final/src/Find.java
index 96fc06f02..8196c36d8 100644
--- a/src/tutorial/tasks-filesets-properties/final/src/Find.java
+++ b/src/tutorial/tasks-filesets-properties/final/src/Find.java
@@ -1,80 +1,40 @@
/*
- * The Apache Software License, Version 1.1
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "Ant" and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
*/
+//package org.apache.tools.ant.taskdefs;
-package org.apache.tools.ant.taskdefs;
-
-
-import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.DirectoryScanner;
-import java.util.Vector;
-import java.util.Iterator;
-import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
public class Find extends Task {
// ===== internal attributes =====
- private Vector foundFiles = new Vector();
+ private List foundFiles = new ArrayList<>();
// ===== attribute support =====
private String file;
private String location;
- private Vector paths = new Vector();
+ private List paths = new ArrayList<>();
private String delimiter = null;
public void setFile(String file) {
@@ -96,45 +56,43 @@ public class Find extends Task {
// ===== the tasks work =====
protected void validate() {
- if (file==null) throw new BuildException("file not set");
- if (location==null) throw new BuildException("location not set");
- if (paths.size()<1) throw new BuildException("path not set");
+ if (file == null) throw new BuildException("file not set");
+ if (location == null) throw new BuildException("location not set");
+ if (paths.isEmpty()) throw new BuildException("path not set");
}
public void execute() {
validate();
// find all files
- for(Iterator itPaths = paths.iterator(); itPaths.hasNext(); ) {
- Path path = (Path)itPaths.next();
- String[] includedFiles = path.list();
- for(int i=0; i 0) {
- if (delimiter==null) {
+ if (!foundFiles.isEmpty()) {
+ if (delimiter == null) {
// only the first
- rv = (String)foundFiles.elementAt(0);
+ rv = foundFiles.get(0);
} else {
// create list
- StringBuffer list = new StringBuffer();
- for(Iterator it=foundFiles.iterator(); it.hasNext(); ) {
- list.append(it.next());
- if (it.hasNext()) list.append(delimiter);
+ StringBuilder list = new StringBuilder();
+ for (String file : foundFiles) {
+ if (list.length() > 0) list.append(delimiter);
+ list.append(file);
}
rv = list.toString();
}
}
// create the property
- if (rv!=null)
+ if (rv != null)
getProject().setNewProperty(location, rv);
}
diff --git a/src/tutorial/tasks-filesets-properties/final/src/FindTest.java b/src/tutorial/tasks-filesets-properties/final/src/FindTest.java
index 117505347..0e0643782 100644
--- a/src/tutorial/tasks-filesets-properties/final/src/FindTest.java
+++ b/src/tutorial/tasks-filesets-properties/final/src/FindTest.java
@@ -1,134 +1,95 @@
/*
- * The Apache Software License, Version 1.1
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
- * reserved.
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "Ant" and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
*/
-package org.apache.tools.ant.taskdefs;
+//package org.apache.tools.ant.taskdefs;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
-import org.apache.tools.ant.BuildFileTest;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.taskdefs.Property;
-import java.io.File;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-public class FindTest extends BuildFileTest {
+public class FindTest {
- public FindTest(String name) {
- super(name);
- }
+ @Rule
+ public BuildFileRule rule = new BuildFileRule();
+
+ @Rule
+ public ExpectedException tried = ExpectedException.none();
+ @Before
public void setUp() {
- configureProject("build.xml");
+ rule.configureProject("build.xml");
}
+ @Test
public void testMissingFile() {
+ tried.expect(BuildException.class);
+ tried.expectMessage("file not set");
Find find = new Find();
- try {
- find.execute();
- fail("No 'no-file'-exception thrown.");
- } catch (Exception e) {
- // exception expected
- String expected = "file not set";
- assertEquals("Wrong exception message.", expected, e.getMessage());
- }
+ find.execute();
}
+ @Test
public void testMissingLocation() {
+ tried.expect(BuildException.class);
+ tried.expectMessage("location not set");
Find find = new Find();
find.setFile("ant.jar");
- try {
- find.execute();
- fail("No 'no-location'-exception thrown.");
- } catch (Exception e) {
- // exception expected
- String expected = "location not set";
- assertEquals("Wrong exception message.", expected, e.getMessage());
- }
+ 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");
- try {
- find.execute();
- fail("No 'no-fileset'-exception thrown.");
- } catch (Exception e) {
- // exception expected
- String expected = "path not set";
- assertEquals("Wrong exception message.", expected, e.getMessage());
- }
+ find.execute();
}
+ @Test
public void testFileNotPresent() {
- executeTarget("testFileNotPresent");
- String result = getProject().getProperty("location.ant-jar");
+ rule.executeTarget("testFileNotPresent");
+ String result = rule.getProject().getProperty("location.ant-jar");
assertNull("Property set to wrong value.", result);
}
+ @Test
public void testFilePresent() {
- executeTarget("testFilePresent");
- String result = getProject().getProperty("location.ant-jar");
+ rule.executeTarget("testFilePresent");
+ String result = rule.getProject().getProperty("location.ant-jar");
assertNotNull("Property not set.", result);
assertTrue("Wrong file found.", result.endsWith("ant.jar"));
}
-
+ @Test
public void testMultipleFiles() {
- executeTarget("testMultipleFiles");
- String result = getProject().getProperty("location.test");
+ rule.executeTarget("testMultipleFiles");
+ String result = rule.getProject().getProperty("location.test");
assertNotNull("Property not set.", result);
- assertTrue("Only one file found.", result.indexOf(";") > -1);
+ assertTrue("Only one file found.", result.contains(";"));
}
-
}
diff --git a/src/tutorial/tasks-start-writing/build.xml b/src/tutorial/tasks-start-writing/build.xml
index 8e502c1b6..3d5789c7b 100644
--- a/src/tutorial/tasks-start-writing/build.xml
+++ b/src/tutorial/tasks-start-writing/build.xml
@@ -1,4 +1,20 @@
-
+
+
@@ -29,7 +45,7 @@
-
+
@@ -37,7 +53,7 @@
-
+
@@ -68,8 +84,7 @@
+ depends="use.without,use.message,use.nestedText,use.nestedElement"/>
@@ -96,8 +111,6 @@
-
+ description="Runs unit tests and creates a report"/>
diff --git a/src/tutorial/tasks-start-writing/src/HelloWorld.java b/src/tutorial/tasks-start-writing/src/HelloWorld.java
index eaa42d6ad..6b5163d42 100644
--- a/src/tutorial/tasks-start-writing/src/HelloWorld.java
+++ b/src/tutorial/tasks-start-writing/src/HelloWorld.java
@@ -1,11 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
-import java.util.Vector;
-import java.util.Iterator;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* The task of the tutorial.
- * Prints a message or let the build fail.
+ * Prints a message or lets the build fail.
* @author Jan Matérne
* @since 2003-08-19
*/
@@ -36,18 +54,17 @@ public class HelloWorld extends Task {
if (fail) throw new BuildException("Fail requested.");
// handle attribute 'message' and nested text
- if (message!=null) log(message);
+ if (message != null) log(message);
// handle nested elements
- for (Iterator it=messages.iterator(); it.hasNext(); ) {
- Message msg = (Message)it.next();
+ for (Message msg : messages) {
log(msg.getMsg());
}
}
/** Store nested 'message's. */
- Vector messages = new Vector();
+ List messages = new ArrayList<>();
/** Factory method for creating nested 'message's. */
public Message createMessage() {
@@ -67,4 +84,4 @@ public class HelloWorld extends Task {
public String getMsg() { return msg; }
}
-}
\ No newline at end of file
+}
diff --git a/src/tutorial/tasks-start-writing/src/HelloWorldTest.java b/src/tutorial/tasks-start-writing/src/HelloWorldTest.java
index 87a7e3142..fe9e90c13 100644
--- a/src/tutorial/tasks-start-writing/src/HelloWorldTest.java
+++ b/src/tutorial/tasks-start-writing/src/HelloWorldTest.java
@@ -1,40 +1,77 @@
-import org.apache.tools.ant.BuildFileTest;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
-public class HelloWorldTest extends BuildFileTest {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
- public HelloWorldTest(String s) {
- super(s);
- }
+public class HelloWorldTest {
+
+ @Rule
+ public BuildFileRule rule = new BuildFileRule();
+
+ @Rule
+ public ExpectedException tried = ExpectedException.none();
+ @Before
public void setUp() {
// initialize Ant
- configureProject("build.xml");
+ rule.configureProject("build.xml");
}
+ @Test
public void testWithout() {
- executeTarget("use.without");
- assertEquals("Message was logged but should not.", getLog(), "");
+ rule.executeTarget("use.without");
+ assertEquals("Message was logged but should not.", "", rule.getLog());
}
+ @Test
public void testMessage() {
// execute target 'use.nestedText' and expect a message
// 'attribute-text' in the log
- expectLog("use.message", "attribute-text");
+ rule.executeTarget("use.message");
+ assertEquals(rule.getLog(), "attribute-text");
}
+ @Test
public void testFail() {
+ tried.expect(BuildException.class);
+ tried.expectMessage("Fail requested.");
// execute target 'use.fail' and expect a BuildException
// with text 'Fail requested.'
- expectBuildException("use.fail", "Fail requested.");
+ rule.executeTarget("use.fail");
}
+ @Test
public void testNestedText() {
- expectLog("use.nestedText", "nested-text");
+ rule.executeTarget("use.nestedText");
+ assertEquals("nested-text", rule.getLog());
}
+ @Test
public void testNestedElement() {
- executeTarget("use.nestedElement");
- assertLogContaining("Nested Element 1");
- assertLogContaining("Nested Element 2");
+ rule.executeTarget("use.nestedElement");
+ assertTrue(rule.getLog().contains("Nested Element 1"));
+ assertTrue(rule.getLog().contains("Nested Element 2"));
}
}