git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@578739 13f79535-47bb-0310-9956-ffa450edef68master
@@ -38,6 +38,8 @@ import org.apache.tools.ant.util.StringUtils; | |||||
*/ | */ | ||||
public class BriefJUnitResultFormatter implements JUnitResultFormatter { | public class BriefJUnitResultFormatter implements JUnitResultFormatter { | ||||
private static final double ONE_SECOND = 1000.0; | |||||
/** | /** | ||||
* Where to write the log to. | * Where to write the log to. | ||||
*/ | */ | ||||
@@ -134,7 +136,7 @@ public class BriefJUnitResultFormatter implements JUnitResultFormatter { | |||||
sb.append(", Errors: "); | sb.append(", Errors: "); | ||||
sb.append(suite.errorCount()); | sb.append(suite.errorCount()); | ||||
sb.append(", Time elapsed: "); | sb.append(", Time elapsed: "); | ||||
sb.append(numberFormat.format(suite.getRunTime() / 1000.0)); | |||||
sb.append(numberFormat.format(suite.getRunTime() / ONE_SECOND)); | |||||
sb.append(" sec"); | sb.append(" sec"); | ||||
sb.append(StringUtils.LINE_SEP); | sb.append(StringUtils.LINE_SEP); | ||||
sb.append(StringUtils.LINE_SEP); | sb.append(StringUtils.LINE_SEP); | ||||
@@ -40,6 +40,8 @@ import org.apache.tools.ant.util.StringUtils; | |||||
public class PlainJUnitResultFormatter implements JUnitResultFormatter { | public class PlainJUnitResultFormatter implements JUnitResultFormatter { | ||||
private static final double ONE_SECOND = 1000.0; | |||||
/** | /** | ||||
* Formatter for timings. | * Formatter for timings. | ||||
*/ | */ | ||||
@@ -122,7 +124,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { | |||||
sb.append(", Errors: "); | sb.append(", Errors: "); | ||||
sb.append(suite.errorCount()); | sb.append(suite.errorCount()); | ||||
sb.append(", Time elapsed: "); | sb.append(", Time elapsed: "); | ||||
sb.append(nf.format(suite.getRunTime() / 1000.0)); | |||||
sb.append(nf.format(suite.getRunTime() / ONE_SECOND)); | |||||
sb.append(" sec"); | sb.append(" sec"); | ||||
sb.append(StringUtils.LINE_SEP); | sb.append(StringUtils.LINE_SEP); | ||||
@@ -190,7 +192,7 @@ public class PlainJUnitResultFormatter implements JUnitResultFormatter { | |||||
// can be null if an error occurred in setUp | // can be null if an error occurred in setUp | ||||
if (l != null) { | if (l != null) { | ||||
seconds = | seconds = | ||||
(System.currentTimeMillis() - l.longValue()) / 1000.0; | |||||
(System.currentTimeMillis() - l.longValue()) / ONE_SECOND; | |||||
} | } | ||||
wri.println(" took " + nf.format(seconds) + " sec"); | wri.println(" took " + nf.format(seconds) + " sec"); | ||||
@@ -33,6 +33,8 @@ import org.apache.tools.ant.BuildException; | |||||
public class SummaryJUnitResultFormatter | public class SummaryJUnitResultFormatter | ||||
implements JUnitResultFormatter, JUnitTaskMirror.SummaryJUnitResultFormatterMirror { | implements JUnitResultFormatter, JUnitTaskMirror.SummaryJUnitResultFormatterMirror { | ||||
private static final double ONE_SECOND = 1000.0; | |||||
/** | /** | ||||
* Formatter for timings. | * Formatter for timings. | ||||
*/ | */ | ||||
@@ -143,7 +145,7 @@ public class SummaryJUnitResultFormatter | |||||
sb.append(", Errors: "); | sb.append(", Errors: "); | ||||
sb.append(suite.errorCount()); | sb.append(suite.errorCount()); | ||||
sb.append(", Time elapsed: "); | sb.append(", Time elapsed: "); | ||||
sb.append(nf.format(suite.getRunTime() / 1000.0)); | |||||
sb.append(nf.format(suite.getRunTime() / ONE_SECOND)); | |||||
sb.append(" sec"); | sb.append(" sec"); | ||||
sb.append(newLine); | sb.append(newLine); | ||||
@@ -50,6 +50,8 @@ import org.w3c.dom.Text; | |||||
public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstants { | public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstants { | ||||
private static final double ONE_SECOND = 1000.0; | |||||
/** constant for unnnamed testsuites/cases */ | /** constant for unnnamed testsuites/cases */ | ||||
private static final String UNKNOWN = "unknown"; | private static final String UNKNOWN = "unknown"; | ||||
@@ -159,7 +161,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); | rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); | ||||
rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); | ||||
rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); | rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); | ||||
rootElement.setAttribute(ATTR_TIME, "" + (suite.getRunTime() / 1000.0)); | |||||
rootElement.setAttribute( | |||||
ATTR_TIME, "" + (suite.getRunTime() / ONE_SECOND)); | |||||
if (out != null) { | if (out != null) { | ||||
Writer wri = null; | Writer wri = null; | ||||
try { | try { | ||||
@@ -219,7 +222,8 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan | |||||
Long l = (Long) testStarts.get(test); | Long l = (Long) testStarts.get(test); | ||||
currentTest.setAttribute(ATTR_TIME, | currentTest.setAttribute(ATTR_TIME, | ||||
"" + ((System.currentTimeMillis() - l.longValue()) / 1000.0)); | |||||
"" + ((System.currentTimeMillis() | |||||
- l.longValue()) / ONE_SECOND)); | |||||
} | } | ||||
/** | /** | ||||
@@ -35,7 +35,7 @@ import org.apache.tools.ant.BuildEvent; | |||||
import org.apache.tools.ant.BuildListener; | import org.apache.tools.ant.BuildListener; | ||||
class SplashScreen extends JWindow implements ActionListener, BuildListener { | class SplashScreen extends JWindow implements ActionListener, BuildListener { | ||||
private static final int FONT_SIZE = 12; | |||||
private JLabel text; | private JLabel text; | ||||
private JProgressBar pb; | private JProgressBar pb; | ||||
private int total; | private int total; | ||||
@@ -63,7 +63,7 @@ class SplashScreen extends JWindow implements ActionListener, BuildListener { | |||||
piccy.setBorder(BorderFactory.createLineBorder(Color.black, 1)); | piccy.setBorder(BorderFactory.createLineBorder(Color.black, 1)); | ||||
text = new JLabel("Building....", JLabel.CENTER); | text = new JLabel("Building....", JLabel.CENTER); | ||||
text.setFont(new Font("Sans-Serif", Font.BOLD, 12)); | |||||
text.setFont(new Font("Sans-Serif", Font.BOLD, FONT_SIZE)); | |||||
text.setBorder(BorderFactory.createEtchedBorder()); | text.setBorder(BorderFactory.createEtchedBorder()); | ||||
pb = new JProgressBar(MIN, MAX); | pb = new JProgressBar(MIN, MAX); | ||||
@@ -36,6 +36,7 @@ import org.apache.tools.ant.BuildException; | |||||
* Abstract class for ssh upload and download | * Abstract class for ssh upload and download | ||||
*/ | */ | ||||
public abstract class AbstractSshMessage { | public abstract class AbstractSshMessage { | ||||
private static final double ONE_SECOND = 1000.0; | |||||
private Session session; | private Session session; | ||||
private boolean verbose; | private boolean verbose; | ||||
@@ -172,7 +173,7 @@ public abstract class AbstractSshMessage { | |||||
protected void logStats(long timeStarted, | protected void logStats(long timeStarted, | ||||
long timeEnded, | long timeEnded, | ||||
long totalLength) { | long totalLength) { | ||||
double duration = (timeEnded - timeStarted) / 1000.0; | |||||
double duration = (timeEnded - timeStarted) / ONE_SECOND; | |||||
NumberFormat format = NumberFormat.getNumberInstance(); | NumberFormat format = NumberFormat.getNumberInstance(); | ||||
format.setMaximumFractionDigits(2); | format.setMaximumFractionDigits(2); | ||||
format.setMinimumFractionDigits(1); | format.setMinimumFractionDigits(1); | ||||
@@ -201,6 +202,7 @@ public abstract class AbstractSshMessage { | |||||
protected final int trackProgress(long filesize, long totalLength, | protected final int trackProgress(long filesize, long totalLength, | ||||
int percentTransmitted) { | int percentTransmitted) { | ||||
// CheckStyle:MagicNumber OFF | |||||
int percent = (int) Math.round(Math.floor((totalLength | int percent = (int) Math.round(Math.floor((totalLength | ||||
/ (double) filesize) * 100)); | / (double) filesize) * 100)); | ||||
@@ -223,6 +225,7 @@ public abstract class AbstractSshMessage { | |||||
} | } | ||||
} | } | ||||
} | } | ||||
// CheckStyle:MagicNumber ON | |||||
return percent; | return percent; | ||||
} | } | ||||
@@ -365,7 +365,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { | |||||
} | } | ||||
// we know that name.endsWith(".class") | // we know that name.endsWith(".class") | ||||
String base = name.substring(0, name.length() - 6); | |||||
String base = name.substring(0, name.length() - ".class".length()); | |||||
String classname = base.replace(File.separatorChar, '.'); | String classname = base.replace(File.separatorChar, '.'); | ||||
if (attributes.getVerify() | if (attributes.getVerify() | ||||
@@ -126,7 +126,8 @@ public class ClassfileSet extends FileSet { | |||||
for (int i = 0; i < files.length; ++i) { | for (int i = 0; i < files.length; ++i) { | ||||
if (files[i].endsWith(".class")) { | if (files[i].endsWith(".class")) { | ||||
String classFilePath | String classFilePath | ||||
= files[i].substring(0, files[i].length() - 6); | |||||
= files[i].substring( | |||||
0, files[i].length() - ".class".length()); | |||||
String className | String className | ||||
= classFilePath.replace('/', '.').replace('\\', '.'); | = classFilePath.replace('/', '.').replace('\\', '.'); | ||||
allRootClasses.addElement(className); | allRootClasses.addElement(className); | ||||
@@ -56,6 +56,7 @@ import org.apache.tools.ant.BuildException; | |||||
*/ | */ | ||||
public class DigestAlgorithm implements Algorithm { | public class DigestAlgorithm implements Algorithm { | ||||
private static final int BYTE_MASK = 0xFF; | |||||
private static final int BUFFER_SIZE = 8192; | private static final int BUFFER_SIZE = 8192; | ||||
// ----- member variables ----- | // ----- member variables ----- | ||||
@@ -171,7 +172,8 @@ public class DigestAlgorithm implements Algorithm { | |||||
byte[] fileDigest = messageDigest.digest(); | byte[] fileDigest = messageDigest.digest(); | ||||
StringBuffer checksumSb = new StringBuffer(); | StringBuffer checksumSb = new StringBuffer(); | ||||
for (int i = 0; i < fileDigest.length; i++) { | for (int i = 0; i < fileDigest.length; i++) { | ||||
String hexStr = Integer.toHexString(0x00ff & fileDigest[i]); | |||||
String hexStr | |||||
= Integer.toHexString(BYTE_MASK & fileDigest[i]); | |||||
if (hexStr.length() < 2) { | if (hexStr.length() < 2) { | ||||
checksumSb.append("0"); | checksumSb.append("0"); | ||||
} | } | ||||
@@ -36,6 +36,8 @@ import java.io.OutputStream; | |||||
* | * | ||||
*/ | */ | ||||
public class TarInputStream extends FilterInputStream { | public class TarInputStream extends FilterInputStream { | ||||
private static final int BUFFER_SIZE = 8 * 1024; | |||||
private static final int BYTE_MASK = 0xFF; | |||||
// CheckStyle:VisibilityModifier OFF - bc | // CheckStyle:VisibilityModifier OFF - bc | ||||
protected boolean debug; | protected boolean debug; | ||||
@@ -149,7 +151,7 @@ public class TarInputStream extends FilterInputStream { | |||||
// This is horribly inefficient, but it ensures that we | // This is horribly inefficient, but it ensures that we | ||||
// properly skip over bytes via the TarBuffer... | // properly skip over bytes via the TarBuffer... | ||||
// | // | ||||
byte[] skipBuf = new byte[8 * 1024]; | |||||
byte[] skipBuf = new byte[BUFFER_SIZE]; | |||||
long skip = numToSkip; | long skip = numToSkip; | ||||
while (skip > 0) { | while (skip > 0) { | ||||
int realSkip = (int) (skip > skipBuf.length ? skipBuf.length : skip); | int realSkip = (int) (skip > skipBuf.length ? skipBuf.length : skip); | ||||
@@ -287,7 +289,7 @@ public class TarInputStream extends FilterInputStream { | |||||
*/ | */ | ||||
public int read() throws IOException { | public int read() throws IOException { | ||||
int num = this.read(this.oneBuf, 0, 1); | int num = this.read(this.oneBuf, 0, 1); | ||||
return num == -1 ? -1 : ((int) this.oneBuf[0]) & 0xFF; | |||||
return num == -1 ? -1 : ((int) this.oneBuf[0]) & BYTE_MASK; | |||||
} | } | ||||
/** | /** | ||||