Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lynggaard Hansen2012-07-19 14:36:51 -0400
committerHenrik Lynggaard Hansen2012-07-19 16:14:31 -0400
commitab9936c58622d403514fd5c2d465f810f0abc162 (patch)
tree4abe28dab352e901956f4eb3bb9450efb6018f64 /hudson-test-utils
parent69ba5185ed3612ec0de2c9bccd1d42eeb8fbc97c (diff)
downloadorg.eclipse.hudson.core-ab9936c58622d403514fd5c2d465f810f0abc162.tar.gz
org.eclipse.hudson.core-ab9936c58622d403514fd5c2d465f810f0abc162.tar.xz
org.eclipse.hudson.core-ab9936c58622d403514fd5c2d465f810f0abc162.zip
Last of the reformat patches
- Reformat test utils maven module - Reformat cli maven module - Reformat few files in core which wasn't caught the first time - Reformat classes in hudson util maven module For whitespace there should now only be a few instances here and there. There is still a bunch of files which has like one or two errors, but whitespace and formatting is no longer the predominant error in sonar. This is intended as the catch the last patch before M4 hardening begins Change-Id: I9e9d5fabd1a3340e3819ec6edb84ecb6cff8152c Signed-off-by: Henrik Lynggaard Hansen <henrik@hlyh.dk>
Diffstat (limited to 'hudson-test-utils')
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java12
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java10
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java28
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java11
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java23
-rw-r--r--hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java52
6 files changed, 62 insertions, 74 deletions
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java
index 6c83966e..de71fec7 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/FileMatchers.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -25,8 +25,7 @@ import org.hamcrest.TypeSafeMatcher;
/**
* Bulk of implementation copied freely from
- * http://www.time4tea.net/wiki/display/MAIN/Testing+Files+with+Hamcrest
- * <p>
+ * http://www.time4tea.net/wiki/display/MAIN/Testing+Files+with+Hamcrest <p>
* Converted to pure Hamcrest
*
* @author time4tea technology ltd 2007
@@ -67,7 +66,6 @@ public class FileMatchers {
description.appendValue(fileTested);
description.appendText(" exists");
}
-
};
}
@@ -128,7 +126,6 @@ public class FileMatchers {
// public static Matcher<File> sized(Long size) {
// return sized(Matchers.equalTo(size));
// }
-
public static Matcher<File> sized(final Matcher<Long> size) {
return new TypeSafeMatcher<File>() {
File fileTested;
@@ -194,7 +191,6 @@ public class FileMatchers {
public static Matcher<File> withAbsolutePath(final Matcher<String> path) {
return new TypeSafeMatcher<File>() {
// File fileTested;
-
@Override
public boolean matchesSafely(File item) {
// fileTested = item;
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java
index c0aae604..ca2c5205 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLMatchers.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -24,12 +24,12 @@ import org.hamcrest.Matcher;
public class URLMatchers {
@Factory
- public static Matcher<URL> respondsWithStatus(int statusCode){
+ public static Matcher<URL> respondsWithStatus(int statusCode) {
return new URLRespondsWithStatusMatcher(statusCode);
}
@Factory
- public static Matcher<URL> respondsWithStatusWithin(int statusCode, int timeoutMillis){
+ public static Matcher<URL> respondsWithStatusWithin(int statusCode, int timeoutMillis) {
return new URLRespondsWithStatusMatcher(statusCode, timeoutMillis);
}
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java
index 6a86dfc9..1432275f 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/hamcrest/URLRespondsWithStatusMatcher.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -38,10 +38,10 @@ public class URLRespondsWithStatusMatcher extends TypeSafeMatcher<URL> {
}
public URLRespondsWithStatusMatcher(final int statusCode, final int timeout) {
- if(timeout < 0){
+ if (timeout < 0) {
throw new IllegalArgumentException("timeout cannot be negative");
}
- if(statusCode < -1){
+ if (statusCode < -1) {
throw new IllegalArgumentException("status code cannot be less than negative one");
}
this.statusCode = statusCode;
@@ -49,24 +49,23 @@ public class URLRespondsWithStatusMatcher extends TypeSafeMatcher<URL> {
}
public void describeTo(Description description) {
- if(timedOut){
+ if (timedOut) {
description.appendValue(urlString).appendText(" to connect within ").appendValue(timeout).appendText("ms");
- } else if (e != null){
+ } else if (e != null) {
description.appendValue(urlString).appendText(" to successfully connect");
} else {
description.appendValue(urlString).appendText(" to respond with ").appendValue(statusCode);
}
}
-
@Override
protected void describeMismatchSafely(URL item, Description mismatchDescription) {
- if(timedOut){
+ if (timedOut) {
mismatchDescription.appendText("took longer.");
- if(this.e != null){
+ if (this.e != null) {
mismatchDescription.appendText(this.e.getMessage());
}
- } else if (e != null){
+ } else if (e != null) {
mismatchDescription.appendText("got ").appendValue(this.e);
// description.appendText("got exception ").appendValue(e);
} else {
@@ -81,23 +80,22 @@ public class URLRespondsWithStatusMatcher extends TypeSafeMatcher<URL> {
try {
URL url = new URL(item.toString());
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- if(timeout > -1){
+ if (timeout > -1) {
urlConnection.setConnectTimeout(timeout);
urlConnection.setReadTimeout(timeout);
}
urlConnection.setUseCaches(false);
urlConnection.connect();
this.receivedStatusCode = urlConnection.getResponseCode();
- } catch (SocketTimeoutException ste){
+ } catch (SocketTimeoutException ste) {
timedOut = true;
this.e = ste;
} catch (IOException ioe) {
this.e = ioe;
- } catch (Exception e){
+ } catch (Exception e) {
this.e = e;
}
return (!timedOut && e == null && this.receivedStatusCode == this.statusCode);
}
-
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java
index f9167fad..1db62b72 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/junit/ext/URLIsReachable.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -30,7 +30,7 @@ public class URLIsReachable {
private String message = ""; // arg 3, ideally the test name
public URLIsReachable(final String urlString) throws MalformedURLException {
- final String[] args = new String[] { urlString };
+ final String[] args = new String[]{urlString};
init(args);
}
@@ -57,10 +57,9 @@ public class URLIsReachable {
} catch (AssertionError ae) {
System.err.println("[WARN] "
+ String.format("%s caused a test to be ignored %s, %s", this.getClass().getSimpleName(),
- this.message, ae.getMessage()));
+ this.message, ae.getMessage()));
return false;
}
return true;
}
-
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java
index ee54d084..925d4c5a 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/PropUtil.java
@@ -7,30 +7,27 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
package org.hudsonci.utils.test;
-public class PropUtil
-{
- public static String get( String name, String def )
- {
- String val = System.getProperty( name, def );
- if ( val == null || val.length() == 0 || ( val.startsWith( "${" ) && val.endsWith( "}" ) ) )
- {
+public class PropUtil {
+
+ public static String get(String name, String def) {
+ String val = System.getProperty(name, def);
+ if (val == null || val.length() == 0 || (val.startsWith("${") && val.endsWith("}"))) {
val = def;
}
return val;
}
- public static int get( String name, int def )
- {
- return Integer.parseInt( get( name, String.valueOf( def ) ) );
+ public static int get(String name, int def) {
+ return Integer.parseInt(get(name, String.valueOf(def)));
}
}
diff --git a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java
index e351ca41..ad6e69d9 100644
--- a/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java
+++ b/hudson-test-utils/src/main/java/org/hudsonci/utils/test/TestUtil.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,23 +29,21 @@ import com.google.common.base.Preconditions;
* @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
* @since 2.1.0
*/
-public class TestUtil
-{
- private final Class owningClass;
+public class TestUtil {
+ private final Class owningClass;
/**
* The base-directory which tests should be run from.
*
- * @see #initBaseDir() This field is initialized from the return of this method on instance construction.
+ * @see #initBaseDir() This field is initialized from the return of this
+ * method on instance construction.
*/
protected final File baseDir;
-
/**
* Instance logger which tests should use to produce tracing information.
*
- * <p>
- * Unless you have a really good reason to, do not change this field from your sub-class.
- * And if you do, please document why you have done so.
+ * <p> Unless you have a really good reason to, do not change this field
+ * from your sub-class. And if you do, please document why you have done so.
*/
protected final Logger log;
@@ -77,17 +75,19 @@ public class TestUtil
}
/**
- * Determine the value of <tt>${basedir}</tt>, which should be the base directory of
- * the module which the concrete test class is defined in.
+ * Determine the value of <tt>${basedir}</tt>, which should be the base
+ * directory of the module which the concrete test class is defined in.
*
- * <p>
- * If The system property <tt>basedir</tt> is already set, then that value is used,
- * otherwise we determine the value from the code-source of the containing concrete class
- * and set the <tt>basedir</tt> system property to that value.
+ * <p> If The system property <tt>basedir</tt> is already set, then that
+ * value is used, otherwise we determine the value from the code-source of
+ * the containing concrete class and set the <tt>basedir</tt> system
+ * property to that value.
*
- * @see #baseDir This field is always initialized to the value which this method returns.
+ * @see #baseDir This field is always initialized to the value which this
+ * method returns.
*
- * @return The base directory of the module which contains the concrete test class.
+ * @return The base directory of the module which contains the concrete test
+ * class.
*/
protected final File initBaseDir() {
File dir;
@@ -96,8 +96,7 @@ public class TestUtil
String tmp = System.getProperty("basedir");
if (tmp != null) {
dir = new File(tmp);
- }
- else {
+ } else {
// Find the directory which this class (or really the sub-class of TestSupport) is defined in.
String path = owningClass.getProtectionDomain().getCodeSource().getLocation().getFile();
@@ -116,8 +115,8 @@ public class TestUtil
/**
* Resolve the given path to a file rooted to {@link #baseDir}.
*
- * @param path The path to resolve.
- * @return The resolved file for the given path.
+ * @param path The path to resolve.
+ * @return The resolved file for the given path.
*/
public final File resolveFile(final String path) {
Preconditions.checkNotNull(path);
@@ -127,8 +126,7 @@ public class TestUtil
// Complain if the file is already absolute... probably an error
if (file.isAbsolute()) {
log.warn("Given path is already absolute; nothing to resolve: {}", file);
- }
- else {
+ } else {
file = new File(baseDir, path);
}
@@ -138,8 +136,8 @@ public class TestUtil
/**
* Resolve the given path to a path rooted to {@link #baseDir}.
*
- * @param path The path to resolve.
- * @return The resolved path for the given path.
+ * @param path The path to resolve.
+ * @return The resolved path for the given path.
*
* @see #resolveFile(String)
*/

Back to the top