JDK 8 JavaDoc Cleanup
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/jmx/JmxServiceConnection.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/jmx/JmxServiceConnection.java
index 2075d28..830c2c3 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/jmx/JmxServiceConnection.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/jmx/JmxServiceConnection.java
@@ -29,8 +29,8 @@
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
+import org.eclipse.jetty.toolchain.test.IO;
-/* ------------------------------------------------------------ */
/**
* JmxServiceConnection
*
@@ -39,37 +39,31 @@
*/
public class JmxServiceConnection
{
- private String _serviceUrl;
- private MBeanServer _server;
- private JMXConnectorServer _connectorServer;
- private JMXConnector _serverConnector;
- private MBeanServerConnection _serviceConnection;
-
- /* ------------------------------------------------------------ */
+ private String serviceUrl;
+ private MBeanServer server;
+ private JMXConnectorServer connectorServer;
+ private JMXConnector serverConnector;
+ private MBeanServerConnection serviceConnection;
+
/**
* Construct a loopback connection to an internal server
- *
- * @throws IOException
*/
public JmxServiceConnection()
- throws IOException
{
this(null);
}
-
- /* ------------------------------------------------------------ */
+
/**
* Construct a connection to specified server
*
- * @param url URL of JMX server
- * @throws IOException
+ * @param url
+ * URL of JMX server
*/
public JmxServiceConnection(String url)
- throws IOException
{
- _serviceUrl = url;
+ serviceUrl = url;
}
-
+
/**
* Retrieve an external URL for the JMX server
*
@@ -77,9 +71,9 @@
*/
public String getServiceUrl()
{
- return _serviceUrl;
+ return serviceUrl;
}
-
+
/* ------------------------------------------------------------ */
/**
* Retrieve a connection to MBean server
@@ -88,80 +82,73 @@
*/
public MBeanServerConnection getConnection()
{
- return _serviceConnection;
+ return serviceConnection;
}
- public void connect()
- throws IOException
+ public void connect() throws IOException
{
- if (_serviceConnection == null)
+ if (serviceConnection == null)
{
- if (_serviceUrl == null)
+ if (serviceUrl == null)
+ {
openLoopbackConnection();
+ }
else
- openServerConnection(_serviceUrl);
+ {
+ openServerConnection(serviceUrl);
+ }
}
}
- /* ------------------------------------------------------------ */
+
/**
* Open a loopback connection to local JMX server
*
* @throws IOException
*/
- private void openLoopbackConnection()
- throws IOException
+ private void openLoopbackConnection() throws IOException
{
- _server = ManagementFactory.getPlatformMBeanServer();
+ server = ManagementFactory.getPlatformMBeanServer();
JMXServiceURL serviceUrl = new JMXServiceURL("service:jmx:rmi://");
- _connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceUrl, null, _server);
- _connectorServer.start();
-
- _serviceUrl = _connectorServer.getAddress().toString();
-
- _serverConnector = JMXConnectorFactory.connect(_connectorServer.getAddress());
- _serviceConnection = _serverConnector.getMBeanServerConnection();
+ connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceUrl,null,server);
+ connectorServer.start();
+
+ this.serviceUrl = connectorServer.getAddress().toString();
+
+ serverConnector = JMXConnectorFactory.connect(connectorServer.getAddress());
+ serviceConnection = serverConnector.getMBeanServerConnection();
}
-
- /* ------------------------------------------------------------ */
+
/**
* Open a connection to remote JMX server
*
* @param url
* @throws IOException
*/
- private void openServerConnection(String url)
- throws IOException
+ private void openServerConnection(String url) throws IOException
{
- _serviceUrl = url;
-
- JMXServiceURL serviceUrl = new JMXServiceURL(_serviceUrl);
- _serverConnector = JMXConnectorFactory.connect(serviceUrl);
- _serviceConnection = _serverConnector.getMBeanServerConnection();
+ serviceUrl = url;
+ serverConnector = JMXConnectorFactory.connect(new JMXServiceURL(serviceUrl));
+ serviceConnection = serverConnector.getMBeanServerConnection();
}
-
- /* ------------------------------------------------------------ */
+
/**
* Close the connections
*/
public void disconnect()
{
- try
+ IO.close(serverConnector);
+
+ if (connectorServer != null)
{
- if (_serverConnector != null)
+ try
{
- _serverConnector.close();
- _serviceConnection = null;
+ connectorServer.stop();
}
- if (_connectorServer != null)
+ catch (Exception ignore)
{
- _connectorServer.stop();
- _connectorServer = null;
+ /* ignore */
}
}
- catch (Exception ex)
- {
- ex.printStackTrace(System.out);
- }
}
}
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/AdvancedRunner.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/AdvancedRunner.java
index 3cc5511..0b804a5 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/AdvancedRunner.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/AdvancedRunner.java
@@ -34,8 +34,6 @@
* Supports @{@link org.eclipse.jetty.toolchain.test.annotation.Slow Slow} and
* @{@link org.eclipse.jetty.toolchain.test.annotation.Stress Stress} supplemental
* annotation on test methods to allow for filtering of what class of test to execute.
- * <p>
- *
*
* <pre>
* @Test
@@ -57,7 +55,6 @@
* </pre>
*
* To enable / disable the various tests, you have some System properties you can utilize.
- * <p>
*
* <dl>
* <dt>-Dtest.fast</dt>
@@ -77,6 +74,7 @@
private boolean slowTestsEnabled = false;
private boolean stressTestsEnabled = false;
+ @SuppressWarnings("javadoc")
public AdvancedRunner(Class<?> klass) throws InitializationError
{
super(klass);
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/EventQueue.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/EventQueue.java
index d394beb..658296c 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/EventQueue.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/EventQueue.java
@@ -28,10 +28,12 @@
* Event Queue for capturing potential events within a testing scenario.
*
* @param <E>
+ * the type of entry in this EventQueue
*/
@SuppressWarnings("serial")
public class EventQueue<E> extends LinkedBlockingQueue<E>
{
+ @SuppressWarnings("javadoc")
public static final boolean DEBUG = false;
private static final long DEBUG_START = System.currentTimeMillis();
private final ReentrantLock lock = new ReentrantLock();
@@ -56,6 +58,20 @@
}
}
+ /**
+ * Await a specific event count
+ *
+ * @param expectedEventCount
+ * the number of events to wait for
+ * @param timeoutDuration
+ * the timeout duration
+ * @param timeoutUnit
+ * the timeout unit
+ * @throws TimeoutException
+ * if timeout while waiting for the event count
+ * @throws InterruptedException
+ * if await was interrupted
+ */
public void awaitEventCount(int expectedEventCount, int timeoutDuration, TimeUnit timeoutUnit) throws TimeoutException, InterruptedException
{
debug("awaitEventCount(%d,%d,%s)",expectedEventCount,timeoutDuration,timeoutUnit);
@@ -117,8 +133,11 @@
}
}
+ /**
+ * Shutdown the queue.
+ */
public void shutdown()
{
- // TODO Auto-generated method stub
+ /* nothing to do */
}
}
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/FS.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/FS.java
index 36cf5cf..7111fb6 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/FS.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/FS.java
@@ -28,10 +28,11 @@
*/
public final class FS
{
- private FS() {
+ private FS()
+ {
/* prevent instantiation */
}
-
+
/**
* Delete a file or a directory.
* <p>
@@ -42,10 +43,11 @@
*/
public static void delete(File path)
{
- if(!path.exists()) {
+ if (!path.exists())
+ {
return; // nothing to delete. we're done.
}
-
+
if (path.isFile())
{
deleteFile(path);
@@ -206,6 +208,7 @@
* @param file
* the file to create or update the timestamp of.
* @throws IOException
+ * if unable to create the new file.
*/
public static void touch(File file) throws IOException
{
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/IO.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/IO.java
index 0a281c6..1f4b420 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/IO.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/IO.java
@@ -36,14 +36,23 @@
*/
public final class IO
{
+ @SuppressWarnings("javadoc")
public static final int BUFFER_SIZE = 64 * 1024;
-
- private IO() {
+
+ private IO()
+ {
/* prevent instantiation */
}
/**
* Copy Reader to Writer out until EOF or exception.
+ *
+ * @param in
+ * the Reader to read from
+ * @param out
+ * the Writer to write to
+ * @throws IOException
+ * if unable to copy the contents
*/
public static void copy(Reader in, Writer out) throws IOException
{
@@ -112,9 +121,12 @@
/**
* Copy files or directories.
*
- * @param from the from path
- * @param to the destination path
+ * @param from
+ * the from path
+ * @param to
+ * the destination path
* @throws IOException
+ * if unable to copy the file
*/
public static void copy(File from, File to) throws IOException
{
@@ -127,13 +139,16 @@
copyFile(from,to);
}
}
-
+
/**
* Copy the contents of a directory from one directory to another.
*
- * @param from the from directory
- * @param to the destination directory
+ * @param from
+ * the from directory
+ * @param to
+ * the destination directory
* @throws IOException
+ * if unable to copy the file
*/
public static void copyDir(File from, File to) throws IOException
{
@@ -145,10 +160,15 @@
}
}
+ /**
+ * A {@link FileFilter} for obtaining a list of contents that does not contain the special
+ * <code>.</code> and <code>..</code> entries that some JVM environments report.
+ */
public static class SafeFileFilter implements FileFilter
{
+ @SuppressWarnings("javadoc")
public static final SafeFileFilter INSTANCE = new SafeFileFilter();
-
+
public boolean accept(File path)
{
String name = path.getName();
@@ -162,9 +182,13 @@
/**
* Copy the entire {@link InputStream} to the {@link OutputStream}
- * @param in the input stream to read from
- * @param out the output stream to write to
+ *
+ * @param in
+ * the input stream to read from
+ * @param out
+ * the output stream to write to
* @throws IOException
+ * if unable to copy the stream
*/
public static void copy(InputStream in, OutputStream out) throws IOException
{
@@ -185,9 +209,11 @@
/**
* Copy a file from one place to another
*
- * @param from the file to copy
- * @param to the destination file to create
- * @throws IOException
+ * @param from
+ * the file to copy
+ * @param to
+ * the destination file to create
+ * @throws IOException if unable to copy the file
*/
public static void copyFile(File from, File to) throws IOException
{
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JAR.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JAR.java
index 6b1976c..3cbde0a 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JAR.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JAR.java
@@ -99,6 +99,11 @@
}
}
+ /**
+ * Close a JAR file.
+ *
+ * @param jar the JarFile to close
+ */
public static void close(JarFile jar)
{
if (jar == null)
@@ -120,8 +125,8 @@
* Create a JAR file out of the contents of a specific directory (recursively)
*
* @param srcDir the source directory
- * @param jarFile the desination jar file to create
- * @throws IOException
+ * @param jarFile the destination jar file to create
+ * @throws IOException if unable to create the jar file, or read the source directory
*/
public static void create(File srcDir, File jarFile) throws IOException
{
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java
index 1ae48b2..d9e0973 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JDK.java
@@ -18,12 +18,30 @@
package org.eclipse.jetty.toolchain.test;
+/**
+ * Common Java JVM/JDK environment utilities
+ */
public class JDK
{
+ /**
+ * True if JDK is 1.5 (or newer)
+ */
public static final boolean IS_5 = isJavaVersionAtLeast(1,5);
+ /**
+ * True if JDK is 1.6 (or newer)
+ */
public static final boolean IS_6 = isJavaVersionAtLeast(1,6);
+ /**
+ * True if JDK is 1.7 (or newer)
+ */
public static final boolean IS_7 = isJavaVersionAtLeast(1,7);
+ /**
+ * True if JDK is 1.8 (or newer)
+ */
public static final boolean IS_8 = isJavaVersionAtLeast(1,8);
+ /**
+ * True if JDK is 1.9 (or newer)
+ */
public static final boolean IS_9 = isJavaVersionAtLeast(1,9);
private static boolean isJavaVersionAtLeast(int maj, int min)
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JettyDistro.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JettyDistro.java
index 2576375..e0f4e45 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JettyDistro.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/JettyDistro.java
@@ -414,6 +414,8 @@
/**
* Create a <code>${jetty.home}/lib/self/${jarFilename}</code> jar file from the content in the <code>${project.basedir}/target/classes/</code> directory.
*
+ * @param jarFilename the jar filename to create library from
+ *
* @throws IOException
* if unable to copy the directory tree
*/
@@ -572,7 +574,7 @@
}
}
- public static List<String> splitAndUnescapeCommandLine(CharSequence rawCmdLine)
+ static List<String> splitAndUnescapeCommandLine(CharSequence rawCmdLine)
{
List<String> cmds = new ArrayList<String>();
@@ -755,7 +757,7 @@
/**
* enable debug on the jetty process
*
- * @param debug
+ * @param debug flag to enable debug on the jetty process
*/
public void setDebug(boolean debug)
{
@@ -841,6 +843,12 @@
}
}
+ /**
+ * Set the startup timeout, failing if the startup takes too long.
+ *
+ * @param startTime the start time
+ * @param timeUnit the start time unit
+ */
public void setStartTime(long startTime, TimeUnit timeUnit)
{
this.startTime = startTime;
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/MavenTestingUtils.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/MavenTestingUtils.java
index 55b6ca7..679e9aa 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/MavenTestingUtils.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/MavenTestingUtils.java
@@ -36,7 +36,7 @@
private static URI baseURI;
private static File testResourcesDir;
private static File targetDir;
-
+
private MavenTestingUtils()
{
/* prevent instantiation */
@@ -45,10 +45,9 @@
/**
* Obtain a reference to the maven ${basedir} for the module.
* <p>
- * Note: while running in maven, the ${basedir} is populated by maven and used by the surefire-plugin.
- * <br>
- * While running in eclipse, the ${basedir} property is unset, resulting in this method falling back to
- * ${user.dir} equivalent use.
+ * Note: while running in maven, the ${basedir} is populated by maven and used by the surefire-plugin. <br>
+ * While running in eclipse, the ${basedir} property is unset, resulting in this method falling back to ${user.dir}
+ * equivalent use.
*
* @return the equivalent to the maven ${basedir} property.
*/
@@ -114,7 +113,7 @@
/**
* Get the directory reference to the maven <code>${basedir}/target/tests/</code> path.
*
- * @return the maven <code>${basedir}/target/tests/</code> directory.
+ * @return the maven <code>${basedir}/target/tests/</code> directory.
* Note: will not validate that the directory exists, or create the directory)
*/
public static File getTargetTestingDir()
@@ -136,8 +135,8 @@
}
/**
- * Get a directory reference to the <code>${basedir}/target/tests/test-${testname}</code>
- * that uses the JUnit 3.x {@link TestCase#getName()} to make itself unique.
+ * Get a directory reference to the <code>${basedir}/target/tests/test-${testname}</code> that uses the JUnit 3.x
+ * {@link TestCase#getName()} to make itself unique.
*
* @param test
* the junit 3.x testcase to base this new directory on.
@@ -151,8 +150,11 @@
/**
* Get a URI reference to a path (File or Dir) within the maven "${basedir}/target" directory.
*
- * @param path the relative path to use
+ * @param path
+ * the relative path to use
* @return the URI reference to the target path
+ * @throws MalformedURLException
+ * if unable to create a new target url due to URL error.
*/
public static URI getTargetURI(String path) throws MalformedURLException
{
@@ -162,9 +164,11 @@
/**
* Get a URL reference to a path (File or Dir) within the maven "${basedir}/target" directory.
*
- * @param path the relative path to use
+ * @param path
+ * the relative path to use
* @return the URL reference to the target path
* @throws MalformedURLException
+ * if unable to create a new target url due to URL error.
*/
public static URL getTargetURL(String path) throws MalformedURLException
{
@@ -172,10 +176,9 @@
}
/**
- * Obtain a testing directory reference in maven
- * <code>${basedir}/target/tests/${condensed-classname}/${methodname}</code>
- * path that uses an condensed directory
- * name based on the testclass and subdirectory based on the testmethod being run.
+ * Obtain a testing directory reference in maven
+ * <code>${basedir}/target/tests/${condensed-classname}/${methodname}</code> path that uses an condensed directory
+ * name based on the testclass and subdirectory based on the testmethod being run.
* <p>
* Note: the @Rule {@link TestingDir} is a better choice in most cases.
*
@@ -183,8 +186,8 @@
* the class for the test case
* @param testmethodname
* the test method name
- * @return the File path to the testname specific testing directory underneath the <code>${basedir}/target/tests/</code>
- * sub directory
+ * @return the File path to the testname specific testing directory underneath the
+ * <code>${basedir}/target/tests/</code> sub directory
* @see FS
* @see TestingDir
*/
@@ -217,7 +220,7 @@
/**
* Using Junit 3.x test naming standards, attempt to discover a suitable test directory name
* based on the execution stack when this method is called.
- *
+ *
* @return the testing directory name (only the name, not the full path)
* @deprecated Upgrade to Junit 4.x and use the {@link TestingDir} @Rule instead
*/
@@ -244,7 +247,8 @@
* <p>
* Note: will throw assertion error if path does point to an existing file
*
- * @param path the relative path to reference
+ * @param path
+ * the relative path to reference
* @return the file reference (must exist)
*/
public static File getProjectFile(String path)
@@ -260,7 +264,8 @@
* <p>
* Note: will throw assertion error if path does point to an existing directory
*
- * @param path the relative path to reference
+ * @param path
+ * the relative path to reference
* @return the directory reference (must exist)
*/
public static File getProjectDir(String path)
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/OS.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/OS.java
index 183e4bf..96de76a 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/OS.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/OS.java
@@ -25,14 +25,35 @@
*/
public final class OS
{
+ /**
+ * The name of the OS
+ */
public static final String OS_NAME = System.getProperty("os.name");
+ /**
+ * True if OS is windows
+ */
public static final boolean IS_WINDOWS = isOSName("Windows");
+ /**
+ * True if OS is OSX
+ */
public static final boolean IS_OSX = isOSName("Mac OS X");
+ /**
+ * True if OS is Linux
+ */
public static final boolean IS_LINUX = isOSName("Linux") || isOSName("LINUX");
+ /**
+ * True if OS is Unix (Unix || AIX || Linux || OSX)
+ */
public static final boolean IS_UNIX = isOSName("Unix") || isOSName("AIX") || IS_LINUX || IS_OSX;
+ /**
+ * Line Separator string.
+ * <p>
+ * Note: For Java 1.7 or newer, use {@link System#lineSeparator()}
+ */
public static final String LN = System.getProperty("line.separator");
-
- private OS() {
+
+ private OS()
+ {
/* prevent instantiation */
}
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/PropertyFlag.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/PropertyFlag.java
index b6d845e..f22c293 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/PropertyFlag.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/PropertyFlag.java
@@ -21,18 +21,20 @@
import org.junit.internal.AssumptionViolatedException;
/**
- * Flag indicating that {@link Test} is part of special group of tests.
+ * Flag indicating that {@link org.junit.Test} is part of special group of tests.
*/
public final class PropertyFlag
{
- private PropertyFlag() {
+ private PropertyFlag()
+ {
/* prevent instantiation */
}
-
+
/**
- * Returns flag indicating if <code>-D<flag></code> or <code>-D<flag>=true</code> is enabled.
+ * Returns flag indicating if <code>-D<flag></code> or <code>-D<flag>=true</code> is enabled.
*
- * @param property name of the system property representing this flag
+ * @param property
+ * name of the system property representing this flag
* @return true if enabled
*/
public static boolean isEnabled(String property)
@@ -52,16 +54,19 @@
}
/**
- * Labels the test method as belonging to Stress testing.
+ * Junit Assumption based on the value of a System Property.
* <p>
- * Checks for the existence of the "STRESS" system property, if found, it allows the test to execute. If not found,
- * the test is flagged as ignored and returned.
+ * If property is found, with no value, then it assumed to be true. Otherwise the value is parsed a
+ * {@link Boolean#parseBoolean(String)} and used for junit assume logic.
+ *
+ * @param property
+ * the system property to look for
*/
public static void assume(String property)
{
if (!isEnabled(property))
{
- throw new AssumptionViolatedException("Test is not enabled");
+ throw new AssumptionViolatedException("System Property '" + property + "' not set");
}
}
}
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/SimpleRequest.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/SimpleRequest.java
index e0d8eaf..a52c17e 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/SimpleRequest.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/SimpleRequest.java
@@ -24,7 +24,6 @@
import java.io.StringWriter;
import java.net.HttpURLConnection;
import java.net.URI;
-import java.net.UnknownHostException;
import java.util.Properties;
/**
@@ -39,11 +38,26 @@
{
private URI baseUri;
- public SimpleRequest(URI serverURI) throws UnknownHostException
+ /**
+ * Setup a SimpleRequest initiator against serverURI
+ *
+ * @param serverURI
+ * the server URI to base all requests off of
+ */
+ public SimpleRequest(URI serverURI)
{
this.baseUri = serverURI;
}
+ /**
+ * Initiate a simple GET request on the path specified.
+ *
+ * @param relativePath
+ * the relative path of the serverURI to resource for this GET request
+ * @return the response contents
+ * @throws IOException
+ * if unable to communicate with server
+ */
public String getString(String relativePath) throws IOException
{
URI uri = this.baseUri.resolve(relativePath);
@@ -77,6 +91,19 @@
}
}
+ /**
+ * Initiate a simple GET request on the path specified, returning the response contents as a {@link Properties}
+ * object.
+ * <p>
+ * This expects that the GET response will be in the form of a Properties text file, in a format that is suitable
+ * for {@link Properties#load(InputStream)} use.
+ *
+ * @param relativePath
+ * the relative path of the serverURI to resource for this GET request
+ * @return the response contents as a {@link Properties} object.
+ * @throws IOException
+ * if unable to communicate with server
+ */
public Properties getProperties(String relativePath) throws IOException
{
URI uri = this.baseUri.resolve(relativePath);
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringAssert.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringAssert.java
index d890da0..8fde4d5 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringAssert.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringAssert.java
@@ -22,6 +22,9 @@
import org.junit.Assert;
+/**
+ * Collection of common asserts for Strings.
+ */
public final class StringAssert
{
private StringAssert() {
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringMangler.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringMangler.java
index 19f0ef6..8684bdb 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringMangler.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/StringMangler.java
@@ -26,7 +26,6 @@
/**
* Condenses a classname by stripping down the package name to just the first character of each package name
* segment.
- * <p>
*
* <pre>
* Examples:
@@ -52,7 +51,6 @@
/**
* Smash a long string to fit within the max string length, by taking the middle section of the string and replacing them with an ellipsis "..."
- * <p>
*
* <pre>
* Examples:
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestTracker.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestTracker.java
index 47ab59a..2d366fa 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestTracker.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestTracker.java
@@ -26,7 +26,6 @@
* <p>
* Note: {@link AdvancedRunner} performs tracking as well, there is no need
* for this @Rule if you have AdvancedRunner in use.
- * <p>
* <pre>
* @Rule
* public TestTracker ttracker = new TestTracker();
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestingDir.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestingDir.java
index 7ffa5fc..60b27a4 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestingDir.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/TestingDir.java
@@ -26,9 +26,9 @@
import org.junit.runners.model.Statement;
/**
- * A junit 4.x {@link Rule} to provide a common, easy to use, testing directory that is unique per unit test method.
+ * A junit 4.x {@link org.junit.Rule} to provide a common, easy to use, testing directory that is unique per unit test method.
* <p>
- * Similar in scope to the {@link TemporaryFolder} rule, as it creates a directory, when asked (via {@link #getDir()} or {@link #getEmptyDir()}) in the maven
+ * Similar in scope to the {@link org.junit.rules.TemporaryFolder} rule, as it creates a directory, when asked (via {@link #getDir()} or {@link #getEmptyDir()}) in the maven
* project familiar and friendly maven location of <code>${basedir}/target/tests/${testclass}/${testmethod}</code>.
* <p>
* Note: {@link MavenTestingUtils} will keep the directory name short for the sake of windows users.
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/annotation/Stress.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/annotation/Stress.java
index f6a6c8b..895ba03 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/annotation/Stress.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/annotation/Stress.java
@@ -24,12 +24,12 @@
import java.lang.annotation.Target;
/**
- * Indication for test cases that require extra knowledge to setup the testing
- * environment properly. (Such as more memory required than usual, or a
+ * Indication for test cases that require extra knowledge to setup the testing
+ * environment properly. (Such as more memory required than usual, or a
* calm system to run large I/O tests on)
* <p>
- * Tests that have been marked as Stress can often be moved to Slow as time progresses
- * (and general system capabilities improve).
+ * Tests that have been marked as Stress can often be moved to Slow as time progresses (and general system capabilities
+ * improve).
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@@ -40,7 +40,9 @@
* <p>
* Indicate what sort of environmental concerns this test has.
* <p>
- * Eg: "High memory use: > 2GB", "High file descriptor use", "Needs calm system"
+ * Eg: "High memory use: > 2GB", "High file descriptor use", "Needs calm system"
+ *
+ * @return the string reason why the test is set as Stress.
*/
- String value();
+ String value();
}
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpParser.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpParser.java
index 5221249..f029ae0 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpParser.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpParser.java
@@ -46,9 +46,11 @@
* Reads from the given {@link BufferedReader} and returns the parsed response in a {@link SimpleHttpResponse}
* object.
*
- * @param reader the inputReader to parse the response from
- * @return {@link SimpleHttpResponse} a {@link SimpleHttpResponse} object representing the parsed response
+ * @param reader
+ * the inputReader to parse the response from
+ * @return {@link SimpleHttpResponse} a {@link SimpleHttpResponse} object representing the parsed response
* @throws IOException
+ * if unable to read/parse the raw lines of http
*/
public SimpleHttpResponse readResponse(BufferedReader reader) throws IOException
{
@@ -57,7 +59,7 @@
if (line == null)
throw new EOFException();
Matcher responseLine = Pattern.compile("HTTP/1.1" + "\\s+(\\d+)").matcher(line);
- assertThat("http version is 1.1", responseLine.lookingAt(), is(true));
+ assertThat("http version is 1.1",responseLine.lookingAt(),is(true));
String code = responseLine.group(1);
Map<String, String> headers = new LinkedHashMap<String, String>();
@@ -66,13 +68,13 @@
if (line.trim().length() == 0)
break;
- parseHeader(line, headers);
+ parseHeader(line,headers);
}
StringBuilder body;
if (headers.containsKey("content-length"))
{
- body = parseContentLengthDelimitedBody(reader, headers);
+ body = parseContentLengthDelimitedBody(reader,headers);
}
else if ("chunked".equals(headers.get("transfer-encoding")))
{
@@ -80,10 +82,10 @@
}
else
{
- body = parseEOFDelimitedBody(reader, headers);
+ body = parseEOFDelimitedBody(reader,headers);
}
- return new SimpleHttpResponse(code, headers, body.toString().trim());
+ return new SimpleHttpResponse(code,headers,body.toString().trim());
}
private void parseHeader(String line, Map<String, String> headers)
@@ -92,7 +94,7 @@
assertTrue(header.lookingAt());
String headerName = header.group(1);
String headerValue = header.group(2);
- headers.put(headerName.toLowerCase(), headerValue.toLowerCase());
+ headers.put(headerName.toLowerCase(),headerValue.toLowerCase());
}
private StringBuilder parseContentLengthDelimitedBody(BufferedReader reader, Map<String, String> headers) throws IOException
@@ -114,7 +116,7 @@
}
catch (SocketTimeoutException e)
{
- System.err.printf("Read %,d bytes (out of an expected %,d bytes)%n", readLen, length);
+ System.err.printf("Read %,d bytes (out of an expected %,d bytes)%n",readLen,length);
throw e;
}
return body;
@@ -130,11 +132,11 @@
if ("0".equals(line))
{
line = reader.readLine();
- assertThat("There's no more content after as 0 indicated the final chunk", line, is(""));
+ assertThat("There's no more content after as 0 indicated the final chunk",line,is(""));
break;
}
- int length = Integer.parseInt(line, 16);
+ int length = Integer.parseInt(line,16);
//TODO: UTF-8 reader from joakim
for (int i = 0; i < length; ++i)
{
diff --git a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpResponse.java b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpResponse.java
index 59321e3..317d766 100644
--- a/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpResponse.java
+++ b/jetty-test-helper/src/main/java/org/eclipse/jetty/toolchain/test/http/SimpleHttpResponse.java
@@ -18,6 +18,7 @@
package org.eclipse.jetty.toolchain.test.http;
+import java.util.Collections;
import java.util.Map;
/**
@@ -29,6 +30,13 @@
private final Map<String, String> headers;
private final String body;
+ /**
+ * Initialize the immutable HTTP Response details
+ *
+ * @param code the response status code
+ * @param headers the response headers
+ * @param body the response body content
+ */
public SimpleHttpResponse(String code, Map<String, String> headers, String body)
{
this.code = code;
@@ -36,16 +44,25 @@
this.body = body;
}
+ /**
+ * @return the response status code
+ */
public String getCode()
{
return code;
}
+ /**
+ * @return the response headers
+ */
public Map<String, String> getHeaders()
{
- return headers;
+ return Collections.unmodifiableMap(headers);
}
+ /**
+ * @return the response body content
+ */
public String getBody()
{
return body;