@Override
public String toString() {
- String fullcmd = "";
+ StringBuffer fullcmd = new StringBuffer();
for (String part : cmd) {
- fullcmd += (part + " ");
+ fullcmd.append(part + " ");
}
return "process(dir = '" + directory + "', cmd = '" + fullcmd + "')";
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
- Assert.fail("ReadLocker thread was interrupted." +
+ ReadWriteLockTest.fail("ReadLocker thread was interrupted." +
Thread.currentThread());
}
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
- Assert.fail("WriteLocker thread was interrupted: " +
+ ReadWriteLockTest.fail("WriteLocker thread was interrupted: " +
Thread.currentThread());
}
}
AndCondition<Integer> and = new AndCondition<Integer>(conditions);
- assertEquals(aResult, and.matches(new Integer(0)));
+ assertEquals(aResult, and.matches(Integer.valueOf(0)));
}
/**
}
OrCondition<Integer> or = new OrCondition<Integer>(conditions);
- assertEquals(aResult, or.matches(new Integer(0)));
+ assertEquals(aResult, or.matches(Integer.valueOf(0)));
}
/**
assertEquals("hello", pair.getSecond());
Pair<Integer, String> pair2 = new Pair<Integer, String>(pair);
- assertEquals(new Integer(10), pair2.getFirst());
+ assertEquals(Integer.valueOf(10), pair2.getFirst());
assertEquals("hello", pair2.getSecond());
}
}
try {
ClassPathResource resource = new ClassPathResource(
"org/wamblee/io/myresource-nonexistent.txt");
- InputStream is = resource.getInputStream();
+ resource.getInputStream();
} catch (IOException e) {
return; // ok
}
FileResource resource = new FileResource(new File(FileSystemUtils
.getTestInputDir(FileResourceTest.class),
"myresource-nonexistent.txt"));
- InputStream is = resource.getInputStream();
+ resource.getInputStream();
} catch (IOException e) {
return; // ok
}
Assert.assertTrue(aSrc.isDirectory());
Assert.assertTrue(!aTarget.exists());
- aTarget.mkdirs();
+ if (!aTarget.mkdirs()) {
+ Assert.fail("Could not create target directory '" + aTarget + "'");
+ }
File[] files = aSrc.listFiles();
* @author Erik Brakkee
*/
public final class TestData {
- private Object testcase;
private File root;
/**
* test.
*/
public TestData(Object aTestcase) {
- testcase = aTestcase;
root = getTestRootDir(aTestcase);
FileSystemUtils.createDir(root);
}
@Override
protected void setUp() throws Exception {
super.setUp();
- observed = new Integer(1);
+ observed = Integer.valueOf(1);
observable = new Observable<Integer, String>(observed,
new DefaultObserverNotifier());
}
*/
package org.wamblee.test;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
/**
* Useful assertions for use in test cases.
*
TestCase.assertEquals("Map sizes differ", aExpectedMap.size(), aActual
.size());
- Set keys = aExpectedMap.keySet();
+ Set<Entry<Key,Value>> expectedEntries = aExpectedMap.entrySet();
- for (Iterator i = keys.iterator(); i.hasNext();) {
- String key = (String) i.next();
+ for (Entry<Key,Value> entry: expectedEntries) {
+ Key key = entry.getKey();
TestCase.assertTrue("Map does not containg entry for key:" + key,
aActual.containsKey(key));
AssertionUtils.assertEquals("Value of key " + key + " of map",
- aExpectedMap.get(key), aActual.get(key));
+ entry.getValue(), aActual.get(key));
}
}
clear();
}
- public void clear() {
+ public synchronized void clear() {
events = new HashMap<Thread, List<Event>>();
}
*/
public void testResolveNonExistingFile() {
try {
- Source source = resolver.resolve(
+ resolver.resolve(
"org/wamblee/xml/reportToHtml-nonexisting.xsl", "");
} catch (TransformerException e) {
return; // ok
* 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.
- */
+ */
package org.wamblee.xml;
-import junit.framework.TestCase;
-
-import org.dom4j.Attribute;
-import org.dom4j.Document;
-import org.dom4j.Element;
-
+import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import junit.framework.TestCase;
+
+import org.dom4j.Attribute;
+import org.dom4j.Document;
+import org.dom4j.Element;
+
/**
* XML test support utilities.
*
* Comparator which compares attributes by name.
*/
private static final class AttributeComparator implements
- Comparator<Attribute> {
+ Comparator<Attribute>, Serializable {
+
+ private static final long serialVersionUID = 7897287273519886301L;
+
/*
* (non-Javadoc)
*
.read(xmlResource.getInputStream()).getBytes();
try {
- Document output1 = transformer.transform(documentData, xslt);
+ transformer.transform(documentData, xslt);
} catch (TransformerException e) {
return; // ok
}
.read(xmlResource.getInputStream()).getBytes();
try {
- Document output1 = transformer.transform(documentData, xslt);
+ transformer.transform(documentData, xslt);
} catch (TransformerException e) {
return; // ok
}
.read(xmlResource.getInputStream()).getBytes();
try {
- Document output1 = transformer.transform(documentData, xslt);
+ transformer.transform(documentData, xslt);
} catch (TransformerException e) {
return; // ok
}
XslTransformer transformer = new XslTransformer();
try {
- Source source = transformer
+ transformer
.resolve("org/wamblee/xml/utilities-nonexistent.xsl");
} catch (TransformerException e) {
return; // ok