diff --git a/src/main/org/apache/tools/ant/ComponentHelper.java b/src/main/org/apache/tools/ant/ComponentHelper.java index 9d0af8519..31ab880d9 100644 --- a/src/main/org/apache/tools/ant/ComponentHelper.java +++ b/src/main/org/apache/tools/ant/ComponentHelper.java @@ -59,7 +59,7 @@ import org.apache.tools.ant.util.FileUtils; */ public class ComponentHelper { /** Map of component name to lists of restricted definitions */ - private Map> restrictedDefinitions = new HashMap>(); + private Map> restrictedDefinitions = new HashMap>(); /** Map from component name to anttypedefinition */ private final Hashtable antTypeTable = new Hashtable(); @@ -146,8 +146,8 @@ public class ComponentHelper { if (project == null) { return null; } - // Singleton for now, it may change ( per/classloader ) - ComponentHelper ph = (ComponentHelper) project.getReference(COMPONENT_HELPER_REFERENCE); + // Singleton for now, it may change (per/classloader) + ComponentHelper ph = project.getReference(COMPONENT_HELPER_REFERENCE); if (ph != null) { return ph; } @@ -972,7 +972,7 @@ public class ComponentHelper { out.println("Cause: The constructor threw the exception"); out.println(t.toString()); t.printStackTrace(out); //NOSONAR - } catch (NoClassDefFoundError ncdfe) { + } catch (NoClassDefFoundError ncdfe) { jars = true; out.println("Cause: A class needed by class " + classname + " cannot be found: "); diff --git a/src/main/org/apache/tools/ant/DemuxOutputStream.java b/src/main/org/apache/tools/ant/DemuxOutputStream.java index e69c3a4e5..9645ca72f 100644 --- a/src/main/org/apache/tools/ant/DemuxOutputStream.java +++ b/src/main/org/apache/tools/ant/DemuxOutputStream.java @@ -124,7 +124,7 @@ public class DemuxOutputStream extends OutputStream { */ private void removeBuffer() { Thread current = Thread.currentThread(); - buffers.remove (current); + buffers.remove(current); } /** diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java index f4b8fdca3..b739ff8ac 100644 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -792,8 +792,7 @@ public class DirectoryScanner System.arraycopy(this.excludes, 0, tmp, 0, this.excludes.length); for (int i = 0; i < excludes.length; i++) { - tmp[this.excludes.length + i] = - normalizePattern(excludes[i]); + tmp[this.excludes.length + i] = normalizePattern(excludes[i]); } this.excludes = tmp; } else { @@ -856,8 +855,7 @@ public class DirectoryScanner while (scanning) { try { scanLock.wait(); - } catch (final InterruptedException e) { - continue; + } catch (final InterruptedException ignored) { } } if (illegal != null) { @@ -875,8 +873,7 @@ public class DirectoryScanner // set in/excludes to reasonable defaults if needed: final boolean nullIncludes = (includes == null); - includes = nullIncludes - ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; + includes = nullIncludes ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; final boolean nullExcludes = (excludes == null); excludes = nullExcludes ? new String[0] : excludes; @@ -954,8 +951,7 @@ public class DirectoryScanner for (int i = 0; i < includePatterns.length; i++) { final String pattern = includePatterns[i].toString(); if (!shouldSkipPattern(pattern)) { - newroots.put(includePatterns[i].rtrimWildcardTokens(), - pattern); + newroots.put(includePatterns[i].rtrimWildcardTokens(), pattern); } } for (final Map.Entry entry : includeNonPatterns.entrySet()) { @@ -983,8 +979,7 @@ public class DirectoryScanner for (final Map.Entry entry : newroots.entrySet()) { TokenizedPath currentPath = entry.getKey(); String currentelement = currentPath.toString(); - if (basedir == null - && !FileUtils.isAbsolutePath(currentelement)) { + if (basedir == null && !FileUtils.isAbsolutePath(currentelement)) { continue; } File myfile = new File(basedir, currentelement); @@ -1003,10 +998,8 @@ public class DirectoryScanner if (myfile != null && basedir != null) { currentelement = FILE_UTILS.removeLeadingPath( basedir, myfile); - if (!currentPath.toString() - .equals(currentelement)) { - currentPath = - new TokenizedPath(currentelement); + if (!currentPath.toString().equals(currentelement)) { + currentPath = new TokenizedPath(currentelement); } } } @@ -1123,8 +1116,7 @@ public class DirectoryScanner // set in/excludes to reasonable defaults if needed: final boolean nullIncludes = (includes == null); - includes = nullIncludes - ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; + includes = nullIncludes ? new String[] {SelectorUtils.DEEP_TREE_MATCH} : includes; final boolean nullExcludes = (excludes == null); excludes = nullExcludes ? new String[0] : excludes; @@ -1294,10 +1286,8 @@ public class DirectoryScanner } else { everythingIncluded = false; dirsNotIncluded.addElement(name); - if (fast && couldHoldIncluded(newPath) - && !contentsExcluded(newPath)) { - scandir(file, newPath, fast, children, - directoryNamesFollowed); + if (fast && couldHoldIncluded(newPath) && !contentsExcluded(newPath)) { + scandir(file, newPath, fast, children, directoryNamesFollowed); } } if (!fast) { @@ -1351,10 +1341,8 @@ public class DirectoryScanner } private void accountForNotFollowedSymlink(final TokenizedPath name, final File file) { - if (!isExcluded(name) && - (isIncluded(name) - || (file.isDirectory() && couldHoldIncluded(name) - && !contentsExcluded(name)))) { + if (!isExcluded(name) && (isIncluded(name) + || (file.isDirectory() && couldHoldIncluded(name) && !contentsExcluded(name)))) { notFollowedSymlinks.add(file.getAbsolutePath()); } } @@ -1383,7 +1371,7 @@ public class DirectoryScanner * Test whether or not a name matches against at least one include * pattern. * - * @param name The name to match. Must not be null. + * @param name The path to match. Must not be null. * @return true when the name matches against at least one * include pattern, or false otherwise. */ @@ -1496,8 +1484,7 @@ public class DirectoryScanner * @since Ant 1.6 */ private boolean isMorePowerfulThanExcludes(final String name) { - final String soughtexclude = - name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH; + final String soughtexclude = name + File.separatorChar + SelectorUtils.DEEP_TREE_MATCH; for (int counter = 0; counter < excludePatterns.length; counter++) { if (excludePatterns[counter].toString().equals(soughtexclude)) { return false; @@ -1761,8 +1748,7 @@ public class DirectoryScanner public synchronized String[] getNotFollowedSymlinks() { String[] links; synchronized (this) { - links = notFollowedSymlinks - .toArray(new String[notFollowedSymlinks.size()]); + links = notFollowedSymlinks.toArray(new String[notFollowedSymlinks.size()]); } Arrays.sort(links); return links; @@ -1854,12 +1840,12 @@ public class DirectoryScanner * @param patterns String[] of patterns. * @since Ant 1.8.0 */ - private TokenizedPattern[] fillNonPatternSet(final Map map, final String[] patterns) { + private TokenizedPattern[] fillNonPatternSet(final Map map, + final String[] patterns) { final ArrayList al = new ArrayList(patterns.length); for (int i = 0; i < patterns.length; i++) { if (!SelectorUtils.hasWildcards(patterns[i])) { - final String s = isCaseSensitive() - ? patterns[i] : patterns[i].toUpperCase(); + final String s = isCaseSensitive() ? patterns[i] : patterns[i].toUpperCase(); map.put(s, new TokenizedPath(s)); } else { al.add(new TokenizedPattern(patterns[i])); @@ -1883,8 +1869,7 @@ public class DirectoryScanner final LinkedList directoryNamesFollowed) { try { if (directoryNamesFollowed.size() >= maxLevelsOfSymlinks - && CollectionUtils.frequency(directoryNamesFollowed, dirName) - >= maxLevelsOfSymlinks + && CollectionUtils.frequency(directoryNamesFollowed, dirName) >= maxLevelsOfSymlinks && SYMLINK_UTILS.isSymbolicLink(parent, dirName)) { final ArrayList files = new ArrayList(); @@ -1899,8 +1884,7 @@ public class DirectoryScanner f = FILE_UTILS.resolveFile(parent, relPath + dir); files.add(f.getCanonicalPath()); if (files.size() > maxLevelsOfSymlinks - && CollectionUtils.frequency(files, target) - > maxLevelsOfSymlinks) { + && CollectionUtils.frequency(files, target) > maxLevelsOfSymlinks) { return true; } } diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index 9740338fe..ff64e9d6d 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -1125,7 +1125,7 @@ public final class IntrospectionHelper { void set(final Project p, final Object parent, final String value) throws InvocationTargetException, IllegalAccessException, BuildException { m.invoke(parent, new Object[] {new FileResource(p, p.resolveFile(value))}); - }; + } }; } // EnumeratedAttributes have their own helper class diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java index b91b83ec9..461b89ac5 100644 --- a/src/main/org/apache/tools/ant/Project.java +++ b/src/main/org/apache/tools/ant/Project.java @@ -192,12 +192,12 @@ public class Project implements ResourceFactory { private ClassLoader coreLoader = null; /** Records the latest task to be executed on a thread. */ - private final Map threadTasks = - Collections.synchronizedMap(new WeakHashMap()); + private final Map threadTasks + = Collections.synchronizedMap(new WeakHashMap()); /** Records the latest task to be executed on a thread group. */ - private final Map threadGroupTasks - = Collections.synchronizedMap(new WeakHashMap()); + private final Map threadGroupTasks + = Collections.synchronizedMap(new WeakHashMap()); /** * Called to handle any input requests. diff --git a/src/main/org/apache/tools/ant/RuntimeConfigurable.java b/src/main/org/apache/tools/ant/RuntimeConfigurable.java index 302d8f6ed..6c4953fa5 100644 --- a/src/main/org/apache/tools/ant/RuntimeConfigurable.java +++ b/src/main/org/apache/tools/ant/RuntimeConfigurable.java @@ -593,8 +593,7 @@ public class RuntimeConfigurable implements Serializable { // Children (this is a shadow of UnknownElement#children) if (r.children != null) { - ArrayList newChildren = new ArrayList(); - newChildren.addAll(r.children); + ArrayList newChildren = new ArrayList(r.children); if (children != null) { newChildren.addAll(children); } diff --git a/src/main/org/apache/tools/ant/UnknownElement.java b/src/main/org/apache/tools/ant/UnknownElement.java index 15770c2f8..f0a274eeb 100644 --- a/src/main/org/apache/tools/ant/UnknownElement.java +++ b/src/main/org/apache/tools/ant/UnknownElement.java @@ -400,8 +400,7 @@ public class UnknownElement extends Task { // Do the runtime getWrapper().applyPreSet(u.getWrapper()); if (u.children != null) { - List newChildren = new ArrayList(); - newChildren.addAll(u.children); + List newChildren = new ArrayList(u.children); if (children != null) { newChildren.addAll(children); } diff --git a/src/main/org/apache/tools/ant/XmlLogger.java b/src/main/org/apache/tools/ant/XmlLogger.java index d03067d13..51d477654 100644 --- a/src/main/org/apache/tools/ant/XmlLogger.java +++ b/src/main/org/apache/tools/ant/XmlLogger.java @@ -466,7 +466,7 @@ public class XmlLogger implements BuildLogger { } private void synchronizedAppend(Node parent, Node child) { - synchronized(parent) { + synchronized (parent) { parent.appendChild(child); } } diff --git a/src/main/org/apache/tools/ant/filters/BaseFilterReader.java b/src/main/org/apache/tools/ant/filters/BaseFilterReader.java index 3b3b02706..dfd16f113 100644 --- a/src/main/org/apache/tools/ant/filters/BaseFilterReader.java +++ b/src/main/org/apache/tools/ant/filters/BaseFilterReader.java @@ -176,7 +176,7 @@ public abstract class BaseFilterReader extends FilterReader { StringBuffer line = new StringBuffer(); while (ch != -1) { - line.append ((char) ch); + line.append((char) ch); if (ch == '\n') { break; } diff --git a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java index f033b6f81..a2ac73215 100644 --- a/src/main/org/apache/tools/ant/filters/ReplaceTokens.java +++ b/src/main/org/apache/tools/ant/filters/ReplaceTokens.java @@ -87,7 +87,8 @@ public final class ReplaceTokens * * @see BaseFilterReader#BaseFilterReader() */ - public ReplaceTokens() {} + public ReplaceTokens() { + } /** * Creates a new filtered reader. @@ -138,12 +139,12 @@ public final class ReplaceTokens if (next == -1) { return next; // end of stream. all buffers empty. } - readBuffer += (char)next; + readBuffer += (char) next; } for (;;) { // get the closest tokens - SortedMap possibleTokens = resolvedTokens.tailMap(readBuffer); + SortedMap possibleTokens = resolvedTokens.tailMap(readBuffer); if (possibleTokens.isEmpty() || !possibleTokens.firstKey().startsWith(readBuffer)) { // if there is none, then deliver the first char from the buffer. return getFirstCharacterFromReadBuffer(); } else if (readBuffer.equals(possibleTokens.firstKey())) { // there exists a nearest token - is it an exact match? @@ -156,7 +157,7 @@ public final class ReplaceTokens } else { // nearest token is not matching exactly - read one character more. int next = in.read(); if (next != -1) { - readBuffer += (char)next; + readBuffer += (char) next; } else { return getFirstCharacterFromReadBuffer(); // end of stream. deliver remaining characters from buffer. } diff --git a/src/main/org/apache/tools/ant/launch/Launcher.java b/src/main/org/apache/tools/ant/launch/Launcher.java index 5c4f6f490..10ca77c69 100644 --- a/src/main/org/apache/tools/ant/launch/Launcher.java +++ b/src/main/org/apache/tools/ant/launch/Launcher.java @@ -120,7 +120,7 @@ public class Launcher { } if (exitCode != 0) { if (launchDiag) { - System.out.println("Exit code: "+exitCode); + System.out.println("Exit code: " + exitCode); } System.exit(exitCode); } @@ -237,7 +237,7 @@ public class Launcher { } } - logPath("Launcher JAR",sourceJar); + logPath("Launcher JAR", sourceJar); logPath("Launcher JAR directory", sourceJar.getParentFile()); logPath("java.home", new File(System.getProperty("java.home"))); @@ -256,7 +256,7 @@ public class Launcher { final URL[] userURLs = noUserLib ? new URL[0] : getUserURLs(); final File toolsJAR = Locator.getToolsJar(); - logPath("tools.jar",toolsJAR); + logPath("tools.jar", toolsJAR); final URL[] jars = getJarArray( libURLs, userURLs, systemURLs, toolsJAR); @@ -279,7 +279,7 @@ public class Launcher { Thread.currentThread().setContextClassLoader(loader); Class mainClass = null; int exitCode = 0; - Throwable thrown=null; + Throwable thrown = null; try { mainClass = loader.loadClass(mainClassname); final AntMain main = (AntMain) mainClass.newInstance(); @@ -297,10 +297,10 @@ public class Launcher { thrown = cnfe; } catch (final Throwable t) { t.printStackTrace(System.err); //NOSONAR - thrown=t; + thrown = t; } - if(thrown!=null) { - System.err.println(ANTHOME_PROPERTY+": "+antHome.getAbsolutePath()); + if (thrown != null) { + System.err.println(ANTHOME_PROPERTY + ": " + antHome.getAbsolutePath()); System.err.println("Classpath: " + baseClassPath.toString()); System.err.println("Launcher JAR: " + sourceJar.getAbsolutePath()); System.err.println("Launcher Directory: " + jarDir.getAbsolutePath()); @@ -374,8 +374,8 @@ public class Launcher { * @return a combined array * @throws MalformedURLException if there is a problem. */ - private URL[] getJarArray ( - final URL[] libJars, final URL[] userJars, final URL[] systemJars, final File toolsJar) + private URL[] getJarArray(final URL[] libJars, final URL[] userJars, + final URL[] systemJars, final File toolsJar) throws MalformedURLException { int numJars = libJars.length + userJars.length + systemJars.length; if (toolsJar != null) { @@ -405,7 +405,7 @@ public class Launcher { System.setProperty(name, value); } - private void logPath(final String name,final File path) { + private void logPath(final String name, final File path) { if(launchDiag) { System.out.println(name+"= \""+path+"\""); } diff --git a/src/main/org/apache/tools/ant/launch/Locator.java b/src/main/org/apache/tools/ant/launch/Locator.java index 7ea070ec2..4f5aef494 100644 --- a/src/main/org/apache/tools/ant/launch/Locator.java +++ b/src/main/org/apache/tools/ant/launch/Locator.java @@ -401,8 +401,7 @@ public final class Locator { * @deprecated since 1.9, use FileUtils.getFileURL(File) */ @Deprecated - public static URL fileToURL(File file) - throws MalformedURLException { + public static URL fileToURL(File file) throws MalformedURLException { return new URL(file.toURI().toASCIIString()); } diff --git a/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java b/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java index 86fd6847a..cb4baa12b 100644 --- a/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java +++ b/src/main/org/apache/tools/ant/listener/CommonsLoggingListener.java @@ -103,8 +103,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { /** {@inheritDoc}. */ public void buildStarted(final BuildEvent event) { - final String categoryString = PROJECT_LOG; - final Log log = getLog(categoryString, null); + final Log log = getLog(PROJECT_LOG, null); if (initialized) { realLog(log, "Build started.", Project.MSG_INFO, null); @@ -114,8 +113,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { /** {@inheritDoc}. */ public void buildFinished(final BuildEvent event) { if (initialized) { - final String categoryString = PROJECT_LOG; - final Log log = getLog(categoryString, event.getProject().getName()); + final Log log = getLog(PROJECT_LOG, event.getProject().getName()); if (event.getException() == null) { realLog(log, "Build finished.", Project.MSG_INFO, null); @@ -245,7 +243,7 @@ public class CommonsLoggingListener implements BuildListener, BuildLogger { final Log log = getLog(categoryString, categoryDetail); final int priority = event.getPriority(); final String message = event.getMessage(); - realLog(log, message, priority , null); + realLog(log, message, priority, null); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java index dbf8a225e..78d06890e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java @@ -369,7 +369,7 @@ public class Ant extends Task { log("calling target(s) " + ((locals.size() > 0) ? locals.toString() : "[default]") + " in build file " + antFile, Project.MSG_VERBOSE); - newProject.setUserProperty(MagicNames.ANT_FILE , antFile); + newProject.setUserProperty(MagicNames.ANT_FILE, antFile); String thisAntFile = getProject().getProperty(MagicNames.ANT_FILE); // Are we trying to call the target in which we are defined (or diff --git a/src/main/org/apache/tools/ant/taskdefs/BindTargets.java b/src/main/org/apache/tools/ant/taskdefs/BindTargets.java index 45ad9ae71..3c07e2826 100644 --- a/src/main/org/apache/tools/ant/taskdefs/BindTargets.java +++ b/src/main/org/apache/tools/ant/taskdefs/BindTargets.java @@ -82,9 +82,8 @@ public class BindTargets extends Task { ProjectHelper.PROJECTHELPER_REFERENCE); for (final Iterator itTarget = targets.iterator(); itTarget.hasNext();) { - helper.getExtensionStack().add( - new String[] {extensionPoint, itTarget.next(), - onMissingExtensionPoint.name()}); + helper.getExtensionStack().add(new String[] {extensionPoint, + itTarget.next(), onMissingExtensionPoint.name()}); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/CVSPass.java b/src/main/org/apache/tools/ant/taskdefs/CVSPass.java index af24504b7..e39adef05 100644 --- a/src/main/org/apache/tools/ant/taskdefs/CVSPass.java +++ b/src/main/org/apache/tools/ant/taskdefs/CVSPass.java @@ -114,7 +114,7 @@ public class CVSPass extends Task { String pwdfile = buf.toString() + cvsRoot + " A" + mangle(password); - log("Writing -> " + pwdfile , Project.MSG_DEBUG); + log("Writing -> " + pwdfile, Project.MSG_DEBUG); writer = new BufferedWriter(new FileWriter(passFile)); diff --git a/src/main/org/apache/tools/ant/taskdefs/Checksum.java b/src/main/org/apache/tools/ant/taskdefs/Checksum.java index 7a94ca098..bd95e9366 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Checksum.java +++ b/src/main/org/apache/tools/ant/taskdefs/Checksum.java @@ -490,7 +490,7 @@ public class Checksum extends MatchingTask implements Condition { dis.close(); fis.close(); fis = null; - byte[] fileDigest = messageDigest.digest (); + byte[] fileDigest = messageDigest.digest(); if (totalproperty != null) { allDigests.put(src, fileDigest); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Classloader.java b/src/main/org/apache/tools/ant/taskdefs/Classloader.java index 99d47a15d..57bbf90bf 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Classloader.java +++ b/src/main/org/apache/tools/ant/taskdefs/Classloader.java @@ -229,7 +229,7 @@ public class Classloader extends Task { for (int i = 0; i < list.length; i++) { File f = new File(list[i]); if (f.exists()) { - log("Adding to class loader " + acl + " " + f.getAbsolutePath(), + log("Adding to class loader " + acl + " " + f.getAbsolutePath(), Project.MSG_DEBUG); acl.addPathElement(f.getAbsolutePath()); } diff --git a/src/main/org/apache/tools/ant/taskdefs/Definer.java b/src/main/org/apache/tools/ant/taskdefs/Definer.java index e4e3ea38c..98a22bed3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Definer.java +++ b/src/main/org/apache/tools/ant/taskdefs/Definer.java @@ -121,7 +121,8 @@ public abstract class Definer extends DefBase { * @return an array of the allowed values for this attribute. */ public String[] getValues() { - return new String[] {POLICY_FAIL, POLICY_REPORT, POLICY_IGNORE, POLICY_FAILALL}; + return new String[] {POLICY_FAIL, POLICY_REPORT, POLICY_IGNORE, + POLICY_FAILALL}; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Delete.java b/src/main/org/apache/tools/ant/taskdefs/Delete.java index 3329318e2..b22c7cc91 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Delete.java +++ b/src/main/org/apache/tools/ant/taskdefs/Delete.java @@ -559,8 +559,7 @@ public class Delete extends MatchingTask { } if (quiet && failonerror) { - throw new BuildException("quiet and failonerror cannot both be " - + "set to true", getLocation()); + throw new BuildException("quiet and failonerror cannot both be set to true", getLocation()); } // delete the single file @@ -609,8 +608,7 @@ public class Delete extends MatchingTask { + " which looks like a broken symlink.", quiet ? Project.MSG_VERBOSE : verbosity); if (!delete(dir)) { - handle("Unable to delete directory " - + dir.getAbsolutePath()); + handle("Unable to delete directory " + dir.getAbsolutePath()); } } } @@ -638,13 +636,11 @@ public class Delete extends MatchingTask { fs.setProject(getProject()); } final File fsDir = fs.getDir(); - if (!fs.getErrorOnMissingDir() && - (fsDir == null || !fsDir.exists())) { + if (!fs.getErrorOnMissingDir() && (fsDir == null || !fsDir.exists())) { continue; } if (fsDir == null) { - throw new BuildException( - "File or Resource without directory or file specified"); + throw new BuildException("File or Resource without directory or file specified"); } else if (!fsDir.isDirectory()) { handle("Directory does not exist: " + fsDir); } else { @@ -657,9 +653,11 @@ public class Delete extends MatchingTask { public boolean isFilesystemOnly() { return true; } + public int size() { return files.length; } + public Iterator iterator() { return new FileResourceIterator(getProject(), fsDir, files); @@ -667,8 +665,7 @@ public class Delete extends MatchingTask { }); if (includeEmpty) { filesetDirs.add(new ReverseDirs(getProject(), fsDir, - ds - .getIncludedDirectories())); + ds.getIncludedDirectories())); } if (removeNotFollowedSymlinks) { @@ -706,8 +703,7 @@ public class Delete extends MatchingTask { for (Resource r : resourcesToDelete) { // nonexistent resources could only occur if we already // deleted something from a fileset: - File f = r.as(FileProvider.class) - .getFile(); + File f = r.as(FileProvider.class).getFile(); if (!f.exists()) { continue; } @@ -741,8 +737,7 @@ public class Delete extends MatchingTask { private void handle(Exception e) { if (failonerror) { - throw (e instanceof BuildException) - ? (BuildException) e : new BuildException(e); + throw (e instanceof BuildException) ? (BuildException) e : new BuildException(e); } log(e, quiet ? Project.MSG_VERBOSE : verbosity); } @@ -825,8 +820,7 @@ public class Delete extends MatchingTask { log("Deleting " + currDir.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity); if (!delete(currDir)) { - handle("Unable to delete directory " - + currDir.getAbsolutePath()); + handle("Unable to delete directory " + currDir.getAbsolutePath()); } else { dirCount++; } @@ -834,8 +828,7 @@ public class Delete extends MatchingTask { } if (dirCount > 0) { - log("Deleted " - + dirCount + log("Deleted " + dirCount + " director" + (dirCount == 1 ? "y" : "ies") + " form " + d.getAbsolutePath(), quiet ? Project.MSG_VERBOSE : verbosity); diff --git a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java index 40939e42f..5524c0d2b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/EchoXML.java +++ b/src/main/org/apache/tools/ant/taskdefs/EchoXML.java @@ -108,7 +108,8 @@ public class EchoXML extends XMLFragment { public static final NamespacePolicy DEFAULT = new NamespacePolicy(IGNORE); - public NamespacePolicy() {} + public NamespacePolicy() { + } public NamespacePolicy(String s) { setValue(s); diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java index b36f2fe66..2f65308d2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java @@ -318,7 +318,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { exe.setVMLauncher(true); File vmsJavaOptionFile = null; try { - String [] args = new String[command.length - 1]; + String[] args = new String[command.length - 1]; System.arraycopy(command, 1, args, 0, command.length - 1); vmsJavaOptionFile = JavaEnvUtils.createVmsJavaOptionFile(args); //we mark the file to be deleted on exit. @@ -326,7 +326,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver { //after execution finished, which is much better for long-lived runtimes //though spawning complicates things... vmsJavaOptionFile.deleteOnExit(); - String [] vmsCmd = {command[0], "-V", vmsJavaOptionFile.getPath()}; + String[] vmsCmd = {command[0], "-V", vmsJavaOptionFile.getPath()}; exe.setCommandline(vmsCmd); } catch (IOException e) { throw new BuildException("Failed to create a temporary file for \"-V\" switch"); diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java index 18cbd29de..39cc03aed 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteOn.java @@ -328,8 +328,7 @@ public class ExecuteOn extends ExecTask { */ protected ExecuteStreamHandler createHandler() throws BuildException { //if we have a RedirectorElement, return a decoy - return (redirectorElement == null) - ? super.createHandler() : new PumpStreamHandler(); + return (redirectorElement == null) ? super.createHandler() : new PumpStreamHandler(); } /** @@ -394,8 +393,7 @@ public class ExecuteOn extends ExecTask { fileNames.copyInto(s); for (int j = 0; j < s.length; j++) { String[] command = getCommandline(s[j], base); - log(Commandline.describeCommand(command), - Project.MSG_VERBOSE); + log(Commandline.describeCommand(command), Project.MSG_VERBOSE); exe.setCommandline(command); if (redirectorElement != null) { @@ -438,11 +436,9 @@ public class ExecuteOn extends ExecTask { continue; } - if ((!res.isDirectory() || !res.isExists()) - && !FileDirBoth.DIR.equals(type)) { + if ((!res.isDirectory() || !res.isExists()) && !FileDirBoth.DIR.equals(type)) { totalFiles++; - } else if (res.isDirectory() - && !FileDirBoth.FILE.equals(type)) { + } else if (res.isDirectory() && !FileDirBoth.FILE.equals(type)) { totalDirs++; } else { continue; @@ -453,8 +449,7 @@ public class ExecuteOn extends ExecTask { if (!parallel) { String[] command = getCommandline(name, base); - log(Commandline.describeCommand(command), - Project.MSG_VERBOSE); + log(Commandline.describeCommand(command), Project.MSG_VERBOSE); exe.setCommandline(command); if (redirectorElement != null) { @@ -479,10 +474,8 @@ public class ExecuteOn extends ExecTask { haveExecuted = true; } if (haveExecuted) { - log("Applied " + cmdl.getExecutable() + " to " - + totalFiles + " file" - + (totalFiles != 1 ? "s" : "") + " and " - + totalDirs + " director" + log("Applied " + cmdl.getExecutable() + " to " + totalFiles + " file" + + (totalFiles != 1 ? "s" : "") + " and " + totalDirs + " director" + (totalDirs != 1 ? "ies" : "y") + ".", verbose ? Project.MSG_INFO : Project.MSG_VERBOSE); } @@ -504,11 +497,8 @@ public class ExecuteOn extends ExecTask { */ private void logSkippingFileset( String currentType, DirectoryScanner ds, File base) { - int includedCount - = ((!FileDirBoth.DIR.equals(currentType)) - ? ds.getIncludedFilesCount() : 0) - + ((!FileDirBoth.FILE.equals(currentType)) - ? ds.getIncludedDirsCount() : 0); + int includedCount = (!FileDirBoth.DIR.equals(currentType) ? ds.getIncludedFilesCount() : 0) + + (!FileDirBoth.FILE.equals(currentType) ? ds.getIncludedDirsCount() : 0); log("Skipping fileset for directory " + base + ". It is " + ((includedCount > 0) ? "up to date." : "empty."), @@ -624,9 +614,8 @@ public class ExecuteOn extends ExecTask { if (forwardSlash && fileSeparator != '/') { src = src.replace(fileSeparator, '/'); } - if (srcFilePos != null && - (srcFilePos.getPrefix().length() > 0 - || srcFilePos.getSuffix().length() > 0)) { + if (srcFilePos != null && (srcFilePos.getPrefix().length() > 0 + || srcFilePos.getSuffix().length() > 0)) { src = srcFilePos.getPrefix() + src + srcFilePos.getSuffix(); } result[srcIndex + i] = src; @@ -702,8 +691,7 @@ public class ExecuteOn extends ExecTask { File[] b = new File[baseDirs.size()]; baseDirs.copyInto(b); - if (maxParallel <= 0 - || s.length == 0 /* this is skipEmpty == false */) { + if (maxParallel <= 0 || s.length == 0 /* this is skipEmpty == false */) { String[] command = getCommandline(s, b); log(Commandline.describeCommand(command), Project.MSG_VERBOSE); exe.setCommandline(command); diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java index 236b125d8..867c579bd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java @@ -687,8 +687,8 @@ public class FixCRLF extends MatchingTask implements ChainableReader { * {@inheritDoc}. */ public String[] getValues() { - return new String[] {"asis", "cr", "lf", "crlf", - "mac", "unix", "dos"}; + return new String[] {"asis", "cr", "lf", "crlf", "mac", "unix", + "dos"}; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java index 26a20e4aa..13f610c53 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ b/src/main/org/apache/tools/ant/taskdefs/Get.java @@ -19,7 +19,6 @@ package org.apache.tools.ant.taskdefs; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -349,7 +348,7 @@ public class Get extends Task { * @param v if "true" then be quiet * @since Ant 1.9.4 */ - public void setQuiet(final boolean v){ + public void setQuiet(final boolean v) { this.quiet = v; } @@ -626,8 +625,8 @@ public class Get extends Task { private int redirections = 0; private String userAgent = null; - GetThread(final URL source, final File dest, - final boolean h, final long t, final DownloadProgress p, final int l, final String userAgent) { + GetThread(final URL source, final File dest, final boolean h, + final long t, final DownloadProgress p, final int l, final String userAgent) { this.source = source; this.dest = dest; hasTimestamp = h; @@ -670,34 +669,29 @@ public class Get extends Task { private boolean redirectionAllowed(final URL aSource, final URL aDest) { - if (!(aSource.getProtocol().equals(aDest.getProtocol()) || (HTTP - .equals(aSource.getProtocol()) && HTTPS.equals(aDest - .getProtocol())))) { - final String message = "Redirection detected from " - + aSource.getProtocol() + " to " + aDest.getProtocol() - + ". Protocol switch unsafe, not allowed."; - if (ignoreErrors) { - log(message, logLevel); - return false; - } else { + if (aSource.getProtocol().equals(aDest.getProtocol()) + && (HTTP.equals(aSource.getProtocol()) || HTTPS.equals(aDest.getProtocol()))) { + redirections++; + if (redirections > REDIRECT_LIMIT) { + final String message = "More than " + REDIRECT_LIMIT + + " times redirected, giving up"; + if (ignoreErrors) { + log(message, logLevel); + return false; + } throw new BuildException(message); } + return true; } - redirections++; - if (redirections > REDIRECT_LIMIT) { - final String message = "More than " + REDIRECT_LIMIT - + " times redirected, giving up"; - if (ignoreErrors) { - log(message, logLevel); - return false; - } else { - throw new BuildException(message); - } + final String message = "Redirection detected from " + + aSource.getProtocol() + " to " + aDest.getProtocol() + + ". Protocol switch unsafe, not allowed."; + if (ignoreErrors) { + log(message, logLevel); + return false; } - - - return true; + throw new BuildException(message); } private URLConnection openConnection(final URL aSource) throws IOException { @@ -721,8 +715,7 @@ public class Get extends Task { // testing final Base64Converter encoder = new Base64Converter(); encoding = encoder.encode(up.getBytes()); - connection.setRequestProperty("Authorization", "Basic " - + encoding); + connection.setRequestProperty("Authorization", "Basic " + encoding); } if (tryGzipEncoding) { @@ -730,10 +723,8 @@ public class Get extends Task { } if (connection instanceof HttpURLConnection) { - ((HttpURLConnection) connection) - .setInstanceFollowRedirects(false); - ((HttpURLConnection) connection) - .setUseCaches(httpUseCaches); + ((HttpURLConnection) connection).setInstanceFollowRedirects(false); + connection.setUseCaches(httpUseCaches); } // connect to the remote site (may take some time) try { @@ -791,14 +782,13 @@ public class Get extends Task { } private boolean isMoved(final int responseCode) { - return responseCode == HttpURLConnection.HTTP_MOVED_PERM || - responseCode == HttpURLConnection.HTTP_MOVED_TEMP || - responseCode == HttpURLConnection.HTTP_SEE_OTHER || - responseCode == HTTP_MOVED_TEMP; + return responseCode == HttpURLConnection.HTTP_MOVED_PERM + || responseCode == HttpURLConnection.HTTP_MOVED_TEMP + || responseCode == HttpURLConnection.HTTP_SEE_OTHER + || responseCode == HTTP_MOVED_TEMP; } - private boolean downloadFile() - throws FileNotFoundException, IOException { + private boolean downloadFile() throws IOException { for (int i = 0; i < numberRetries; i++) { // this three attempt trick is to get round quirks in different // Java implementations. Some of them take a few goes to bind @@ -855,9 +845,7 @@ public class Get extends Task { if (verbose) { final Date t = new Date(remoteTimestamp); log("last modified = " + t.toString() - + ((remoteTimestamp == 0) - ? " - using current time instead" - : ""), logLevel); + + ((remoteTimestamp == 0) ? " - using current time instead" : ""), logLevel); } if (remoteTimestamp != 0) { FILE_UTILS.setFileLastModified(dest, remoteTimestamp); diff --git a/src/main/org/apache/tools/ant/taskdefs/HostInfo.java b/src/main/org/apache/tools/ant/taskdefs/HostInfo.java index 43a121108..139129831 100644 --- a/src/main/org/apache/tools/ant/taskdefs/HostInfo.java +++ b/src/main/org/apache/tools/ant/taskdefs/HostInfo.java @@ -242,7 +242,7 @@ public class HostInfo extends Task { int idx = fqdn.indexOf('.'); if (idx > 0) { setProperty(NAME, fqdn.substring(0, idx)); - setProperty(DOMAIN, fqdn.substring(idx+1)); + setProperty(DOMAIN, fqdn.substring(idx + 1)); } else { setProperty(NAME, fqdn); setProperty(DOMAIN, DEF_DOMAIN); diff --git a/src/main/org/apache/tools/ant/taskdefs/Input.java b/src/main/org/apache/tools/ant/taskdefs/Input.java index ed051318b..2f5eea044 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Input.java +++ b/src/main/org/apache/tools/ant/taskdefs/Input.java @@ -122,11 +122,10 @@ public class Input extends Task { public static class HandlerType extends EnumeratedAttribute { private static final String[] VALUES = {"default", "propertyfile", "greedy", "secure"}; - private static final InputHandler[] HANDLERS - = {new DefaultInputHandler(), - new PropertyFileInputHandler(), - new GreedyInputHandler(), - new SecureInputHandler()}; + private static final InputHandler[] HANDLERS = {new DefaultInputHandler(), + new PropertyFileInputHandler(), + new GreedyInputHandler(), + new SecureInputHandler()}; /** {@inheritDoc} */ @Override @@ -153,7 +152,7 @@ public class Input extends Task { * * @param validargs A comma separated String defining valid input args. */ - public void setValidargs (final String validargs) { + public void setValidargs(final String validargs) { this.validargs = validargs; } @@ -164,7 +163,7 @@ public class Input extends Task { * * @param addproperty Name for the property to be created from input */ - public void setAddproperty (final String addproperty) { + public void setAddproperty(final String addproperty) { this.addproperty = addproperty; } @@ -172,7 +171,7 @@ public class Input extends Task { * Sets the Message which gets displayed to the user during the build run. * @param message The message to be displayed. */ - public void setMessage (final String message) { + public void setMessage(final String message) { this.message = message; messageAttribute = true; } @@ -184,7 +183,7 @@ public class Input extends Task { * @param defaultvalue Default value for the property if no input * is received */ - public void setDefaultvalue (final String defaultvalue) { + public void setDefaultvalue(final String defaultvalue) { this.defaultvalue = defaultvalue; } @@ -210,7 +209,7 @@ public class Input extends Task { * @throws BuildException on error */ @Override - public void execute () throws BuildException { + public void execute() throws BuildException { if (addproperty != null && getProject().getProperty(addproperty) != null) { log("skipping " + getTaskName() + " as property " + addproperty diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java index 791fd0dbd..f31ac6f75 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Jar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java @@ -1180,9 +1180,7 @@ public class Jar extends Zip { if (rcs[i] instanceof FileSet) { resources = grabResources(new FileSet[] {(FileSet) rcs[i]}); } else { - resources = grabNonFileSetResources(new ResourceCollection[] { - rcs[i] - }); + resources = grabNonFileSetResources(new ResourceCollection[] {rcs[i]}); } for (int j = 0; j < resources[0].length; j++) { String name = resources[0][j].getName().replace('\\', '/'); @@ -1227,7 +1225,7 @@ public class Jar extends Zip { * @return the list of values. */ public String[] getValues() { - return new String[]{"fail", "warn", "ignore"}; + return new String[] {"fail", "warn", "ignore"}; } /** * @return The log level according to the strict mode. diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 7ccc5a1ae..0237ab61c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -1671,9 +1671,8 @@ public class Javac extends MatchingTask { throw new BuildException("The modulesourcepath entry must contain at most one module mark"); } final String pathToModule = pattern.substring(0, startIndex); - final String pathInModule = endIndex == pattern.length() ? - null : - pattern.substring(endIndex + 1); //+1 the separator + final String pathInModule = endIndex == pattern.length() + ? null : pattern.substring(endIndex + 1); //+1 the separator findModules(root, pathToModule, pathInModule, collector); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index d5e77fda0..931449f2a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -1334,7 +1334,7 @@ public class Javadoc extends Task { private String scope = "a"; /** Sole constructor. */ - public TagArgument () { + public TagArgument() { //empty } @@ -1344,7 +1344,7 @@ public class Javadoc extends Task { * @param name The name of the tag. * Must not be null or empty. */ - public void setName (final String name) { + public void setName(final String name) { this.name = name; } @@ -1364,7 +1364,7 @@ public class Javadoc extends Task { * elements are specified, or if any unrecognised elements are * specified. */ - public void setScope (String verboseScope) throws BuildException { + public void setScope(String verboseScope) throws BuildException { verboseScope = verboseScope.toLowerCase(Locale.ENGLISH); final boolean[] elements = new boolean[SCOPE_ELEMENTS.length]; @@ -1374,7 +1374,7 @@ public class Javadoc extends Task { // Go through the tokens one at a time, updating the // elements array and issuing warnings where appropriate. - final StringTokenizer tok = new StringTokenizer (verboseScope, ","); + final StringTokenizer tok = new StringTokenizer(verboseScope, ","); while (tok.hasMoreTokens()) { final String next = tok.nextToken().trim(); if (next.equals("all")) { @@ -1430,7 +1430,7 @@ public class Javadoc extends Task { * * @param enabled Whether or not this tag is enabled. */ - public void setEnabled (final boolean enabled) { + public void setEnabled(final boolean enabled) { this.enabled = enabled; } diff --git a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java index 64fbf7cf2..4e331dace 100644 --- a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java +++ b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java @@ -176,18 +176,18 @@ public class KeySubst extends Task { while ((index = origString.indexOf("${", i)) > -1) { key = origString.substring(index + 2, origString.indexOf("}", index + 3)); - finalString.append (origString.substring(i, index)); + finalString.append(origString.substring(i, index)); if (keys.containsKey(key)) { - finalString.append (keys.get(key)); + finalString.append(keys.get(key)); } else { - finalString.append ("${"); - finalString.append (key); - finalString.append ("}"); + finalString.append("${"); + finalString.append(key); + finalString.append("}"); } i = index + 3 + key.length(); } // CheckStyle:MagicNumber ON - finalString.append (origString.substring(i)); + finalString.append(origString.substring(i)); return finalString.toString(); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java index abbc5fd64..0fc1f5bb6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java +++ b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java @@ -170,7 +170,7 @@ public class PathConvert extends Task { */ @Override public String[] getValues() { - return new String[]{"windows", "unix", "netware", "os/2", "tandem"}; + return new String[] {"windows", "unix", "netware", "os/2", "tandem"}; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java index b2474a5f7..6ea6f650e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java @@ -514,7 +514,7 @@ public class Replace extends MatchingTask { Properties props = getProperties(replaceFilterResource); Iterator e = getOrderedIterator(props); while (e.hasNext()) { - String tok = e.next().toString(); + String tok = e.next().toString(); Replacefilter replaceFilter = createReplacefilter(); replaceFilter.setToken(tok); replaceFilter.setValue(props.getProperty(tok)); diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index 2f247c999..e801ac02f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -1109,9 +1109,9 @@ public class SQLExec extends JDBCTask { public int lastDelimiterPosition(StringBuffer buf, String currentLine) { if (strictDelimiterMatching) { if ((delimiterType.equals(DelimiterType.NORMAL) - && StringUtils.endsWith(buf, delimiter)) || - (delimiterType.equals(DelimiterType.ROW) - && currentLine.equals(delimiter))) { + && StringUtils.endsWith(buf, delimiter)) + || (delimiterType.equals(DelimiterType.ROW) + && currentLine.equals(delimiter))) { return buf.length() - delimiter.length(); } // no match @@ -1123,17 +1123,15 @@ public class SQLExec extends JDBCTask { // StringUtils.endsWith int endIndex = delimiter.length() - 1; int bufferIndex = buf.length() - 1; - while (bufferIndex >= 0 - && Character.isWhitespace(buf.charAt(bufferIndex))) { + while (bufferIndex >= 0 && Character.isWhitespace(buf.charAt(bufferIndex))) { --bufferIndex; } if (bufferIndex < endIndex) { return -1; } while (endIndex >= 0) { - if (buf.substring(bufferIndex, bufferIndex + 1) - .toLowerCase(Locale.ENGLISH).charAt(0) - != d.charAt(endIndex)) { + if (buf.substring(bufferIndex, bufferIndex + 1).toLowerCase(Locale.ENGLISH) + .charAt(0) != d.charAt(endIndex)) { return -1; } bufferIndex--; diff --git a/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java b/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java index 59d886b79..676b5fb52 100644 --- a/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java +++ b/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java @@ -143,7 +143,7 @@ public class StreamPumper implements Runnable { } // On completion, drain any available data (which might be the first data available for quick executions) if (finish) { - while((length = is.available()) > 0) { + while ((length = is.available()) > 0) { if (Thread.interrupted()) { break; } diff --git a/src/main/org/apache/tools/ant/taskdefs/Tar.java b/src/main/org/apache/tools/ant/taskdefs/Tar.java index 97547022d..0d319d1ca 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tar.java @@ -987,7 +987,7 @@ public class Tar extends MatchingTask { */ @Override public String[] getValues() { - return new String[] {NONE, GZIP, BZIP2 }; + return new String[] {NONE, GZIP, BZIP2}; } /** diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java index f86ed0300..aee260739 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java +++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java @@ -77,14 +77,14 @@ public class Tstamp extends Task { cts.execute(getProject(), d, getLocation()); } - SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd"); + SimpleDateFormat dstamp = new SimpleDateFormat("yyyyMMdd"); setProperty("DSTAMP", dstamp.format(d)); - SimpleDateFormat tstamp = new SimpleDateFormat ("HHmm"); + SimpleDateFormat tstamp = new SimpleDateFormat("HHmm"); setProperty("TSTAMP", tstamp.format(d)); SimpleDateFormat today - = new SimpleDateFormat ("MMMM d yyyy", Locale.US); + = new SimpleDateFormat("MMMM d yyyy", Locale.US); setProperty("TODAY", today.format(d)); } catch (Exception e) { @@ -189,16 +189,14 @@ public class Tstamp extends Task { if (st.hasMoreElements()) { variant = st.nextToken(); if (st.hasMoreElements()) { - throw new BuildException("bad locale format", - getLocation()); + throw new BuildException("bad locale format", getLocation()); } } } else { country = ""; } } catch (NoSuchElementException e) { - throw new BuildException("bad locale format", e, - getLocation()); + throw new BuildException("bad locale format", e, getLocation()); } } @@ -266,25 +264,20 @@ public class Tstamp extends Task { */ public void execute(Project project, Date date, Location location) { if (propertyName == null) { - throw new BuildException("property attribute must be provided", - location); + throw new BuildException("property attribute must be provided", location); } if (pattern == null) { - throw new BuildException("pattern attribute must be provided", - location); + throw new BuildException("pattern attribute must be provided", location); } SimpleDateFormat sdf; if (language == null) { sdf = new SimpleDateFormat(pattern); } else if (variant == null) { - sdf = new SimpleDateFormat(pattern, - new Locale(language, country)); + sdf = new SimpleDateFormat(pattern, new Locale(language, country)); } else { - sdf = new SimpleDateFormat(pattern, - new Locale(language, country, - variant)); + sdf = new SimpleDateFormat(pattern, new Locale(language, country, variant)); } if (offset != 0) { Calendar calendar = Calendar.getInstance(); diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index 676f6ae9a..83943141f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -1310,10 +1310,10 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { if (p.shouldUse()) { final Object evaluatedParam = evaluateParam(p); if (liaison instanceof XSLTLiaison4) { - ((XSLTLiaison4)liaison).addParam(p.getName(), evaluatedParam); + ((XSLTLiaison4) liaison).addParam(p.getName(), evaluatedParam); } else { if (evaluatedParam == null || evaluatedParam instanceof String) { - liaison.addParam(p.getName(), (String)evaluatedParam); + liaison.addParam(p.getName(), (String) evaluatedParam); } else { log("XSLTLiaison '" + liaison.getClass().getName() + "' supports only String parameters. Converting parameter '" + p.getName() @@ -1398,7 +1398,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { final String fileName = FileUtils.getRelativePath(baseDir, inFile); final File file = new File(fileName); // Give always a slash as file separator, so the stylesheet could be sure about that - // Use '.' so a dir+"/"+name would not result in an absolute path + // Use '.' so a dir + "/" + name would not result in an absolute path liaison.addParam(fileDirParameter, file.getParent() != null ? file.getParent().replace( '\\', '/') : "."); } diff --git a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java index c919d3365..6f64a888e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java +++ b/src/main/org/apache/tools/ant/taskdefs/XmlProperty.java @@ -335,7 +335,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { * either a String if this node resulted in setting an attribute, * or a Path. */ - public Object processNode (Node node, String prefix, Object container) { + public Object processNode(Node node, String prefix, Object container) { // Parse the attribute(s) and text of this node, adding // properties for each. @@ -465,7 +465,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { * Actually add the given property/value to the project * after writing a log message. */ - private void addProperty (String name, String value, String id) { + private void addProperty(String name, String value, String id) { String msg = name + ":" + value; if (id != null) { msg += ("(id=" + id + ")"); @@ -502,7 +502,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { * Otherwise, we return "(nodename)". This is long-standing * (and default) <xmlproperty> behavior. */ - private String getAttributeName (Node attributeNode) { + private String getAttributeName(Node attributeNode) { String attributeName = attributeNode.getNodeName(); if (semanticAttributes) { @@ -523,7 +523,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { /** * Return whether the provided attribute name is recognized or not. */ - private static boolean isSemanticAttribute (String attributeName) { + private static boolean isSemanticAttribute(String attributeName) { for (int i = 0; i < ATTRIBUTES.length; i++) { if (attributeName.equals(ATTRIBUTES[i])) { return true; @@ -544,7 +544,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { * resolved to absolute file names. Also for refid values, look * up the referenced object from the project.

*/ - private String getAttributeValue (Node attributeNode) { + private String getAttributeValue(Node attributeNode) { String nodeValue = attributeNode.getNodeValue().trim(); if (semanticAttributes) { String attributeName = attributeNode.getNodeName(); @@ -673,7 +673,7 @@ public class XmlProperty extends org.apache.tools.ant.Task { /** * @return the file attribute. */ - protected File getFile () { + protected File getFile() { FileProvider fp = src.as(FileProvider.class); return fp != null ? fp.getFile() : null; } @@ -693,42 +693,42 @@ public class XmlProperty extends org.apache.tools.ant.Task { /** * @return the prefix attribute. */ - protected String getPrefix () { + protected String getPrefix() { return this.prefix; } /** * @return the keeproot attribute. */ - protected boolean getKeeproot () { + protected boolean getKeeproot() { return this.keepRoot; } /** * @return the validate attribute. */ - protected boolean getValidate () { + protected boolean getValidate() { return this.validate; } /** * @return the collapse attributes attribute. */ - protected boolean getCollapseAttributes () { + protected boolean getCollapseAttributes() { return this.collapseAttributes; } /** * @return the semantic attributes attribute. */ - protected boolean getSemanticAttributes () { + protected boolean getSemanticAttributes() { return this.semanticAttributes; } /** * @return the root directory attribute. */ - protected File getRootDirectory () { + protected File getRootDirectory() { return this.rootDirectory; } diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index bc965e15a..987afa733 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -103,7 +103,7 @@ public class Zip extends MatchingTask { protected String archiveType = "zip"; // For directories: - private static final long EMPTY_CRC = new CRC32 ().getValue (); + private static final long EMPTY_CRC = new CRC32().getValue(); protected String emptyBehavior = "skip"; private final Vector resources = new Vector(); protected Hashtable addedDirs = new Hashtable(); @@ -783,7 +783,7 @@ public class Zip extends MatchingTask { // temporary file if (doUpdate) { if (!renamedFile.delete()) { - log ("Warning: unable to delete temporary file " + log("Warning: unable to delete temporary file " + renamedFile.getName(), Project.MSG_WARN); } } @@ -1761,7 +1761,7 @@ public class Zip extends MatchingTask { addedDirs.put(vPath, vPath); if (!skipWriting) { - final ZipEntry ze = new ZipEntry (vPath); + final ZipEntry ze = new ZipEntry(vPath); // ZIPs store time with a granularity of 2 seconds, round up final int millisToAdd = roundUp ? ROUNDUP_MILLIS : 0; @@ -1773,10 +1773,10 @@ public class Zip extends MatchingTask { } else { ze.setTime(System.currentTimeMillis() + millisToAdd); } - ze.setSize (0); - ze.setMethod (ZipEntry.STORED); + ze.setSize(0); + ze.setMethod(ZipEntry.STORED); // This is faintly ridiculous: - ze.setCrc (EMPTY_CRC); + ze.setCrc(EMPTY_CRC); ze.setUnixMode(mode); if (extra != null) { diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index 7b291f5e9..1cd5e6233 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -433,8 +433,8 @@ public abstract class DefaultCompilerAdapter cmd.createArgument().setPath(ump); } if (attributes.getNativeHeaderDir() != null) { - if (assumeJava13() || assumeJava14() || assumeJava15() - || assumeJava16() || assumeJava17()) { + if (assumeJava13() || assumeJava14() || assumeJava15() || assumeJava16() + || assumeJava17()) { attributes.log("Support for javac -h has been added in Java8," + " ignoring it"); } else { @@ -485,8 +485,7 @@ public abstract class DefaultCompilerAdapter * @param cmd the command line */ protected void logAndAddFilesToCompile(final Commandline cmd) { - attributes.log("Compilation " + cmd.describeArguments(), - Project.MSG_VERBOSE); + attributes.log("Compilation " + cmd.describeArguments(), Project.MSG_VERBOSE); final StringBuffer niceSourceList = new StringBuffer("File"); if (compileList.length != 1) { @@ -728,10 +727,10 @@ public abstract class DefaultCompilerAdapter return "javac1.9".equals(attributes.getCompilerVersion()) || "javac9".equals(attributes.getCompilerVersion()) || "javac10+".equals(attributes.getCompilerVersion()) - || (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9) && - ("classic".equals(attributes.getCompilerVersion()) - || "modern".equals(attributes.getCompilerVersion()) - || "extJavac".equals(attributes.getCompilerVersion()))); + || (JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9) + && ("classic".equals(attributes.getCompilerVersion()) + || "modern".equals(attributes.getCompilerVersion()) + || "extJavac".equals(attributes.getCompilerVersion()))); } /** @@ -740,8 +739,8 @@ public abstract class DefaultCompilerAdapter */ private boolean assumeJavaXY(final String javacXY, final String javaEnvVersionXY) { return javacXY.equals(attributes.getCompilerVersion()) - || (JavaEnvUtils.isJavaVersion(javaEnvVersionXY) && - ("classic".equals(attributes.getCompilerVersion()) + || (JavaEnvUtils.isJavaVersion(javaEnvVersionXY) + && ("classic".equals(attributes.getCompilerVersion()) || "modern".equals(attributes.getCompilerVersion()) || "extJavac".equals(attributes.getCompilerVersion()))); } @@ -830,8 +829,7 @@ public abstract class DefaultCompilerAdapter t = t.substring(2); } return t.equals("1") || t.equals("2") || t.equals("3") || t.equals("4") - || ((t.equals("5") || t.equals("6")) - && !assumeJava15() && !assumeJava16()) + || ((t.equals("5") || t.equals("6")) && !assumeJava15() && !assumeJava16()) || (t.equals("7") && !assumeJava17()) || (t.equals("8") && !assumeJava18()) || (t.equals("9") && !assumeJava9Plus()); diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java index 3167cc244..a665e475c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java @@ -142,10 +142,9 @@ public class Gcj extends DefaultCompilerAdapter { int argsLength = 0; while (!nativeBuild && argsLength < additionalArguments.length) { int conflictLength = 0; - while (!nativeBuild - && conflictLength < CONFLICT_WITH_DASH_C.length) { - nativeBuild = (additionalArguments[argsLength].startsWith - (CONFLICT_WITH_DASH_C[conflictLength])); + while (!nativeBuild && conflictLength < CONFLICT_WITH_DASH_C.length) { + nativeBuild = additionalArguments[argsLength] + .startsWith(CONFLICT_WITH_DASH_C[conflictLength]); conflictLength++; } argsLength++; @@ -153,8 +152,6 @@ public class Gcj extends DefaultCompilerAdapter { return nativeBuild; } - private static final String [] CONFLICT_WITH_DASH_C = { - "-o" , "--main=", "-D", "-fjni", "-L" - }; + private static final String[] CONFLICT_WITH_DASH_C = {"-o", "--main=", "-D", "-fjni", "-L"}; } diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java index 3fd8ccdda..1bb259590 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac12.java @@ -68,7 +68,7 @@ public class Javac12 extends DefaultCompilerAdapter { new Object[] {cmd.getArguments()}); return ok.booleanValue(); } catch (ClassNotFoundException ex) { - throw new BuildException("Cannot use classic compiler , as it is " + throw new BuildException("Cannot use classic compiler, as it is " + "not available. \n" + " A common solution is " + "to set the environment variable" diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java index acb6a7f06..6ca04c5fc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java +++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Javac13.java @@ -50,7 +50,7 @@ public class Javac13 extends DefaultCompilerAdapter { // Use reflection to be able to build on all JDKs >= 1.1: try { - Class c = Class.forName ("com.sun.tools.javac.Main"); + Class c = Class.forName("com.sun.tools.javac.Main"); Object compiler = c.newInstance (); Method compile = c.getMethod ("compile", new Class [] {(new String [] {}).getClass ()}); diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java index 0958c2df6..c163ad7dc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/Http.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/Http.java @@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs.condition; import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.ProtocolException; import java.net.URL; import java.net.URLConnection; import java.util.Locale; @@ -115,7 +116,7 @@ public class Http extends ProjectComponent implements Condition { } return false; } - } catch (java.net.ProtocolException pe) { + } catch (ProtocolException pe) { throw new BuildException("Invalid HTTP protocol: " + requestMethod, pe); } catch (java.io.IOException e) { diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java b/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java index a8bdbba81..ac054782b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java +++ b/src/main/org/apache/tools/ant/taskdefs/condition/IsLastModified.java @@ -161,7 +161,7 @@ public class IsLastModified extends ProjectComponent implements Condition { long expected = getMillis(); long actual = resource.getLastModified(); log("expected timestamp: " + expected + " (" + new Date(expected) + ")" - + ", actual timestamp: " + actual + " (" + new Date(actual) + ")" , + + ", actual timestamp: " + actual + " (" + new Date(actual) + ")", Project.MSG_VERBOSE); if (CompareMode.EQUALS_TEXT.equals(mode.getValue())) { return expected == actual; diff --git a/src/main/org/apache/tools/ant/taskdefs/email/Message.java b/src/main/org/apache/tools/ant/taskdefs/email/Message.java index c121f5d78..8869ef11a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/email/Message.java +++ b/src/main/org/apache/tools/ant/taskdefs/email/Message.java @@ -165,7 +165,7 @@ public class Message extends ProjectComponent { * @since Ant 1.6 */ public void setCharset(String charset) { - this.charset = charset; + this.charset = charset; } /** * Returns the charset of mail message. @@ -174,7 +174,7 @@ public class Message extends ProjectComponent { * @since Ant 1.6 */ public String getCharset() { - return charset; + return charset; } /** diff --git a/src/main/org/apache/tools/ant/taskdefs/launcher/Java13CommandLauncher.java b/src/main/org/apache/tools/ant/taskdefs/launcher/Java13CommandLauncher.java index e022ade9b..12ec7d9c3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/launcher/Java13CommandLauncher.java +++ b/src/main/org/apache/tools/ant/taskdefs/launcher/Java13CommandLauncher.java @@ -56,9 +56,9 @@ public class Java13CommandLauncher extends CommandLauncher { Project.MSG_DEBUG); } return Runtime.getRuntime().exec(cmd, env, workingDir); - } catch(IOException ioex) { + } catch (IOException ioex) { throw ioex; - } catch(Exception exc) { + } catch (Exception exc) { // IllegalAccess, IllegalArgument, ClassCast throw new BuildException("Unable to execute command", exc); } diff --git a/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java b/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java index 4c1b3f090..b7c914c8c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java +++ b/src/main/org/apache/tools/ant/taskdefs/launcher/VmsCommandLauncher.java @@ -80,9 +80,7 @@ public class VmsCommandLauncher extends Java13CommandLauncher { public Process exec(Project project, String[] cmd, String[] env, File workingDir) throws IOException { File cmdFile = createCommandFile(cmd, env); - Process p = super.exec(project, new String[] { - cmdFile.getPath() - }, env, workingDir); + Process p = super.exec(project, new String[] {cmdFile.getPath()}, env, workingDir); deleteAfter(cmdFile, p); return p; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java index 11c091a8b..7e71aedbc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java @@ -264,8 +264,7 @@ public class Cab extends MatchingTask { try { Process p = Execute.launch(getProject(), new String[] {"listcab"}, null, - baseDir != null ? baseDir - : getProject().getBaseDir(), + baseDir != null ? baseDir : getProject().getBaseDir(), true); OutputStream out = p.getOutputStream(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java index 141ed17ff..8a0a9e18e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/EchoProperties.java @@ -243,7 +243,7 @@ public class EchoProperties extends Task { * The values are "xml" and "text". */ public static class FormatAttribute extends EnumeratedAttribute { - private String [] formats = new String[]{"xml", "text"}; + private String[] formats = new String[] {"xml", "text"}; /** * @see EnumeratedAttribute#getValues() diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java b/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java index bf2d679a1..e9753df75 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java @@ -467,11 +467,9 @@ public class Javah extends Task { classpath = classpath.concatSystemClasspath("ignore"); } - JavahAdapter ad = - nestedAdapter != null ? nestedAdapter : - JavahAdapterFactory.getAdapter(facade.getImplementation(), - this, - createImplementationClasspath()); + JavahAdapter ad = nestedAdapter != null ? nestedAdapter + : JavahAdapterFactory.getAdapter(facade.getImplementation(), this, + createImplementationClasspath()); if (!ad.compile(this)) { throw new BuildException("compilation failed"); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java b/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java index 2221e3985..664e574f0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Native2Ascii.java @@ -294,11 +294,9 @@ public class Native2Ascii extends MatchingTask { } log("converting " + srcName, Project.MSG_VERBOSE); - Native2AsciiAdapter ad = - nestedAdapter != null ? nestedAdapter : - Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(), - this, - createImplementationClasspath()); + Native2AsciiAdapter ad = nestedAdapter != null ? nestedAdapter + : Native2AsciiAdapterFactory.getAdapter(facade.getImplementation(), this, + createImplementationClasspath()); if (!ad.convert(this, srcFile, destFile)) { throw new BuildException("conversion failed"); } @@ -324,8 +322,7 @@ public class Native2Ascii extends MatchingTask { public String[] mapFileName(String fileName) { int lastDot = fileName.lastIndexOf('.'); if (lastDot >= 0) { - return new String[] {fileName.substring(0, lastDot) - + extension}; + return new String[] {fileName.substring(0, lastDot) + extension}; } else { return new String[] {fileName + extension}; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java index 3f85ed749..a8aec7b6b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java @@ -1023,7 +1023,7 @@ public class NetRexxC extends MatchingTask { public static class TraceAttr extends EnumeratedAttribute { /** {@inheritDoc}. */ public String[] getValues() { - return new String[]{"trace", "trace1", "trace2", "notrace"}; + return new String[] {"trace", "trace1", "trace2", "notrace"}; } } @@ -1033,9 +1033,8 @@ public class NetRexxC extends MatchingTask { public static class VerboseAttr extends EnumeratedAttribute { /** {@inheritDoc}. */ public String[] getValues() { - return new String[]{"verbose", "verbose0", "verbose1", - "verbose2", "verbose3", "verbose4", - "verbose5", "noverbose"}; + return new String[] {"verbose", "verbose0", "verbose1", "verbose2", + "verbose3", "verbose4", "verbose5", "noverbose"}; } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java index f9f317c01..71f2841e4 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/PropertyFile.java @@ -298,14 +298,14 @@ public class PropertyFile extends Task { private static final String DEFAULT_DATE_VALUE = "now"; private static final String DEFAULT_STRING_VALUE = ""; - private String key = null; - private int type = Type.STRING_TYPE; - private int operation = Operation.EQUALS_OPER; - private String value = null; - private String defaultValue = null; - private String newValue = null; - private String pattern = null; - private int field = Calendar.DATE; + private String key = null; + private int type = Type.STRING_TYPE; + private int operation = Operation.EQUALS_OPER; + private String value = null; + private String defaultValue = null; + private String newValue = null; + private String pattern = null; + private int field = Calendar.DATE; /** * Name of the property name/value pair @@ -404,8 +404,7 @@ public class PropertyFile extends Task { } else if (type == Type.STRING_TYPE) { executeString(oldValue); } else { - throw new BuildException("Unknown operation type: " - + type); + throw new BuildException("Unknown operation type: " + type); } } catch (NullPointerException npe) { // Default to string type @@ -615,13 +614,13 @@ public class PropertyFile extends Task { // Property type operations /** + */ - public static final int INCREMENT_OPER = 0; + public static final int INCREMENT_OPER = 0; /** - */ - public static final int DECREMENT_OPER = 1; + public static final int DECREMENT_OPER = 1; /** = */ - public static final int EQUALS_OPER = 2; + public static final int EQUALS_OPER = 2; /** del */ - public static final int DELETE_OPER = 3; + public static final int DELETE_OPER = 3; /** {@inheritDoc}. */ @Override @@ -653,11 +652,11 @@ public class PropertyFile extends Task { // Property types /** int */ - public static final int INTEGER_TYPE = 0; + public static final int INTEGER_TYPE = 0; /** date */ - public static final int DATE_TYPE = 1; + public static final int DATE_TYPE = 1; /** string */ - public static final int STRING_TYPE = 2; + public static final int STRING_TYPE = 2; /** {@inheritDoc} */ @Override @@ -697,9 +696,8 @@ public class PropertyFile extends Task { private static final String MONTH = "month"; private static final String YEAR = "year"; - private static final String[] UNITS - = {MILLISECOND, SECOND, MINUTE, HOUR, - DAY, WEEK, MONTH, YEAR }; + private static final String[] UNITS = {MILLISECOND, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, + YEAR}; private Map calendarFields = new HashMap(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java b/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java index d58238b57..a816f6e50 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Rpm.java @@ -114,9 +114,8 @@ public class Rpm extends Task { Commandline toExecute = new Commandline(); - toExecute.setExecutable(rpmBuildCommand == null - ? guessRpmBuildCommand() - : rpmBuildCommand); + toExecute.setExecutable(rpmBuildCommand == null ? guessRpmBuildCommand() + : rpmBuildCommand); if (topDir != null) { toExecute.createArgument().setValue("--define"); toExecute.createArgument().setValue("_topdir " + topDir); @@ -169,7 +168,7 @@ public class Rpm extends Task { fos = new FileOutputStream(error); BufferedOutputStream bos = new BufferedOutputStream(fos); errorstream = new PrintStream(bos); - } catch (IOException e) { + } catch (IOException e) { FileUtils.close(fos); throw new BuildException(e, getLocation()); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java index 4eefaebfe..99694f6fd 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandDeploymentTool.java @@ -253,12 +253,11 @@ public class BorlandDeploymentTool extends GenericDeploymentTool File borlandDD = new File(getConfig().descriptorDir, ddPrefix + dd); if (borlandDD.exists()) { log("Borland specific file found " + borlandDD, Project.MSG_VERBOSE); - ejbFiles.put(META_DIR + dd , borlandDD); + ejbFiles.put(META_DIR + dd, borlandDD); } else { log("Unable to locate borland deployment descriptor. " + "It was expected to be in " + borlandDD.getPath(), Project.MSG_WARN); - return; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java index ac2aa7224..9ae0e6707 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java @@ -29,6 +29,7 @@ import java.util.Hashtable; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.xml.sax.AttributeList; +import org.xml.sax.HandlerBase; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -40,7 +41,7 @@ import org.xml.sax.SAXException; * inserted into an EJB jar as to a File representing the file on disk. This * list can then be accessed through the getFiles() method. */ -public class DescriptorHandler extends org.xml.sax.HandlerBase { +public class DescriptorHandler extends HandlerBase { private static final int DEFAULT_HASH_TABLE_SIZE = 10; private static final int STATE_LOOKING_EJBJAR = 1; private static final int STATE_IN_EJBJAR = 2; @@ -220,7 +221,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { } } - owningTask.log("Could not resolve ( publicId: " + publicId + owningTask.log("Could not resolve (publicId: " + publicId + ", systemId: " + systemId + ") to a local entity", Project.MSG_INFO); return null; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index 964a455ac..3329a8bc1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -790,7 +790,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { manifest = new Manifest(in); } catch (IOException e) { - throw new BuildException ("Unable to read manifest", e, getLocation()); + throw new BuildException("Unable to read manifest", e, getLocation()); } finally { if (in != null) { in.close(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java index ee5dc854b..9aca1cbd7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java @@ -114,7 +114,7 @@ public class IPlanetEjbcTask extends Task { * @param iasdescriptor The name and location of the iAS-specific EJB * descriptor. */ - public void setIasdescriptor (File iasdescriptor) { + public void setIasdescriptor(File iasdescriptor) { this.iasdescriptor = iasdescriptor; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java index 81fe8059e..d474f8b47 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java @@ -587,7 +587,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool { log("Cannot find GenIC class in classpath.", Project.MSG_ERR); throw new BuildException("GenIC class not found, please check the classpath."); } else { - log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE); + log("Using '" + genicClass + "' GenIC class.", Project.MSG_VERBOSE); genicTask.setClassname(genicClass); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/OrionDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/OrionDeploymentTool.java index 02d646ee0..a73780349 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/OrionDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/OrionDeploymentTool.java @@ -46,7 +46,7 @@ public class OrionDeploymentTool extends GenericDeploymentTool { * @param baseName String */ protected void addVendorFiles(Hashtable ejbFiles, String baseName) { - String ddPrefix = (usingBaseJarName() ? "" : baseName ); + String ddPrefix = usingBaseJarName() ? "" : baseName; File orionDD = new File(getConfig().descriptorDir, ddPrefix + ORION_DD); if (orionDD.exists()) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java b/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java index b3cfddc2f..4befa4f69 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/extension/ExtensionAdapter.java @@ -172,7 +172,7 @@ public class ExtensionAdapter extends DataType { } /** - * Convert this adpater object into an extension object. + * Convert this adapter object into an extension object. * * @return the extension object */ diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java b/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java index 8641a7707..108d2e272 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/image/Image.java @@ -239,7 +239,7 @@ public class Image extends MatchingTask { final String dstName = dstNames[j]; final File dstFile = new File(dstDir, dstName).getAbsoluteFile(); - if (dstFile.exists()){ + if (dstFile.exists()) { // avoid overwriting unless necessary if(!overwrite && srcFile.lastModified() <= dstFile.lastModified()) { @@ -252,7 +252,7 @@ public class Image extends MatchingTask { } // avoid extra work while overwriting - if (!srcFile.equals(dstFile)){ + if (!srcFile.equals(dstFile)) { dstFile.delete(); } } @@ -317,7 +317,7 @@ public class Image extends MatchingTask { + dstParent); } - if ((overwrite && newFile.exists()) && (!newFile.equals(file))) { + if (overwrite && newFile.exists() && !newFile.equals(file)) { newFile.delete(); } @@ -333,7 +333,7 @@ public class Image extends MatchingTask { FileUtils.close(stream); } } catch (IOException err) { - if (!file.equals(newFile)){ + if (!file.equals(newFile)) { newFile.delete(); } if (!failonerror) { @@ -362,7 +362,7 @@ public class Image extends MatchingTask { validateAttributes(); try { - File dest = destDir != null ? destDir : srcDir; + File dest = (destDir != null) ? destDir : srcDir; int writeCount = 0; @@ -392,9 +392,8 @@ public class Image extends MatchingTask { writeCount += processDir(fromDir, files, dest, mapper); } - if (writeCount>0){ - log("Processed " + writeCount + - (writeCount == 1 ? " image." : " images.")); + if (writeCount > 0) { + log("Processed " + writeCount + (writeCount == 1 ? " image." : " images.")); } } catch (Exception err) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java index 7875ef19a..4c7866c62 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java @@ -53,8 +53,8 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements /** * All the valid actions that weblogic.deploy permits * */ - private static final String[] VALID_ACTIONS - = {ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, ACTION_UNDEPLOY, ACTION_UPDATE}; + private static final String[] VALID_ACTIONS = {ACTION_DELETE, ACTION_DEPLOY, ACTION_LIST, + ACTION_UNDEPLOY, ACTION_UPDATE}; /** * Description of the Field diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java index 5157416ee..acccf9f8b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java @@ -320,7 +320,7 @@ public class JDependTask extends Task { * @see EnumeratedAttribute */ public static class FormatAttribute extends EnumeratedAttribute { - private String [] formats = new String[]{"xml", "text"}; + private String[] formats = new String[] {"xml", "text"}; /** * @return the enumerated values diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java index 592f4235c..4cadace35 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java @@ -459,7 +459,7 @@ public class JspC extends MatchingTask { throw new BuildException("srcdir attribute must be set!", getLocation()); } - String [] list = src.list(); + String[] list = src.list(); if (list.length == 0) { throw new BuildException("srcdir attribute must be set!", getLocation()); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java index 850c6bca9..965f41308 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java @@ -67,7 +67,7 @@ public class JspNameMangler implements JspMangler { * map from a jsp file to a base name; does not deal with extensions * * @param jspFile jspFile file - * @return exensionless potentially remapped name + * @return extensionless potentially remapped name */ private String mapJspToBaseName(File jspFile) { String className; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java index 45a427ad5..26808474c 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java @@ -231,7 +231,7 @@ public class WLJspc extends MatchingTask { * Set the directory containing the source jsp's * * - * @param dirName the directory containg the source jsp's + * @param dirName the directory containing the source jsp's */ public void setSrc(File dirName) { @@ -242,7 +242,7 @@ public class WLJspc extends MatchingTask { * Set the directory containing the source jsp's * * - * @param dirName the directory containg the source jsp's + * @param dirName the directory containing the source jsp's */ public void setDest(File dirName) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java index fd7a321eb..2c1b13d7f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java @@ -115,7 +115,7 @@ public class AggregateTransformer { /** * Used to ensure the uniqueness of a property */ - private volatile static int counter = 0; + private static volatile int counter = 0; /** the format to use for the report. Must be FRAMES or NOFRAMES */ protected String format = FRAMES; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java index 85f1309e2..24e6c07c2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java @@ -41,7 +41,8 @@ public abstract class BaseTest { protected String errorProperty; // CheckStyle:VisibilityModifier ON - private Object ifCond, unlessCond; + private Object ifCond; + private Object unlessCond; private boolean skipNonTests; /** diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java index 368c72e2a..e9bd301ea 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/Constants.java @@ -39,8 +39,8 @@ public class Constants { static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents="; static final String TESTSFILE = "testsfile="; static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; - static final String LOG_FAILED_TESTS="logfailedtests="; + static final String LOG_FAILED_TESTS = "logfailedtests="; static final String SKIP_NON_TESTS = "skipNonTests="; /** @since Ant 1.9.4 */ - static final String THREADID="threadid="; + static final String THREADID = "threadid="; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java index 325f44cfb..cb1939ee3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/DOMUtil.java @@ -135,7 +135,7 @@ public final class DOMUtil { * the parent is null or if a child does not match the * given name. */ - public static Element getChildByTagName (Node parent, String tagname) { + public static Element getChildByTagName(Node parent, String tagname) { if (parent == null) { return null; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java index 69e8f0794..e7ffa6756 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FailureRecorder.java @@ -54,8 +54,8 @@ import org.apache.tools.ant.util.StringUtils; * } * public static Test suite() { * TestSuite suite = new TestSuite(); - * suite.addTest( new B("test04") ); - * suite.addTest( new org.D("test10") ); + * suite.addTest(new B("test04")); + * suite.addTest(new org.D("test10")); * return suite; * } * } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/IgnoredTestResult.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/IgnoredTestResult.java index ae82857a1..149715125 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/IgnoredTestResult.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/IgnoredTestResult.java @@ -44,7 +44,7 @@ public class IgnoredTestResult extends TestResult { public synchronized void addListener(TestListener listener) { if (listener instanceof IgnoredTestListener) { - listeners.add((IgnoredTestListener)listener); + listeners.add((IgnoredTestListener) listener); } super.addListener(listener); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 57399fb7b..dcf66c174 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -370,8 +370,7 @@ public class JUnitTask extends Task { */ @Override public String[] getValues() { - return new String[] {"true", "yes", "false", "no", - "on", "off", "withOutAndErr"}; + return new String[] {"true", "yes", "false", "no", "on", "off", "withOutAndErr"}; } /** @@ -821,23 +820,13 @@ public class JUnitTask extends Task { mirrorLoader = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return new SplitClassLoader(myLoader, path, getProject(), - new String[] { - "BriefJUnitResultFormatter", - "JUnit4TestMethodAdapter", - "JUnitResultFormatter", - "JUnitTaskMirrorImpl", - "JUnitTestRunner", - "JUnitVersionHelper", - "OutErrSummaryJUnitResultFormatter", - "PlainJUnitResultFormatter", - "SummaryJUnitResultFormatter", - "TearDownOnVmCrash", - "XMLJUnitResultFormatter", - "IgnoredTestListener", - "IgnoredTestResult", - "CustomJUnit4TestAdapterCache", - "TestListenerWrapper" - }); + new String[] {"BriefJUnitResultFormatter", "JUnit4TestMethodAdapter", + "JUnitResultFormatter", "JUnitTaskMirrorImpl", "JUnitTestRunner", + "JUnitVersionHelper", "OutErrSummaryJUnitResultFormatter", + "PlainJUnitResultFormatter", "SummaryJUnitResultFormatter", + "TearDownOnVmCrash", "XMLJUnitResultFormatter", "IgnoredTestListener", + "IgnoredTestResult", "CustomJUnit4TestAdapterCache", + "TestListenerWrapper"}); } }); } else { @@ -860,9 +849,7 @@ public class JUnitTask extends Task { final List testLists = new ArrayList(); /* parallel test execution is only supported for multi-process execution */ - final int threads = ((!fork) || (forkMode.getValue().equals(ForkMode.ONCE)) - ? 1 - : this.threads); + final int threads = !fork || forkMode.getValue().equals(ForkMode.ONCE) ? 1 : this.threads; final boolean forkPerTest = forkMode.getValue().equals(ForkMode.PER_TEST); if (forkPerTest || forkMode.getValue().equals(ForkMode.ONCE)) { @@ -1002,7 +989,7 @@ public class JUnitTask extends Task { /* create 1 thread using the passthrough class, and let each thread start */ for (i = 0; i < numThreads; i++) { - threads[i] = new Thread(new JunitTestThread(this, iter, i+1)); + threads[i] = new Thread(new JunitTestThread(this, iter, i + 1)); threads[i].start(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java index 694e1d8cb..b95e7dcf5 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskMirror.java @@ -77,7 +77,7 @@ public interface JUnitTaskMirror { /** The interface that JUnitResultFormatter extends. */ - public interface JUnitResultFormatterMirror { + interface JUnitResultFormatterMirror { /** * Set the output stream. * @param outputStream the stream to use. @@ -86,7 +86,7 @@ public interface JUnitTaskMirror { } /** The interface that SummaryJUnitResultFormatter extends. */ - public interface SummaryJUnitResultFormatterMirror + interface SummaryJUnitResultFormatterMirror extends JUnitResultFormatterMirror { /** @@ -97,7 +97,7 @@ public interface JUnitTaskMirror { } /** Interface that test runners implement. */ - public interface JUnitTestRunnerMirror { + interface JUnitTestRunnerMirror { /** * Used in formatter arguments as a placeholder for the basename diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java index 2d16c3583..2eb23163d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java @@ -23,6 +23,7 @@ import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; @@ -99,25 +100,22 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR */ private Permissions perm = null; - private static final String JUNIT_4_TEST_ADAPTER - = "junit.framework.JUnit4TestAdapter"; - - private static final String[] DEFAULT_TRACE_FILTERS = new String[] { - "junit.framework.TestCase", - "junit.framework.TestResult", - "junit.framework.TestSuite", - "junit.framework.Assert.", // don't filter AssertionFailure - "junit.swingui.TestRunner", - "junit.awtui.TestRunner", - "junit.textui.TestRunner", - "java.lang.reflect.Method.invoke(", - "sun.reflect.", - "org.apache.tools.ant.", - // JUnit 4 support: - "org.junit.", - "junit.framework.JUnit4TestAdapter", - " more", - }; + private static final String JUNIT_4_TEST_ADAPTER = "junit.framework.JUnit4TestAdapter"; + + private static final String[] DEFAULT_TRACE_FILTERS = new String[] {"junit.framework.TestCase", + "junit.framework.TestResult", + "junit.framework.TestSuite", + "junit.framework.Assert.", // don't filter AssertionFailure + "junit.swingui.TestRunner", + "junit.awtui.TestRunner", + "junit.textui.TestRunner", + "java.lang.reflect.Method.invoke(", + "sun.reflect.", + "org.apache.tools.ant.", + // JUnit 4 support: + "org.junit.", + "junit.framework.JUnit4TestAdapter", + " more"}; /** @@ -459,12 +457,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR useSingleMethodAdapter = true; } } else { - junit4TestAdapterClass = - Class.forName(JUNIT_4_TEST_ADAPTER, + junit4TestAdapterClass = Class.forName(JUNIT_4_TEST_ADAPTER, true, loader); if (testMethodsSpecified) { - junit4TestAdapterClass = - Class.forName( + junit4TestAdapterClass = Class.forName( "org.apache.tools.ant.taskdefs.optional.junit.JUnit4TestMethodAdapter", true, loader); useSingleMethodAdapter = true; @@ -491,13 +487,13 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR formalParams = new Class[] {Class.class, String[].class}; actualParams = new Object[] {testClass, methods}; } else { - formalParams = new Class[] {Class.class, Class.forName("junit.framework.JUnit4TestAdapterCache")}; - actualParams = new Object[] {testClass, junit4TestAdapterCacheClass.getMethod("getInstance").invoke(null)}; + formalParams = new Class[] {Class.class, Class.forName( + "junit.framework.JUnit4TestAdapterCache")}; + actualParams = new Object[] {testClass, junit4TestAdapterCacheClass + .getMethod("getInstance").invoke(null)}; } - suite = - (Test) junit4TestAdapterClass - .getConstructor(formalParams). - newInstance(actualParams); + suite = (Test) junit4TestAdapterClass.getConstructor(formalParams) + .newInstance(actualParams); } else { // Use JUnit 3. @@ -532,8 +528,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR if (exception != null) { // had an exception constructing suite final int formatterSize = formatters.size(); for (int i = 0; i < formatterSize; i++) { - ((TestListener) formatters.elementAt(i)) - .addError(null, exception); + ((TestListener) formatters.elementAt(i)).addError(null, exception); } junitTest.setCounts(1, 0, 1, 0); junitTest.setRunTime(0); @@ -542,10 +537,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR logTestListenerEvent("tests to run: " + suite.countTestCases()); suite.run(res); } finally { - if (junit4 || - suite.getClass().getName().equals(JUNIT_4_TEST_ADAPTER)) { + if (junit4 || suite.getClass().getName().equals(JUNIT_4_TEST_ADAPTER)) { final int[] cnts = findJUnit4FailureErrorCount(res); - junitTest.setCounts(res.runCount() + res.ignoredCount(), cnts[0], cnts[1], res.ignoredCount() + res.skippedCount()); + junitTest.setCounts(res.runCount() + res.ignoredCount(), cnts[0], cnts[1], + res.ignoredCount() + res.skippedCount()); } else { junitTest.setCounts(res.runCount() + res.ignoredCount(), res.failureCount(), res.errorCount(), res.ignoredCount() + res.skippedCount()); @@ -610,12 +605,12 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR try { suiteAnnotation = Class.forName("org.junit.Suite.SuiteClasses"); - } catch(final ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { // ignore - we don't have this annotation so make sure we don't check for it } try { runWithAnnotation = Class.forName("org.junit.runner.RunWith"); - } catch(final ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { // also ignore as this annotation doesn't exist so tests can't use it } @@ -643,12 +638,13 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR return true; } if (runWithAnnotation != null && testClass.getAnnotation(runWithAnnotation) != null) { - /* Class is marked with @RunWith. If this class is badly written (no test methods, multiple - * constructors, private constructor etc) then the class is automatically run and fails in the - * IDEs I've tried... so I'm happy handing the class to JUnit to try and run, and let JUnit - * report a failure if a bad test case is provided. Trying to do anything else is likely to - * result in us filtering out cases that could be valid for future versions of JUnit so would - * just increase future maintenance work. + /* Class is marked with @RunWith. If this class is badly written (no test methods, + * multiple constructors, private constructor etc) then the class is automatically + * run and fails in the IDEs I've tried... so I'm happy handing the class to JUnit + * to try and run, and let JUnit report a failure if a bad test case is provided. + * Trying to do anything else is likely to result in us filtering out cases that + * could be valid for future versions of JUnit so would just increase future + * maintenance work. */ return true; } @@ -661,7 +657,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR return true; } } else { - // check if JUnit3 class have public or protected no-args methods starting with names starting with test + // check if JUnit3 class have public or protected no-args methods starting with + // names starting with test if (m.getName().startsWith("test") && m.getParameterTypes().length == 0 && (Modifier.isProtected(m.getModifiers()) || Modifier.isPublic(m.getModifiers()))) { return true; @@ -713,6 +710,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR private void logTestListenerEvent(String msg) { if (logTestListenerEvents) { + @SuppressWarnings("resource") final PrintStream out = savedOut != null ? savedOut : System.out; out.flush(); if (msg == null) { @@ -720,8 +718,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR } final StringTokenizer msgLines = new StringTokenizer(msg, "\r\n", false); while (msgLines.hasMoreTokens()) { - out.println(JUnitTask.TESTLISTENER_PREFIX - + msgLines.nextToken()); + out.println(JUnitTask.TESTLISTENER_PREFIX + msgLines.nextToken()); } out.flush(); } @@ -840,16 +837,14 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR private void fireStartTestSuite() { final int size = formatters.size(); for (int i = 0; i < size; i++) { - ((JUnitResultFormatter) formatters.elementAt(i)) - .startTestSuite(junitTest); + ((JUnitResultFormatter) formatters.elementAt(i)).startTestSuite(junitTest); } } private void fireEndTestSuite() { final int size = formatters.size(); for (int i = 0; i < size; i++) { - ((JUnitResultFormatter) formatters.elementAt(i)) - .endTestSuite(junitTest); + ((JUnitResultFormatter) formatters.elementAt(i)).endTestSuite(junitTest); } } @@ -915,7 +910,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR boolean logFailedTests = true; boolean logTestListenerEvents = false; boolean skipNonTests = false; - int antThreadID = 0; /* Ant id of thread running this unit test, 0 in single-threaded mode */ + /* Ant id of thread running this unit test, 0 in single-threaded mode */ + int antThreadID = 0; if (args.length == 0) { System.err.println("required argument TestClassName missing"); @@ -954,7 +950,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR } } else if (args[i].startsWith(Constants.PROPSFILE)) { final FileInputStream in = new FileInputStream(args[i] - .substring(Constants.PROPSFILE.length())); + .substring(Constants.PROPSFILE.length())); props.load(in); in.close(); } else if (args[i].startsWith(Constants.SHOWOUTPUT)) { @@ -986,8 +982,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR int returnCode = SUCCESS; if (multipleTests) { try { - final java.io.BufferedReader reader = - new java.io.BufferedReader(new java.io.FileReader(args[0])); + final BufferedReader reader = new BufferedReader(new FileReader(args[0])); String testCaseName; String[] testMethodNames; int code = 0; @@ -1020,8 +1015,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR errorOccurred = (code == ERRORS); failureOccurred = (code != SUCCESS); if (errorOccurred || failureOccurred) { - if ((errorOccurred && haltError) - || (failureOccurred && haltFail)) { + if ((errorOccurred && haltError) || (failureOccurred && haltFail)) { registerNonCrash(); System.exit(code); } else { @@ -1029,8 +1023,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR returnCode = code; } if (logFailedTests) { - System.out.println("TEST " + t.getName() - + " FAILED"); + System.out.println("TEST " + t.getName() + " FAILED"); } } } @@ -1043,9 +1036,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR t.setThread(antThreadID); t.setProperties(props); t.setSkipNonTests(skipNonTests); - returnCode = launch( - t, methods, haltError, stackfilter, haltFail, - showOut, outputToFormat, logTestListenerEvents); + returnCode = launch(t, methods, haltError, stackfilter, haltFail, showOut, + outputToFormat, logTestListenerEvents); } registerNonCrash(); @@ -1090,9 +1082,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR for (int i = 0; i < size; i++) { final FormatterElement fe = (FormatterElement) fromCmdLine.elementAt(i); if (multipleTests && fe.getUseFile()) { - final File destFile = - new File(test.getTodir(), - test.getOutfile() + fe.getExtension()); + final File destFile = new File(test.getTodir(), + test.getOutfile() + fe.getExtension()); fe.setOutfile(destFile); } runner.addFormatter((JUnitResultFormatter) fe.createFormatter()); @@ -1119,9 +1110,8 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR } else { final int fName = line.indexOf(IGNORED_FILE_NAME); if (fName > -1) { - fe.setExtension(line - .substring(fName - + IGNORED_FILE_NAME.length())); + fe.setExtension(line.substring(fName + + IGNORED_FILE_NAME.length())); } } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrash.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrash.java index e381a70c3..7bf881628 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrash.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrash.java @@ -45,8 +45,7 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { */ public void startTestSuite(final JUnitTest suite) { suiteName = suite.getName(); - if (suiteName != null && - suiteName.endsWith(JUnitTask.NAME_OF_DUMMY_TEST)) { + if (suiteName != null && suiteName.endsWith(JUnitTask.NAME_OF_DUMMY_TEST)) { // no way to know which class caused the timeout suiteName = null; } @@ -58,28 +57,35 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { * error generated by Ant. */ public void addError(final Test fakeTest, final Throwable t) { - if (suiteName != null - && fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) { + if (suiteName != null && fakeTest instanceof JUnitTaskMirrorImpl.VmExitErrorTest) { tearDown(); } } // no need to implement the rest - public void addFailure(Test test, Throwable t) {} + public void addFailure(Test test, Throwable t) { + } - public void addFailure(Test test, AssertionFailedError t) {} + public void addFailure(Test test, AssertionFailedError t) { + } - public void startTest(Test test) {} + public void startTest(Test test) { + } - public void endTest(Test test) {} + public void endTest(Test test) { + } - public void endTestSuite(JUnitTest suite) {} + public void endTestSuite(JUnitTest suite) { + } - public void setOutput(OutputStream out) {} + public void setOutput(OutputStream out) { + } - public void setSystemOutput(String out) {} + public void setSystemOutput(String out) { + } - public void setSystemError(String err) {} + public void setSystemError(String err) { + } private void tearDown() { try { @@ -96,8 +102,7 @@ public class TearDownOnVmCrash implements JUnitResultFormatter { } if (testClass == null && getClass().getClassLoader() != null) { try { - testClass = - getClass().getClassLoader().loadClass(suiteName); + testClass = getClass().getClassLoader().loadClass(suiteName); } catch (ClassNotFoundException cnfe) { // ignore } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java index 80cb68109..13b418de3 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java @@ -447,33 +447,27 @@ public class FTP extends Task implements FTPTaskConfig { } if (isOK) { currentelement = path.replace(remoteFileSep.charAt(0), File.separatorChar); - if (!isFollowSymlinks() - && traversesSymlinks) { + if (!isFollowSymlinks() && traversesSymlinks) { continue; } if (myfile.isDirectory()) { - if (isIncluded(currentelement) - && currentelement.length() > 0) { + if (isIncluded(currentelement) && currentelement.length() > 0) { accountForIncludedDir(currentelement, myfile, true); } else { if (currentelement.length() > 0) { - if (currentelement.charAt(currentelement - .length() - 1) + if (currentelement.charAt(currentelement.length() - 1) != File.separatorChar) { - currentelement = - currentelement + File.separatorChar; + currentelement = currentelement + File.separatorChar; } } scandir(myfile.getAbsolutePath(), currentelement, true); } } else { - if (isCaseSensitive - && originalpattern.equals(currentelement)) { + if (isCaseSensitive && originalpattern.equals(currentelement)) { accountForIncludedFile(currentelement); } else if (!isCaseSensitive - && originalpattern - .equalsIgnoreCase(currentelement)) { + && originalpattern.equalsIgnoreCase(currentelement)) { accountForIncludedFile(currentelement); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java index 5efcb3f79..74ef819d0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java @@ -337,7 +337,7 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { try { path = myfile.getRelativePath(); traversesSymlinks = myfile.isTraverseSymlinks(); - } catch (IOException be) { + } catch (IOException be) { throw new BuildException(be, task.getLocation()); } catch (BuildException be) { isOK = false; @@ -1177,8 +1177,8 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { for (int i = 0; i < dsfiles.length; i++) { final String dsfile = dsfiles[i]; executeRetryable(h, new Retryable() { - public void execute() throws IOException { - switch (task.getAction()) { + public void execute() throws IOException { + switch (task.getAction()) { case FTPTask.SEND_FILES: sendFile(ftp, fdir, dsfile); break; @@ -1199,9 +1199,9 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { default: throw new BuildException("unknown ftp action " + task.getAction()); - } } - }, dsfile); + } + }, dsfile); } } } finally { @@ -1443,20 +1443,20 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { + task.getGranularityMillis(); StringBuffer msg; - synchronized(TIMESTAMP_LOGGING_SDF) { + synchronized (TIMESTAMP_LOGGING_SDF) { msg = new StringBuffer(" [") .append(TIMESTAMP_LOGGING_SDF.format(new Date(localTimestamp))) .append("] local"); } task.log(msg.toString(), Project.MSG_VERBOSE); - synchronized(TIMESTAMP_LOGGING_SDF) { + synchronized (TIMESTAMP_LOGGING_SDF) { msg = new StringBuffer(" [") .append(TIMESTAMP_LOGGING_SDF.format(new Date(adjustedRemoteTimestamp))) .append("] remote"); } if (remoteTimestamp != adjustedRemoteTimestamp) { - synchronized(TIMESTAMP_LOGGING_SDF) { + synchronized (TIMESTAMP_LOGGING_SDF) { msg.append(" - (raw: ") .append(TIMESTAMP_LOGGING_SDF.format(new Date(remoteTimestamp))) .append(")"); @@ -1936,4 +1936,3 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror { } } } - diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java index 98f51ca0a..6956019af 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/pvcs/Pvcs.java @@ -202,10 +202,8 @@ public class Pvcs extends org.apache.tools.ant.Task { tmp2 = new File("pvcs_ant_" + rand.nextLong() + ".log"); log(commandLine.describeCommand(), Project.MSG_VERBOSE); try { - result = runCmd(commandLine, - new PumpStreamHandler(fos, - new LogOutputStream(this, - Project.MSG_WARN))); + result = runCmd(commandLine, new PumpStreamHandler(fos, + new LogOutputStream(this, Project.MSG_WARN))); } finally { FileUtils.close(fos); } @@ -250,8 +248,7 @@ public class Pvcs extends org.apache.tools.ant.Task { commandLine.createArgument().setValue("-v" + getLabel()); } else { if (getRevision() != null) { - commandLine.createArgument().setValue("-r" - + getRevision()); + commandLine.createArgument().setValue("-r" + getRevision()); } } } @@ -304,10 +301,10 @@ public class Pvcs extends org.apache.tools.ant.Task { String line = in.readLine(); while (line != null) { log("Considering \"" + line + "\"", Project.MSG_VERBOSE); - if (line.startsWith("\"\\") // Checking for "\ - || line.startsWith("\"/") // or "/ - // or "X:\... - || (line.length() > POS_3 && line.startsWith("\"") + if (line.startsWith("\"\\") // Checking for "\ + || line.startsWith("\"/") // or "/ + // or "X:\... + || (line.length() > POS_3 && line.startsWith("\"") && Character.isLetter(line.charAt(POS_1)) && String.valueOf(line.charAt(POS_2)).equals(":") && String.valueOf(line.charAt(POS_3)).equals("\\"))) { diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java index b5088a7d5..db857fc1a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Directory.java @@ -48,7 +48,7 @@ public class Directory { * @param directory a directory * @param parent a parent Directory */ - public Directory(File directory , Directory parent) { + public Directory(File directory, Directory parent) { this.parent = parent; this.childDirectories = new LinkedHashSet(); this.files = new ArrayList(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java index 26d7e1499..4e04a461e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/Scp.java @@ -428,8 +428,7 @@ public class Scp extends SSHBase { // password. (so if the path contains an @ and a : it will not work) int indexOfCurrentAt = indexOfAt; final int indexOfLastColon = uri.lastIndexOf(':'); - while (indexOfCurrentAt > -1 && indexOfCurrentAt < indexOfLastColon) - { + while (indexOfCurrentAt > -1 && indexOfCurrentAt < indexOfLastColon) { indexOfAt = indexOfCurrentAt; indexOfCurrentAt = uri.indexOf('@', indexOfCurrentAt + 1); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java index b6b9b01b7..bce3f78a9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpFromMessage.java @@ -42,7 +42,7 @@ public class ScpFromMessage extends AbstractSshMessage { private static final int HUNDRED_KILOBYTES = 102400; private static final byte LINE_FEED = 0x0a; - private static final int BUFFER_SIZE = 100*1024; + private static final int BUFFER_SIZE = 100 * 1024; private String remoteFile; private File localFile; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java index b095c40c9..650804f7b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ssh/ScpToMessage.java @@ -36,7 +36,7 @@ import com.jcraft.jsch.Session; public class ScpToMessage extends AbstractSshMessage { private static final int HUNDRED_KILOBYTES = 102400; - private static final int BUFFER_SIZE = 100*1024; + private static final int BUFFER_SIZE = 100 * 1024; private static final int DEFAULT_DIR_MODE = 0755; private static final int DEFAULT_FILE_MODE = 0644; diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java index 16f10158b..26c3c8dac 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSCREATE.java @@ -76,7 +76,7 @@ public class MSVSSCREATE extends MSVSS { * * @param quiet The boolean value for quiet. */ - public final void setQuiet (boolean quiet) { + public final void setQuiet(boolean quiet) { super.setInternalQuiet(quiet); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java index 59ee27298..afecf9538 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/vss/MSVSSGET.java @@ -93,7 +93,7 @@ public class MSVSSGET extends MSVSS { * * @param quiet The boolean value for quiet. */ - public final void setQuiet (boolean quiet) { + public final void setQuiet(boolean quiet) { super.setInternalQuiet(quiet); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java b/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java index e02919141..5c0b96ab6 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/windows/Attrib.java @@ -176,8 +176,8 @@ public class Attrib extends ExecuteOn { * @return true if the os is valid. */ protected boolean isValidOs() { - return getOs() == null && getOsFamily() == null ? - Os.isFamily(Os.FAMILY_WINDOWS) : super.isValidOs(); + return getOs() == null && getOsFamily() == null + ? Os.isFamily(Os.FAMILY_WINDOWS) : super.isValidOs(); } private static String getSignString(boolean attr) { diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java index 559c76985..81e043ee9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/XNewRmic.java @@ -45,8 +45,7 @@ public class XNewRmic extends ForkingSunRmic { String[] options = new String[] { "-Xnew" }; - Commandline commandline = super.setupRmicCommand(options); - return commandline; + return super.setupRmicCommand(options); } } diff --git a/src/main/org/apache/tools/ant/types/Commandline.java b/src/main/org/apache/tools/ant/types/Commandline.java index 8b201cf9d..c8f4eaf31 100644 --- a/src/main/org/apache/tools/ant/types/Commandline.java +++ b/src/main/org/apache/tools/ant/types/Commandline.java @@ -188,7 +188,7 @@ public class Commandline implements Cloneable { */ public String[] getParts() { if (parts == null || parts.length == 0 - || (prefix.length() == 0 && suffix.length() == 0)) { + || (prefix.length() == 0 && suffix.length() == 0)) { return parts; } String[] fullParts = new String[parts.length]; diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index f5886295d..e6f82cf9a 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -385,15 +385,12 @@ public class CommandlineJava implements Cloneable { javaCommand.setExecutable(module, false); break; case CLASS: - javaCommand.setExecutable(createModuleClassPair( - module, + javaCommand.setExecutable(createModuleClassPair(module, javaCommand.getExecutable()), false); break; case MODULE: - javaCommand.setExecutable(createModuleClassPair( - module, - parseClassFromModuleClassPair(javaCommand.getExecutable())), - false); + javaCommand.setExecutable(createModuleClassPair(module, + parseClassFromModuleClassPair(javaCommand.getExecutable())), false); break; } } @@ -500,8 +497,7 @@ public class CommandlineJava implements Cloneable { if (isCloneVm()) { SysProperties clonedSysProperties = new SysProperties(); PropertySet ps = new PropertySet(); - PropertySet.BuiltinPropertySetName sys = - new PropertySet.BuiltinPropertySetName(); + PropertySet.BuiltinPropertySetName sys = new PropertySet.BuiltinPropertySetName(); sys.setValue("system"); ps.appendBuiltin(sys); clonedSysProperties.addSyspropertyset(ps); @@ -515,20 +511,17 @@ public class CommandlineJava implements Cloneable { //main classpath if (haveClasspath()) { listIterator.add("-classpath"); - listIterator.add( - classpath.concatSystemClasspath("ignore").toString()); + listIterator.add(classpath.concatSystemClasspath("ignore").toString()); } //module path if (haveModulepath()) { listIterator.add("--module-path"); - listIterator.add( - modulepath.concatSystemClasspath("ignore").toString()); + listIterator.add(modulepath.concatSystemClasspath("ignore").toString()); } //upgrade module path if (haveUpgrademodulepath()) { listIterator.add("--upgrade-module-path"); - listIterator.add( - upgrademodulepath.concatSystemClasspath("ignore").toString()); + listIterator.add(upgrademodulepath.concatSystemClasspath("ignore").toString()); } //now any assertions are added if (getAssertions() != null) { @@ -762,10 +755,8 @@ public class CommandlineJava implements Cloneable { * @since Ant 1.6 */ public boolean haveClasspath() { - Path fullClasspath = classpath != null - ? classpath.concatSystemClasspath("ignore") : null; - return fullClasspath != null - && fullClasspath.toString().trim().length() > 0; + Path fullClasspath = classpath != null ? classpath.concatSystemClasspath("ignore") : null; + return fullClasspath != null && fullClasspath.toString().trim().length() > 0; } /** @@ -789,7 +780,7 @@ public class CommandlineJava implements Cloneable { */ public boolean haveModulepath() { Path fullClasspath = modulepath != null - ? modulepath.concatSystemClasspath("ignore") : null; + ? modulepath.concatSystemClasspath("ignore") : null; return fullClasspath != null && fullClasspath.toString().trim().length() > 0; } @@ -802,8 +793,7 @@ public class CommandlineJava implements Cloneable { public boolean haveUpgrademodulepath() { Path fullClasspath = upgrademodulepath != null ? upgrademodulepath.concatSystemClasspath("ignore") : null; - return fullClasspath != null - && fullClasspath.toString().trim().length() > 0; + return fullClasspath != null && fullClasspath.toString().trim().length() > 0; } /** @@ -816,8 +806,7 @@ public class CommandlineJava implements Cloneable { private Path calculateBootclasspath(boolean log) { if (vmVersion.startsWith("1.1")) { if (bootclasspath != null && log) { - bootclasspath.log("Ignoring bootclasspath as " - + "the target VM doesn't support it."); + bootclasspath.log("Ignoring bootclasspath as the target VM doesn't support it."); } } else { Path b = bootclasspath; @@ -839,8 +828,7 @@ public class CommandlineJava implements Cloneable { * @since 1.7 */ private boolean isCloneVm() { - return cloneVm - || "true".equals(System.getProperty("ant.build.clonevm")); + return cloneVm || "true".equals(System.getProperty("ant.build.clonevm")); } /** @@ -851,9 +839,7 @@ public class CommandlineJava implements Cloneable { * @since 1.9.7 */ private static String createModuleClassPair(final String module, final String classname) { - return classname == null ? - module : - String.format("%s/%s", module, classname); //NOI18N + return classname == null ? module : String.format("%s/%s", module, classname); //NOI18N } /** @@ -881,9 +867,7 @@ public class CommandlineJava implements Cloneable { return null; } final String[] moduleAndClass = moduleClassPair.split("/"); //NOI18N - return moduleAndClass.length == 2 ? - moduleAndClass[1] : - null; + return moduleAndClass.length == 2 ? moduleAndClass[1] : null; } /** diff --git a/src/main/org/apache/tools/ant/types/DataType.java b/src/main/org/apache/tools/ant/types/DataType.java index c5ee1c977..7b2ec7a00 100644 --- a/src/main/org/apache/tools/ant/types/DataType.java +++ b/src/main/org/apache/tools/ant/types/DataType.java @@ -363,7 +363,7 @@ public abstract class DataType extends ProjectComponent implements Cloneable { } private String displayName(Class clazz) { - return clazz.getName() + " (loaded via " + clazz.getClassLoader() +")"; + return clazz.getName() + " (loaded via " + clazz.getClassLoader() + ")"; } } diff --git a/src/main/org/apache/tools/ant/types/XMLCatalog.java b/src/main/org/apache/tools/ant/types/XMLCatalog.java index 20bbe948a..7001359a0 100644 --- a/src/main/org/apache/tools/ant/types/XMLCatalog.java +++ b/src/main/org/apache/tools/ant/types/XMLCatalog.java @@ -47,7 +47,6 @@ import org.xml.sax.SAXException; import org.xml.sax.XMLReader; - /** *

This data type provides a catalog of resource locations (such as * DTDs and XML entities), based on the "); + int prevEnd = 0; + int cdataEndPos = value.indexOf("]]>"); while (prevEnd < len) { final int end = (cdataEndPos < 0 ? len : cdataEndPos); // Write out stretches of legal characters in the range [prevEnd, end). diff --git a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java index 2fc36b210..7206d778e 100644 --- a/src/main/org/apache/tools/ant/util/JavaEnvUtils.java +++ b/src/main/org/apache/tools/ant/util/JavaEnvUtils.java @@ -545,8 +545,7 @@ public final class JavaEnvUtils { tests.addElement("org.xml.sax.XMLReader"); } if (isAtLeastJavaVersion(JAVA_1_5)) { - tests.addElement( - "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"); + tests.addElement("com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl"); } if (isAtLeastJavaVersion(JAVA_1_7)) { tests.addElement("jdk.net.Sockets"); diff --git a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java index 116a4314a..e4df722e0 100644 --- a/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java +++ b/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java @@ -357,7 +357,7 @@ public class LayoutPreservingProperties extends Properties { line = new Blank(); } else { line = new Pair(logicalLineBuffer.toString()); - final String key = unescape(((Pair)line).getName()); + final String key = unescape(((Pair) line).getName()); if (keyedPairLines.containsKey(key)) { // this key is already present, so we remove it and add // the new one @@ -474,7 +474,7 @@ public class LayoutPreservingProperties extends Properties { buffy.append('\t'); } else if (c == 'u') { // handle unicode escapes - c = unescapeUnicode(ch, i+1); + c = unescapeUnicode(ch, i + 1); i += 4; buffy.append(c); } else { @@ -554,7 +554,7 @@ public class LayoutPreservingProperties extends Properties { } final int p = forEscaping.indexOf(c); if (p != -1) { - buffy.append("\\").append(escaped.substring(p,p+1)); + buffy.append("\\").append(escaped.substring(p, p + 1)); } else if (c < 0x0020 || c > 0x007e) { buffy.append(escapeUnicode(c)); } else { @@ -715,7 +715,7 @@ public class LayoutPreservingProperties extends Properties { value = null; } else { name = text.substring(0, pos); - value = text.substring(pos+1, text.length()); + value = text.substring(pos + 1, text.length()); } // trim leading whitespace only name = stripStart(name, " \t\f"); @@ -727,7 +727,7 @@ public class LayoutPreservingProperties extends Properties { } int i = 0; - for (;i < s.length(); i++) { + for (; i < s.length(); i++) { if (chars.indexOf(s.charAt(i)) == -1) { break; } diff --git a/src/main/org/apache/tools/ant/util/MergingMapper.java b/src/main/org/apache/tools/ant/util/MergingMapper.java index f148e8b3e..d61ae303c 100644 --- a/src/main/org/apache/tools/ant/util/MergingMapper.java +++ b/src/main/org/apache/tools/ant/util/MergingMapper.java @@ -31,7 +31,8 @@ public class MergingMapper implements FileNameMapper { protected String[] mergedFile = null; // CheckStyle:VisibilityModifier ON - public MergingMapper() {} + public MergingMapper() { + } /** * @param to String diff --git a/src/main/org/apache/tools/ant/util/ProcessUtil.java b/src/main/org/apache/tools/ant/util/ProcessUtil.java index 998c7130b..58086f39f 100644 --- a/src/main/org/apache/tools/ant/util/ProcessUtil.java +++ b/src/main/org/apache/tools/ant/util/ProcessUtil.java @@ -54,7 +54,7 @@ public class ProcessUtil { return fallback; } - public static void main(String [] args) { + public static void main(String[] args) { System.out.println(getProcessId("")); try { Thread.sleep(120000); diff --git a/src/main/org/apache/tools/ant/util/ReaderInputStream.java b/src/main/org/apache/tools/ant/util/ReaderInputStream.java index f327b7770..21733b60b 100644 --- a/src/main/org/apache/tools/ant/util/ReaderInputStream.java +++ b/src/main/org/apache/tools/ant/util/ReaderInputStream.java @@ -173,7 +173,7 @@ public class ReaderInputStream extends InputStream { /** * @return false - mark is not supported */ - public boolean markSupported () { + public boolean markSupported() { return false; // would be imprecise } diff --git a/src/main/org/apache/tools/ant/util/ReflectUtil.java b/src/main/org/apache/tools/ant/util/ReflectUtil.java index b10ef396e..bc62fa0ae 100644 --- a/src/main/org/apache/tools/ant/util/ReflectUtil.java +++ b/src/main/org/apache/tools/ant/util/ReflectUtil.java @@ -91,7 +91,7 @@ public class ReflectUtil { method = ((Class) obj).getMethod( methodName, (Class[]) null); return method.invoke(obj, (Object[]) null); - } catch (Exception t) { + } catch (Exception t) { throwBuildException(t); return null; // NotReached } diff --git a/src/main/org/apache/tools/ant/util/ResourceUtils.java b/src/main/org/apache/tools/ant/util/ResourceUtils.java index 0c319addc..004cb6cd6 100644 --- a/src/main/org/apache/tools/ant/util/ResourceUtils.java +++ b/src/main/org/apache/tools/ant/util/ResourceUtils.java @@ -72,7 +72,7 @@ public class ResourceUtils { */ public static final String ISO_8859_1 = "ISO-8859-1"; - private static final long MAX_IO_CHUNK_SIZE = 16*1024*1024l; // 16 MB + private static final long MAX_IO_CHUNK_SIZE = 16 * 1024 * 1024L; // 16 MB /** * Tells which source files should be reprocessed based on the diff --git a/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java b/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java index 0f4cd1f9f..45c3ede6b 100644 --- a/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java +++ b/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java @@ -137,12 +137,11 @@ public class ScriptRunner extends ScriptRunnerBase { * @return BuildException the converted exception. */ private BuildException getBuildException(BSFException be) { - Throwable t = be; Throwable te = be.getTargetException(); if (te instanceof BuildException) { return (BuildException) te; } - return new BuildException(te == null ? t : te); + return new BuildException(te == null ? be : te); } private void declareBeans(BSFManager m) throws BSFException { diff --git a/src/main/org/apache/tools/bzip2/BlockSort.java b/src/main/org/apache/tools/bzip2/BlockSort.java index 0a50fdf76..e2aaf3783 100644 --- a/src/main/org/apache/tools/bzip2/BlockSort.java +++ b/src/main/org/apache/tools/bzip2/BlockSort.java @@ -291,7 +291,7 @@ class BlockSort { for (j = i + 1; j <= hi && ec_tmp > eclass[fmap[j]]; j++) { fmap[j - 1] = fmap[j]; } - fmap[j-1] = tmp; + fmap[j - 1] = tmp; } } @@ -312,7 +312,9 @@ class BlockSort { private void fvswap(int[] fmap, int yyp1, int yyp2, int yyn) { while (yyn > 0) { fswap(fmap, yyp1, yyp2); - yyp1++; yyp2++; yyn--; + yyp1++; + yyp2++; + yyn--; } } @@ -326,7 +328,7 @@ class BlockSort { } private int[] fpop(int sp) { - return new int[] { stack_ll[sp], stack_hh[sp] }; + return new int[] {stack_ll[sp], stack_hh[sp]}; } /** @@ -351,7 +353,8 @@ class BlockSort { while (sp > 0) { int[] s = fpop(--sp); - lo = s[0]; hi = s[1]; + lo = s[0]; + hi = s[1]; if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) { fallbackSimpleSort(fmap, eclass, lo, hi); @@ -388,7 +391,8 @@ class BlockSort { n = eclass[fmap[unLo]] - (int) med; if (n == 0) { fswap(fmap, unLo, ltLo); - ltLo++; unLo++; + ltLo++; + unLo++; continue; } if (n > 0) { @@ -403,7 +407,8 @@ class BlockSort { n = eclass[fmap[unHi]] - (int) med; if (n == 0) { fswap(fmap, unHi, gtHi); - gtHi--; unHi--; + gtHi--; + unHi--; continue; } if (n < 0) { @@ -414,7 +419,9 @@ class BlockSort { if (unLo > unHi) { break; } - fswap(fmap, unLo, unHi); unLo++; unHi--; + fswap(fmap, unLo, unHi); + unLo++; + unHi--; } if (gtHi < ltLo) { @@ -578,9 +585,9 @@ class BlockSort { * Possibly because the number of elems to sort is usually small, typically * <= 20. */ - private static final int[] INCS = { 1, 4, 13, 40, 121, 364, 1093, 3280, - 9841, 29524, 88573, 265720, 797161, - 2391484 }; + private static final int[] INCS = {1, 4, 13, 40, 121, 364, 1093, 3280, + 9841, 29524, 88573, 265720, 797161, + 2391484}; /** * This is the most hammered method of this class. @@ -637,17 +644,17 @@ class BlockSort { // unrolled version: // start inline mainGTU - boolean onceRunned = false; + boolean onceRun = false; int a = 0; HAMMER: while (true) { - if (onceRunned) { + if (onceRun) { fmap[j] = a; if ((j -= h) <= mj) { //NOSONAR break HAMMER; } } else { - onceRunned = true; + onceRun = true; } a = fmap[j - h]; @@ -938,7 +945,7 @@ class BlockSort { for (int i = 0; i < BZip2Constants.NUM_OVERSHOOT_BYTES; i++) { block[lastShadow + i + 2] = block[(i % (lastShadow + 1)) + 1]; } - for (int i = lastShadow + BZip2Constants.NUM_OVERSHOOT_BYTES +1; --i >= 0;) { + for (int i = lastShadow + BZip2Constants.NUM_OVERSHOOT_BYTES + 1; --i >= 0;) { quadrant[i] = 0; } block[0] = block[lastShadow + 1]; diff --git a/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java b/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java index dd118ea43..a5ca068c2 100644 --- a/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java +++ b/src/main/org/apache/tools/bzip2/CBZip2OutputStream.java @@ -203,9 +203,10 @@ public class CBZip2OutputStream extends OutputStream * Possibly because the number of elems to sort is usually small, typically * <= 20. */ - private static final int[] INCS = { 1, 4, 13, 40, 121, 364, 1093, 3280, - 9841, 29524, 88573, 265720, 797161, - 2391484 }; + @SuppressWarnings("unused") + private static final int[] INCS = {1, 4, 13, 40, 121, 364, 1093, 3280, + 9841, 29524, 88573, 265720, 797161, + 2391484}; /** * This method is accessible by subclasses for historical @@ -675,41 +676,34 @@ public class CBZip2OutputStream extends OutputStream int runLengthShadow = this.runLength; this.crc.updateCRC(currentCharShadow, runLengthShadow); + final byte[] block = dataShadow.block; switch (runLengthShadow) { - case 1: - dataShadow.block[lastShadow + 2] = ch; - this.last = lastShadow + 1; - break; - - case 2: - dataShadow.block[lastShadow + 2] = ch; - dataShadow.block[lastShadow + 3] = ch; - this.last = lastShadow + 2; - break; - - case 3: { - final byte[] block = dataShadow.block; - block[lastShadow + 2] = ch; - block[lastShadow + 3] = ch; - block[lastShadow + 4] = ch; - this.last = lastShadow + 3; - } - break; - - default: { - runLengthShadow -= 4; - dataShadow.inUse[runLengthShadow] = true; - final byte[] block = dataShadow.block; - block[lastShadow + 2] = ch; - block[lastShadow + 3] = ch; - block[lastShadow + 4] = ch; - block[lastShadow + 5] = ch; - block[lastShadow + 6] = (byte) runLengthShadow; - this.last = lastShadow + 5; - } - break; - + case 1: + block[lastShadow + 2] = ch; + this.last = lastShadow + 1; + break; + case 2: + block[lastShadow + 2] = ch; + block[lastShadow + 3] = ch; + this.last = lastShadow + 2; + break; + case 3: + block[lastShadow + 2] = ch; + block[lastShadow + 3] = ch; + block[lastShadow + 4] = ch; + this.last = lastShadow + 3; + break; + default: + runLengthShadow -= 4; + dataShadow.inUse[runLengthShadow] = true; + block[lastShadow + 2] = ch; + block[lastShadow + 3] = ch; + block[lastShadow + 4] = ch; + block[lastShadow + 5] = ch; + block[lastShadow + 6] = (byte) runLengthShadow; + this.last = lastShadow + 5; + break; } } else { endBlock(); diff --git a/src/main/org/apache/tools/mail/MailMessage.java b/src/main/org/apache/tools/mail/MailMessage.java index 72875018d..b1ca493b7 100644 --- a/src/main/org/apache/tools/mail/MailMessage.java +++ b/src/main/org/apache/tools/mail/MailMessage.java @@ -65,7 +65,7 @@ import java.util.Vector; * * Enumeration enum = req.getParameterNames(); * while (enum.hasMoreElements()) { - * String name = (String)enum.nextElement(); + * String name = (String) enum.nextElement(); * String value = req.getParameter(name); * out.println(name + " = " + value); * } diff --git a/src/main/org/apache/tools/tar/TarBuffer.java b/src/main/org/apache/tools/tar/TarBuffer.java index b089d9bf8..252d88c73 100644 --- a/src/main/org/apache/tools/tar/TarBuffer.java +++ b/src/main/org/apache/tools/tar/TarBuffer.java @@ -333,7 +333,7 @@ public class TarBuffer { } if (outStream == null) { - if (inStream == null){ + if (inStream == null) { throw new IOException("Output buffer is closed"); } throw new IOException("writing to an input buffer"); @@ -373,7 +373,7 @@ public class TarBuffer { } if (outStream == null) { - if (inStream == null){ + if (inStream == null) { throw new IOException("Output buffer is closed"); } throw new IOException("writing to an input buffer"); diff --git a/src/main/org/apache/tools/tar/TarEntry.java b/src/main/org/apache/tools/tar/TarEntry.java index fad702f07..c44e47f7a 100644 --- a/src/main/org/apache/tools/tar/TarEntry.java +++ b/src/main/org/apache/tools/tar/TarEntry.java @@ -989,34 +989,33 @@ public class TarEntry implements TarConstants { int type = evaluateType(header); switch (type) { - case FORMAT_OLDGNU: { - offset += ATIMELEN_GNU; - offset += CTIMELEN_GNU; - offset += OFFSETLEN_GNU; - offset += LONGNAMESLEN_GNU; - offset += PAD2LEN_GNU; - offset += SPARSELEN_GNU; - isExtended = TarUtils.parseBoolean(header, offset); - offset += ISEXTENDEDLEN_GNU; - realSize = TarUtils.parseOctal(header, offset, REALSIZELEN_GNU); - offset += REALSIZELEN_GNU; - break; - } - case FORMAT_POSIX: - default: { - String prefix = oldStyle - ? TarUtils.parseName(header, offset, PREFIXLEN) - : TarUtils.parseName(header, offset, PREFIXLEN, encoding); - // SunOS tar -E does not add / to directory names, so fix - // up to be consistent - if (isDirectory() && !name.endsWith("/")) { - name = name + "/"; + case FORMAT_OLDGNU: { + offset += ATIMELEN_GNU; + offset += CTIMELEN_GNU; + offset += OFFSETLEN_GNU; + offset += LONGNAMESLEN_GNU; + offset += PAD2LEN_GNU; + offset += SPARSELEN_GNU; + isExtended = TarUtils.parseBoolean(header, offset); + offset += ISEXTENDEDLEN_GNU; + realSize = TarUtils.parseOctal(header, offset, REALSIZELEN_GNU); + offset += REALSIZELEN_GNU; + break; } - if (prefix.length() > 0) { - name = prefix + "/" + name; + case FORMAT_POSIX: + default: { + String prefix = oldStyle ? TarUtils.parseName(header, offset, PREFIXLEN) + : TarUtils.parseName(header, offset, PREFIXLEN, encoding); + // SunOS tar -E does not add / to directory names, so fix + // up to be consistent + if (isDirectory() && !name.endsWith("/")) { + name = name + "/"; + } + if (prefix.length() > 0) { + name = prefix + "/" + name; + } } } - } } /** @@ -1116,9 +1115,9 @@ public class TarEntry implements TarConstants { final byte[] buffer1, final int offset1, final int length1, final byte[] buffer2, final int offset2, final int length2, boolean ignoreTrailingNulls) { - int minLen=length1 < length2 ? length1 : length2; - for (int i=0; i < minLen; i++) { - if (buffer1[offset1+i] != buffer2[offset2+i]) { + int minLen = (length1 < length2) ? length1 : length2; + for (int i = 0; i < minLen; i++) { + if (buffer1[offset1 + i] != buffer2[offset2 + i]) { return false; } } @@ -1126,15 +1125,15 @@ public class TarEntry implements TarConstants { return true; } if (ignoreTrailingNulls) { - if (length1 > length2){ - for(int i = length2; i < length1; i++){ - if (buffer1[offset1+i] != 0) { + if (length1 > length2) { + for (int i = length2; i < length1; i++) { + if (buffer1[offset1 + i] != 0) { return false; } } } else { - for (int i = length1; i < length2; i++){ - if (buffer2[offset2+i] != 0) { + for (int i = length1; i < length2; i++) { + if (buffer2[offset2 + i] != 0) { return false; } } diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java index bacc20047..971599214 100644 --- a/src/main/org/apache/tools/tar/TarInputStream.java +++ b/src/main/org/apache/tools/tar/TarInputStream.java @@ -331,11 +331,11 @@ public class TarInputStream extends FilterInputStream { currEntry.setName(encoding.decode(longNameData)); } - if (currEntry.isPaxHeader()){ // Process Pax headers + if (currEntry.isPaxHeader()) { // Process Pax headers paxHeaders(); } - if (currEntry.isGNUSparse()){ // Process sparse files + if (currEntry.isGNUSparse()) { // Process sparse files readGNUSparse(); } @@ -414,7 +414,7 @@ public class TarInputStream extends FilterInputStream { return hasHitEOF ? null : headerBuf; } - private void paxHeaders() throws IOException{ + private void paxHeaders() throws IOException { Map headers = parsePaxHeaders(this); getNextEntry(); // Get the actual file entry applyPaxHeadersToCurrentEntry(headers); @@ -423,18 +423,18 @@ public class TarInputStream extends FilterInputStream { Map parsePaxHeaders(InputStream i) throws IOException { Map headers = new HashMap(); // Format is "length keyword=value\n"; - while(true){ // get length + while (true) { // get length int ch; int len = 0; int read = 0; - while((ch = i.read()) != -1) { + while ((ch = i.read()) != -1) { read++; - if (ch == ' '){ // End of length string + if (ch == ' ') { // End of length string // Get keyword ByteArrayOutputStream coll = new ByteArrayOutputStream(); - while((ch = i.read()) != -1) { + while ((ch = i.read()) != -1) { read++; - if (ch == '='){ // end of keyword + if (ch == '=') { // end of keyword String keyword = coll.toString("UTF-8"); // Get rest of entry final int restLen = len - read; @@ -463,7 +463,7 @@ public class TarInputStream extends FilterInputStream { len *= 10; len += ch - '0'; } - if (ch == -1){ // EOF + if (ch == -1) { // EOF break; } } @@ -482,28 +482,28 @@ public class TarInputStream extends FilterInputStream { * uid,uname * SCHILY.devminor, SCHILY.devmajor: don't have setters/getters for those */ - for (Entry ent : headers.entrySet()){ + for (Entry ent : headers.entrySet()) { String key = ent.getKey(); String val = ent.getValue(); - if ("path".equals(key)){ + if ("path".equals(key)) { currEntry.setName(val); - } else if ("linkpath".equals(key)){ + } else if ("linkpath".equals(key)) { currEntry.setLinkName(val); - } else if ("gid".equals(key)){ + } else if ("gid".equals(key)) { currEntry.setGroupId(Long.parseLong(val)); - } else if ("gname".equals(key)){ + } else if ("gname".equals(key)) { currEntry.setGroupName(val); - } else if ("uid".equals(key)){ + } else if ("uid".equals(key)) { currEntry.setUserId(Long.parseLong(val)); - } else if ("uname".equals(key)){ + } else if ("uname".equals(key)) { currEntry.setUserName(val); - } else if ("size".equals(key)){ + } else if ("size".equals(key)) { currEntry.setSize(Long.parseLong(val)); - } else if ("mtime".equals(key)){ + } else if ("mtime".equals(key)) { currEntry.setModTime((long) (Double.parseDouble(val) * 1000)); - } else if ("SCHILY.devminor".equals(key)){ + } else if ("SCHILY.devminor".equals(key)) { currEntry.setDevMinor(Integer.parseInt(val)); - } else if ("SCHILY.devmajor".equals(key)){ + } else if ("SCHILY.devmajor".equals(key)) { currEntry.setDevMajor(Integer.parseInt(val)); } } diff --git a/src/main/org/apache/tools/tar/TarOutputStream.java b/src/main/org/apache/tools/tar/TarOutputStream.java index f2f094367..217ed208d 100644 --- a/src/main/org/apache/tools/tar/TarOutputStream.java +++ b/src/main/org/apache/tools/tar/TarOutputStream.java @@ -246,7 +246,7 @@ public class TarOutputStream extends FilterOutputStream { */ @Override public void close() throws IOException { - if(!finished) { + if (!finished) { finish(); } @@ -279,7 +279,7 @@ public class TarOutputStream extends FilterOutputStream { * @throws IOException on error */ public void putNextEntry(TarEntry entry) throws IOException { - if(finished) { + if (finished) { throw new IOException("Stream has already been finished"); } Map paxHeaders = new HashMap(); @@ -342,7 +342,7 @@ public class TarOutputStream extends FilterOutputStream { if (finished) { throw new IOException("Stream has already been finished"); } - if (!haveUnclosedEntry){ + if (!haveUnclosedEntry) { throw new IOException("No current entry to close"); } if (assemLen > 0) { @@ -624,7 +624,7 @@ public class TarOutputStream extends FilterOutputStream { * @param fieldName the name of the field * @return whether a pax header has been written. */ - private boolean handleLongName(TarEntry entry , String name, + private boolean handleLongName(TarEntry entry, String name, Map paxHeaders, String paxHeaderName, byte linkType, String fieldName) throws IOException { diff --git a/src/main/org/apache/tools/tar/TarUtils.java b/src/main/org/apache/tools/tar/TarUtils.java index 70e6a44d4..93d1583c8 100644 --- a/src/main/org/apache/tools/tar/TarUtils.java +++ b/src/main/org/apache/tools/tar/TarUtils.java @@ -46,7 +46,9 @@ public class TarUtils { * Encapsulates the algorithms used up to Ant 1.8 as ZipEncoding. */ static final ZipEncoding FALLBACK_ENCODING = new ZipEncoding() { - public boolean canEncode(final String name) { return true; } + public boolean canEncode(final String name) { + return true; + } public ByteBuffer encode(final String name) { final int length = name.length(); @@ -76,7 +78,7 @@ public class TarUtils { }; /** Private constructor to prevent instantiation of this utility class. */ - private TarUtils(){ + private TarUtils() { } /** @@ -105,8 +107,8 @@ public class TarUtils { int end = offset + length; int start = offset; - if (length < 2){ - throw new IllegalArgumentException("Length "+length+" must be at least 2"); + if (length < 2) { + throw new IllegalArgumentException("Length " + length + " must be at least 2"); } if (buffer[start] == 0) { @@ -114,8 +116,8 @@ public class TarUtils { } // Skip leading spaces - while (start < end){ - if (buffer[start] == ' '){ + while (start < end) { + if (buffer[start] == ' ') { start++; } else { break; @@ -132,15 +134,16 @@ public class TarUtils { trailer = buffer[end - 1]; } - for ( ;start < end; start++) { + while (start < end) { final byte currentByte = buffer[start]; // CheckStyle:MagicNumber OFF - if (currentByte < '0' || currentByte > '7'){ + if (currentByte < '0' || currentByte > '7') { throw new IllegalArgumentException( exceptionMessage(buffer, offset, length, start, currentByte)); } result = (result << 3) + (currentByte - '0'); // convert from ASCII // CheckStyle:MagicNumber ON + start++; } return result; @@ -179,10 +182,9 @@ public class TarUtils { final int length, final boolean negative) { if (length >= 9) { - throw new IllegalArgumentException("At offset " + offset + ", " - + length + " byte binary number" - + " exceeds maximum signed long" - + " value"); + throw new IllegalArgumentException(String.format( + "At offset %d, %d byte binary number exceeds maximum signed long value", + offset, length)); } long val = 0; for (int i = 1; i < length; i++) { @@ -208,10 +210,9 @@ public class TarUtils { val = val.add(BigInteger.valueOf(-1)).not(); } if (val.bitLength() > 63) { - throw new IllegalArgumentException("At offset " + offset + ", " - + length + " byte binary number" - + " exceeds maximum signed long" - + " value"); + throw new IllegalArgumentException(String.format( + "At offset %d, %d byte binary number exceeds maximum signed long value", + offset, length)); } return negative ? -val.longValue() : val.longValue(); } @@ -242,9 +243,9 @@ public class TarUtils { // can throw an IOException which parseOctal* doesn't declare String string = new String(buffer, offset, length); - string=string.replaceAll("\0", "{NUL}"); // Replace NULs to allow string to be printed - final String s = "Invalid byte "+currentByte+" at offset "+(current-offset)+" in '"+string+"' len="+length; - return s; + string = string.replaceAll("\0", "{NUL}"); // Replace NULs to allow string to be printed + return String.format("Invalid byte %s at offset %d in '%s' len=%d", + currentByte, current - offset, string, length); } /** @@ -390,9 +391,10 @@ public class TarUtils { val = val >>> 3; // CheckStyle:MagicNumber ON } - if (val != 0){ - throw new IllegalArgumentException - (value+"="+Long.toOctalString(value)+ " will not fit in octal number buffer of length "+length); + if (val != 0) { + throw new IllegalArgumentException(String.format( + "%d=%s will not fit in octal number buffer of length %d", + value, Long.toOctalString(value), length)); } } @@ -417,7 +419,7 @@ public class TarUtils { */ public static int formatOctalBytes(final long value, final byte[] buf, final int offset, final int length) { - int idx=length-2; // For space and trailing null + int idx = length - 2; // For space and trailing null formatUnsignedOctalString(value, buf, offset, idx); buf[offset + idx++] = (byte) ' '; // Trailing space @@ -442,7 +444,7 @@ public class TarUtils { */ public static int formatLongOctalBytes(final long value, final byte[] buf, final int offset, final int length) { - final int idx=length-1; // For space + final int idx = length - 1; // For space formatUnsignedOctalString(value, buf, offset, idx); buf[offset + idx] = (byte) ' '; // Trailing space @@ -538,11 +540,11 @@ public class TarUtils { */ public static int formatCheckSumOctalBytes(final long value, final byte[] buf, final int offset, final int length) { - int idx=length-2; // for NUL and space + int idx = length - 2; // for NUL and space formatUnsignedOctalString(value, buf, offset, idx); - buf[offset + idx++] = 0; // Trailing null - buf[offset + idx] = (byte) ' '; // Trailing space + buf[offset + idx++] = 0; // Trailing null + buf[offset + idx] = (byte) ' '; // Trailing space return offset + length; } diff --git a/src/main/org/apache/tools/zip/ExtraFieldUtils.java b/src/main/org/apache/tools/zip/ExtraFieldUtils.java index d7a6c9d41..18bb85064 100644 --- a/src/main/org/apache/tools/zip/ExtraFieldUtils.java +++ b/src/main/org/apache/tools/zip/ExtraFieldUtils.java @@ -140,45 +140,38 @@ public class ExtraFieldUtils { ZipShort headerId = new ZipShort(data, start); int length = (new ZipShort(data, start + 2)).getValue(); if (start + WORD + length > data.length) { - switch(onUnparseableData.getKey()) { - case UnparseableExtraField.THROW_KEY: - throw new ZipException("bad extra field starting at " - + start + ". Block length of " - + length + " bytes exceeds remaining" - + " data of " - + (data.length - start - WORD) - + " bytes."); - case UnparseableExtraField.READ_KEY: - UnparseableExtraFieldData field = - new UnparseableExtraFieldData(); - if (local) { - field.parseFromLocalFileData(data, start, - data.length - start); - } else { - field.parseFromCentralDirectoryData(data, start, - data.length - start); - } - v.add(field); - //$FALL-THROUGH$ - case UnparseableExtraField.SKIP_KEY: - // since we cannot parse the data we must assume - // the extra field consumes the whole rest of the - // available data - break LOOP; - default: - throw new ZipException("unknown UnparseableExtraField key: " - + onUnparseableData.getKey()); + switch (onUnparseableData.getKey()) { + case UnparseableExtraField.THROW_KEY: + throw new ZipException("bad extra field starting at " + + start + ". Block length of " + length + + " bytes exceeds remaining data of " + + (data.length - start - WORD) + " bytes."); + case UnparseableExtraField.READ_KEY: + UnparseableExtraFieldData field = new UnparseableExtraFieldData(); + if (local) { + field.parseFromLocalFileData(data, start, data.length - start); + } else { + field.parseFromCentralDirectoryData(data, start, data.length - start); + } + v.add(field); + //$FALL-THROUGH$ + case UnparseableExtraField.SKIP_KEY: + // since we cannot parse the data we must assume + // the extra field consumes the whole rest of the + // available data + break LOOP; + default: + throw new ZipException("unknown UnparseableExtraField key: " + + onUnparseableData.getKey()); } } try { ZipExtraField ze = createExtraField(headerId); - if (local - || !(ze instanceof CentralDirectoryParsingZipExtraField)) { + if (local || !(ze instanceof CentralDirectoryParsingZipExtraField)) { ze.parseFromLocalFileData(data, start + WORD, length); } else { ((CentralDirectoryParsingZipExtraField) ze) - .parseFromCentralDirectoryData(data, start + WORD, - length); + .parseFromCentralDirectoryData(data, start + WORD, length); } v.add(ze); } catch (InstantiationException ie) { @@ -201,9 +194,8 @@ public class ExtraFieldUtils { */ public static byte[] mergeLocalFileDataData(ZipExtraField[] data) { final boolean lastIsUnparseableHolder = data.length > 0 - && data[data.length - 1] instanceof UnparseableExtraFieldData; - int regularExtraFieldCount = - lastIsUnparseableHolder ? data.length - 1 : data.length; + && data[data.length - 1] instanceof UnparseableExtraFieldData; + int regularExtraFieldCount = lastIsUnparseableHolder ? data.length - 1 : data.length; int sum = WORD * regularExtraFieldCount; for (ZipExtraField element : data) { @@ -214,9 +206,9 @@ public class ExtraFieldUtils { int start = 0; for (int i = 0; i < regularExtraFieldCount; i++) { System.arraycopy(data[i].getHeaderId().getBytes(), - 0, result, start, 2); + 0, result, start, 2); System.arraycopy(data[i].getLocalFileDataLength().getBytes(), - 0, result, start + 2, 2); + 0, result, start + 2, 2); byte[] local = data[i].getLocalFileDataData(); System.arraycopy(local, 0, result, start + WORD, local.length); start += (local.length + WORD); @@ -237,8 +229,7 @@ public class ExtraFieldUtils { public static byte[] mergeCentralDirectoryData(ZipExtraField[] data) { final boolean lastIsUnparseableHolder = data.length > 0 && data[data.length - 1] instanceof UnparseableExtraFieldData; - int regularExtraFieldCount = - lastIsUnparseableHolder ? data.length - 1 : data.length; + int regularExtraFieldCount = lastIsUnparseableHolder ? data.length - 1 : data.length; int sum = WORD * regularExtraFieldCount; for (ZipExtraField element : data) { @@ -283,22 +274,19 @@ public class ExtraFieldUtils { /** * Throw an exception if field cannot be parsed. */ - public static final UnparseableExtraField THROW - = new UnparseableExtraField(THROW_KEY); + public static final UnparseableExtraField THROW = new UnparseableExtraField(THROW_KEY); /** * Skip the extra field entirely and don't make its data * available - effectively removing the extra field data. */ - public static final UnparseableExtraField SKIP - = new UnparseableExtraField(SKIP_KEY); + public static final UnparseableExtraField SKIP = new UnparseableExtraField(SKIP_KEY); /** * Read the extra field data into an instance of {@link * UnparseableExtraFieldData UnparseableExtraFieldData}. */ - public static final UnparseableExtraField READ - = new UnparseableExtraField(READ_KEY); + public static final UnparseableExtraField READ = new UnparseableExtraField(READ_KEY); private final int key; @@ -311,6 +299,8 @@ public class ExtraFieldUtils { * * @return int */ - public int getKey() { return key; } + public int getKey() { + return key; + } } } diff --git a/src/main/org/apache/tools/zip/FallbackZipEncoding.java b/src/main/org/apache/tools/zip/FallbackZipEncoding.java index 96cff33af..7e0f3159c 100644 --- a/src/main/org/apache/tools/zip/FallbackZipEncoding.java +++ b/src/main/org/apache/tools/zip/FallbackZipEncoding.java @@ -85,7 +85,7 @@ class FallbackZipEncoding implements ZipEncoding { if (this.charset == null) { // i.e. use default charset, see no-args constructor return new String(data); } else { - return new String(data,this.charset); + return new String(data, this.charset); } } } diff --git a/src/main/org/apache/tools/zip/GeneralPurposeBit.java b/src/main/org/apache/tools/zip/GeneralPurposeBit.java index 3246fbee1..f5f353cb4 100644 --- a/src/main/org/apache/tools/zip/GeneralPurposeBit.java +++ b/src/main/org/apache/tools/zip/GeneralPurposeBit.java @@ -27,7 +27,7 @@ public final class GeneralPurposeBit implements Cloneable { /** * Indicates that the file is encrypted. */ - private static final int ENCRYPTION_FLAG = 1 << 0; + private static final int ENCRYPTION_FLAG = 1; /** * Indicates that a data descriptor stored after the file contents @@ -155,13 +155,10 @@ public final class GeneralPurposeBit implements Cloneable { */ public void encode(byte[] buf, int offset) { ZipShort.putShort((dataDescriptorFlag ? DATA_DESCRIPTOR_FLAG : 0) - | - (languageEncodingFlag ? UFT8_NAMES_FLAG : 0) - | - (encryptionFlag ? ENCRYPTION_FLAG : 0) - | - (strongEncryptionFlag ? STRONG_ENCRYPTION_FLAG : 0) - , buf, offset); + | (languageEncodingFlag ? UFT8_NAMES_FLAG : 0) + | (encryptionFlag ? ENCRYPTION_FLAG : 0) + | (strongEncryptionFlag ? STRONG_ENCRYPTION_FLAG : 0), + buf, offset); } /** diff --git a/src/main/org/apache/tools/zip/NioZipEncoding.java b/src/main/org/apache/tools/zip/NioZipEncoding.java index 462b51928..f566615b9 100644 --- a/src/main/org/apache/tools/zip/NioZipEncoding.java +++ b/src/main/org/apache/tools/zip/NioZipEncoding.java @@ -75,7 +75,7 @@ class NioZipEncoding implements ZipEncoding { + (name.length() + 1) / 2); while (cb.remaining() > 0) { - final CoderResult res = enc.encode(cb, out,true); + final CoderResult res = enc.encode(cb, out, true); if (res.isUnmappable() || res.isMalformed()) { @@ -86,8 +86,8 @@ class NioZipEncoding implements ZipEncoding { + res.length() * 6); } - for (int i=0; ir with - * r.capacity() = max(b.capacity()*2,newCapacity) and + * r.capacity() = max(b.capacity() * 2,newCapacity) and * all the data contained in b copied to the beginning * of r. * @@ -163,8 +163,7 @@ public abstract class ZipEncodingHelper { * The hexadecimal digits 0,...,9,A,...,F encoded as * ASCII bytes. */ - private static final byte[] HEX_DIGITS = - new byte [] { + private static final byte[] HEX_DIGITS = new byte[] { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 }; @@ -181,9 +180,9 @@ public abstract class ZipEncodingHelper { bb.put((byte) '%'); bb.put((byte) 'U'); - bb.put(HEX_DIGITS[(c >> 12)&0x0f]); - bb.put(HEX_DIGITS[(c >> 8)&0x0f]); - bb.put(HEX_DIGITS[(c >> 4)&0x0f]); + bb.put(HEX_DIGITS[(c >> 12) & 0x0f]); + bb.put(HEX_DIGITS[(c >> 8) & 0x0f]); + bb.put(HEX_DIGITS[(c >> 4) & 0x0f]); bb.put(HEX_DIGITS[c & 0x0f]); } @@ -223,7 +222,7 @@ public abstract class ZipEncodingHelper { final SimpleEncodingHolder h = simpleEncodings.get(name); - if (h!=null) { + if (h != null) { return h.getEncoding(); } diff --git a/src/main/org/apache/tools/zip/ZipEntry.java b/src/main/org/apache/tools/zip/ZipEntry.java index eac5f6380..4d619d399 100644 --- a/src/main/org/apache/tools/zip/ZipEntry.java +++ b/src/main/org/apache/tools/zip/ZipEntry.java @@ -110,8 +110,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { final byte[] extra = entry.getExtra(); if (extra != null) { setExtraFields(ExtraFieldUtils.parse(extra, true, - ExtraFieldUtils - .UnparseableExtraField.READ)); + ExtraFieldUtils.UnparseableExtraField.READ)); } else { // initializes extra data to an empty byte array setExtra(); @@ -137,8 +136,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { setExtraFields(getAllExtraFieldsNoCopy()); setPlatform(entry.getPlatform()); GeneralPurposeBit other = entry.getGeneralPurposeBit(); - setGeneralPurposeBit(other == null ? null : - (GeneralPurposeBit) other.clone()); + setGeneralPurposeBit(other == null ? null : (GeneralPurposeBit) other.clone()); } /** @@ -161,9 +159,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { * @param entryName String */ public ZipEntry(final File inputFile, final String entryName) { - this(inputFile.isDirectory() && !entryName.endsWith("/") ? - entryName + "/" : entryName); - if (inputFile.isFile()){ + this(inputFile.isDirectory() && !entryName.endsWith("/") ? entryName + "/" : entryName); + if (inputFile.isFile()) { setSize(inputFile.length()); } setTime(inputFile.lastModified()); @@ -205,8 +202,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { @Override public void setMethod(final int method) { if (method < 0) { - throw new IllegalArgumentException( - "ZIP compression method can not be negative: " + method); + throw new IllegalArgumentException("ZIP compression method can not be negative: " + + method); } this.method = method; } @@ -276,8 +273,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { * @since Ant 1.6 */ public int getUnixMode() { - return platform != PLATFORM_UNIX ? 0 : - (int) ((getExternalAttributes() >> SHORT_SHIFT) & SHORT_MASK); + return platform != PLATFORM_UNIX ? 0 + : (int) ((getExternalAttributes() >> SHORT_SHIFT) & SHORT_MASK); } /** @@ -315,7 +312,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { if (field instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) field; } else { - newFields.add( field); + newFields.add(field); } } extraFields = newFields.toArray(new ZipExtraField[newFields.size()]); @@ -341,9 +338,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { * @since 1.1 */ public ZipExtraField[] getExtraFields(final boolean includeUnparseable) { - return includeUnparseable ? - getAllExtraFields() : - getParseableExtraFields(); + return includeUnparseable ? getAllExtraFields() : getParseableExtraFields(); } private ZipExtraField[] getParseableExtraFieldsNoCopy() { @@ -355,36 +350,34 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { private ZipExtraField[] getParseableExtraFields() { final ZipExtraField[] parseableExtraFields = getParseableExtraFieldsNoCopy(); - return (parseableExtraFields == extraFields) - ? copyOf(parseableExtraFields) : parseableExtraFields; + return (parseableExtraFields == extraFields) ? copyOf(parseableExtraFields) + : parseableExtraFields; } - private ZipExtraField[] copyOf(ZipExtraField[] src){ + private ZipExtraField[] copyOf(ZipExtraField[] src) { return copyOf(src, src.length); } - private ZipExtraField[] copyOf(ZipExtraField[] src, int length){ + private ZipExtraField[] copyOf(ZipExtraField[] src, int length) { ZipExtraField[] cpy = new ZipExtraField[length]; System.arraycopy(src, 0, cpy, 0, Math.min(src.length, length)); return cpy; } private ZipExtraField[] getMergedFields() { - final ZipExtraField[] zipExtraFields = - copyOf(extraFields, extraFields.length + 1); + final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1); zipExtraFields[extraFields.length] = unparseableExtra; return zipExtraFields; } private ZipExtraField[] getUnparseableOnly() { - return unparseableExtra == null - ? noExtraFields : new ZipExtraField[] { unparseableExtra }; + return unparseableExtra == null ? noExtraFields : new ZipExtraField[] {unparseableExtra}; } private ZipExtraField[] getAllExtraFields() { final ZipExtraField[] allExtraFieldsNoCopy = getAllExtraFieldsNoCopy(); - return (allExtraFieldsNoCopy == extraFields) - ? copyOf(allExtraFieldsNoCopy) : allExtraFieldsNoCopy; + return (allExtraFieldsNoCopy == extraFields) ? copyOf(allExtraFieldsNoCopy) + : allExtraFieldsNoCopy; } /** @@ -416,11 +409,10 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { if (extraFields == null) { extraFields = new ZipExtraField[] {ze}; } else { - if (getExtraField(ze.getHeaderId()) != null){ + if (getExtraField(ze.getHeaderId()) != null) { removeExtraField(ze.getHeaderId()); } - final ZipExtraField[] zipExtraFields = - copyOf(extraFields, extraFields.length + 1); + final ZipExtraField[] zipExtraFields = copyOf(extraFields, extraFields.length + 1); zipExtraFields[extraFields.length] = ze; extraFields = zipExtraFields; } @@ -441,14 +433,14 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { if (ze instanceof UnparseableExtraFieldData) { unparseableExtra = (UnparseableExtraFieldData) ze; } else { - if (getExtraField(ze.getHeaderId()) != null){ + if (getExtraField(ze.getHeaderId()) != null) { removeExtraField(ze.getHeaderId()); } ZipExtraField[] copy = extraFields; - int newLen = extraFields != null ? extraFields.length + 1: 1; + int newLen = extraFields != null ? extraFields.length + 1 : 1; extraFields = new ZipExtraField[newLen]; extraFields[0] = ze; - if (copy != null){ + if (copy != null) { System.arraycopy(copy, 0, extraFields, 1, extraFields.length - 1); } } @@ -467,7 +459,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { } List newResult = new ArrayList(); for (ZipExtraField extraField : extraFields) { - if (!type.equals(extraField.getHeaderId())){ + if (!type.equals(extraField.getHeaderId())) { newResult.add(extraField); } } @@ -528,9 +520,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { @Override public void setExtra(final byte[] extra) throws RuntimeException { try { - final ZipExtraField[] local = - ExtraFieldUtils.parse(extra, true, - ExtraFieldUtils.UnparseableExtraField.READ); + final ZipExtraField[] local = ExtraFieldUtils.parse(extra, true, + ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(local, true); } catch (final ZipException e) { // actually this is not be possible as of Ant 1.8.1 @@ -558,9 +549,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { */ public void setCentralDirectoryExtra(final byte[] b) { try { - final ZipExtraField[] central = - ExtraFieldUtils.parse(b, false, - ExtraFieldUtils.UnparseableExtraField.READ); + final ZipExtraField[] central = ExtraFieldUtils.parse(b, false, + ExtraFieldUtils.UnparseableExtraField.READ); mergeExtraFields(central, false); } catch (final ZipException e) { throw new RuntimeException(e.getMessage(), e); //NOSONAR @@ -632,8 +622,7 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { * @param name the name to use */ protected void setName(String name) { - if (name != null && getPlatform() == PLATFORM_FAT - && name.indexOf("/") == -1) { + if (name != null && getPlatform() == PLATFORM_FAT && !name.contains("/")) { name = name.replace('\\', '/'); } this.name = name; @@ -813,10 +802,8 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { && getSize() == other.getSize() && getCrc() == other.getCrc() && getCompressedSize() == other.getCompressedSize() - && Arrays.equals(getCentralDirectoryExtra(), - other.getCentralDirectoryExtra()) - && Arrays.equals(getLocalFileDataExtra(), - other.getLocalFileDataExtra()) + && Arrays.equals(getCentralDirectoryExtra(), other.getCentralDirectoryExtra()) + && Arrays.equals(getLocalFileDataExtra(), other.getLocalFileDataExtra()) && gpb.equals(other.gpb); } } diff --git a/src/main/org/apache/tools/zip/ZipLong.java b/src/main/org/apache/tools/zip/ZipLong.java index 618082359..5932f8469 100644 --- a/src/main/org/apache/tools/zip/ZipLong.java +++ b/src/main/org/apache/tools/zip/ZipLong.java @@ -75,7 +75,7 @@ public final class ZipLong implements Cloneable { * @param bytes the bytes to store as a ZipLong * @since 1.1 */ - public ZipLong (byte[] bytes) { + public ZipLong(byte[] bytes) { this(bytes, 0); } @@ -85,7 +85,7 @@ public final class ZipLong implements Cloneable { * @param offset the offset to start * @since 1.1 */ - public ZipLong (byte[] bytes, int offset) { + public ZipLong(byte[] bytes, int offset) { value = ZipLong.getValue(bytes, offset); } diff --git a/src/main/org/apache/tools/zip/ZipOutputStream.java b/src/main/org/apache/tools/zip/ZipOutputStream.java index 3001a72c4..f2117d853 100644 --- a/src/main/org/apache/tools/zip/ZipOutputStream.java +++ b/src/main/org/apache/tools/zip/ZipOutputStream.java @@ -519,7 +519,7 @@ public class ZipOutputStream extends FilterOutputStream { int count = 0; for (ZipEntry ze : entries) { byteArrayOutputStream.write(createCentralFileHeader(ze)); - if (++count > NUM_PER_WRITE){ + if (++count > NUM_PER_WRITE) { writeCounted(byteArrayOutputStream.toByteArray()); byteArrayOutputStream.reset(); count = 0; @@ -663,7 +663,7 @@ public class ZipOutputStream extends FilterOutputStream { return requestedMode == Zip64Mode.Always || isTooLageForZip32(entry1); } - private boolean isTooLageForZip32(ZipEntry zipArchiveEntry){ + private boolean isTooLageForZip32(ZipEntry zipArchiveEntry) { return zipArchiveEntry.getSize() >= ZIP64_MAGIC || zipArchiveEntry.getCompressedSize() >= ZIP64_MAGIC; } @@ -941,7 +941,7 @@ public class ZipOutputStream extends FilterOutputStream { * @param offset int * @param length int */ - private void writeDeflated(byte[]b, int offset, int length) + private void writeDeflated(byte[] b, int offset, int length) throws IOException { if (length > 0 && !def.finished()) { entry.bytesRead += length; @@ -1070,7 +1070,7 @@ public class ZipOutputStream extends FilterOutputStream { private byte[] createLocalFileHeader(ZipEntry ze, ByteBuffer name, boolean encodable) { byte[] extra = ze.getLocalFileDataExtra(); final int nameLen = name.limit() - name.position(); - int len= LFH_FILENAME_OFFSET + nameLen + extra.length; + int len = LFH_FILENAME_OFFSET + nameLen + extra.length; byte[] buf = new byte[len]; System.arraycopy(LFH_SIG, 0, buf, LFH_SIG_OFFSET, WORD); @@ -1099,7 +1099,7 @@ public class ZipOutputStream extends FilterOutputStream { // compressed length // uncompressed length - if (hasZip64Extra(entry.entry)){ + if (hasZip64Extra(entry.entry)) { // point to ZIP64 extended information extra field for // sizes, may get rewritten once sizes are known if // stream is seekable @@ -1243,7 +1243,7 @@ public class ZipOutputStream extends FilterOutputStream { ByteBuffer commentB = getEntryEncoding(ze).encode(comm); final int nameLen = name.limit() - name.position(); final int commentLen = commentB.limit() - commentB.position(); - int len= CFH_FILENAME_OFFSET + nameLen + extra.length + commentLen; + int len = CFH_FILENAME_OFFSET + nameLen + extra.length + commentLen; byte[] buf = new byte[len]; System.arraycopy(CFH_SIG, 0, buf, CFH_SIG_OFFSET, WORD); @@ -1566,9 +1566,8 @@ public class ZipOutputStream extends FilterOutputStream { } // requires version 2 as we are going to store length info // in the data descriptor - return (isDeflatedToOutputStream(zipMethod)) ? - DATA_DESCRIPTOR_MIN_VERSION : - INITIAL_VERSION; + return (isDeflatedToOutputStream(zipMethod)) + ? DATA_DESCRIPTOR_MIN_VERSION : INITIAL_VERSION; } private boolean isDeflatedToOutputStream(int zipMethod) { diff --git a/src/main/org/apache/tools/zip/ZipShort.java b/src/main/org/apache/tools/zip/ZipShort.java index 2f5482ff0..ccbca3dff 100644 --- a/src/main/org/apache/tools/zip/ZipShort.java +++ b/src/main/org/apache/tools/zip/ZipShort.java @@ -36,7 +36,7 @@ public final class ZipShort implements Cloneable { * @param value the int to store as a ZipShort * @since 1.1 */ - public ZipShort (int value) { + public ZipShort(int value) { this.value = value; } @@ -45,7 +45,7 @@ public final class ZipShort implements Cloneable { * @param bytes the bytes to store as a ZipShort * @since 1.1 */ - public ZipShort (byte[] bytes) { + public ZipShort(byte[] bytes) { this(bytes, 0); } @@ -55,7 +55,7 @@ public final class ZipShort implements Cloneable { * @param offset the offset to start * @since 1.1 */ - public ZipShort (byte[] bytes, int offset) { + public ZipShort(byte[] bytes, int offset) { value = ZipShort.getValue(bytes, offset); } @@ -80,7 +80,7 @@ public final class ZipShort implements Cloneable { */ public static void putShort(int value, byte[] buf, int offset) { buf[offset] = (byte) (value & BYTE_MASK); - buf[offset+1] = (byte) ((value & BYTE_1_MASK) >> BYTE_1_SHIFT); + buf[offset + 1] = (byte) ((value & BYTE_1_MASK) >> BYTE_1_SHIFT); } /** diff --git a/src/main/org/apache/tools/zip/ZipUtil.java b/src/main/org/apache/tools/zip/ZipUtil.java index 9926a298c..ff35ca47c 100644 --- a/src/main/org/apache/tools/zip/ZipUtil.java +++ b/src/main/org/apache/tools/zip/ZipUtil.java @@ -76,7 +76,7 @@ public abstract class ZipUtil { int year = c.get(Calendar.YEAR); if (year < 1980) { - System.arraycopy(DOS_TIME_MIN, 0, buf, offset, DOS_TIME_MIN.length);// stop callers from changing the array + System.arraycopy(DOS_TIME_MIN, 0, buf, offset, DOS_TIME_MIN.length); // stop callers from changing the array return; } int month = c.get(Calendar.MONTH) + 1; diff --git a/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java b/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java index bddf729f5..a016d492f 100644 --- a/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java +++ b/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java @@ -70,7 +70,7 @@ public class AntClassLoaderTest { String extjarstring = buildRule.getProject().getProperty("ext.jar"); Path myPath = new Path(buildRule.getProject()); myPath.setLocation(new File(mainjarstring)); - buildRule.getProject().setUserProperty("build.sysclasspath","ignore"); + buildRule.getProject().setUserProperty("build.sysclasspath", "ignore"); loader = buildRule.getProject().createClassLoader(myPath); String path = loader.getClasspath(); assertEquals(mainjarstring + File.pathSeparator + extjarstring, path); @@ -82,7 +82,7 @@ public class AntClassLoaderTest { String extjarstring = buildRule.getProject().getProperty("ext.jar.nonascii"); Path myPath = new Path(buildRule.getProject()); myPath.setLocation(new File(mainjarstring)); - buildRule.getProject().setUserProperty("build.sysclasspath","ignore"); + buildRule.getProject().setUserProperty("build.sysclasspath", "ignore"); loader = buildRule.getProject().createClassLoader(myPath); String path = loader.getClasspath(); assertEquals(mainjarstring + File.pathSeparator + extjarstring, path); @@ -129,7 +129,7 @@ public class AntClassLoaderTest { buildRule.executeTarget("prepareGetPackageTest"); Path myPath = new Path(buildRule.getProject()); myPath.setLocation(new File(buildRule.getProject().getProperty("test.jar"))); - buildRule.getProject().setUserProperty("build.sysclasspath","ignore"); + buildRule.getProject().setUserProperty("build.sysclasspath", "ignore"); loader = buildRule.getProject().createClassLoader(myPath); assertNotNull("should find class", loader.findClass("org.example.Foo")); assertNotNull("should find package", @@ -142,7 +142,7 @@ public class AntClassLoaderTest { Path myPath = new Path(buildRule.getProject()); File testJar = new File(buildRule.getProject().getProperty("test.jar")); myPath.setLocation(testJar); - buildRule.getProject().setUserProperty("build.sysclasspath","ignore"); + buildRule.getProject().setUserProperty("build.sysclasspath", "ignore"); loader = buildRule.getProject().createClassLoader(myPath); Class foo = loader.findClass("org.example.Foo"); URL codeSourceLocation = @@ -158,7 +158,7 @@ public class AntClassLoaderTest { Path myPath = new Path(buildRule.getProject()); myPath.setLocation(jar); - buildRule.getProject().setUserProperty("build.sysclasspath","ignore"); + buildRule.getProject().setUserProperty("build.sysclasspath", "ignore"); loader = buildRule.getProject().createClassLoader(myPath); Class foo = loader.findClass("org.example.Foo"); @@ -182,7 +182,7 @@ public class AntClassLoaderTest { Path myPath = new Path(buildRule.getProject()); myPath.setLocation(jar); - buildRule.getProject().setUserProperty("build.sysclasspath","ignore"); + buildRule.getProject().setUserProperty("build.sysclasspath", "ignore"); loader = buildRule.getProject().createClassLoader(myPath); PrintStream sysErr = System.err; try { diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileRule.java b/src/tests/junit/org/apache/tools/ant/BuildFileRule.java index 2611cb241..c5a71c75a 100644 --- a/src/tests/junit/org/apache/tools/ant/BuildFileRule.java +++ b/src/tests/junit/org/apache/tools/ant/BuildFileRule.java @@ -222,7 +222,7 @@ public class BuildFileRule extends ExternalResource { } public void write(int b) { - buffer.append((char)b); + buffer.append((char) b); } } diff --git a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java index 681cef34d..e821bae6d 100644 --- a/src/tests/junit/org/apache/tools/ant/BuildFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/BuildFileTest.java @@ -400,7 +400,7 @@ public abstract class BuildFileTest extends TestCase { public void expectSpecificBuildException(String target, String cause, String msg) { try { executeTarget(target); - } catch (org.apache.tools.ant.BuildException ex) { + } catch (BuildException ex) { buildException = ex; if ((null != msg) && (!ex.getMessage().equals(msg))) { fail("Should throw BuildException because '" + cause @@ -453,7 +453,7 @@ public abstract class BuildFileTest extends TestCase { */ public void assertPropertyEquals(String property, String value) { String result = project.getProperty(property); - assertEquals("property " + property,value,result); + assertEquals("property " + property, value, result); } /** @@ -461,7 +461,7 @@ public abstract class BuildFileTest extends TestCase { * * @param property property name */ - public void assertPropertySet(String property) { + public void assertPropertySet(String property) { assertPropertyEquals(property, "true"); } @@ -484,7 +484,7 @@ public abstract class BuildFileTest extends TestCase { * @param target build file target * @param property property name */ - public void expectPropertySet(String target, String property) { + public void expectPropertySet(String target, String property) { expectPropertySet(target, property, "true"); } @@ -494,7 +494,7 @@ public abstract class BuildFileTest extends TestCase { * @param target build file target * @param property property name */ - public void expectPropertyUnset(String target, String property) { + public void expectPropertyUnset(String target, String property) { expectPropertySet(target, property, null); } @@ -523,7 +523,7 @@ public abstract class BuildFileTest extends TestCase { } public void write(int b) { - buffer.append((char)b); + buffer.append((char) b); } } diff --git a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java index 3691d9417..819d4e50e 100644 --- a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java +++ b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java @@ -104,7 +104,7 @@ public class DirectoryScannerTest { ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); ds.scan(); compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); + new String[] {}); } @Test @@ -114,9 +114,8 @@ public class DirectoryScannerTest { ds.setIncludes(new String[] {"ALPHA/"}); ds.setCaseSensitive(false); ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); + compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}, + new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); } @Test @@ -130,14 +129,13 @@ public class DirectoryScannerTest { ds.setIncludes(new String[] {"alpha/beta/gamma/"}); ds.scan(); compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha/beta/gamma"}); + new String[] {"alpha/beta/gamma"}); } @Test public void testProhibitSymlinks() { assumeTrue("Current system does not support Symlinks", supportsSymlinks); - buildRule.getProject().executeTarget("symlink-setup"); DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); @@ -150,9 +148,9 @@ public class DirectoryScannerTest { // father and child pattern test @Test public void testOrderOfIncludePatternsIrrelevant() { - String [] expectedFiles = {"alpha/beta/beta.xml", + String[] expectedFiles = {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}; - String [] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" }; + String[] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" }; DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); ds.setIncludes(new String[] {"alpha/be?a/**", "alpha/beta/gamma/"}); @@ -172,9 +170,8 @@ public class DirectoryScannerTest { ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); ds.setIncludes(new String[] {"alpha/", "ALPHA/"}); ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); + compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}, + new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); } @Test @@ -184,36 +181,27 @@ public class DirectoryScannerTest { ds.setIncludes(new String[] {"alpha/", "ALPHA/"}); ds.setCaseSensitive(false); ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); + compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}, + new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); } @Test public void testFullpathDiffersInCaseScanningSensitive() { DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); - ds.setIncludes(new String[] { - "alpha/beta/gamma/gamma.xml", - "alpha/beta/gamma/GAMMA.XML" - }); + ds.setIncludes(new String[] {"alpha/beta/gamma/gamma.xml", "alpha/beta/gamma/GAMMA.XML"}); ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); + compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {}); } @Test public void testFullpathDiffersInCaseScanningInsensitive() { DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); - ds.setIncludes(new String[] { - "alpha/beta/gamma/gamma.xml", - "alpha/beta/gamma/GAMMA.XML" - }); + ds.setIncludes(new String[] {"alpha/beta/gamma/gamma.xml", "alpha/beta/gamma/GAMMA.XML"}); ds.setCaseSensitive(false); ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); + compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, new String[] {}); } @Test @@ -222,9 +210,8 @@ public class DirectoryScannerTest { ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"}); ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); + compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}, + new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); } @Test @@ -234,9 +221,8 @@ public class DirectoryScannerTest { ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"}); ds.setCaseSensitive(false); ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); + compareFiles(ds, new String[] {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}, + new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); } /** @@ -254,13 +240,10 @@ public class DirectoryScannerTest { try { // add conditions and more commands as soon as the need arises - String[] command = new String[] { - "ln", "-s", "ant", linkFile.getAbsolutePath() - }; + String[] command = new String[] {"ln", "-s", "ant", linkFile.getAbsolutePath()}; Process process = Runtime.getRuntime().exec(command); assertEquals("0 return code expected for external process", 0, process.waitFor()); - File dir = new File(System.getProperty("root"), "src/main/org/apache/tools"); DirectoryScanner ds = new DirectoryScanner(); @@ -280,9 +263,7 @@ public class DirectoryScannerTest { for (String included : includeds) { if (included.equals("zip")) { haveZipPackage = true; - } else if (included.equals("ThisIsALink" - + File.separator - + "taskdefs")) { + } else if (included.equals("ThisIsALink" + File.separator + "taskdefs")) { haveTaskdefsPackage = true; } } @@ -306,9 +287,7 @@ public class DirectoryScannerTest { for (String included : includeds) { if (included.equals("zip")) { haveZipPackage = true; - } else if (included.equals("ThisIsALink" - + File.separator - + "taskdefs")) { + } else if (included.equals("ThisIsALink" + File.separator + "taskdefs")) { haveTaskdefsPackage = true; } } @@ -329,65 +308,44 @@ public class DirectoryScannerTest { public void testExcludeOneFile() { DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); - ds.setIncludes(new String[] { - "**/*.xml" - }); - ds.setExcludes(new String[] { - "alpha/beta/b*xml" - }); + ds.setIncludes(new String[] {"**/*.xml"}); + ds.setExcludes(new String[] {"alpha/beta/b*xml"}); ds.scan(); compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); + new String[] {}); } @Test public void testExcludeHasPrecedence() { DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); - ds.setIncludes(new String[] { - "alpha/**" - }); - ds.setExcludes(new String[] { - "alpha/**" - }); + ds.setIncludes(new String[] {"alpha/**"}); + ds.setExcludes(new String[] {"alpha/**"}); ds.scan(); compareFiles(ds, new String[] {}, - new String[] {}); - + new String[] {}); } @Test public void testAlternateIncludeExclude() { DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); - ds.setIncludes(new String[] { - "alpha/**", - "alpha/beta/gamma/**" - }); - ds.setExcludes(new String[] { - "alpha/beta/**" - }); + ds.setIncludes(new String[] {"alpha/**", "alpha/beta/gamma/**"}); + ds.setExcludes(new String[] {"alpha/beta/**"}); ds.scan(); compareFiles(ds, new String[] {}, - new String[] {"alpha"}); - + new String[] {"alpha"}); } @Test public void testAlternateExcludeInclude() { DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); - ds.setExcludes(new String[] { - "alpha/**", - "alpha/beta/gamma/**" - }); - ds.setIncludes(new String[] { - "alpha/beta/**" - }); + ds.setExcludes(new String[] {"alpha/**", "alpha/beta/gamma/**"}); + ds.setIncludes(new String[] {"alpha/beta/**"}); ds.scan(); compareFiles(ds, new String[] {}, - new String[] {}); - + new String[] {}); } /** @@ -424,9 +382,9 @@ public class DirectoryScannerTest { // a sysproperty with name tests.and.ant.share.classloader and value // ${tests.and.ant.share.classloader} will be set // we are trying to catch this here. - assumeFalse("cannot execute testIsExcludedDirectoryScanned when tests are forked, " + - "package private method called", shareclassloader == null - || (shareclassloader != null && shareclassloader.indexOf("${") == 0)); + assumeFalse("cannot execute testIsExcludedDirectoryScanned when tests are forked, " + + "package private method called", shareclassloader == null + || shareclassloader.indexOf("${") == 0); buildRule.getProject().executeTarget("children-of-excluded-dir-setup"); DirectoryScanner ds = new DirectoryScanner(); ds.setBasedir(new File(buildRule.getProject().getProperty("output"))); @@ -448,13 +406,14 @@ public class DirectoryScannerTest { File.separatorChar, '/'); ds.setIncludes(new String[] {tmpdir + "/**/*"}); ds.scan(); - compareFiles(ds, new String[] {tmpdir + "/alpha/beta/beta.xml", - tmpdir + "/alpha/beta/gamma/gamma.xml", - tmpdir + "/delta/delta.xml"}, - new String[] {tmpdir + "/alpha", - tmpdir + "/alpha/beta", - tmpdir + "/alpha/beta/gamma", - tmpdir + "/delta"}); + compareFiles(ds, + new String[] {tmpdir + "/alpha/beta/beta.xml", + tmpdir + "/alpha/beta/gamma/gamma.xml", + tmpdir + "/delta/delta.xml"}, + new String[] {tmpdir + "/alpha", + tmpdir + "/alpha/beta", + tmpdir + "/alpha/beta/gamma", + tmpdir + "/delta"}); } @Test @@ -473,14 +432,14 @@ public class DirectoryScannerTest { String tmpdir = buildRule.getProject().getProperty("output").replace( File.separatorChar, '/'); ds.setIncludes(new String[] {tmpdir + "/**/*"}); - ds.setExcludes(new String[] {"**/alpha", - "**/delta/*"}); + ds.setExcludes(new String[] {"**/alpha", "**/delta/*"}); ds.scan(); - compareFiles(ds, new String[] {tmpdir + "/alpha/beta/beta.xml", - tmpdir + "/alpha/beta/gamma/gamma.xml"}, - new String[] {tmpdir + "/alpha/beta", - tmpdir + "/alpha/beta/gamma", - tmpdir + "/delta"}); + compareFiles(ds, + new String[] {tmpdir + "/alpha/beta/beta.xml", + tmpdir + "/alpha/beta/gamma/gamma.xml"}, + new String[] {tmpdir + "/alpha/beta", + tmpdir + "/alpha/beta/gamma", + tmpdir + "/delta"}); } @Test @@ -489,19 +448,20 @@ public class DirectoryScannerTest { DirectoryScanner ds = new DirectoryScanner(); String tmpdir = buildRule.getProject().getProperty("output").replace( File.separatorChar, '/'); - ds.setIncludes(new String[] {tmpdir + "/alpha/beta/**/*", - tmpdir + "/delta/*"}); + ds.setIncludes(new String[] {tmpdir + "/alpha/beta/**/*", tmpdir + "/delta/*"}); ds.setExcludes(new String[] {"**/beta.xml"}); ds.scan(); - compareFiles(ds, new String[] {tmpdir + "/alpha/beta/gamma/gamma.xml", - tmpdir + "/delta/delta.xml"}, - new String[] {tmpdir + "/alpha/beta/gamma"}); + compareFiles(ds, + new String[] {tmpdir + "/alpha/beta/gamma/gamma.xml", + tmpdir + "/delta/delta.xml"}, + new String[] {tmpdir + "/alpha/beta/gamma"}); } @Test public void testAbsolute5() { //testing drive letter search from root: - assumeTrue("Can't use drive letters on non DOS or Netware systems", (Os.isFamily("dos") || Os.isFamily("netware"))); + assumeTrue("Can't use drive letters on non DOS or Netware systems", + Os.isFamily("dos") || Os.isFamily("netware")); DirectoryScanner ds = new DirectoryScanner(); String pattern = new File(File.separator).getAbsolutePath().toUpperCase() + "*"; ds.setIncludes(new String[] {pattern}); @@ -526,8 +486,7 @@ public class DirectoryScannerTest { } TreeSet directories = new TreeSet(); for (String includedDirectory : includedDirectories) { - directories.add(includedDirectory - .replace(File.separatorChar, '/')); + directories.add(includedDirectory.replace(File.separatorChar, '/')); } String currentfile; @@ -556,19 +515,16 @@ public class DirectoryScannerTest { ds.scan(); List dirs = Arrays.asList(ds.getExcludedDirectories()); assertEquals(2, dirs.size()); - assertTrue("beta is excluded", - dirs.contains("alpha/beta".replace('/', File.separatorChar))); - assertTrue("gamma is excluded", - dirs.contains("alpha/beta/gamma".replace('/', - File.separatorChar))); + assertTrue("beta is excluded", dirs.contains("alpha/beta" + .replace('/', File.separatorChar))); + assertTrue("gamma is excluded", dirs.contains("alpha/beta/gamma" + .replace('/', File.separatorChar))); List files = Arrays.asList(ds.getExcludedFiles()); assertEquals(2, files.size()); - assertTrue("beta.xml is excluded", - files.contains("alpha/beta/beta.xml" - .replace('/', File.separatorChar))); - assertTrue("gamma.xml is excluded", - files.contains("alpha/beta/gamma/gamma.xml" - .replace('/', File.separatorChar))); + assertTrue("beta.xml is excluded", files.contains("alpha/beta/beta.xml" + .replace('/', File.separatorChar))); + assertTrue("gamma.xml is excluded", files.contains("alpha/beta/gamma/gamma.xml" + .replace('/', File.separatorChar))); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/FileUtilities.java b/src/tests/junit/org/apache/tools/ant/FileUtilities.java index 79b57168f..321d8d445 100644 --- a/src/tests/junit/org/apache/tools/ant/FileUtilities.java +++ b/src/tests/junit/org/apache/tools/ant/FileUtilities.java @@ -70,7 +70,7 @@ public class FileUtilities { return; } - assumeTrue(file.setLastModified(file.lastModified() - (seconds * 1000))); + assumeTrue(file.setLastModified(file.lastModified() - seconds * 1000)); if (file.isDirectory()) { File[] children = file.listFiles(); diff --git a/src/tests/junit/org/apache/tools/ant/ImmutableTest.java b/src/tests/junit/org/apache/tools/ant/ImmutableTest.java index 933bd28c4..eb8c4cc8f 100644 --- a/src/tests/junit/org/apache/tools/ant/ImmutableTest.java +++ b/src/tests/junit/org/apache/tools/ant/ImmutableTest.java @@ -41,7 +41,7 @@ public class ImmutableTest { @Test public void test1() { buildRule.executeTarget("test1"); - assertEquals("override",buildRule.getProject().getProperty("test")); + assertEquals("override", buildRule.getProject().getProperty("test")); } // ensure 's new prefix attribute is working diff --git a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java index 157438e8d..34cd928b0 100644 --- a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java +++ b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java @@ -551,11 +551,11 @@ public class IntrospectionHelperTest { assertAttrMethod("sixteen", "setSixteen", Character.class, new Character('a'), new Character('b')); assertAttrMethod("seventeen", "setSeventeen", Byte.TYPE, - new Byte((byte)17), new Byte((byte)10)); + new Byte((byte) 17), new Byte((byte) 10)); assertAttrMethod("eightteen", "setEightteen", Short.TYPE, - new Short((short)18), new Short((short)10)); + new Short((short) 18), new Short((short) 10)); assertAttrMethod("nineteen", "setNineteen", Double.TYPE, - new Double(19), new Double((short)10)); + new Double(19), new Double((short) 10)); try { assertAttrMethod("onehundred", null, null, null, null); diff --git a/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java b/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java index 601391e49..c943d3e84 100644 --- a/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java +++ b/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java @@ -47,17 +47,17 @@ public class PropertyExpansionTest { */ @Test public void testPropertyExpansion() { - assertExpandsTo("",""); - assertExpandsTo("$","$"); - assertExpandsTo("$$-","$-"); - assertExpandsTo("$$","$"); - buildRule.getProject().setProperty("expanded","EXPANDED"); - assertExpandsTo("a${expanded}b","aEXPANDEDb"); - assertExpandsTo("${expanded}${expanded}","EXPANDEDEXPANDED"); - assertExpandsTo("$$$","$$"); - assertExpandsTo("$$$$-","$$-"); - assertExpandsTo("",""); - assertExpandsTo("Class$$subclass","Class$subclass"); + assertExpandsTo("", ""); + assertExpandsTo("$", "$"); + assertExpandsTo("$$-", "$-"); + assertExpandsTo("$$", "$"); + buildRule.getProject().setProperty("expanded", "EXPANDED"); + assertExpandsTo("a${expanded}b", "aEXPANDEDb"); + assertExpandsTo("${expanded}${expanded}", "EXPANDEDEXPANDED"); + assertExpandsTo("$$$", "$$"); + assertExpandsTo("$$$$-", "$$-"); + assertExpandsTo("", ""); + assertExpandsTo("Class$$subclass", "Class$subclass"); } /** @@ -65,13 +65,13 @@ public class PropertyExpansionTest { */ @Test public void testDollarPassthru() { - assertExpandsTo("$-","$-"); - assertExpandsTo("Class$subclass","Class$subclass"); - assertExpandsTo("$$$-","$$-"); - assertExpandsTo("$$$$$","$$$"); - assertExpandsTo("${unassigned.property}","${unassigned.property}"); - assertExpandsTo("a$b","a$b"); - assertExpandsTo("$}}","$}}"); + assertExpandsTo("$-", "$-"); + assertExpandsTo("Class$subclass", "Class$subclass"); + assertExpandsTo("$$$-", "$$-"); + assertExpandsTo("$$$$$", "$$$"); + assertExpandsTo("${unassigned.property}", "${unassigned.property}"); + assertExpandsTo("a$b", "a$b"); + assertExpandsTo("$}}", "$}}"); } @@ -81,10 +81,10 @@ public class PropertyExpansionTest { @Test @Ignore("Previously disabled through naming convention") public void oldtestQuirkyLegacyBehavior() { - assertExpandsTo("Class$subclass","Classsubclass"); - assertExpandsTo("$$$-","$-"); - assertExpandsTo("a$b","ab"); - assertExpandsTo("$}}","}}"); + assertExpandsTo("Class$subclass", "Classsubclass"); + assertExpandsTo("$$$-", "$-"); + assertExpandsTo("a$b", "ab"); + assertExpandsTo("$}}", "}}"); } /** diff --git a/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java b/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java index 38835c4ab..b07abe0d5 100644 --- a/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java +++ b/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java @@ -265,10 +265,10 @@ public class TokenFilterTest { public static class Capitalize implements TokenFilter.Filter { public String filter(String token) { - if (token.length() == 0) + if (token.length() == 0) { return token; - return token.substring(0, 1).toUpperCase() + - token.substring(1); + } + return token.substring(0, 1).toUpperCase() + token.substring(1); } } diff --git a/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java b/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java index 318458921..b8dffae6a 100644 --- a/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java +++ b/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java @@ -33,8 +33,8 @@ public class LocatorTest { private boolean windows; private boolean unix; private static final String LAUNCHER_JAR = "//morzine/slo/Java/Apache/ant/lib/ant-launcher.jar"; - private static final String SHARED_JAR_URI = "jar:file:" + LAUNCHER_JAR + - "!/org/apache/tools/ant/launch/Launcher.class"; + private static final String SHARED_JAR_URI = "jar:file:" + LAUNCHER_JAR + + "!/org/apache/tools/ant/launch/Launcher.class"; @Before diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java index 1d7c25250..d3bb33cc7 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java @@ -126,9 +126,7 @@ public class AntTest { File dir1 = buildRule.getProject().getBaseDir(); File dir2 = buildRule.getProject().resolveFile(".."); testBaseDirs("explicitBasedir1", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath() - }); + new String[] {dir1.getAbsolutePath(), dir2.getAbsolutePath()}); } @Test @@ -136,9 +134,7 @@ public class AntTest { File dir1 = buildRule.getProject().getBaseDir(); File dir2 = buildRule.getProject().resolveFile(".."); testBaseDirs("explicitBasedir2", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath() - }); + new String[] {dir1.getAbsolutePath(), dir2.getAbsolutePath()}); } @Test @@ -152,9 +148,7 @@ public class AntTest { File dir1 = buildRule.getProject().getBaseDir(); File dir2 = buildRule.getProject().resolveFile("ant"); testBaseDirs("doNotInheritBasedir", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath() - }); + new String[] {dir1.getAbsolutePath(), dir2.getAbsolutePath()}); } @Test @@ -162,10 +156,7 @@ public class AntTest { File dir1 = buildRule.getProject().getBaseDir(); File dir2 = buildRule.getProject().resolveFile("ant"); testBaseDirs("tripleCall", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath(), - dir1.getAbsolutePath() - }); + new String[] {dir1.getAbsolutePath(), dir2.getAbsolutePath(), dir1.getAbsolutePath()}); } protected void testBaseDirs(String target, String[] dirs) { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java b/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java index b85af3fe3..d080fae63 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java @@ -20,7 +20,6 @@ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.BuildFileRule; import org.apache.tools.bzip2.CBZip2InputStream; -import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java index faa830fb0..d44f51450 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java @@ -57,7 +57,7 @@ public class ExecTaskTest { private File logFile; private MonitoredBuild myBuild = null; - volatile private boolean buildFinished = false; + private volatile boolean buildFinished = false; @Before diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java index 9e87af084..06beab434 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java @@ -35,10 +35,9 @@ import static org.junit.Assert.assertTrue; */ public class ExecuteJavaTest { - private final static int TIME_OUT = 5000; - - private final static int CLOCK_ERROR = 200; - private final static int TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; + private static final int TIME_OUT = 5000; + private static final int CLOCK_ERROR = 200; + private static final int TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; private ExecuteJava ej; private Project project; @@ -47,7 +46,7 @@ public class ExecuteJavaTest { @Before public void setUp() { ej = new ExecuteJava(); - ej.setTimeout((long)TIME_OUT); + ej.setTimeout((long) TIME_OUT); project = new Project(); project.setBasedir("."); project.setProperty(MagicNames.ANT_HOME, System.getProperty(MagicNames.ANT_HOME)); @@ -121,7 +120,7 @@ public class ExecuteJavaTest { private static String getTestClassPath() { String classpath = System.getProperty("build.tests"); if (classpath == null) { - System.err.println("WARNING: 'build.tests' property is not available !"); + System.err.println("WARNING: 'build.tests' property is not available!"); classpath = System.getProperty("java.class.path"); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java index f23ea3bcf..b557e7670 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java @@ -36,12 +36,11 @@ import static org.junit.Assert.assertTrue; */ public class ExecuteWatchdogTest { - private final static long TIME_OUT = 5000; + private static final String TEST_CLASSPATH = getTestClassPath(); - private final static String TEST_CLASSPATH = getTestClassPath(); - - private final static int CLOCK_ERROR = 200; - private final static long TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; + private static final long TIME_OUT = 5000; + private static final int CLOCK_ERROR = 200; + private static final long TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; private ExecuteWatchdog watchdog; @@ -57,7 +56,7 @@ public class ExecuteWatchdogTest { private static String getTestClassPath() { String classpath = System.getProperty("build.tests"); if (classpath == null) { - System.err.println("WARNING: 'build.tests' property is not available !"); + System.err.println("WARNING: 'build.tests' property is not available!"); classpath = System.getProperty("java.class.path"); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java index 0a26606d6..3b916b6d1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java @@ -54,7 +54,8 @@ public class JarTest { private static String tempJar = "tmp.jar"; private static String tempDir = "jartmp/"; - private Reader r1, r2; + private Reader r1; + private Reader r2; @Before diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java index ea1bdbfee..5579f85d5 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java @@ -41,7 +41,6 @@ import org.junit.Test; import org.junit.internal.AssumptionViolatedException; import static org.apache.tools.ant.AntAssert.assertContains; -import org.apache.tools.ant.types.Path; import org.junit.Assert; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -498,7 +497,7 @@ public class JavaTest { * test class for spawn */ public static class SpawnEntryPoint { - public static void main(String [] argv) throws InterruptedException { + public static void main(String[] argv) throws InterruptedException { int sleepTime = 10; String logFile = "spawn.log"; if (argv.length >= 1) { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java index 7f78b7b4f..cfdbf1126 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java @@ -106,30 +106,30 @@ public class ManifestClassPathTest { public void testParentLevel1() { buildRule.executeTarget("test-parent-level1"); - assertEquals(buildRule.getProject().getProperty("jar.classpath"), "dsp-core/ " + - "dsp-pres/ " + - "dsp-void/ " + - "../generated/dsp-core/ " + - "../generated/dsp-pres/ " + - "../generated/dsp-void/ " + - "../resources/dsp-core/ " + - "../resources/dsp-pres/ " + - "../resources/dsp-void/"); + assertEquals(buildRule.getProject().getProperty("jar.classpath"), "dsp-core/ " + + "dsp-pres/ " + + "dsp-void/ " + + "../generated/dsp-core/ " + + "../generated/dsp-pres/ " + + "../generated/dsp-void/ " + + "../resources/dsp-core/ " + + "../resources/dsp-pres/ " + + "../resources/dsp-void/"); } @Test public void testParentLevel2() { buildRule.executeTarget("test-parent-level2"); - assertEquals(buildRule.getProject().getProperty("jar.classpath"), "../dsp-core/ " + - "../dsp-pres/ " + - "../dsp-void/ " + - "../../generated/dsp-core/ " + - "../../generated/dsp-pres/ " + - "../../generated/dsp-void/ " + - "../../resources/dsp-core/ " + - "../../resources/dsp-pres/ " + - "../../resources/dsp-void/"); + assertEquals(buildRule.getProject().getProperty("jar.classpath"), "../dsp-core/ " + + "../dsp-pres/ " + + "../dsp-void/ " + + "../../generated/dsp-core/ " + + "../../generated/dsp-pres/ " + + "../../generated/dsp-void/ " + + "../../resources/dsp-core/ " + + "../../resources/dsp-pres/ " + + "../../resources/dsp-void/"); } @Test @@ -148,12 +148,12 @@ public class ManifestClassPathTest { Assume.assumeTrue("No regexp matcher is present", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); buildRule.executeTarget("test-pseudo-tahoe-refid"); - assertEquals(buildRule.getProject().getProperty("jar.classpath"), "classes/dsp-core/ " + - "classes/dsp-pres/ " + - "classes/dsp-void/ " + - "generated/dsp-core/ " + - "resources/dsp-core/ " + - "resources/dsp-pres/"); + assertEquals(buildRule.getProject().getProperty("jar.classpath"), "classes/dsp-core/ " + + "classes/dsp-pres/ " + + "classes/dsp-void/ " + + "generated/dsp-core/ " + + "resources/dsp-core/ " + + "resources/dsp-pres/"); } @Test @@ -161,29 +161,29 @@ public class ManifestClassPathTest { Assume.assumeTrue("No regexp matcher is present", RegexpMatcherFactory.regexpMatcherPresent(buildRule.getProject())); buildRule.executeTarget("test-pseudo-tahoe-nested"); - assertEquals(buildRule.getProject().getProperty("jar.classpath"), "classes/dsp-core/ " + - "classes/dsp-pres/ " + - "classes/dsp-void/ " + - "generated/dsp-core/ " + - "resources/dsp-core/ " + - "resources/dsp-pres/"); + assertEquals(buildRule.getProject().getProperty("jar.classpath"), "classes/dsp-core/ " + + "classes/dsp-pres/ " + + "classes/dsp-void/ " + + "generated/dsp-core/ " + + "resources/dsp-core/ " + + "resources/dsp-pres/"); } @Test public void testParentLevel2WithJars() { buildRule.executeTarget("test-parent-level2-with-jars"); - assertEquals(buildRule.getProject().getProperty("jar.classpath"), "../../lib/acme-core.jar " + - "../../lib/acme-pres.jar " + - "../dsp-core/ " + - "../dsp-pres/ " + - "../dsp-void/ " + - "../../generated/dsp-core/ " + - "../../generated/dsp-pres/ " + - "../../generated/dsp-void/ " + - "../../resources/dsp-core/ " + - "../../resources/dsp-pres/ " + - "../../resources/dsp-void/"); + assertEquals(buildRule.getProject().getProperty("jar.classpath"), "../../lib/acme-core.jar " + + "../../lib/acme-pres.jar " + + "../dsp-core/ " + + "../dsp-pres/ " + + "../dsp-void/ " + + "../../generated/dsp-core/ " + + "../../generated/dsp-pres/ " + + "../../generated/dsp-void/ " + + "../../resources/dsp-core/ " + + "../../resources/dsp-pres/ " + + "../../resources/dsp-void/"); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java index e5a1aa700..ca1a94d8f 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java @@ -301,14 +301,14 @@ public class ManifestTest { fin.close(); } - assertTrue("Manifest file should have contained string ", set - .remove(" NOT_LONG")); - assertTrue("Manifest file should have contained string ", set - .remove(" NG")); - assertTrue("Manifest file should have contained string ", set - .remove(LONG_70_NAME + ": ")); - assertTrue("Manifest file should have contained string ", set - .remove(NOT_LONG_NAME + ": NOT_LO")); + assertTrue("Manifest file should have contained string ", + set.remove(" NOT_LONG")); + assertTrue("Manifest file should have contained string ", + set.remove(" NG")); + assertTrue("Manifest file should have contained string ", + set.remove(LONG_70_NAME + ": ")); + assertTrue("Manifest file should have contained string ", + set.remove(NOT_LONG_NAME + ": NOT_LO")); } /** @@ -320,15 +320,15 @@ public class ManifestTest { Manifest manifest = getManifest(expandedManifest); Enumeration e = manifest.getSectionNames(); - String section1 = (String)e.nextElement(); - String section2 = (String)e.nextElement(); + String section1 = (String) e.nextElement(); + String section2 = (String) e.nextElement(); assertEquals("First section name unexpected", "Test1", section1); assertEquals("Second section name unexpected", "Test2", section2); Manifest.Section section = manifest.getSection("Test1"); e = section.getAttributeKeys(); - String attr1Key = (String)e.nextElement(); - String attr2Key = (String)e.nextElement(); + String attr1Key = (String) e.nextElement(); + String attr2Key = (String) e.nextElement(); String attr1 = section.getAttribute(attr1Key).getName(); String attr2 = section.getAttribute(attr2Key).getName(); assertEquals("First attribute name unexpected", "TestAttr1", attr1); @@ -344,15 +344,15 @@ public class ManifestTest { Manifest manifest = getManifest(expandedManifest); Enumeration e = manifest.getSectionNames(); - String section1 = (String)e.nextElement(); - String section2 = (String)e.nextElement(); + String section1 = (String) e.nextElement(); + String section2 = (String) e.nextElement(); assertEquals("First section name unexpected", "Test2", section1); assertEquals("Second section name unexpected", "Test1", section2); Manifest.Section section = manifest.getSection("Test1"); e = section.getAttributeKeys(); - String attr1Key = (String)e.nextElement(); - String attr2Key = (String)e.nextElement(); + String attr1Key = (String) e.nextElement(); + String attr2Key = (String) e.nextElement(); String attr1 = section.getAttribute(attr1Key).getName(); String attr2 = section.getAttribute(attr2Key).getName(); assertEquals("First attribute name unexpected", "TestAttr2", attr1); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java index 4f7a4d0e7..0da59783d 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java @@ -40,16 +40,14 @@ public class ParallelTest { public final BuildFileRule buildRule = new BuildFileRule(); /** Standard property value for the basic test */ - public final static String DIRECT_MESSAGE = "direct"; + public static final String DIRECT_MESSAGE = "direct"; /** Standard property value for the basic and fail test */ - public final static String DELAYED_MESSAGE = "delayed"; + public static final String DELAYED_MESSAGE = "delayed"; /** Standard property value for the fail test */ - public final static String FAILURE_MESSAGE = "failure"; + public static final String FAILURE_MESSAGE = "failure"; /** the build file associated with this test */ - public final static String TEST_BUILD_FILE - = "src/etc/testcases/taskdefs/parallel.xml"; - + public static final String TEST_BUILD_FILE = "src/etc/testcases/taskdefs/parallel.xml"; /** The JUnit setup method */ @Before diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java index 4e40c2861..4a9691eae 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java @@ -134,7 +134,7 @@ public class ReplaceTest { buildRule.executeTarget("lastModifiedSetup"); File testFile = new File(buildRule.getOutputDir(), "test.txt"); assumeTrue("Could not change file modification time", - testFile.setLastModified(testFile.lastModified() - (FileUtils.getFileUtils().getFileTimestampGranularity() * 5))); + testFile.setLastModified(testFile.lastModified() - FileUtils.getFileUtils().getFileTimestampGranularity() * 5)); long ts1 = testFile.lastModified(); buildRule.executeTarget("testNoPreserve"); assertTrue(ts1 < new File(buildRule.getOutputDir(), "test.txt").lastModified()); @@ -145,8 +145,9 @@ public class ReplaceTest { buildRule.executeTarget("lastModifiedSetup"); File testFile = new File(buildRule.getOutputDir(), "test.txt"); assumeTrue("Could not change file modification time", - testFile.setLastModified(testFile.lastModified() - (FileUtils.getFileUtils().getFileTimestampGranularity() * 5))); - long ts1 = testFile.lastModified();buildRule.executeTarget("testPreserve"); + testFile.setLastModified(testFile.lastModified() - FileUtils.getFileUtils().getFileTimestampGranularity() * 5)); + long ts1 = testFile.lastModified(); + buildRule.executeTarget("testPreserve"); assertTrue(ts1 == new File(buildRule.getOutputDir(), "test.txt").lastModified()); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java index 604e683dd..138712dbb 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java @@ -39,7 +39,7 @@ import static org.junit.Assert.fail; */ public class RmicAdvancedTest { - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/rmic/"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/rmic/"; @Rule public BuildFileRule buildRule = new BuildFileRule(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java index a8ef90c20..eb81857fe 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java @@ -88,7 +88,7 @@ public class RmicTest { // check defaults String compiler = rmic.getCompiler(); assertNotNull(compiler); - assertEquals("expected sun or kaffe, but found " + compiler, compiler,"default"); + assertEquals("expected sun or kaffe, but found " + compiler, compiler, "default"); project.setNewProperty("build.rmic", "weblogic"); compiler = rmic.getCompiler(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java index 979ec23d4..24b042d85 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java @@ -50,17 +50,17 @@ import static org.junit.Assert.fail; public class SQLExecTest { // some database keys, see #getProperties(int) - public final static int NULL = 0; - public final static int ORACLE = 1; - public final static int MYSQL = 2; + public static final int NULL = 0; + public static final int ORACLE = 1; + public static final int MYSQL = 2; // keys used in properties. - public final static String DRIVER = "driver"; - public final static String USER = "user"; - public final static String PASSWORD = "password"; - public final static String URL = "url"; - public final static String PATH = "path"; - public final static String SQL = "sql"; + public static final String DRIVER = "driver"; + public static final String USER = "user"; + public static final String PASSWORD = "password"; + public static final String URL = "url"; + public static final String PATH = "path"; + public static final String SQL = "sql"; @Before public void setUp() throws Exception { @@ -223,7 +223,7 @@ public class SQLExecTest { //--- NULL JDBC driver just for simple test since there are no db driver // available as a default in Ant :) - public final static String NULL_DRIVER = NullDriver.class.getName(); + public static final String NULL_DRIVER = NullDriver.class.getName(); public static class NullDriver implements Driver { public Connection connect(String url, Properties info) @@ -326,8 +326,7 @@ public class SQLExecTest { assertEquals(0, s.lastDelimiterPosition(new StringBuffer("; "), "; ")); assertEquals(1, s.lastDelimiterPosition(new StringBuffer("ab"), ";")); s.setDelimiter("GO"); - assertEquals(1, - s.lastDelimiterPosition(new StringBuffer("abcd"), "GO ")); + assertEquals(1, s.lastDelimiterPosition(new StringBuffer("abcd"), "GO ")); assertEquals(0, s.lastDelimiterPosition(new StringBuffer("go"), "go")); assertEquals(0, s.lastDelimiterPosition(new StringBuffer("ab"), "GO")); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java index e9db64be2..3d6ce87cf 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java @@ -32,8 +32,8 @@ public class SleepTest { @Rule public final BuildFileRule buildRule = new BuildFileRule(); - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/"; - private final static int ERROR_RANGE = 1000; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/"; + private static final int ERROR_RANGE = 1000; @Before public void setUp() { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java index a45a0984f..9fd4667fb 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java @@ -156,40 +156,55 @@ public class StyleTest { @Test public void testWithFileResource() throws Exception { - expectFileContains("testWithFileResource", buildRule.getOutputDir().getAbsoluteFile() + "/out.xml", "set='value'"); + expectFileContains("testWithFileResource", buildRule.getOutputDir().getAbsoluteFile() + + "/out.xml", "set='value'"); } @Test public void testWithUrlResource() throws Exception { - expectFileContains("testWithUrlResource", buildRule.getOutputDir().getAbsoluteFile() + "/out.xml", "set='value'"); + expectFileContains("testWithUrlResource", buildRule.getOutputDir().getAbsoluteFile() + + "/out.xml", "set='value'"); } @Test public void testFilenameAsParam() throws Exception { buildRule.executeTarget("testFilenameAsParam"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", "filename='one.xml'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/two.txt", "filename='two.xml'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/three.txt", "filename='three.xml'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='four.xml'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filedir ='-not-set-'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", + "filename='one.xml'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/two.txt", + "filename='two.xml'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/three.txt", + "filename='three.xml'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", + "filename='four.xml'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", + "filedir ='-not-set-'"); } @Test public void testFilenameAsParamNoSetting() throws Exception { buildRule.executeTarget("testFilenameAsParamNoSetting"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", "filename='-not-set-'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/two.txt", "filename='-not-set-'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/three.txt", "filename='-not-set-'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='-not-set-'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", + "filename='-not-set-'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/two.txt", + "filename='-not-set-'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/three.txt", + "filename='-not-set-'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", + "filename='-not-set-'"); } @Test public void testFilenameAndFiledirAsParam() throws Exception { buildRule.executeTarget("testFilenameAndFiledirAsParam"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", "filename='one.xml'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", "filedir ='.'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filename='four.xml'"); - assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", "filedir ='dir'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", + "filename='one.xml'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/one.txt", + "filedir ='.'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", + "filename='four.xml'"); + assertFileContains(buildRule.getOutputDir().getAbsoluteFile() + "/dir/four.txt", + "filedir ='dir'"); } @@ -205,8 +220,7 @@ public class StyleTest { return FileUtilities.getFileContents(new File(filename)); } - private void expectFileContains( - String target, String filename, String contains) + private void expectFileContains(String target, String filename, String contains) throws IOException { buildRule.executeTarget(target); assertFileContains(filename, contains); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java index 7489015f3..0a7321fad 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java @@ -48,7 +48,7 @@ public class SubAntTest { @Test public void testnodirs() { buildRule.executeTarget("testnodirs"); - assertEquals("No sub-builds to iterate on",buildRule.getLog()); + assertEquals("No sub-builds to iterate on", buildRule.getLog()); } // target must be specified @@ -59,11 +59,9 @@ public class SubAntTest { File dir3 = buildRule.getProject().resolveFile("subant/subant-test2"); testBaseDirs("testgenericantfile", - new String[] { dir1.getAbsolutePath(), - dir2.getAbsolutePath(), - dir3.getAbsolutePath() - - }); + new String[] {dir1.getAbsolutePath(), + dir2.getAbsolutePath(), + dir3.getAbsolutePath()}); } @Test @@ -77,11 +75,9 @@ public class SubAntTest { File dir3 = buildRule.getProject().resolveFile("subant"); testBaseDirs("testantfile", - new String[] { dir1.getAbsolutePath(), - dir2.getAbsolutePath(), - dir3.getAbsolutePath() - - }); + new String[] {dir1.getAbsolutePath(), + dir2.getAbsolutePath(), + dir3.getAbsolutePath()}); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java index fe6902f28..0f901462c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java @@ -97,7 +97,7 @@ public class TouchTest { long now = System.currentTimeMillis(); buildRule.executeTarget("testNow"); long time = getTargetTime(); - assertTimesNearlyMatch(time,now,5000); + assertTimesNearlyMatch(time, now, 5000); } /** * verify that the millis test sets things up diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java index bf8f28d30..aac89aee4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java @@ -124,16 +124,14 @@ public class TypeAdapterTest { try { Method execMethod = proxyClass.getMethod(execMethodName); if (!Void.TYPE.equals(execMethod.getReturnType())) { - String message = - "return type of " + execMethodName + "() should be " - + "void but was \"" + execMethod.getReturnType() + - "\" in " + proxyClass; + String message = "return type of " + execMethodName + "() should be " + + "void but was \"" + execMethod.getReturnType() + + "\" in " + proxyClass; log(message, Project.MSG_WARN); } return execMethod; } catch (NoSuchMethodException e) { - String message = "No public " + execMethodName + "() method in " - + proxyClass; + String message = "No public " + execMethodName + "() method in " + proxyClass; log(message, Project.MSG_ERR); throw new BuildException(message); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java index 661d6e984..55d4c8b8f 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java @@ -107,8 +107,10 @@ public class UnzipTest { @Test public void testPatternSetExcludeOnly() { buildRule.executeTarget("testPatternSetExcludeOnly"); - assertFileMissing("1/foo is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileExists("2/bar is not excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); + assertFileMissing("1/foo is excluded", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileExists("2/bar is not excluded", + buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); } /* @@ -117,8 +119,10 @@ public class UnzipTest { @Test public void testPatternSetIncludeOnly() { buildRule.executeTarget("testPatternSetIncludeOnly"); - assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileExists("2/bar is included", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); + assertFileMissing("1/foo is not included", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileExists("2/bar is included", + buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); } /* @@ -127,8 +131,10 @@ public class UnzipTest { @Test public void testPatternSetIncludeAndExclude() { buildRule.executeTarget("testPatternSetIncludeAndExclude"); - assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileMissing("2/bar is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); + assertFileMissing("1/foo is not included", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileMissing("2/bar is excluded", + buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); } /* @@ -137,8 +143,10 @@ public class UnzipTest { @Test public void testTwoPatternSets() { buildRule.executeTarget("testTwoPatternSets"); - assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileExists("2/bar is included", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); + assertFileMissing("1/foo is not included", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileExists("2/bar is included", + buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); } /* @@ -147,8 +155,10 @@ public class UnzipTest { @Test public void testTwoPatternSetsWithExcludes() { buildRule.executeTarget("testTwoPatternSetsWithExcludes"); - assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileMissing("2/bar is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); + assertFileMissing("1/foo is not included", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileMissing("2/bar is excluded", + buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); } /* @@ -169,8 +179,10 @@ public class UnzipTest { @Test public void testPatternSetSlashOnly() { buildRule.executeTarget("testPatternSetSlashOnly"); - assertFileMissing("1/foo is not included", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileExists("\"2/bar is included", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); + assertFileMissing("1/foo is not included", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileExists("\"2/bar is included", + buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); } @@ -180,7 +192,8 @@ public class UnzipTest { @Test public void testEncoding() { buildRule.executeTarget("encodingTest"); - assertFileExists("foo has been properly named", buildRule.getProject().getProperty("output") + "/unziptestout/foo"); + assertFileExists("foo has been properly named", + buildRule.getProject().getProperty("output") + "/unziptestout/foo"); } /* @@ -189,8 +202,10 @@ public class UnzipTest { @Test public void testFlattenMapper() { buildRule.executeTarget("testFlattenMapper"); - assertFileMissing("1/foo is not flattened", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileExists("foo is flattened", buildRule.getProject().getProperty("output") + "/unziptestout/foo"); + assertFileMissing("1/foo is not flattened", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileExists("foo is flattened", + buildRule.getProject().getProperty("output") + "/unziptestout/foo"); } /** @@ -220,8 +235,10 @@ public class UnzipTest { @Test public void testGlobMapper() { buildRule.executeTarget("testGlobMapper"); - assertFileMissing("1/foo is not mapped", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileExists("1/foo is mapped", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo.txt"); + assertFileMissing("1/foo is not mapped", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileExists("1/foo is mapped", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo.txt"); } @Test @@ -244,7 +261,9 @@ public class UnzipTest { @Test public void testDocumentationClaimsOnCopy() { buildRule.executeTarget("testDocumentationClaimsOnCopy"); - assertFileMissing("1/foo is excluded", buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); - assertFileExists("2/bar is not excluded", buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); + assertFileMissing("1/foo is excluded", + buildRule.getProject().getProperty("output") + "/unziptestout/1/foo"); + assertFileExists("2/bar is not excluded", + buildRule.getProject().getProperty("output") + "/unziptestout/2/bar"); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java index 1cb722f70..d833f75cc 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java @@ -219,7 +219,7 @@ public class XmlPropertyTest { String propertyValue = properties.getProperty(currentKey); - String xmlValue = (String)xmlproperties.get(currentKey); + String xmlValue = (String) xmlproperties.get(currentKey); if (propertyValue.startsWith("ID.")) { // The property is an id's thing -- either a property diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java index 276157d60..2a754ae76 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java @@ -136,7 +136,8 @@ public class ZipTest { public void testZipgroupfileset() throws IOException { buildRule.executeTarget("testZipgroupfileset"); - ZipFile zipFile = new ZipFile(new File(buildRule.getProject().getProperty("output"), "zipgroupfileset.zip")); + ZipFile zipFile = new ZipFile(new File(buildRule.getProject().getProperty("output"), + "zipgroupfileset.zip")); assertTrue(zipFile.getEntry("ant.xml") != null); assertTrue(zipFile.getEntry("optional/jspc.xml") != null); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java index 1d93b925c..4ea079c22 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java @@ -238,8 +238,8 @@ public class DefaultCompilerAdapterTest { try { final File src = new File(workDir, "src"); src.mkdir(); - final File java1 = createFile(src,"org/apache/ant/tests/J1.java"); - final File java2 = createFile(src,"org/apache/ant/tests/J2.java"); + final File java1 = createFile(src, "org/apache/ant/tests/J1.java"); + final File java2 = createFile(src, "org/apache/ant/tests/J2.java"); final File modules = new File(workDir, "modules"); modules.mkdir(); final Project prj = new Project(); @@ -277,8 +277,7 @@ public class DefaultCompilerAdapterTest { //J1.java & J2.java has to be in files list final Set expected = new TreeSet(); Collections.addAll(expected, java1.getAbsolutePath(), java2.getAbsolutePath()); - final Set actual = new TreeSet(); - actual.addAll(cmdLine.subList(cmdLine.size() - 2, cmdLine.size())); + final Set actual = new TreeSet(cmdLine.subList(cmdLine.size() - 2, cmdLine.size())); assertEquals(expected, actual); } finally { delete(workDir); @@ -291,9 +290,9 @@ public class DefaultCompilerAdapterTest { try { final File src = new File(workDir, "src"); src.mkdir(); - final File java1 = createFile(src,"main/m1/lin64/classes/org/apache/ant/tests/J1.java"); - final File java2 = createFile(src,"main/m2/lin32/classes/org/apache/ant/tests/J2.java"); - final File java3 = createFile(src,"main/m3/sol/classes/org/apache/ant/tests/J3.java"); + final File java1 = createFile(src, "main/m1/lin64/classes/org/apache/ant/tests/J1.java"); + final File java2 = createFile(src, "main/m2/lin32/classes/org/apache/ant/tests/J2.java"); + final File java3 = createFile(src, "main/m3/sol/classes/org/apache/ant/tests/J3.java"); final File modules = new File(workDir, "modules"); modules.mkdir(); final File build = new File(workDir, "build"); @@ -343,8 +342,7 @@ public class DefaultCompilerAdapterTest { java1.getAbsolutePath(), java2.getAbsolutePath(), java3.getAbsolutePath()); - final Set actualFiles = new TreeSet(); - actualFiles.addAll(cmdLine.subList(cmdLine.size() - 3, cmdLine.size())); + final Set actualFiles = new TreeSet(cmdLine.subList(cmdLine.size() - 3, cmdLine.size())); assertEquals(expectedFiles, actualFiles); } finally { delete(workDir); @@ -357,10 +355,10 @@ public class DefaultCompilerAdapterTest { try { final File src = new File(workDir, "src"); src.mkdir(); - final File java1 = createFile(src,"main/m1/lin/classes/org/apache/ant/tests/J1.java"); - final File java2 = createFile(src,"main/m3/sol/classes/org/apache/ant/tests/J2.java"); + final File java1 = createFile(src, "main/m1/lin/classes/org/apache/ant/tests/J1.java"); + final File java2 = createFile(src, "main/m3/sol/classes/org/apache/ant/tests/J2.java"); @SuppressWarnings("unused") - final File java3 = createFile(src,"main/m3/sol/classes/org/apache/ant/invisible/J3.java"); + final File java3 = createFile(src, "main/m3/sol/classes/org/apache/ant/invisible/J3.java"); final File build = new File(workDir, "build"); build.mkdirs(); final Project prj = new Project(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriterTest.java index ba464a91c..19b37a400 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriterTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriterTest.java @@ -45,7 +45,7 @@ public class ChangeLogWriterTest { CVSEntry entry = new CVSEntry(new Date(), "Se\u00f1orita", "2003 < 2004 && 3 > 5"); entry.addFile("Medicare & review.doc", "1.1"); entry.addFile("El\u00e8ments de style", "1.2"); - CVSEntry[] entries = { entry }; + CVSEntry[] entries = {entry}; ByteArrayOutputStream output = new ByteArrayOutputStream(); PrintWriter pwriter = new PrintWriter(new OutputStreamWriter(output, "UTF-8")); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/dir2/A.java b/src/tests/junit/org/apache/tools/ant/taskdefs/dir2/A.java index 437e0bc70..82b2048dd 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/dir2/A.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/dir2/A.java @@ -19,7 +19,7 @@ package org.apache.tools.ant.taskdefs.dir2; public class A { - public static void main(String [] args) { + public static void main(String[] args) { System.out.println("MAIN"); System.out.println(a); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java index 127de51cc..f57e418e6 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java @@ -46,7 +46,7 @@ import static org.junit.Assert.fail; */ public class ANTLRTest { - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; @Rule public BuildFileRule buildRule = new BuildFileRule(); @@ -207,10 +207,10 @@ public class ANTLRTest { } -} - -class HTMLFilter implements FilenameFilter { - public boolean accept(File dir, String name) { - return name.endsWith("html"); + class HTMLFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith("html"); + } } + } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java index 9a77203b2..f55c3f971 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java @@ -30,7 +30,9 @@ import javax.xml.parsers.DocumentBuilderFactory; import org.apache.tools.ant.taskdefs.XSLTLiaison; import org.apache.tools.ant.util.FileUtils; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.w3c.dom.Document; /** @@ -45,6 +47,9 @@ public abstract class AbstractXSLTLiaisonTest { protected XSLTLiaison liaison; + @Rule + public TemporaryFolder testFolder = new TemporaryFolder(); + @Before public void setUp() throws Exception { liaison = createLiaison(); @@ -79,13 +84,8 @@ public abstract class AbstractXSLTLiaisonTest { liaison.setStylesheet(xsl); liaison.addParam("param", "value"); File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); - File out = new File("xsltliaison.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - } finally { - out.delete(); - } + File out = testFolder.newFile("xsltliaison.tmp"); + liaison.transform(in, out); } @Test @@ -93,17 +93,13 @@ public abstract class AbstractXSLTLiaisonTest { File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl"); liaison.setStylesheet(xsl); File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml"); - File out = new File("xsltliaison-encoding.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - Document doc = parseXML(out); - assertEquals("root",doc.getDocumentElement().getNodeName()); - assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName()); - assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); - } finally { - out.delete(); - } + File out = testFolder.newFile("xsltliaison-encoding.tmp"); + liaison.transform(in, out); + Document doc = parseXML(out); + assertEquals("root", doc.getDocumentElement().getNodeName()); + assertEquals("message", doc.getDocumentElement().getFirstChild().getNodeName()); + assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9", + doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); } public Document parseXML(File file) throws Exception { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java index cbd66b694..d1c3aea12 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java @@ -87,8 +87,8 @@ public class EchoPropertiesTest { try { buildRule.executeTarget("testReadBadFile"); fail("BuildException should have been thrown on bad file"); - } catch(BuildException ex) { - assertContains("srcfile is a directory","srcfile is a directory!", ex.getMessage()); + } catch (BuildException ex) { + assertContains("srcfile is a directory", "srcfile is a directory!", ex.getMessage()); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java index 91f7b3278..32ec8bb81 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java @@ -31,8 +31,7 @@ import static org.junit.Assert.assertTrue; public class JavahTest { - private final static String BUILD_XML = - "src/etc/testcases/taskdefs/optional/javah/build.xml"; + private static final String BUILD_XML = "src/etc/testcases/taskdefs/optional/javah/build.xml"; @Rule public BuildFileRule buildRule = new BuildFileRule(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java index d1a0f57f1..3955f576e 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java @@ -44,7 +44,7 @@ import static org.junit.Assert.fail; */ public class JspcTest { - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; @Rule public BuildFileRule buildRule = new BuildFileRule(); @@ -149,7 +149,7 @@ public class JspcTest { @Test public void testJasperNameManglerSelection() { JspCompilerAdapter adapter = - JspCompilerAdapterFactory.getCompiler("jasper", null,null); + JspCompilerAdapterFactory.getCompiler("jasper", null, null); JspMangler mangler = adapter.createMangler(); assertTrue(mangler instanceof JspNameMangler); adapter = JspCompilerAdapterFactory.getCompiler("jasper41", null, null); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java index 748225e65..0ea5d9bbe 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java @@ -32,7 +32,7 @@ import static org.junit.Assert.assertTrue; public class Native2AsciiTest { - private final static String BUILD_XML = + private static final String BUILD_XML = "src/etc/testcases/taskdefs/optional/native2ascii/build.xml"; @Rule diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java index 8b1e08175..fa6cd86bc 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java @@ -117,15 +117,15 @@ public class PropertyFileTest { @Test public void testExerciseDefaultAndIncrement() throws Exception { buildRule.executeTarget("exercise"); - assertEquals("3",buildRule.getProject().getProperty("int.with.default")); - assertEquals("1",buildRule.getProject().getProperty("int.without.default")); - assertEquals("-->",buildRule.getProject().getProperty("string.with.default")); - assertEquals(".",buildRule.getProject().getProperty("string.without.default")); + assertEquals("3", buildRule.getProject().getProperty("int.with.default")); + assertEquals("1", buildRule.getProject().getProperty("int.without.default")); + assertEquals("-->", buildRule.getProject().getProperty("string.with.default")); + assertEquals(".", buildRule.getProject().getProperty("string.without.default")); assertEquals("2002/01/21 12:18", buildRule.getProject().getProperty("ethans.birth")); assertEquals("2003/01/21", buildRule.getProject().getProperty("first.birthday")); assertEquals("0124", buildRule.getProject().getProperty("olderThanAWeek")); assertEquals("37", buildRule.getProject().getProperty("existing.prop")); - assertEquals("6",buildRule.getProject().getProperty("int.without.value")); + assertEquals("6", buildRule.getProject().getProperty("int.without.value")); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java index cd7a43168..29b2685a9 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java @@ -41,7 +41,7 @@ public class PvcsTest { try { buildRule.executeTarget("test1"); fail("Required argument repository not specified"); - } catch (BuildException ex) { + } catch (BuildException ex) { //TODO check exception message } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java index 667c8904c..643aa6eba 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java @@ -35,8 +35,7 @@ public class SchemaValidateTest { /** * where tasks run */ - private final static String TASKDEFS_DIR = - "src/etc/testcases/taskdefs/optional/"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; @Rule public BuildFileRule buildRule = new BuildFileRule(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java index c4f28ab05..527e26457 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java @@ -38,9 +38,7 @@ import org.junit.Test; /** * TraX XSLTLiaison testcase */ -public class TraXLiaisonTest extends AbstractXSLTLiaisonTest - implements XSLTLogger { - +public class TraXLiaisonTest extends AbstractXSLTLiaisonTest implements XSLTLogger { @After public void tearDown() { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java index c9948bb9a..33fa189a4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java @@ -33,7 +33,7 @@ public class XmlValidateCatalogTest { /** * where tasks run */ - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; @Rule public BuildFileRule buildRule = new BuildFileRule(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java index d5f27a66a..9cd6eb2e9 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java @@ -40,8 +40,7 @@ public class XmlValidateTest { /** * where tasks run */ - private final static String TASKDEFS_DIR = - "src/etc/testcases/taskdefs/optional/"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; @Rule public BuildFileRule buildRule = new BuildFileRule(); @@ -112,11 +111,10 @@ public class XmlValidateTest { try { buildRule.executeTarget("testSchemaGood"); } catch (BuildException e) { - if (e - .getMessage() - .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema") - || e.getMessage().endsWith( - " doesn't support feature http://apache.org/xml/features/validation/schema")) { + if (e.getMessage().endsWith( + " doesn't recognize feature http://apache.org/xml/features/validation/schema") + || e.getMessage().endsWith( + " doesn't support feature http://apache.org/xml/features/validation/schema")) { throw new AssumptionViolatedException("parser doesn't support schema"); } else { throw e; @@ -132,11 +130,10 @@ public class XmlValidateTest { buildRule.executeTarget("testSchemaBad"); fail("Should throw BuildException because 'Bad Schema Validation'"); } catch (BuildException e) { - if (e - .getMessage() - .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema") - || e.getMessage().endsWith( - " doesn't support feature http://apache.org/xml/features/validation/schema")) { + if (e.getMessage().endsWith( + " doesn't recognize feature http://apache.org/xml/features/validation/schema") + || e.getMessage().endsWith( + " doesn't support feature http://apache.org/xml/features/validation/schema")) { throw new AssumptionViolatedException("parser doesn't support schema"); } else { assertTrue( diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java index b45505b3a..d84fc6907 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java @@ -35,7 +35,7 @@ public class XsltTest { /** * where tasks run */ - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; @Rule public BuildFileRule buildRule = new BuildFileRule(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java index 15564a7fb..75c91d4d3 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java @@ -39,9 +39,9 @@ public class TranslateTest { @Rule public final BuildFileRule buildRule = new BuildFileRule(); - static private final int BUF_SIZE = 32768; + private static final int BUF_SIZE = 32768; - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/i18n/translate"; + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/i18n/translate"; @Before public void setUp() { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java index 85747ab17..b39832ba8 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java @@ -39,11 +39,9 @@ import static org.junit.Assume.assumeTrue; */ public class ImageTest { - private final static String TASKDEFS_DIR = - "src/etc/testcases/taskdefs/optional/image/"; - private final static String LARGEIMAGE = "largeimage.jpg"; - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); + private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/image/"; + private static final String LARGEIMAGE = "largeimage.jpg"; @Rule public BuildFileRule buildRule = new BuildFileRule(); @@ -66,9 +64,7 @@ public class ImageTest { AntAssert.assertContains("Processing File", buildRule.getLog()); File f = new File(buildRule.getOutputDir(), LARGEIMAGE); - assertTrue("Did not create " + f.getAbsolutePath(), - f.exists()); - + assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); } @Test @@ -77,14 +73,13 @@ public class ImageTest { AntAssert.assertContains("Processing File", buildRule.getLog()); File f = new File(buildRule.getOutputDir(), LARGEIMAGE); assumeTrue("Could not change file modificaiton date", - f.setLastModified(f.lastModified() - (FILE_UTILS.getFileTimestampGranularity() * 2))); + f.setLastModified(f.lastModified() - FILE_UTILS.getFileTimestampGranularity() * 2)); long lastModified = f.lastModified(); buildRule.executeTarget("testOverwriteTrue"); AntAssert.assertContains("Processing File", buildRule.getLog()); f = new File(buildRule.getOutputDir(), LARGEIMAGE); long overwrittenLastModified = f.lastModified(); - assertTrue("File was not overwritten.", - lastModified < overwrittenLastModified); + assertTrue("File was not overwritten.", lastModified < overwrittenLastModified); } @Test @@ -97,8 +92,7 @@ public class ImageTest { AntAssert.assertContains("Processing File", buildRule.getLog()); f = new File(buildRule.getOutputDir(), LARGEIMAGE); long overwrittenLastModified = f.lastModified(); - assertTrue("File was overwritten.", - lastModified == overwrittenLastModified); + assertTrue("File was overwritten.", lastModified == overwrittenLastModified); } @Test @@ -106,9 +100,7 @@ public class ImageTest { buildRule.executeTarget("testSimpleScaleWithMapper"); AntAssert.assertContains("Processing File", buildRule.getLog()); File f = new File(buildRule.getOutputDir(), "scaled-" + LARGEIMAGE); - assertTrue("Did not create " + f.getAbsolutePath(), - f.exists()); - + assertTrue("Did not create " + f.getAbsolutePath(), f.exists()); } @Test @@ -117,13 +109,10 @@ public class ImageTest { try { buildRule.executeTarget("testFailOnError"); AntAssert.assertContains("Unable to process image stream", buildRule.getLog()); - } - catch (RuntimeException re){ - assertTrue("Run time exception should say " - + "'Unable to process image stream'. :" + } catch (RuntimeException re){ + assertTrue("Run time exception should say 'Unable to process image stream'. :" + re.toString(), - re.toString() - .indexOf("Unable to process image stream") > -1); + re.toString().indexOf("Unable to process image stream") > -1); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java index e99c4625e..c467e9a17 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java @@ -21,7 +21,6 @@ package org.apache.tools.ant.taskdefs.optional.junit; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.apache.tools.ant.AntAssert.assertContains; -import static org.junit.Assert.fail; import java.io.ByteArrayInputStream; import java.io.File; diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java index 3c2250708..28d7f9c54 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java @@ -375,7 +375,7 @@ public class JUnitTaskTest { assertEquals("Incorrect ignore message on explicit ignored test", "Please don't ignore me!", xpath.compile("//testsuite/testcase[@name='explicitIgnoreTest']/skipped/@message").evaluate(doc)); assertEquals("No message should be set on Ignored tests with no Ignore annotation text", 0, - ((Node)xpath.compile("//testsuite/testcase[@name='explicitlyIgnoreTestNoMessage']/skipped") + ((Node) xpath.compile("//testsuite/testcase[@name='explicitlyIgnoreTestNoMessage']/skipped") .evaluate(doc, XPathConstants.NODE)).getAttributes().getLength()); assertEquals("Incorrect ignore message on implicit ignored test", "This test will be ignored", xpath.compile("//testsuite/testcase[@name='implicitlyIgnoreTest']/skipped/@message").evaluate(doc)); @@ -469,7 +469,7 @@ public class JUnitTaskTest { System.currentTimeMillis() / 1000)); workDir.mkdirs(); try { - final File modulesDir = new File(workDir,"modules"); //NOI18N + final File modulesDir = new File(workDir, "modules"); //NOI18N modulesDir.mkdirs(); final Project project = new Project(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java index 0067203d9..a4798efc1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java @@ -64,24 +64,24 @@ public class JUnitTestListenerTest { public void testTestCountFired() { buildRule.getProject().setProperty("enableEvents", "true"); buildRule.executeTarget(PASS_TEST_TARGET); - assertContains("expecting test count message", JUnitTask.TESTLISTENER_PREFIX + - "tests to run: ", buildRule.getFullLog()); + assertContains("expecting test count message", JUnitTask.TESTLISTENER_PREFIX + + "tests to run: ", buildRule.getFullLog()); } @Test public void testStartTestFired() { buildRule.getProject().setProperty("enableEvents", "true"); buildRule.executeTarget(PASS_TEST_TARGET); - assertContains("expecting test started message", JUnitTask.TESTLISTENER_PREFIX + - "startTest(" + PASS_TEST + ")", buildRule.getFullLog()); + assertContains("expecting test started message", JUnitTask.TESTLISTENER_PREFIX + + "startTest(" + PASS_TEST + ")", buildRule.getFullLog()); } @Test public void testEndTestFired() { buildRule.getProject().setProperty("enableEvents", "true"); buildRule.executeTarget(PASS_TEST_TARGET); - assertContains("expecting test ended message", JUnitTask.TESTLISTENER_PREFIX + - "endTest(" + PASS_TEST + ")", buildRule.getFullLog()); + assertContains("expecting test ended message", JUnitTask.TESTLISTENER_PREFIX + + "endTest(" + PASS_TEST + ")", buildRule.getFullLog()); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java index 3886fe741..e8544ce1c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java @@ -42,7 +42,7 @@ public class JUnitTestRunnerTest { // check that a valid method name generates no errors @Test public void testValidMethod() { - TestRunner runner = createRunnerForTestMethod(ValidMethodTestCase.class,"testA"); + TestRunner runner = createRunnerForTestMethod(ValidMethodTestCase.class, "testA"); runner.run(); assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode()); } @@ -50,7 +50,7 @@ public class JUnitTestRunnerTest { // check that having an invalid method name generates an error @Test public void testInvalidMethod() { - TestRunner runner = createRunnerForTestMethod(InvalidMethodTestCase.class,"testInvalid"); + TestRunner runner = createRunnerForTestMethod(InvalidMethodTestCase.class, "testInvalid"); runner.run(); String error = runner.getFormatter().getError(); // might be FAILURES or ERRORS depending on JUnit version? @@ -118,7 +118,7 @@ public class JUnitTestRunnerTest { // check that JUnit 4 synthetic AssertionFailedError gets message and cause from AssertionError @Test public void testJUnit4AssertionError() { - TestRunner runner = createRunnerForTestMethod(AssertionErrorTest.class,"throwsAssertionError"); + TestRunner runner = createRunnerForTestMethod(AssertionErrorTest.class, "throwsAssertionError"); runner.run(); AssertionFailedError failure = runner.getFormatter().getFailure(); @@ -140,7 +140,7 @@ public class JUnitTestRunnerTest { } // the test runner that wrap the dummy formatter that interests us - private final static class TestRunner extends JUnitTestRunner { + private static final class TestRunner extends JUnitTestRunner { private ResultFormatter formatter = new ResultFormatter(); TestRunner(JUnitTest test, String[] methods, boolean haltonerror, boolean filtertrace, boolean haltonfailure) { @@ -157,16 +157,16 @@ public class JUnitTestRunnerTest { } // dummy formatter just to catch the error - private final static class ResultFormatter implements JUnitResultFormatter { + private static final class ResultFormatter implements JUnitResultFormatter { private AssertionFailedError failure; private Throwable error; public void setSystemOutput(String output) { } public void setSystemError(String output) { } - public void startTestSuite(JUnitTest suite) throws BuildException{ + public void startTestSuite(JUnitTest suite) throws BuildException { } - public void endTestSuite(JUnitTest suite) throws BuildException{ + public void endTestSuite(JUnitTest suite) throws BuildException { } public void setOutput(OutputStream out) { } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java index 3f464d872..1221ba4a1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java @@ -34,21 +34,21 @@ public class XMLFormatterWithCDATAOnSystemOut { private static final String REPORT = "TEST-" + XMLFormatterWithCDATAOnSystemOut.class.getName() + ".xml"; - private static final String TESTDATA = - "" + - "" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - "]]>" + - ""; + private static final String TESTDATA + = "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + "]]>" + + ""; @Rule public BuildFileRule buildRule = new BuildFileRule(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java index f8c89f267..9ee85758d 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java @@ -216,8 +216,8 @@ public class FTPTest { FileSet fsDestination = (FileSet) buildRule.getProject().getReference("fileset-destination-without-selector"); DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(buildRule.getProject()); dsDestination.scan(); - String [] sortedDestinationDirectories = dsDestination.getIncludedDirectories(); - String [] sortedDestinationFiles = dsDestination.getIncludedFiles(); + String[] sortedDestinationDirectories = dsDestination.getIncludedDirectories(); + String[] sortedDestinationFiles = dsDestination.getIncludedFiles(); for (int counter = 0; counter < sortedDestinationDirectories.length; counter++) { sortedDestinationDirectories[counter] = sortedDestinationDirectories[counter].replace(File.separatorChar, '/'); @@ -306,8 +306,8 @@ public class FTPTest { public void testOrderOfIncludePatternsIrrelevant() { Assume.assumeTrue(loginFailureMessage, loginSucceeded); Assume.assumeTrue("Could not change remote directory", changeRemoteDir(remoteTmpDir)); - String [] expectedFiles = {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}; - String [] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" }; + String[] expectedFiles = {"alpha/beta/beta.xml", "alpha/beta/gamma/gamma.xml"}; + String[] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" }; FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); ds.setBasedir(new File(buildRule.getProject().getBaseDir(), "tmp")); ds.setIncludes(new String[] {"alpha/be?a/**", "alpha/beta/gamma/"}); @@ -797,12 +797,12 @@ public class FTPTest { @Test public void testInitialCommand() { - performCommandTest("test-initial-command", new int[] { 1,0 }); + performCommandTest("test-initial-command", new int[] {1, 0}); } @Test public void testSiteAction() { - performCommandTest("test-site-action", new int[] { 1,0 }); + performCommandTest("test-site-action", new int[] {1, 0}); } private void performCommandTest(String target, int[] expectedCounts) { diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java index 5d4d4cf61..66e656745 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java @@ -117,10 +117,8 @@ public class ScriptDefTest { public void testDoubleDef() { buildRule.executeTarget("doubledef"); String log = buildRule.getLog(); - assertTrue("Task1 did not execute", - log.indexOf("Task1") != -1); - assertTrue("Task2 did not execute", - log.indexOf("Task2") != -1); + assertTrue("Task1 did not execute", log.indexOf("Task1") != -1); + assertTrue("Task2 did not execute", log.indexOf("Task2") != -1); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java index 1354e5290..3e8caf590 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java @@ -180,7 +180,7 @@ public class SOSTest { "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password", "", "-database", VSS_SERVER_PATH, "-project", DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", - project.getBaseDir().getAbsolutePath(), "-log", SRC_COMMENT,}; + project.getBaseDir().getAbsolutePath(), "-log", SRC_COMMENT}; // Set up a SOSCheckin task SOSCheckin sosCheckin = new SOSCheckin(); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java index e19a37aaf..f32b4ff4a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java @@ -95,8 +95,8 @@ public class ScpTest { scpTask.setTodir(sshHostUri); scpTask.execute(); - File testFile = new File(tempDir.getPath() + File.separator + - "download-testSingleFileUploadAndDownload.test"); + File testFile = new File(tempDir.getPath() + File.separator + + "download-testSingleFileUploadAndDownload.test"); addCleanup(testFile); assertFalse("Assert that the testFile does not exist.", testFile.exists()); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java index 772c6c1f7..5d27f5730 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java @@ -377,8 +377,8 @@ public class MSVSSTest implements MSVSSConstants { @Test public void testCpCommandLine() { String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_CP, - DS_VSS_PROJECT_PATH, MSVSS.FLAG_AUTORESPONSE_DEF, MSVSS.FLAG_LOGIN + - VSS_USERNAME}; + DS_VSS_PROJECT_PATH, MSVSS.FLAG_AUTORESPONSE_DEF, + MSVSS.FLAG_LOGIN + VSS_USERNAME}; // Set up a VSSCp task MSVSSCP vssCp = new MSVSSCP(); @@ -403,7 +403,7 @@ public class MSVSSTest implements MSVSSConstants { /** Tests Create commandline generation. */ @Test public void testCreateCommandLine() { - String[] sTestCmdLine = { MSVSS.SS_EXE, MSVSS.COMMAND_CREATE, + String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_CREATE, DS_VSS_PROJECT_PATH, MSVSS.FLAG_COMMENT + SRC_COMMENT, MSVSS.FLAG_AUTORESPONSE_NO, MSVSS.FLAG_QUIET, MSVSS.FLAG_LOGIN + VSS_USERNAME}; diff --git a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java index 6807a3345..4ba00bb78 100644 --- a/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java @@ -58,8 +58,7 @@ public class CommandlineTest { s = Commandline.translateCommandline("1 \"2\'3\" 4"); assertEquals("Case with double quotes around single quote", 3, s.length); - assertEquals("Double quotes stripped, single quote included", "2\'3", - s[1]); + assertEquals("Double quotes stripped, single quote included", "2\'3", s[1]); s = Commandline.translateCommandline("1 \'2 3\' 4"); assertEquals("Case with single quotes and whitespace", 3, s.length); @@ -67,8 +66,7 @@ public class CommandlineTest { s = Commandline.translateCommandline("1 \'2\"3\' 4"); assertEquals("Case with single quotes around double quote", 3, s.length); - assertEquals("Single quotes stripped, double quote included", "2\"3", - s[1]); + assertEquals("Single quotes stripped, double quote included", "2\"3", s[1]); // \ doesn't have a special meaning anymore - this is different from // what the Unix sh does but causes a lot of problems on DOS diff --git a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java index af1a88b66..14436de8d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java @@ -49,7 +49,7 @@ public class EnumeratedAttributeTest { @Test public void testFactory() { - Factory ea = (Factory)EnumeratedAttribute.getInstance(Factory.class, "one"); + Factory ea = (Factory) EnumeratedAttribute.getInstance(Factory.class, "one"); assertEquals("Factory did not set the right value.", ea.getValue(), "one"); try { EnumeratedAttribute.getInstance(Factory.class, "illegal"); @@ -98,7 +98,7 @@ public class EnumeratedAttributeTest { public static class Factory extends EnumeratedAttribute { public String[] getValues() { - return new String[] { "one", "two", "three" }; + return new String[] {"one", "two", "three"}; } } diff --git a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java index 7cf905e89..68c175437 100644 --- a/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java @@ -40,7 +40,7 @@ import static org.junit.Assert.fail; */ public class FilterSetTest { - static private final int BUF_SIZE = 32768; + private static final int BUF_SIZE = 32768; @Rule public BuildFileRule buildRule = new BuildFileRule(); @@ -87,7 +87,7 @@ public class FilterSetTest { String line = "@test@ line"; FilterSet fs = new FilterSet(); fs.addFilter("test", "@test1@"); - fs.addFilter("test1","@test2@"); + fs.addFilter("test1", "@test2@"); fs.addFilter("test2", "it works"); fs.setBeginToken("@"); fs.setEndToken("@"); @@ -104,7 +104,7 @@ public class FilterSetTest { String line = "@test@ line @test3@"; FilterSet fs = new FilterSet(); fs.addFilter("test", "@test1@"); - fs.addFilter("test1","@test2@"); + fs.addFilter("test1", "@test2@"); fs.addFilter("test2", "@test@"); fs.addFilter("test3", "testvalue"); fs.setBeginToken("@"); @@ -122,7 +122,7 @@ public class FilterSetTest { String line = "@test@ line @test2@"; FilterSet fs = new FilterSet(); fs.addFilter("test", "@test1@"); - fs.addFilter("test1","@test@"); + fs.addFilter("test1", "@test@"); fs.addFilter("test2", "testvalue"); fs.setBeginToken("@"); fs.setEndToken("@"); diff --git a/src/tests/junit/org/apache/tools/ant/types/PatternSetTest.java b/src/tests/junit/org/apache/tools/ant/types/PatternSetTest.java index 1dbacfc79..a4f27b0ce 100644 --- a/src/tests/junit/org/apache/tools/ant/types/PatternSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/PatternSetTest.java @@ -199,7 +199,7 @@ public class PatternSetTest { String[] excludes = p.getExcludePatterns(project); String[] includes = p.getIncludePatterns(project); - assertEquals("Includes","**/*.java", includes[0]); - assertEquals("Excludes","**/*.class", excludes[0]); + assertEquals("Includes", "**/*.java", includes[0]); + assertEquals("Excludes", "**/*.class", excludes[0]); } } diff --git a/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java b/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java index 28251e0d1..391e248f6 100644 --- a/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java @@ -104,7 +104,7 @@ public class TarFileSetTest extends AbstractFileSetTest { f.setPrefix("/examples"); f.setFileMode("600"); f.setDirMode("530"); - getProject().addReference("test",f); + getProject().addReference("test", f); TarFileSet zid = (TarFileSet) getInstance(); zid.setRefid(new Reference(getProject(), "test")); assertTrue("src attribute copied by copy constructor", diff --git a/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java b/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java index e2df448f0..961e55dca 100644 --- a/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java @@ -91,8 +91,7 @@ public class XMLCatalogTest { Source result = catalog.resolve("i/dont/exist.dtd", null); String expected = toURLString(new File(project.getBaseDir() + "/i/dont/exist.dtd")); - String resultStr = - fileURLPartWithoutLeadingSlashes((SAXSource)result); + String resultStr = fileURLPartWithoutLeadingSlashes((SAXSource) result); assertTrue("Empty catalog should return input with a system ID like " + expected + " but was " + resultStr, expected.endsWith(resultStr)); @@ -131,8 +130,7 @@ public class XMLCatalogTest { Source result = catalog.resolve("i/dont/exist.dtd", null); String expected = toURLString(new File(project.getBaseDir().toURL() + "/i/dont/exist.dtd")); - String resultStr = - fileURLPartWithoutLeadingSlashes((SAXSource)result); + String resultStr = fileURLPartWithoutLeadingSlashes((SAXSource) result); assertTrue("Nonexistent Catalog entry return input with a system ID like " + expected + " but was " + resultStr, expected.endsWith(resultStr)); diff --git a/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java b/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java index d89b0bd1d..c89b42040 100644 --- a/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java @@ -103,7 +103,7 @@ public class ZipFileSetTest extends AbstractFileSetTest { f.setPrefix("/examples"); f.setFileMode("600"); f.setDirMode("530"); - getProject().addReference("test",f); + getProject().addReference("test", f); ZipFileSet zid = (ZipFileSet) getInstance(); zid.setRefid(new Reference(getProject(), "test")); assertTrue("src attribute copied by copy constructor", diff --git a/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java b/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java index a52cabf35..8382e0516 100644 --- a/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java +++ b/src/tests/junit/org/apache/tools/ant/types/mappers/MapperResult.java @@ -90,14 +90,7 @@ public class MapperResult extends Task { flattened = b.toString(); } if (!flattened.equals(output)) { - throw new BuildException( - failMessage - + " " - + "got " - + flattened - + " " - + "expected " - + output); + throw new BuildException(failMessage + " got " + flattened + " expected " + output); } } } diff --git a/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java b/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java index 392667cb7..ce86f06aa 100644 --- a/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java @@ -55,7 +55,7 @@ public class ClassFileSetTest { public void testBasicSet() { Project p = buildRule.getProject(); buildRule.executeTarget("testbasicset"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); + FileSet resultFileSet = p.getReference(RESULT_FILESET); DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); @@ -81,7 +81,7 @@ public class ClassFileSetTest { public void testSmallSet() { Project p = buildRule.getProject(); buildRule.executeTarget("testsmallset"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); + FileSet resultFileSet = p.getReference(RESULT_FILESET); DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); @@ -103,7 +103,7 @@ public class ClassFileSetTest { public void testComboSet() { Project p = buildRule.getProject(); buildRule.executeTarget("testcomboset"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); + FileSet resultFileSet = p.getReference(RESULT_FILESET); DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); @@ -131,7 +131,7 @@ public class ClassFileSetTest { public void testMethodParam() { Project p = buildRule.getProject(); buildRule.executeTarget("testmethodparam"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); + FileSet resultFileSet = p.getReference(RESULT_FILESET); DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); @@ -159,7 +159,7 @@ public class ClassFileSetTest { public void testMethodParamInner() { Project p = buildRule.getProject(); buildRule.executeTarget("testmethodparaminner"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); + FileSet resultFileSet = p.getReference(RESULT_FILESET); DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); diff --git a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java index 9e998722c..3a2a7ec79 100644 --- a/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java @@ -81,8 +81,7 @@ public class LazyResourceCollectionTest { Iterator it = lazyCollection.iterator(); assertOneCreatedIterator(collectionTest); - StringResourceIterator stringResourceIterator = (StringResourceIterator) collectionTest.createdIterators - .get(0); + StringResourceIterator stringResourceIterator = (StringResourceIterator) collectionTest.createdIterators.get(0); assertEquals("A resource was loaded without iterating", 1, stringResourceIterator.cursor); @@ -130,8 +129,7 @@ public class LazyResourceCollectionTest { Iterator it2 = lazyCollection.iterator(); assertOneCreatedIterator(collectionTest); - StringResourceIterator stringResourceIterator = (StringResourceIterator) collectionTest.createdIterators - .get(0); + StringResourceIterator stringResourceIterator = (StringResourceIterator) collectionTest.createdIterators.get(0); assertEquals("A resource was loaded without iterating", 1, stringResourceIterator.cursor); @@ -142,8 +140,7 @@ public class LazyResourceCollectionTest { r = (StringResource) it2.next(); assertEquals("r1", r.getValue()); - assertEquals( - "The second iterator did not lookup in the cache for a resource", + assertEquals("The second iterator did not lookup in the cache for a resource", 2, stringResourceIterator.cursor); r = (StringResource) it2.next(); @@ -153,8 +150,7 @@ public class LazyResourceCollectionTest { r = (StringResource) it1.next(); assertEquals("r2", r.getValue()); - assertEquals( - "The first iterator did not lookup in the cache for a resource", + assertEquals("The first iterator did not lookup in the cache for a resource", 3, stringResourceIterator.cursor); r = (StringResource) it2.next(); @@ -164,8 +160,7 @@ public class LazyResourceCollectionTest { r = (StringResource) it1.next(); assertEquals("r3", r.getValue()); - assertEquals( - "The first iterator did not lookup in the cache for a resource", + assertEquals("The first iterator did not lookup in the cache for a resource", 3, stringResourceIterator.cursor); try { diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java index 64bf741b3..735a4dd37 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java @@ -33,11 +33,11 @@ public class BaseSelectorRule extends BuildFileRule { private File beddir; private File mirrordir; - private final String[] filenames = {".","asf-logo.gif.md5","asf-logo.gif.bz2", - "asf-logo.gif.gz","copy.filterset.filtered","zip/asf-logo.gif.zip", - "tar/asf-logo.gif.tar","tar/asf-logo-huge.tar.gz", - "tar/gz/asf-logo.gif.tar.gz","tar/bz2/asf-logo.gif.tar.bz2", - "tar/bz2/asf-logo-huge.tar.bz2","tar/bz2"}; + private final String[] filenames = {".", "asf-logo.gif.md5", "asf-logo.gif.bz2", + "asf-logo.gif.gz", "copy.filterset.filtered", "zip/asf-logo.gif.zip", + "tar/asf-logo.gif.tar", "tar/asf-logo-huge.tar.gz", + "tar/gz/asf-logo.gif.tar.gz", "tar/bz2/asf-logo.gif.tar.bz2", + "tar/bz2/asf-logo-huge.tar.bz2", "tar/bz2"}; private File[] files = new File[filenames.length]; private File[] mirrorfiles = new File[filenames.length]; @@ -54,8 +54,8 @@ public class BaseSelectorRule extends BuildFileRule { mirrordir = new File(super.getProject().getProperty("mirror.dir")); for (int x = 0; x < files.length; x++) { - files[x] = new File(beddir,filenames[x]); - mirrorfiles[x] = new File(mirrordir,filenames[x]); + files[x] = new File(beddir, filenames[x]); + mirrorfiles[x] = new File(mirrordir, filenames[x]); } } @@ -90,7 +90,7 @@ public class BaseSelectorRule extends BuildFileRule { * @param selector FileSelector */ public String selectionString(FileSelector selector) { - return selectionString(beddir,files,selector); + return selectionString(beddir, files, selector); } /** diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java index 34c135a1b..81333082d 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java @@ -39,11 +39,11 @@ public abstract class BaseSelectorTest extends BuildFileTest { protected File basedir; protected File beddir; protected File mirrordir; - protected String[] filenames = {".","asf-logo.gif.md5","asf-logo.gif.bz2", - "asf-logo.gif.gz","copy.filterset.filtered","zip/asf-logo.gif.zip", - "tar/asf-logo.gif.tar","tar/asf-logo-huge.tar.gz", - "tar/gz/asf-logo.gif.tar.gz","tar/bz2/asf-logo.gif.tar.bz2", - "tar/bz2/asf-logo-huge.tar.bz2","tar/bz2"}; + protected String[] filenames = {".", "asf-logo.gif.md5", "asf-logo.gif.bz2", + "asf-logo.gif.gz", "copy.filterset.filtered", "zip/asf-logo.gif.zip", + "tar/asf-logo.gif.tar", "tar/asf-logo-huge.tar.gz", + "tar/gz/asf-logo.gif.tar.gz", "tar/bz2/asf-logo.gif.tar.bz2", + "tar/bz2/asf-logo-huge.tar.bz2", "tar/bz2"}; protected File[] files = new File[filenames.length]; protected File[] mirrorfiles = new File[filenames.length]; @@ -61,8 +61,8 @@ public abstract class BaseSelectorTest extends BuildFileTest { project.init(); project.setBaseDir(basedir); for (int x = 0; x < files.length; x++) { - files[x] = new File(beddir,filenames[x]); - mirrorfiles[x] = new File(mirrordir,filenames[x]); + files[x] = new File(beddir, filenames[x]); + mirrorfiles[x] = new File(mirrordir, filenames[x]); } } @@ -100,7 +100,7 @@ public abstract class BaseSelectorTest extends BuildFileTest { } s.setError("test error"); try { - s.isSelected(beddir,filenames[0],files[0]); + s.isSelected(beddir, filenames[0], files[0]); fail("Cannot cause BuildException when setError() is called"); } catch (BuildException be) { assertEquals("test error", @@ -117,7 +117,7 @@ public abstract class BaseSelectorTest extends BuildFileTest { * @param selector FileSelector */ public String selectionString(FileSelector selector) { - return selectionString(beddir,files,selector); + return selectionString(beddir, files, selector); } /** @@ -130,7 +130,7 @@ public abstract class BaseSelectorTest extends BuildFileTest { * @param selector FileSelector */ public String mirrorSelectionString(FileSelector selector) { - return selectionString(mirrordir,mirrorfiles,selector); + return selectionString(mirrordir, mirrorfiles, selector); } /** diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java index f1d7ca959..ec3ea8927 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java @@ -197,7 +197,7 @@ public class DateSelectorTest { param1.setValue("11/21/2001 4:56 AM"); param2.setName("when"); param2.setValue("after"); - Parameter[] params = {param1,param2}; + Parameter[] params = {param1, param2}; s.setParameters(params); results = selectorRule.selectionString(s); assertEquals("TFFTFTTTFFFT", results); diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java index bac48958a..e9591b528 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java @@ -240,7 +240,7 @@ public class ModifiedSelectorTest { sel.configure(); // get the cache, so we can check our things - MockCache cache = (MockCache)sel.getCache(); + MockCache cache = (MockCache) sel.getCache(); // the test assertFalse("Cache must not be saved before 1st selection.", cache.saved); @@ -757,11 +757,11 @@ public class ModifiedSelectorTest { s.addParam(createParam("cache.cachefile", cachefile)); //s.addParam(createParam("algorithm.provider","---")); // i don't know any valid - s.addParam(createParam("cache","propertyfile")); - s.addParam(createParam("update","true")); - s.addParam(createParam("comparator","rule")); - s.addParam(createParam("algorithm.name","sha")); - s.addParam(createParam("algorithm","digest")); + s.addParam(createParam("cache", "propertyfile")); + s.addParam(createParam("update", "true")); + s.addParam(createParam("comparator", "rule")); + s.addParam(createParam("algorithm.name", "sha")); + s.addParam(createParam("algorithm", "digest")); // first and second run performTests(s, "TTTTTTTTTTTT"); @@ -889,7 +889,9 @@ public class ModifiedSelectorTest { } public void doTarget(String target) { - if (!isConfigured) setUp(); + if (!isConfigured) { + setUp(); + } executeTarget(target); } @@ -898,7 +900,9 @@ public class ModifiedSelectorTest { } public void writeProperties(String line) { - if (!isConfigured) setUp(); + if (!isConfigured) { + setUp(); + } File dir = getProject().getBaseDir(); File file = new File(dir, propfile); try { diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/README b/src/tests/junit/org/apache/tools/ant/types/selectors/README index eb48f6bbc..f44ac9ae1 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/README +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/README @@ -37,20 +37,20 @@ the following code: makeBed(); - s = (DepthSelector)getInstance(); + s = (DepthSelector) getInstance(); s.setMin(20); s.setMax(25); results = selectionString(s); assertEquals("FFFFFFFFFFFF", results); - s = (DepthSelector)getInstance(); + s = (DepthSelector) getInstance(); s.setMin(0); results = selectionString(s); assertEquals("TTTTTTTTTTTT", results); - s = (DepthSelector)getInstance(); + s = (DepthSelector) getInstance(); s.setMin(1); results = selectionString(s); assertEquals("FFFFFTTTTTTT", results); diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java index 467b42a31..38179c314 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java @@ -180,7 +180,7 @@ public class SizeSelectorTest { param2.setValue("Ki"); param3.setName("when"); param3.setValue("more"); - Parameter[] params = {param1,param2,param3}; + Parameter[] params = {param1, param2, param3}; s.setParameters(params); results = selectorRule.selectionString(s); assertEquals("TFFFFFFTFFTT", results); diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java index 1124a48e3..f6be24055 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java @@ -42,7 +42,7 @@ public class TypeSelectorTest { TypeSelector s = new TypeSelector(); try { s.isSelected(selectorRule.getProject().getBaseDir(), - selectorRule.getFilenames()[0],selectorRule.getFiles()[0]); + selectorRule.getFilenames()[0], selectorRule.getFiles()[0]); fail("TypeSelector did not check for required fields"); } catch (BuildException be1) { assertEquals("The type attribute is required", be1.getMessage()); diff --git a/src/tests/junit/org/apache/tools/ant/util/Base64ConverterTest.java b/src/tests/junit/org/apache/tools/ant/util/Base64ConverterTest.java index 48a4cbd70..61fdfba39 100644 --- a/src/tests/junit/org/apache/tools/ant/util/Base64ConverterTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/Base64ConverterTest.java @@ -29,9 +29,9 @@ public class Base64ConverterTest { @Test public void testOneValue() { - byte[] mybytes = {0, 0, (byte)0xFF}; + byte[] mybytes = {0, 0, (byte) 0xFF}; Base64Converter base64Converter = new Base64Converter(); - assertEquals("AAD/",base64Converter.encode(mybytes)); + assertEquals("AAD/", base64Converter.encode(mybytes)); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java index e7edf2300..ca223d9cf 100644 --- a/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java @@ -56,7 +56,7 @@ public class DateUtilsTest { public void testDateTimeISO() { TimeZone timeZone = TimeZone.getTimeZone("GMT+1"); Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23,10,11,12); + cal.set(2002, 1, 23, 10, 11, 12); String text = DateUtils.format(cal.getTime(), DateUtils.ISO8601_DATETIME_PATTERN); assertEquals("2002-02-23T09:11:12", text); @@ -66,7 +66,7 @@ public class DateUtilsTest { public void testDateISO() { TimeZone timeZone = TimeZone.getTimeZone("GMT"); Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23); + cal.set(2002, 1, 23); String text = DateUtils.format(cal.getTime(), DateUtils.ISO8601_DATE_PATTERN); assertEquals("2002-02-23", text); @@ -77,7 +77,7 @@ public class DateUtilsTest { // make sure that elapsed time in set via date works TimeZone timeZone = TimeZone.getTimeZone("GMT+1"); Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23, 21, 11, 12); + cal.set(2002, 1, 23, 21, 11, 12); String text = DateUtils.format(cal.getTime(), DateUtils.ISO8601_TIME_PATTERN); assertEquals("20:11:12", text); diff --git a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java index e26a7cb3e..cd479d5aa 100644 --- a/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java @@ -19,14 +19,11 @@ package org.apache.tools.ant.util; import java.io.File; -import junit.framework.AssertionFailedError; - import org.apache.tools.ant.taskdefs.condition.Os; import org.junit.Assume; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; @@ -38,7 +35,6 @@ public class JavaEnvUtilsTest { private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - @Test public void testGetExecutableNetware() { Assume.assumeTrue("Test only runs on netware", Os.isName("netware")); @@ -51,33 +47,28 @@ public class JavaEnvUtilsTest { @Test public void testGetExecutableWindows() { Assume.assumeTrue("Test only runs on windows", Os.isFamily("windows")); - String javaHome = - FILE_UTILS.normalize(System.getProperty("java.home")) + String javaHome = FILE_UTILS.normalize(System.getProperty("java.home")) .getAbsolutePath(); String j = JavaEnvUtils.getJreExecutable("java"); assertTrue(j.endsWith(".exe")); assertTrue(j + " is absolute", (new File(j)).isAbsolute()); try { - assertTrue(j + " is normalized and in the JRE dir", - j.startsWith(javaHome)); - } catch (AssertionFailedError e) { + assertTrue(j + " is normalized and in the JRE dir", j.startsWith(javaHome)); + } catch (AssertionError e) { // java.home is bogus assertEquals("java.exe", j); } j = JavaEnvUtils.getJdkExecutable("javac"); assertTrue(j.endsWith(".exe")); + try { assertTrue(j + " is absolute", (new File(j)).isAbsolute()); - String javaHomeParent = - FILE_UTILS.normalize(javaHome + "/..").getAbsolutePath(); - assertTrue(j + " is normalized and in the JDK dir", - j.startsWith(javaHomeParent)); - assertTrue(j + " is normalized and not in the JRE dir", - !j.startsWith(javaHome)); - - } catch (AssertionFailedError e) { + String javaHomeParent = FILE_UTILS.normalize(javaHome + "/..").getAbsolutePath(); + assertTrue(j + " is normalized and in the JDK dir", j.startsWith(javaHomeParent)); + assertTrue(j + " is normalized and not in the JRE dir", !j.startsWith(javaHome)); + } catch (AssertionError e) { // java.home is bogus assertEquals("javac.exe", j); } @@ -90,9 +81,7 @@ public class JavaEnvUtilsTest { public void testGetExecutableMostPlatforms() { Assume.assumeTrue("Test only runs on non Netware and non Windows systems", !Os.isName("netware") && !Os.isFamily("windows")); - String javaHome = - FILE_UTILS.normalize(System.getProperty("java.home")) - .getAbsolutePath(); + String javaHome = FILE_UTILS.normalize(System.getProperty("java.home")).getAbsolutePath(); // could still be OS/2 String extension = Os.isFamily("dos") ? ".exe" : ""; @@ -102,8 +91,7 @@ public class JavaEnvUtilsTest { assertTrue(j.endsWith(extension)); } assertTrue(j + " is absolute", (new File(j)).isAbsolute()); - assertTrue(j + " is normalized and in the JRE dir", - j.startsWith(javaHome)); + assertTrue(j + " is normalized and in the JRE dir", j.startsWith(javaHome)); j = JavaEnvUtils.getJdkExecutable("javac"); if (!extension.equals("")) { @@ -111,30 +99,23 @@ public class JavaEnvUtilsTest { } assertTrue(j + " is absolute", (new File(j)).isAbsolute()); - String javaHomeParent = - FILE_UTILS.normalize(javaHome + "/..").getAbsolutePath(); - assertTrue(j + " is normalized and in the JDK dir", - j.startsWith(javaHomeParent)); + String javaHomeParent = FILE_UTILS.normalize(javaHome + "/..").getAbsolutePath(); + assertTrue(j + " is normalized and in the JDK dir", j.startsWith(javaHomeParent)); if ((Os.isFamily("mac") && JavaEnvUtils.getJavaVersionNumber() <= JavaEnvUtils.VERSION_1_6) || JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9)) { - assertTrue(j+" is normalized and in the JRE dir", - j.startsWith(javaHome)); + assertTrue(j + " is normalized and in the JRE dir", j.startsWith(javaHome)); } else { - assertTrue(j+" is normalized and not in the JRE dir", - !j.startsWith(javaHome)); + assertTrue(j + " is normalized and not in the JRE dir", !j.startsWith(javaHome)); } - assertEquals("foo" + extension, - JavaEnvUtils.getJreExecutable("foo")); - assertEquals("foo" + extension, - JavaEnvUtils.getJdkExecutable("foo")); + assertEquals("foo" + extension, JavaEnvUtils.getJreExecutable("foo")); + assertEquals("foo" + extension, JavaEnvUtils.getJdkExecutable("foo")); } @Test public void testIsAtLeastJavaVersion() { - assertTrue( - "Current java version is not at least the current java version...", + assertTrue("Current java version is not at least the current java version...", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.getJavaVersion())); } diff --git a/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java b/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java index 77dbdac50..5edaf571c 100644 --- a/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.util.Vector; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -34,7 +33,7 @@ import static org.junit.Assert.assertTrue; */ public abstract class RegexpMatcherTest { - public final static String UNIX_LINE = "\n"; + public static final String UNIX_LINE = "\n"; private RegexpMatcher reg; diff --git a/src/tests/junit/org/apache/tools/bzip2/BlockSortTest.java b/src/tests/junit/org/apache/tools/bzip2/BlockSortTest.java index e043f5db3..ed0269ed4 100644 --- a/src/tests/junit/org/apache/tools/bzip2/BlockSortTest.java +++ b/src/tests/junit/org/apache/tools/bzip2/BlockSortTest.java @@ -25,8 +25,8 @@ import static org.junit.Assert.assertEquals; public class BlockSortTest { - private static final byte[] FIXTURE = { 0, 1, (byte) 252, (byte) 253, (byte) 255, - (byte) 254, 3, 2, (byte) 128 }; + private static final byte[] FIXTURE = {0, 1, (byte) 252, (byte) 253, (byte) 255, + (byte) 254, 3, 2, (byte) 128}; /* Burrows-Wheeler transform of fixture the manual way: @@ -62,8 +62,8 @@ public class BlockSortTest { and the original line has been 0 */ - private static final byte[] FIXTURE_BWT = { (byte) 128, 0, 3, (byte) 254, 2, 1, - (byte) 252, (byte) 255, (byte) 253 }; + private static final byte[] FIXTURE_BWT = {(byte) 128, 0, 3, (byte) 254, 2, 1, + (byte) 252, (byte) 255, (byte) 253}; private static final int[] FIXTURE_SORTED = { 0, 1, 7, 6, 8, 2, 3, 5, 4 diff --git a/src/tests/junit/org/apache/tools/mail/MailMessageTest.java b/src/tests/junit/org/apache/tools/mail/MailMessageTest.java index cabeef51b..f61e6b4e8 100644 --- a/src/tests/junit/org/apache/tools/mail/MailMessageTest.java +++ b/src/tests/junit/org/apache/tools/mail/MailMessageTest.java @@ -82,8 +82,8 @@ public class MailMessageTest { testMailClient.cc("cc2@you.com"); testMailClient.bcc("bcc@you.com"); testMailClient.setSubject("Test subject"); - testMailClient.setMessage("test line 1\n" + - "test line 2"); + testMailClient.setMessage("test line 1\n" + + "test line 2"); Thread client = new Thread(testMailClient); client.start(); @@ -92,34 +92,33 @@ public class MailMessageTest { client.join(30 * 1000); // a further 30s String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "Cc: cc1@you.com, cc2@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; + String expectedResult = "220 test SMTP EmailTaskTest\r\n" + + "HELO " + local + "\r\n" + + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + + "MAIL FROM: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "DATA\r\n" + + "354\r\n" + + "Subject: Test subject\r\n" + "From: Mail Message \r\n" + + "To: to@you.com\r\n" + + "Cc: cc1@you.com, cc2@you.com\r\n" + + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + + "\r\n" + + "test line 1\r\n" + + "test line 2\r\n" + + "\r\n" + + ".\r\n" + + "250\r\n" + + "QUIT\r\n" + + "221\r\n"; assertEquals(expectedResult, result); // order of headers cannot be guaranteed assertFalse(testMailClient.getFailMessage(), testMailClient.isFailed()); } @@ -140,8 +139,7 @@ public class MailMessageTest { testMailClient.from("Mail Message "); testMailClient.to("to@you.com"); testMailClient.setSubject("Test subject"); - testMailClient.setMessage("test line 1\n" + - "test line 2"); + testMailClient.setMessage("test line 1\n" + "test line 2"); Thread client = new Thread(testMailClient); client.start(); @@ -150,27 +148,27 @@ public class MailMessageTest { client.join(30 * 1000); // a further 30s String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; + String expectedResult = "220 test SMTP EmailTaskTest\r\n" + + "HELO " + local + "\r\n" + + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + + "MAIL FROM: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "DATA\r\n" + + "354\r\n" + + "Subject: Test subject\r\n" + + "From: Mail Message \r\n" + + "To: to@you.com\r\n" + + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + + "\r\n" + + "test line 1\r\n" + + "test line 2\r\n" + + "\r\n" + + ".\r\n" + + "250\r\n" + + "QUIT\r\n" + + "221\r\n"; assertEquals(expectedResult, result); // order of headers cannot be guaranteed assertFalse(testMailClient.getFailMessage(), testMailClient.isFailed()); } @@ -191,8 +189,7 @@ public class MailMessageTest { testMailClient.from("Mail Message "); testMailClient.cc("cc@you.com"); testMailClient.setSubject("Test subject"); - testMailClient.setMessage("test line 1\n" + - "test line 2"); + testMailClient.setMessage("test line 1\n" + "test line 2"); Thread client = new Thread(testMailClient); client.start(); @@ -201,27 +198,27 @@ public class MailMessageTest { client.join(30 * 1000); // a further 30s String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "Cc: cc@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; + String expectedResult = "220 test SMTP EmailTaskTest\r\n" + + "HELO " + local + "\r\n" + + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + + "MAIL FROM: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "DATA\r\n" + + "354\r\n" + + "Subject: Test subject\r\n" + + "From: Mail Message \r\n" + + "Cc: cc@you.com\r\n" + + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + + "\r\n" + + "test line 1\r\n" + + "test line 2\r\n" + + "\r\n" + + ".\r\n" + + "250\r\n" + + "QUIT\r\n" + + "221\r\n"; assertEquals(expectedResult, result); assertFalse(testMailClient.getFailMessage(), testMailClient.isFailed()); } @@ -242,8 +239,7 @@ public class MailMessageTest { testMailClient.from("Mail Message "); testMailClient.bcc("bcc@you.com"); testMailClient.setSubject("Test subject"); - testMailClient.setMessage("test line 1\n" + - "test line 2"); + testMailClient.setMessage("test line 1\n" + "test line 2"); Thread client = new Thread(testMailClient); client.start(); @@ -252,26 +248,26 @@ public class MailMessageTest { client.join(30 * 1000); // a further 30s String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; + String expectedResult = "220 test SMTP EmailTaskTest\r\n" + + "HELO " + local + "\r\n" + + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + + "MAIL FROM: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "DATA\r\n" + + "354\r\n" + + "Subject: Test subject\r\n" + + "From: Mail Message \r\n" + + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + + "\r\n" + + "test line 1\r\n" + + "test line 2\r\n" + + "\r\n" + + ".\r\n" + + "250\r\n" + + "QUIT\r\n" + + "221\r\n"; assertEquals(expectedResult, result); assertFalse(testMailClient.getFailMessage(), testMailClient.isFailed()); } @@ -292,8 +288,7 @@ public class MailMessageTest { testMailClient.from("Mail Message "); testMailClient.to("to@you.com"); - testMailClient.setMessage("test line 1\n" + - "test line 2"); + testMailClient.setMessage("test line 1\n" + "test line 2"); Thread client = new Thread(testMailClient); client.start(); @@ -302,26 +297,26 @@ public class MailMessageTest { client.join(30 * 1000); // a further 30s String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; + String expectedResult = "220 test SMTP EmailTaskTest\r\n" + + "HELO " + local + "\r\n" + + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + + "MAIL FROM: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "DATA\r\n" + + "354\r\n" + + "From: Mail Message \r\n" + + "To: to@you.com\r\n" + + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + + "\r\n" + + "test line 1\r\n" + + "test line 2\r\n" + + "\r\n" + + ".\r\n" + + "250\r\n" + + "QUIT\r\n" + + "221\r\n"; assertEquals(expectedResult, result); assertFalse(testMailClient.getFailMessage(), testMailClient.isFailed()); } @@ -351,26 +346,26 @@ public class MailMessageTest { client.join(30 * 1000); // a further 30s String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; + String expectedResult = "220 test SMTP EmailTaskTest\r\n" + + "HELO " + local + "\r\n" + + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + + "MAIL FROM: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "DATA\r\n" + + "354\r\n" + + "Subject: Test subject\r\n" + + "From: Mail Message \r\n" + + "To: to@you.com\r\n" + + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + ".\r\n" + + "250\r\n" + + "QUIT\r\n" + + "221\r\n"; assertEquals(expectedResult, result); assertFalse(testMailClient.getFailMessage(), testMailClient.isFailed()); } @@ -402,26 +397,26 @@ public class MailMessageTest { client.join(30 * 1000); // a further 30s String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: Ceki G\u00fclc\u00fc \r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; + String expectedResult = "220 test SMTP EmailTaskTest\r\n" + + "HELO " + local + "\r\n" + + "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + + "MAIL FROM: \r\n" + + "250\r\n" + + "RCPT TO: \r\n" + + "250\r\n" + + "DATA\r\n" + + "354\r\n" + + "Subject: Test subject\r\n" + + "From: Mail Message \r\n" + + "To: Ceki G\u00fclc\u00fc \r\n" + + "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + + "\r\n" + + "\r\n" + + "\r\n" + + ".\r\n" + + "250\r\n" + + "QUIT\r\n" + + "221\r\n"; ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); PrintStream bos1 = new PrintStream(baos1, true); @@ -475,8 +470,8 @@ public class MailMessageTest { sb.append(response).append("\r\n"); if (!data && response.startsWith("HELO")) { - send("250 " + local + " Hello " + local + " " + - "[127.0.0.1], pleased to meet you\r\n"); + send("250 " + local + " Hello " + local + " " + + "[127.0.0.1], pleased to meet you\r\n"); } else if (!data && response.startsWith("MAIL")) { send("250\r\n"); } else if (!data && response.startsWith("RCPT")) { @@ -493,8 +488,8 @@ public class MailMessageTest { } else if (!data) { //throw new IllegalStateException("Command unrecognized: " // + response); - send("500 5.5.1 Command unrecognized: \"" + - response + "\"\r\n"); + send("500 5.5.1 Command unrecognized: \"" + + response + "\"\r\n"); loop = false; } else { // sb.append(response + "\r\n"); @@ -643,7 +638,6 @@ public class MailMessageTest { } catch (IOException ioe) { fail = true; failMessage = "IOException: " + ioe; - return; } } diff --git a/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java b/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java index c62e3e18a..af44e7d47 100644 --- a/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java +++ b/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java @@ -57,21 +57,21 @@ public class AsiExtraFieldTest implements UnixStat { byte[] b = a.getLocalFileDataData(); // CRC manually calculated, sorry - byte[] expect = {(byte)0xC6, 0x02, 0x78, (byte)0xB6, // CRC - 0123, (byte)0x80, // mode - 0, 0, 0, 0, // link length - 5, 0, 6, 0}; // uid, gid + byte[] expect = {(byte) 0xC6, 0x02, 0x78, (byte) 0xB6, // CRC + 0123, (byte) 0x80, // mode + 0, 0, 0, 0, // link length + 5, 0, 6, 0}; // uid, gid assertEquals("no link", expect.length, b.length); for (int i = 0; i < expect.length; i++) { assertEquals("no link, byte " + i, expect[i], b[i]); } a.setLinkedFile("test"); - expect = new byte[] {0x75, (byte)0x8E, 0x41, (byte)0xFD, // CRC - 0123, (byte)0xA0, // mode - 4, 0, 0, 0, // link length - 5, 0, 6, 0, // uid, gid - (byte)'t', (byte)'e', (byte)'s', (byte)'t'}; + expect = new byte[] {0x75, (byte) 0x8E, 0x41, (byte) 0xFD, // CRC + 0123, (byte) 0xA0, // mode + 4, 0, 0, 0, // link length + 5, 0, 6, 0, // uid, gid + (byte) 't', (byte) 'e', (byte) 's', (byte) 't'}; b = a.getLocalFileDataData(); assertEquals("no link", expect.length, b.length); for (int i = 0; i < expect.length; i++) { @@ -85,12 +85,12 @@ public class AsiExtraFieldTest implements UnixStat { */ @Test public void testReparse() throws Exception { - // CRC manually calculated, sorry - byte[] data = {(byte)0xC6, 0x02, 0x78, (byte)0xB6, // CRC - 0123, (byte)0x80, // mode - 0, 0, 0, 0, // link length - 5, 0, 6, 0}; // uid, gid AsiExtraField a = new AsiExtraField(); + // CRC manually calculated, sorry + byte[] data = {(byte) 0xC6, 0x02, 0x78, (byte) 0xB6, // CRC + 0123, (byte) 0x80, // mode + 0, 0, 0, 0, // link length + 5, 0, 6, 0}; // uid, gid a.parseFromLocalFileData(data, 0, data.length); assertEquals("length plain file", data.length, a.getLocalFileDataLength().getValue()); @@ -100,11 +100,11 @@ public class AsiExtraFieldTest implements UnixStat { assertEquals("uid plain file", 5, a.getUserId()); assertEquals("gid plain file", 6, a.getGroupId()); - data = new byte[] {0x75, (byte)0x8E, 0x41, (byte)0xFD, // CRC - 0123, (byte)0xA0, // mode - 4, 0, 0, 0, // link length - 5, 0, 6, 0, // uid, gid - (byte)'t', (byte)'e', (byte)'s', (byte)'t'}; + data = new byte[] {0x75, (byte) 0x8E, 0x41, (byte) 0xFD, // CRC + 0123, (byte) 0xA0, // mode + 4, 0, 0, 0, // link length + 5, 0, 6, 0, // uid, gid + (byte) 't', (byte) 'e', (byte) 's', (byte) 't'}; a = new AsiExtraField(); a.parseFromLocalFileData(data, 0, data.length); assertEquals("length link", data.length, @@ -116,10 +116,10 @@ public class AsiExtraFieldTest implements UnixStat { assertEquals("gid link", 6, a.getGroupId()); assertEquals("test", a.getLinkedFile()); - data = new byte[] {(byte)0x8E, 0x01, (byte)0xBF, (byte)0x0E, // CRC - 0123, (byte)0x40, // mode - 0, 0, 0, 0, // link - 5, 0, 6, 0}; // uid, gid + data = new byte[] {(byte) 0x8E, 0x01, (byte) 0xBF, (byte) 0x0E, // CRC + 0123, (byte) 0x40, // mode + 0, 0, 0, 0, // link + 5, 0, 6, 0}; // uid, gid a = new AsiExtraField(); a.parseFromLocalFileData(data, 0, data.length); assertEquals("length dir", data.length, @@ -131,7 +131,7 @@ public class AsiExtraFieldTest implements UnixStat { assertEquals("gid dir", 6, a.getGroupId()); data = new byte[] {0, 0, 0, 0, // bad CRC - 0123, (byte)0x40, // mode + 0123, (byte) 0x40, // mode 0, 0, 0, 0, // link 5, 0, 6, 0}; // uid, gid a = new AsiExtraField(); diff --git a/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java b/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java index 6761e4f81..6f21ca8e9 100644 --- a/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java +++ b/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java @@ -187,7 +187,9 @@ public class UTF8ZipFilesTest { if (zos != null) { try { zos.close(); - } catch (IOException e) { /* swallow */ } + } catch (IOException e) { + /* swallow */ + } } } } @@ -234,7 +236,7 @@ public class UTF8ZipFilesTest { ByteBuffer ne = enc.encode(ze.getName()); CRC32 crc = new CRC32(); - crc.update(ne.array(),ne.arrayOffset(),ne.limit()); + crc.update(ne.array(), ne.arrayOffset(), ne.limit()); assertEquals(crc.getValue(), ucpf.getNameCRC32()); assertEquals(expectedName, new String(ucpf.getUnicodeName(), diff --git a/src/tests/junit/org/apache/tools/zip/ZipEncodingTest.java b/src/tests/junit/org/apache/tools/zip/ZipEncodingTest.java index a0f9f55a9..f05d55348 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipEncodingTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipEncodingTest.java @@ -57,8 +57,7 @@ public class ZipEncodingTest { // the defined ones // retrieved by // awk '/^0x/ && NF>2 {print $1;}' CP1252.TXT - byte[] b = - new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + byte[] b = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, @@ -104,9 +103,9 @@ public class ZipEncodingTest { (byte) 0xF1, (byte) 0xF2, (byte) 0xF3, (byte) 0xF4, (byte) 0xF5, (byte) 0xF6, (byte) 0xF7, (byte) 0xF8, (byte) 0xF9, (byte) 0xFA, (byte) 0xFB, (byte) 0xFC, - (byte) 0xFD, (byte) 0xFE, (byte) 0xFF }; + (byte) 0xFD, (byte) 0xFE, (byte) 0xFF}; - doSimpleEncodingTest("Cp1252",b); + doSimpleEncodingTest("Cp1252", b); } private static void assertByteEquals(byte[] expected, ByteBuffer actual) { diff --git a/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java b/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java index 1fd9fd101..fc30eca23 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java @@ -20,6 +20,8 @@ package org.apache.tools.zip; import org.junit.Test; +import java.util.NoSuchElementException; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; @@ -81,7 +83,7 @@ public class ZipEntryTest { try { ze.removeExtraField(ExtraFieldUtilsTest.UNRECOGNIZED_HEADER); fail("should be no such element"); - } catch (java.util.NoSuchElementException nse) { + } catch (NoSuchElementException nse) { //TODO assert exception values } } @@ -178,29 +180,25 @@ public class ZipEntryTest { assertEquals(0, ze.getPlatform()); ze.setUnixMode(0755); assertEquals(3, ze.getPlatform()); - assertEquals(0755, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0, ze.getExternalAttributes() & 0xFFFF); + assertEquals(0755, (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(0, ze.getExternalAttributes() & 0xFFFF); ze.setUnixMode(0444); assertEquals(3, ze.getPlatform()); - assertEquals(0444, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(1, ze.getExternalAttributes() & 0xFFFF); + assertEquals(0444, (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(1, ze.getExternalAttributes() & 0xFFFF); ze = new ZipEntry("foo/"); assertEquals(0, ze.getPlatform()); ze.setUnixMode(0777); assertEquals(3, ze.getPlatform()); - assertEquals(0777, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0x10, ze.getExternalAttributes() & 0xFFFF); + assertEquals(0777, (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(0x10, ze.getExternalAttributes() & 0xFFFF); ze.setUnixMode(0577); assertEquals(3, ze.getPlatform()); - assertEquals(0577, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0x11, ze.getExternalAttributes() & 0xFFFF); + assertEquals(0577, (ze.getExternalAttributes() >> 16) & 0xFFFF); + assertEquals(0x11, ze.getExternalAttributes() & 0xFFFF); } /** diff --git a/src/tests/junit/org/apache/tools/zip/ZipLongTest.java b/src/tests/junit/org/apache/tools/zip/ZipLongTest.java index 12aad022f..b17de99a0 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipLongTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipLongTest.java @@ -79,7 +79,7 @@ public class ZipLongTest { */ @Test public void testSign() { - ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); + ZipLong zl = new ZipLong(new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}); assertEquals(0x00000000FFFFFFFFL, zl.getValue()); } diff --git a/src/tests/junit/org/apache/tools/zip/ZipShortTest.java b/src/tests/junit/org/apache/tools/zip/ZipShortTest.java index 0e3cf2868..b32fa0af0 100644 --- a/src/tests/junit/org/apache/tools/zip/ZipShortTest.java +++ b/src/tests/junit/org/apache/tools/zip/ZipShortTest.java @@ -76,7 +76,7 @@ public class ZipShortTest { */ @Test public void testSign() { - ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF}); + ZipShort zs = new ZipShort(new byte[] {(byte) 0xFF, (byte) 0xFF}); assertEquals(0x0000FFFF, zs.getValue()); }