LANG-1024: Fix JavaDoc errors in test code

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1609902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2014-07-12 11:01:37 +00:00
parent 6240a05c12
commit 967fdd064c
21 changed files with 206 additions and 100 deletions

View File

@ -71,10 +71,6 @@ The code base is monitored by a Sonar instance running on <a href="https://analy
<li>Examine the <a href="article3_0.html">2.x to 3.0 upgrade notes</a></li> <li>Examine the <a href="article3_0.html">2.x to 3.0 upgrade notes</a></li>
<li>Compare major versions via the <a href="lang2-lang3-clirr-report.html">Lang2 to Lang3 Clirr report</a></li> <li>Compare major versions via the <a href="lang2-lang3-clirr-report.html">Lang2 to Lang3 Clirr report</a></li>
</ul> </ul>
<p><em>Special note on 3.3.2 and Java 8:</em> Due to the addition of <a href="http://openjdk.java.net/jeps/172">DocLint</a>
to the JavaDoc tool <code>mvn site</code> will currently fail because the test code contains malformed JavaDoc comments.
If you want to build the site yourself use Java 6 or Java 7 or deactivate DocLint by configuring the Maven JavaDoc with
<code>&lt;additionalparam&gt;-Xdoclint:none&lt;&#47;additionalparam&gt;</code>.</p>
<p> <p>
Alternatively you can pull it from the central Maven repositories: Alternatively you can pull it from the central Maven repositories:
<pre> <pre>

View File

@ -468,6 +468,8 @@ public class ObjectUtilsTest {
/** /**
* Tests {@link ObjectUtils#clone(Object)} with an uncloneable object. * Tests {@link ObjectUtils#clone(Object)} with an uncloneable object.
*
* @throws java.lang.Throwable because we expect this to fail
*/ */
@Test(expected = NoSuchMethodException.class) @Test(expected = NoSuchMethodException.class)
public void testCloneOfUncloneable() throws Throwable { public void testCloneOfUncloneable() throws Throwable {
@ -518,6 +520,8 @@ public class ObjectUtilsTest {
/** /**
* Tests {@link ObjectUtils#cloneIfPossible(Object)} with an uncloneable object. * Tests {@link ObjectUtils#cloneIfPossible(Object)} with an uncloneable object.
*
* @throws java.lang.Throwable because we expect this to fail
*/ */
@Test(expected = NoSuchMethodException.class) @Test(expected = NoSuchMethodException.class)
public void testPossibleCloneOfUncloneable() throws Throwable { public void testPossibleCloneOfUncloneable() throws Throwable {

View File

@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.nio.charset.Charset;
import java.util.Random; import java.util.Random;
import org.junit.Test; import org.junit.Test;
@ -334,16 +335,14 @@ public class RandomStringUtilsTest {
* can be converted to UTF-8 and back without loss. * can be converted to UTF-8 and back without loss.
* *
* @see <a href="http://issues.apache.org/jira/browse/LANG-100">LANG-100</a> * @see <a href="http://issues.apache.org/jira/browse/LANG-100">LANG-100</a>
*
* @throws Exception
*/ */
@Test @Test
public void testLang100() throws Exception { public void testLang100() {
final int size = 5000; final int size = 5000;
final String encoding = "UTF-8"; final Charset charset = Charset.forName("UTF-8");
final String orig = RandomStringUtils.random(size); final String orig = RandomStringUtils.random(size);
final byte[] bytes = orig.getBytes(encoding); final byte[] bytes = orig.getBytes(charset);
final String copy = new String(bytes, encoding); final String copy = new String(bytes, charset);
// for a verbose compare: // for a verbose compare:
for (int i=0; i < orig.length() && i < copy.length(); i++) { for (int i=0; i < orig.length() && i < copy.length(); i++) {

View File

@ -84,7 +84,7 @@ public class RandomUtilsTest {
* Tests a zero byte array length. * Tests a zero byte array length.
*/ */
@Test @Test
public void testZeroLengthNextBytes() throws Exception { public void testZeroLengthNextBytes() {
assertArrayEquals(new byte[0], RandomUtils.nextBytes(0)); assertArrayEquals(new byte[0], RandomUtils.nextBytes(0));
} }
@ -92,7 +92,7 @@ public class RandomUtilsTest {
* Tests random byte array. * Tests random byte array.
*/ */
@Test @Test
public void testNextBytes() throws Exception { public void testNextBytes() {
final byte[] result = RandomUtils.nextBytes(20); final byte[] result = RandomUtils.nextBytes(20);
assertEquals(20, result.length); assertEquals(20, result.length);
} }
@ -101,7 +101,7 @@ public class RandomUtilsTest {
* Test next int range with minimal range. * Test next int range with minimal range.
*/ */
@Test @Test
public void testNextIntMinimalRange() throws Exception { public void testNextIntMinimalRange() {
assertEquals(42, RandomUtils.nextInt(42, 42)); assertEquals(42, RandomUtils.nextInt(42, 42));
} }
@ -109,7 +109,7 @@ public class RandomUtilsTest {
* Tests next int range. * Tests next int range.
*/ */
@Test @Test
public void testNextInt() throws Exception { public void testNextInt() {
final int result = RandomUtils.nextInt(33, 42); final int result = RandomUtils.nextInt(33, 42);
assertTrue(result >= 33 && result < 42); assertTrue(result >= 33 && result < 42);
} }
@ -118,7 +118,7 @@ public class RandomUtilsTest {
* Test next double range with minimal range. * Test next double range with minimal range.
*/ */
@Test @Test
public void testNextDoubleMinimalRange() throws Exception { public void testNextDoubleMinimalRange() {
assertEquals(42.1, RandomUtils.nextDouble(42.1, 42.1), DELTA); assertEquals(42.1, RandomUtils.nextDouble(42.1, 42.1), DELTA);
} }
@ -126,7 +126,7 @@ public class RandomUtilsTest {
* Test next float range with minimal range. * Test next float range with minimal range.
*/ */
@Test @Test
public void testNextFloatMinimalRange() throws Exception { public void testNextFloatMinimalRange() {
assertEquals(42.1f, RandomUtils.nextFloat(42.1f, 42.1f), DELTA); assertEquals(42.1f, RandomUtils.nextFloat(42.1f, 42.1f), DELTA);
} }
@ -134,7 +134,7 @@ public class RandomUtilsTest {
* Tests next double range. * Tests next double range.
*/ */
@Test @Test
public void testNextDouble() throws Exception { public void testNextDouble() {
final double result = RandomUtils.nextDouble(33d, 42d); final double result = RandomUtils.nextDouble(33d, 42d);
assertTrue(result >= 33d && result <= 42d); assertTrue(result >= 33d && result <= 42d);
} }
@ -143,7 +143,7 @@ public class RandomUtilsTest {
* Tests next float range. * Tests next float range.
*/ */
@Test @Test
public void testNextFloat() throws Exception { public void testNextFloat() {
final double result = RandomUtils.nextFloat(33f, 42f); final double result = RandomUtils.nextFloat(33f, 42f);
assertTrue(result >= 33f && result <= 42f); assertTrue(result >= 33f && result <= 42f);
} }
@ -152,7 +152,7 @@ public class RandomUtilsTest {
* Test next long range with minimal range. * Test next long range with minimal range.
*/ */
@Test @Test
public void testNextLongMinimalRange() throws Exception { public void testNextLongMinimalRange() {
assertEquals(42L, RandomUtils.nextLong(42L, 42L)); assertEquals(42L, RandomUtils.nextLong(42L, 42L));
} }
@ -160,7 +160,7 @@ public class RandomUtilsTest {
* Tests next long range. * Tests next long range.
*/ */
@Test @Test
public void testNextLong() throws Exception { public void testNextLong() {
final long result = RandomUtils.nextLong(33L, 42L); final long result = RandomUtils.nextLong(33L, 42L);
assertTrue(result >= 33L && result < 42L); assertTrue(result >= 33L && result < 42L);
} }
@ -170,7 +170,7 @@ public class RandomUtilsTest {
* Tests extreme range. * Tests extreme range.
*/ */
@Test @Test
public void testExtremeRangeInt() throws Exception { public void testExtremeRangeInt() {
final int result = RandomUtils.nextInt(0, Integer.MAX_VALUE); final int result = RandomUtils.nextInt(0, Integer.MAX_VALUE);
assertTrue(result >= 0 && result < Integer.MAX_VALUE); assertTrue(result >= 0 && result < Integer.MAX_VALUE);
} }
@ -179,7 +179,7 @@ public class RandomUtilsTest {
* Tests extreme range. * Tests extreme range.
*/ */
@Test @Test
public void testExtremeRangeLong() throws Exception { public void testExtremeRangeLong() {
final long result = RandomUtils.nextLong(0, Long.MAX_VALUE); final long result = RandomUtils.nextLong(0, Long.MAX_VALUE);
assertTrue(result >= 0 && result < Long.MAX_VALUE); assertTrue(result >= 0 && result < Long.MAX_VALUE);
} }
@ -188,7 +188,7 @@ public class RandomUtilsTest {
* Tests extreme range. * Tests extreme range.
*/ */
@Test @Test
public void testExtremeRangeFloat() throws Exception { public void testExtremeRangeFloat() {
final float result = RandomUtils.nextFloat(0, Float.MAX_VALUE); final float result = RandomUtils.nextFloat(0, Float.MAX_VALUE);
assertTrue(result >= 0f && result <= Float.MAX_VALUE); assertTrue(result >= 0f && result <= Float.MAX_VALUE);
} }
@ -197,7 +197,7 @@ public class RandomUtilsTest {
* Tests extreme range. * Tests extreme range.
*/ */
@Test @Test
public void testExtremeRangeDouble() throws Exception { public void testExtremeRangeDouble() {
final double result = RandomUtils.nextDouble(0, Double.MAX_VALUE); final double result = RandomUtils.nextDouble(0, Double.MAX_VALUE);
assertTrue(result >= 0 && result <= Double.MAX_VALUE); assertTrue(result >= 0 && result <= Double.MAX_VALUE);
} }

View File

@ -27,6 +27,7 @@ import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.nio.charset.Charset;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.text.translate.CharSequenceTranslator; import org.apache.commons.lang3.text.translate.CharSequenceTranslator;
@ -510,18 +511,16 @@ public class StringEscapeUtilsTest {
/** /**
* Tests // https://issues.apache.org/jira/browse/LANG-480 * Tests // https://issues.apache.org/jira/browse/LANG-480
*
* @throws java.io.UnsupportedEncodingException
*/ */
@Test @Test
public void testEscapeHtmlHighUnicode() throws java.io.UnsupportedEncodingException { public void testEscapeHtmlHighUnicode() {
// this is the utf8 representation of the character: // this is the utf8 representation of the character:
// COUNTING ROD UNIT DIGIT THREE // COUNTING ROD UNIT DIGIT THREE
// in Unicode // in Unicode
// codepoint: U+1D362 // codepoint: U+1D362
final byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 }; final byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 };
final String original = new String(data, "UTF8"); final String original = new String(data, Charset.forName("UTF8"));
final String escaped = StringEscapeUtils.escapeHtml4( original ); final String escaped = StringEscapeUtils.escapeHtml4( original );
assertEquals( "High Unicode should not have been escaped", original, escaped); assertEquals( "High Unicode should not have been escaped", original, escaped);

View File

@ -2316,22 +2316,21 @@ public class StringUtilsTest {
/** /**
* Tests {@link StringUtils#toString(byte[], String)} * Tests {@link StringUtils#toString(byte[], String)}
* *
* @throws UnsupportedEncodingException * @throws java.io.UnsupportedEncodingException because the method under test max throw it
* @see StringUtils#toString(byte[], String) * @see StringUtils#toString(byte[], String)
*/ */
@Test @Test
public void testToString() throws UnsupportedEncodingException { public void testToString() throws UnsupportedEncodingException {
final String expectedString = "The quick brown fox jumped over the lazy dog."; final String expectedString = "The quick brown fox jumped over the lazy dog.";
String encoding = SystemUtils.FILE_ENCODING; byte[] expectedBytes = expectedString.getBytes(Charset.defaultCharset());
byte[] expectedBytes = expectedString.getBytes(encoding);
// sanity check start // sanity check start
assertArrayEquals(expectedBytes, expectedString.getBytes()); assertArrayEquals(expectedBytes, expectedString.getBytes());
// sanity check end // sanity check end
assertEquals(expectedString, StringUtils.toString(expectedBytes, null)); assertEquals(expectedString, StringUtils.toString(expectedBytes, null));
assertEquals(expectedString, StringUtils.toString(expectedBytes, encoding)); assertEquals(expectedString, StringUtils.toString(expectedBytes, SystemUtils.FILE_ENCODING));
encoding = "UTF-16"; String encoding = "UTF-16";
expectedBytes = expectedString.getBytes(encoding); expectedBytes = expectedString.getBytes(Charset.forName(encoding));
assertEquals(expectedString, StringUtils.toString(expectedBytes, encoding)); assertEquals(expectedString, StringUtils.toString(expectedBytes, encoding));
} }
@ -2349,11 +2348,9 @@ public class StringUtilsTest {
/** /**
* Tests LANG-858. * Tests LANG-858.
*
* @throws Exception
*/ */
@Test @Test
public void testEscapeSurrogatePairsLang858() throws Exception { public void testEscapeSurrogatePairsLang858() {
assertEquals("\\uDBFF\\uDFFD", StringEscapeUtils.escapeJava("\uDBFF\uDFFD")); //fail LANG-858 assertEquals("\\uDBFF\\uDFFD", StringEscapeUtils.escapeJava("\uDBFF\uDFFD")); //fail LANG-858
assertEquals("\\uDBFF\\uDFFD", StringEscapeUtils.escapeEcmaScript("\uDBFF\uDFFD")); //fail LANG-858 assertEquals("\\uDBFF\\uDFFD", StringEscapeUtils.escapeEcmaScript("\uDBFF\uDFFD")); //fail LANG-858
} }
@ -2468,21 +2465,20 @@ public class StringUtilsTest {
/** /**
* Tests {@link StringUtils#toEncodedString(byte[], Charset)} * Tests {@link StringUtils#toEncodedString(byte[], Charset)}
* *
* @throws UnsupportedEncodingException
* @see StringUtils#toEncodedString(byte[], Charset) * @see StringUtils#toEncodedString(byte[], Charset)
*/ */
@Test @Test
public void testToEncodedString() throws UnsupportedEncodingException { public void testToEncodedString() {
final String expectedString = "The quick brown fox jumped over the lazy dog."; final String expectedString = "The quick brown fox jumped over the lazy dog.";
String encoding = SystemUtils.FILE_ENCODING; String encoding = SystemUtils.FILE_ENCODING;
byte[] expectedBytes = expectedString.getBytes(encoding); byte[] expectedBytes = expectedString.getBytes(Charset.defaultCharset());
// sanity check start // sanity check start
assertArrayEquals(expectedBytes, expectedString.getBytes()); assertArrayEquals(expectedBytes, expectedString.getBytes());
// sanity check end // sanity check end
assertEquals(expectedString, StringUtils.toEncodedString(expectedBytes, Charset.defaultCharset())); assertEquals(expectedString, StringUtils.toEncodedString(expectedBytes, Charset.defaultCharset()));
assertEquals(expectedString, StringUtils.toEncodedString(expectedBytes, Charset.forName(encoding))); assertEquals(expectedString, StringUtils.toEncodedString(expectedBytes, Charset.forName(encoding)));
encoding = "UTF-16"; encoding = "UTF-16";
expectedBytes = expectedString.getBytes(encoding); expectedBytes = expectedString.getBytes(Charset.forName(encoding));
assertEquals(expectedString, StringUtils.toEncodedString(expectedBytes, Charset.forName(encoding))); assertEquals(expectedString, StringUtils.toEncodedString(expectedBytes, Charset.forName(encoding)));
} }

View File

@ -396,7 +396,7 @@ public class ToStringBuilderTest {
* Test an array element pointing to its container. * Test an array element pointing to its container.
*/ */
@Test @Test
public void testReflectionArrayCycle() throws Exception { public void testReflectionArrayCycle() {
final Object[] objects = new Object[1]; final Object[] objects = new Object[1];
objects[0] = objects; objects[0] = objects;
assertEquals( assertEquals(
@ -408,7 +408,7 @@ public class ToStringBuilderTest {
* Test an array element pointing to its container. * Test an array element pointing to its container.
*/ */
@Test @Test
public void testReflectionArrayCycleLevel2() throws Exception { public void testReflectionArrayCycleLevel2() {
final Object[] objects = new Object[1]; final Object[] objects = new Object[1];
final Object[] objectsLevel2 = new Object[1]; final Object[] objectsLevel2 = new Object[1];
objects[0] = objectsLevel2; objects[0] = objectsLevel2;
@ -522,11 +522,9 @@ public class ToStringBuilderTest {
/** /**
* Test an Object pointing to itself, the simplest test. * Test an Object pointing to itself, the simplest test.
*
* @throws Exception
*/ */
@Test @Test
public void testSimpleReflectionObjectCycle() throws Exception { public void testSimpleReflectionObjectCycle() {
final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture(); final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture();
simple.o = simple; simple.o = simple;
assertEquals(this.toBaseString(simple) + "[o=" + this.toBaseString(simple) + "]", simple.toString()); assertEquals(this.toBaseString(simple) + "[o=" + this.toBaseString(simple) + "]", simple.toString());
@ -534,11 +532,9 @@ public class ToStringBuilderTest {
/** /**
* Test a class that defines an ivar pointing to itself. * Test a class that defines an ivar pointing to itself.
*
* @throws Exception
*/ */
@Test @Test
public void testSelfInstanceVarReflectionObjectCycle() throws Exception { public void testSelfInstanceVarReflectionObjectCycle() {
final SelfInstanceVarReflectionTestFixture test = new SelfInstanceVarReflectionTestFixture(); final SelfInstanceVarReflectionTestFixture test = new SelfInstanceVarReflectionTestFixture();
assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + "]", test.toString()); assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + "]", test.toString());
} }
@ -546,11 +542,9 @@ public class ToStringBuilderTest {
/** /**
* Test a class that defines an ivar pointing to itself. This test was * Test a class that defines an ivar pointing to itself. This test was
* created to show that handling cyclical object resulted in a missing endFieldSeparator call. * created to show that handling cyclical object resulted in a missing endFieldSeparator call.
*
* @throws Exception
*/ */
@Test @Test
public void testSelfInstanceTwoVarsReflectionObjectCycle() throws Exception { public void testSelfInstanceTwoVarsReflectionObjectCycle() {
final SelfInstanceTwoVarsReflectionTestFixture test = new SelfInstanceTwoVarsReflectionTestFixture(); final SelfInstanceTwoVarsReflectionTestFixture test = new SelfInstanceTwoVarsReflectionTestFixture();
assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + ",otherType=" + test.getOtherType().toString() + "]", test.toString()); assertEquals(this.toBaseString(test) + "[typeIsSelf=" + this.toBaseString(test) + ",otherType=" + test.getOtherType().toString() + "]", test.toString());
} }
@ -558,11 +552,9 @@ public class ToStringBuilderTest {
/** /**
* Test Objects pointing to each other. * Test Objects pointing to each other.
*
* @throws Exception
*/ */
@Test @Test
public void testReflectionObjectCycle() throws Exception { public void testReflectionObjectCycle() {
final ReflectionTestCycleA a = new ReflectionTestCycleA(); final ReflectionTestCycleA a = new ReflectionTestCycleA();
final ReflectionTestCycleB b = new ReflectionTestCycleB(); final ReflectionTestCycleB b = new ReflectionTestCycleB();
a.b = b; a.b = b;
@ -575,11 +567,9 @@ public class ToStringBuilderTest {
/** /**
* Test a nasty combination of arrays and Objects pointing to each other. * Test a nasty combination of arrays and Objects pointing to each other.
* objects[0] -&gt; SimpleReflectionTestFixture[ o -&gt; objects ] * objects[0] -&gt; SimpleReflectionTestFixture[ o -&gt; objects ]
*
* @throws Exception
*/ */
@Test @Test
public void testReflectionArrayAndObjectCycle() throws Exception { public void testReflectionArrayAndObjectCycle() {
final Object[] objects = new Object[1]; final Object[] objects = new Object[1];
final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture(objects); final SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture(objects);
objects[0] = simple; objects[0] = simple;
@ -985,6 +975,7 @@ public class ToStringBuilderTest {
* <p>If the style is <code>null</code>, the default * <p>If the style is <code>null</code>, the default
* <code>ToStringStyle</code> is used.</p> * <code>ToStringStyle</code> is used.</p>
* *
* @param <T> the type of the output object
* @param object the Object to be output * @param object the Object to be output
* @param style the style of the <code>toString</code> to create, * @param style the style of the <code>toString</code> to create,
* may be <code>null</code> * may be <code>null</code>

View File

@ -39,6 +39,8 @@ import org.junit.Test;
public abstract class AbstractConcurrentInitializerTest { public abstract class AbstractConcurrentInitializerTest {
/** /**
* Tests a simple invocation of the get() method. * Tests a simple invocation of the get() method.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException because the object under test may throw it
*/ */
@Test @Test
public void testGet() throws ConcurrentException { public void testGet() throws ConcurrentException {
@ -48,6 +50,8 @@ public abstract class AbstractConcurrentInitializerTest {
/** /**
* Tests whether sequential get() invocations always return the same * Tests whether sequential get() invocations always return the same
* instance. * instance.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException because the object under test may throw it
*/ */
@Test @Test
public void testGetMultipleTimes() throws ConcurrentException { public void testGetMultipleTimes() throws ConcurrentException {
@ -61,6 +65,9 @@ public abstract class AbstractConcurrentInitializerTest {
/** /**
* Tests whether get() can be invoked from multiple threads concurrently. * Tests whether get() can be invoked from multiple threads concurrently.
* Always the same object should be returned. * Always the same object should be returned.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException because the object under test may throw it
* @throws java.lang.InterruptedException because the threading API my throw it
*/ */
@Test @Test
public void testGetConcurrent() throws ConcurrentException, public void testGetConcurrent() throws ConcurrentException,

View File

@ -50,6 +50,9 @@ public class AtomicSafeInitializerTest extends
/** /**
* Tests that initialize() is called only once. * Tests that initialize() is called only once.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException because {@link #testGetConcurrent()} may throw it
* @throws java.lang.InterruptedException because {@link #testGetConcurrent()} may throw it
*/ */
@Test @Test
public void testNumberOfInitializeInvocations() throws ConcurrentException, public void testNumberOfInitializeInvocations() throws ConcurrentException,

View File

@ -108,7 +108,7 @@ public class BackgroundInitializerTest {
* setExternalExecutor() method. * setExternalExecutor() method.
*/ */
@Test @Test
public void testSetExternalExecutor() throws Exception { public void testSetExternalExecutor() {
final ExecutorService exec = Executors.newCachedThreadPool(); final ExecutorService exec = Executors.newCachedThreadPool();
try { try {
final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(); final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
@ -126,6 +126,8 @@ public class BackgroundInitializerTest {
/** /**
* Tests that setting an executor after start() causes an exception. * Tests that setting an executor after start() causes an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException because the test implementation may throw it
*/ */
@Test @Test
public void testSetExternalExecutorAfterStart() throws ConcurrentException { public void testSetExternalExecutorAfterStart() throws ConcurrentException {
@ -155,6 +157,8 @@ public class BackgroundInitializerTest {
/** /**
* Tests calling get() before start(). This should cause an exception. * Tests calling get() before start(). This should cause an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException because the test implementation may throw it
*/ */
@Test(expected=IllegalStateException.class) @Test(expected=IllegalStateException.class)
public void testGetBeforeStart() throws ConcurrentException { public void testGetBeforeStart() throws ConcurrentException {
@ -167,7 +171,7 @@ public class BackgroundInitializerTest {
* exception. * exception.
*/ */
@Test @Test
public void testGetRuntimeException() throws Exception { public void testGetRuntimeException() {
final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(); final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
final RuntimeException rex = new RuntimeException(); final RuntimeException rex = new RuntimeException();
init.ex = rex; init.ex = rex;
@ -185,7 +189,7 @@ public class BackgroundInitializerTest {
* exception. * exception.
*/ */
@Test @Test
public void testGetCheckedException() throws Exception { public void testGetCheckedException() {
final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(); final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl();
final Exception ex = new Exception(); final Exception ex = new Exception();
init.ex = ex; init.ex = ex;
@ -200,9 +204,11 @@ public class BackgroundInitializerTest {
/** /**
* Tests the get() method if waiting for the initialization is interrupted. * Tests the get() method if waiting for the initialization is interrupted.
*
* @throws java.lang.InterruptedException because we're making use of Java's concurrent API
*/ */
@Test @Test
public void testGetInterruptedException() throws Exception { public void testGetInterruptedException() throws InterruptedException {
final ExecutorService exec = Executors.newSingleThreadExecutor(); final ExecutorService exec = Executors.newSingleThreadExecutor();
final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl( final BackgroundInitializerTestImpl init = new BackgroundInitializerTestImpl(
exec); exec);
@ -289,6 +295,8 @@ public class BackgroundInitializerTest {
/** /**
* Records this invocation. Optionally throws an exception or sleeps a * Records this invocation. Optionally throws an exception or sleeps a
* while. * while.
*
* @throws Exception in case of an error
*/ */
@Override @Override
protected Integer initialize() throws Exception { protected Integer initialize() throws Exception {

View File

@ -66,6 +66,8 @@ public class CallableBackgroundInitializerTest {
/** /**
* Tests the implementation of initialize(). * Tests the implementation of initialize().
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testInitialize() throws Exception { public void testInitialize() throws Exception {

View File

@ -200,6 +200,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests handleCause() if the cause is an error. * Tests handleCause() if the cause is an error.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testHandleCauseError() throws ConcurrentException { public void testHandleCauseError() throws ConcurrentException {
@ -214,6 +216,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests handleCause() if the cause is an unchecked exception. * Tests handleCause() if the cause is an unchecked exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testHandleCauseUncheckedException() throws ConcurrentException { public void testHandleCauseUncheckedException() throws ConcurrentException {
@ -244,6 +248,8 @@ public class ConcurrentUtilsTest {
* Tests handleCause() for a null parameter or a null cause. In this case * Tests handleCause() for a null parameter or a null cause. In this case
* the method should do nothing. We can only test that no exception is * the method should do nothing. We can only test that no exception is
* thrown. * thrown.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testHandleCauseNull() throws ConcurrentException { public void testHandleCauseNull() throws ConcurrentException {
@ -308,6 +314,8 @@ public class ConcurrentUtilsTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Tests initialize() for a null argument. * Tests initialize() for a null argument.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeNull() throws ConcurrentException { public void testInitializeNull() throws ConcurrentException {
@ -316,6 +324,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests a successful initialize() operation. * Tests a successful initialize() operation.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitialize() throws ConcurrentException { public void testInitialize() throws ConcurrentException {
@ -341,6 +351,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests a successful initializeUnchecked() operation. * Tests a successful initializeUnchecked() operation.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeUnchecked() throws ConcurrentException { public void testInitializeUnchecked() throws ConcurrentException {
@ -358,6 +370,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests whether exceptions are correctly handled by initializeUnchecked(). * Tests whether exceptions are correctly handled by initializeUnchecked().
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeUncheckedEx() throws ConcurrentException { public void testInitializeUncheckedEx() throws ConcurrentException {
@ -380,6 +394,8 @@ public class ConcurrentUtilsTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Tests constant future. * Tests constant future.
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testConstantFuture_Integer() throws Exception { public void testConstantFuture_Integer() throws Exception {
@ -396,6 +412,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests constant future. * Tests constant future.
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testConstantFuture_null() throws Exception { public void testConstantFuture_null() throws Exception {
@ -449,6 +467,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests createIfAbsent() if the key is found in the map. * Tests createIfAbsent() if the key is found in the map.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testCreateIfAbsentKeyPresent() throws ConcurrentException { public void testCreateIfAbsentKeyPresent() throws ConcurrentException {
@ -469,6 +489,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests createIfAbsent() if the map does not contain the key in question. * Tests createIfAbsent() if the map does not contain the key in question.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testCreateIfAbsentKeyNotPresent() throws ConcurrentException { public void testCreateIfAbsentKeyNotPresent() throws ConcurrentException {
@ -489,6 +511,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests createIfAbsent() if a null map is passed in. * Tests createIfAbsent() if a null map is passed in.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testCreateIfAbsentNullMap() throws ConcurrentException { public void testCreateIfAbsentNullMap() throws ConcurrentException {
@ -504,6 +528,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests createIfAbsent() if a null initializer is passed in. * Tests createIfAbsent() if a null initializer is passed in.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testCreateIfAbsentNullInit() throws ConcurrentException { public void testCreateIfAbsentNullInit() throws ConcurrentException {
@ -532,6 +558,8 @@ public class ConcurrentUtilsTest {
/** /**
* Tests createIfAbsentUnchecked() if an exception is thrown. * Tests createIfAbsentUnchecked() if an exception is thrown.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testCreateIfAbsentUncheckedException() public void testCreateIfAbsentUncheckedException()

View File

@ -68,6 +68,8 @@ public class ConstantInitializerTest {
/** /**
* Tests whether get() returns the correct object. * Tests whether get() returns the correct object.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testGet() throws ConcurrentException { public void testGet() throws ConcurrentException {

View File

@ -88,6 +88,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests the background processing if there are no child initializers. * Tests the background processing if there are no child initializers.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeNoChildren() throws ConcurrentException { public void testInitializeNoChildren() throws ConcurrentException {
@ -104,6 +106,8 @@ public class MultiBackgroundInitializerTest {
* operate with both an external and a temporary executor service. * operate with both an external and a temporary executor service.
* *
* @return the result object produced by the initializer * @return the result object produced by the initializer
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
private MultiBackgroundInitializer.MultiBackgroundInitializerResults checkInitialize() private MultiBackgroundInitializer.MultiBackgroundInitializerResults checkInitialize()
throws ConcurrentException { throws ConcurrentException {
@ -132,6 +136,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests background processing if a temporary executor is used. * Tests background processing if a temporary executor is used.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeTempExec() throws ConcurrentException { public void testInitializeTempExec() throws ConcurrentException {
@ -142,6 +148,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests background processing if an external executor service is provided. * Tests background processing if an external executor service is provided.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeExternalExec() throws ConcurrentException { public void testInitializeExternalExec() throws ConcurrentException {
@ -160,6 +168,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests the behavior of initialize() if a child initializer has a specific * Tests the behavior of initialize() if a child initializer has a specific
* executor service. Then this service should not be overridden. * executor service. Then this service should not be overridden.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeChildWithExecutor() throws ConcurrentException { public void testInitializeChildWithExecutor() throws ConcurrentException {
@ -183,6 +193,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tries to add another child initializer after the start() method has been * Tries to add another child initializer after the start() method has been
* called. This should not be allowed. * called. This should not be allowed.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testAddInitializerAfterStart() throws ConcurrentException { public void testAddInitializerAfterStart() throws ConcurrentException {
@ -199,6 +211,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tries to query an unknown child initializer from the results object. This * Tries to query an unknown child initializer from the results object. This
* should cause an exception. * should cause an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test(expected = NoSuchElementException.class) @Test(expected = NoSuchElementException.class)
public void testResultGetInitializerUnknown() throws ConcurrentException { public void testResultGetInitializerUnknown() throws ConcurrentException {
@ -209,6 +223,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tries to query the results of an unknown child initializer from the * Tries to query the results of an unknown child initializer from the
* results object. This should cause an exception. * results object. This should cause an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test(expected = NoSuchElementException.class) @Test(expected = NoSuchElementException.class)
public void testResultGetResultObjectUnknown() throws ConcurrentException { public void testResultGetResultObjectUnknown() throws ConcurrentException {
@ -219,6 +235,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tries to query the exception of an unknown child initializer from the * Tries to query the exception of an unknown child initializer from the
* results object. This should cause an exception. * results object. This should cause an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test(expected = NoSuchElementException.class) @Test(expected = NoSuchElementException.class)
public void testResultGetExceptionUnknown() throws ConcurrentException { public void testResultGetExceptionUnknown() throws ConcurrentException {
@ -229,6 +247,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tries to query the exception flag of an unknown child initializer from * Tries to query the exception flag of an unknown child initializer from
* the results object. This should cause an exception. * the results object. This should cause an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test(expected = NoSuchElementException.class) @Test(expected = NoSuchElementException.class)
public void testResultIsExceptionUnknown() throws ConcurrentException { public void testResultIsExceptionUnknown() throws ConcurrentException {
@ -238,6 +258,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests that the set with the names of the initializers cannot be modified. * Tests that the set with the names of the initializers cannot be modified.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test(expected = UnsupportedOperationException.class) @Test(expected = UnsupportedOperationException.class)
public void testResultInitializerNamesModify() throws ConcurrentException { public void testResultInitializerNamesModify() throws ConcurrentException {
@ -270,6 +292,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests the behavior of the initializer if one of the child initializers * Tests the behavior of the initializer if one of the child initializers
* throws a checked exception. * throws a checked exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeEx() throws ConcurrentException { public void testInitializeEx() throws ConcurrentException {
@ -288,6 +312,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests the isSuccessful() method of the result object if no child * Tests the isSuccessful() method of the result object if no child
* initializer has thrown an exception. * initializer has thrown an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeResultsIsSuccessfulTrue() public void testInitializeResultsIsSuccessfulTrue()
@ -303,6 +329,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests the isSuccessful() method of the result object if at least one * Tests the isSuccessful() method of the result object if at least one
* child initializer has thrown an exception. * child initializer has thrown an exception.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeResultsIsSuccessfulFalse() public void testInitializeResultsIsSuccessfulFalse()
@ -319,6 +347,8 @@ public class MultiBackgroundInitializerTest {
/** /**
* Tests whether MultiBackgroundInitializers can be combined in a nested * Tests whether MultiBackgroundInitializers can be combined in a nested
* way. * way.
*
* @throws org.apache.commons.lang3.concurrent.ConcurrentException so we don't have to catch it
*/ */
@Test @Test
public void testInitializeNested() throws ConcurrentException { public void testInitializeNested() throws ConcurrentException {

View File

@ -96,6 +96,8 @@ public class TimedSemaphoreTest {
/** /**
* Tests starting the timer. * Tests starting the timer.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testStartTimer() throws InterruptedException { public void testStartTimer() throws InterruptedException {
@ -160,6 +162,8 @@ public class TimedSemaphoreTest {
/** /**
* Tests the shutdown() method for a shared executor after the task was * Tests the shutdown() method for a shared executor after the task was
* started. In this case the task must be canceled. * started. In this case the task must be canceled.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testShutdownSharedExecutorTask() throws InterruptedException { public void testShutdownSharedExecutorTask() throws InterruptedException {
@ -179,6 +183,8 @@ public class TimedSemaphoreTest {
/** /**
* Tests multiple invocations of the shutdown() method. * Tests multiple invocations of the shutdown() method.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testShutdownMultipleTimes() throws InterruptedException { public void testShutdownMultipleTimes() throws InterruptedException {
@ -199,6 +205,8 @@ public class TimedSemaphoreTest {
/** /**
* Tests the acquire() method if a limit is set. * Tests the acquire() method if a limit is set.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testAcquireLimit() throws InterruptedException { public void testAcquireLimit() throws InterruptedException {
@ -236,6 +244,8 @@ public class TimedSemaphoreTest {
* This method starts a number of threads that all invoke the semaphore. The * This method starts a number of threads that all invoke the semaphore. The
* semaphore's limit is set to 1, so in each period only a single thread can * semaphore's limit is set to 1, so in each period only a single thread can
* acquire the semaphore. * acquire the semaphore.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testAcquireMultipleThreads() throws InterruptedException { public void testAcquireMultipleThreads() throws InterruptedException {
@ -271,6 +281,8 @@ public class TimedSemaphoreTest {
* Tests the acquire() method if no limit is set. A test thread is started * Tests the acquire() method if no limit is set. A test thread is started
* that calls the semaphore a large number of times. Even if the semaphore's * that calls the semaphore a large number of times. Even if the semaphore's
* period does not end, the thread should never block. * period does not end, the thread should never block.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testAcquireNoLimit() throws InterruptedException { public void testAcquireNoLimit() throws InterruptedException {
@ -291,6 +303,8 @@ public class TimedSemaphoreTest {
/** /**
* Tries to call acquire() after shutdown(). This should cause an exception. * Tries to call acquire() after shutdown(). This should cause an exception.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test(expected = IllegalStateException.class) @Test(expected = IllegalStateException.class)
public void testPassAfterShutdown() throws InterruptedException { public void testPassAfterShutdown() throws InterruptedException {
@ -304,6 +318,8 @@ public class TimedSemaphoreTest {
* period is set to a very short time. A background thread calls the * period is set to a very short time. A background thread calls the
* semaphore a large number of times. While it runs at last one end of a * semaphore a large number of times. While it runs at last one end of a
* period should be reached. * period should be reached.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testAcquireMultiplePeriods() throws InterruptedException { public void testAcquireMultiplePeriods() throws InterruptedException {
@ -321,6 +337,8 @@ public class TimedSemaphoreTest {
/** /**
* Tests the methods for statistics. * Tests the methods for statistics.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testGetAverageCallsPerPeriod() throws InterruptedException { public void testGetAverageCallsPerPeriod() throws InterruptedException {
@ -345,6 +363,8 @@ public class TimedSemaphoreTest {
/** /**
* Tests whether the available non-blocking calls can be queried. * Tests whether the available non-blocking calls can be queried.
*
* @throws java.lang.InterruptedException so we don't have to catch it
*/ */
@Test @Test
public void testGetAvailablePermits() throws InterruptedException { public void testGetAvailablePermits() throws InterruptedException {
@ -403,6 +423,8 @@ public class TimedSemaphoreTest {
/** /**
* Invokes the latch if one is set. * Invokes the latch if one is set.
*
* @throws java.lang.InterruptedException because it is declared that way in TimedSemaphore
*/ */
@Override @Override
public synchronized void acquire() throws InterruptedException { public synchronized void acquire() throws InterruptedException {

View File

@ -78,7 +78,7 @@ public class DateUtilsRoundingTest {
/** /**
* Tests DateUtils.round()-method with Calendar.Year * Tests DateUtils.round()-method with Calendar.Year
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -95,7 +95,7 @@ public class DateUtilsRoundingTest {
* Includes rounding months with 28, 29, 30 and 31 days * Includes rounding months with 28, 29, 30 and 31 days
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -139,7 +139,7 @@ public class DateUtilsRoundingTest {
* Includes rounding months with 28, 29, 30 and 31 days, each with first and second half * Includes rounding months with 28, 29, 30 and 31 days, each with first and second half
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -207,7 +207,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of one day * Includes rounding the extremes of one day
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -232,7 +232,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of one day * Includes rounding the extremes of one day
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -257,7 +257,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of both AM and PM of one day * Includes rounding the extremes of both AM and PM of one day
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -289,7 +289,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of one hour * Includes rounding the extremes of one hour
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -314,7 +314,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of one hour * Includes rounding the extremes of one hour
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -339,7 +339,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of one minute * Includes rounding the extremes of one minute
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -364,7 +364,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of one second * Includes rounding the extremes of one second
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -389,7 +389,7 @@ public class DateUtilsRoundingTest {
* Includes rounding the extremes of one second * Includes rounding the extremes of one second
* Includes rounding to January 1 * Includes rounding to January 1
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -410,7 +410,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.YEAR * Test DateUtils.truncate()-method with Calendar.YEAR
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -423,7 +423,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.MONTH * Test DateUtils.truncate()-method with Calendar.MONTH
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -438,7 +438,7 @@ public class DateUtilsRoundingTest {
* Test DateUtils.truncate()-method with DateUtils.SEMI_MONTH * Test DateUtils.truncate()-method with DateUtils.SEMI_MONTH
* Includes truncating months with 28, 29, 30 and 31 days, each with first and second half * Includes truncating months with 28, 29, 30 and 31 days, each with first and second half
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -491,7 +491,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.DATE * Test DateUtils.truncate()-method with Calendar.DATE
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -504,7 +504,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.DAY_OF_MONTH * Test DateUtils.truncate()-method with Calendar.DAY_OF_MONTH
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -518,7 +518,7 @@ public class DateUtilsRoundingTest {
* Test DateUtils.truncate()-method with Calendar.AM_PM * Test DateUtils.truncate()-method with Calendar.AM_PM
* Includes truncating the extremes of both AM and PM of one day * Includes truncating the extremes of both AM and PM of one day
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -537,7 +537,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.HOUR * Test DateUtils.truncate()-method with Calendar.HOUR
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -550,7 +550,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.HOUR_OF_DAY * Test DateUtils.truncate()-method with Calendar.HOUR_OF_DAY
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -563,7 +563,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.MINUTE * Test DateUtils.truncate()-method with Calendar.MINUTE
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -576,7 +576,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.SECOND * Test DateUtils.truncate()-method with Calendar.SECOND
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -589,7 +589,7 @@ public class DateUtilsRoundingTest {
/** /**
* Test DateUtils.truncate()-method with Calendar.SECOND * Test DateUtils.truncate()-method with Calendar.SECOND
* *
* @throws Exception * @throws Exception so we don't have to catch it
* @since 3.0 * @since 3.0
*/ */
@Test @Test
@ -607,7 +607,7 @@ public class DateUtilsRoundingTest {
* @param roundedUpDate the next rounded date after <strong>roundedDownDate</strong> when using <strong>calendarField</strong> * @param roundedUpDate the next rounded date after <strong>roundedDownDate</strong> when using <strong>calendarField</strong>
* @param roundedDownDate the result if <strong>lastRoundDownDate</strong> was rounded with <strong>calendarField</strong> * @param roundedDownDate the result if <strong>lastRoundDownDate</strong> was rounded with <strong>calendarField</strong>
* @param lastRoundDownDate rounding this value with <strong>calendarField</strong> will result in <strong>roundedDownDate</strong> * @param lastRoundDownDate rounding this value with <strong>calendarField</strong> will result in <strong>roundedDownDate</strong>
* @param calendarField * @param calendarField a Calendar.field value
* @since 3.0 * @since 3.0
*/ */
protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDate, final Date lastRoundDownDate, final int calendarField) { protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDate, final Date lastRoundDownDate, final int calendarField) {
@ -694,9 +694,9 @@ public class DateUtilsRoundingTest {
* Any January 1 could be considered as the ultimate extreme. * Any January 1 could be considered as the ultimate extreme.
* Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first. * Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first.
* *
* @param minDate * @param minDate the lower bound
* @param maxDate * @param maxDate the upper bound
* @param calendarField * @param calendarField a Calendar.field value
* @since 3.0 * @since 3.0
*/ */
protected void roundToJanuaryFirst(final Date minDate, final Date maxDate, final int calendarField) { protected void roundToJanuaryFirst(final Date minDate, final Date maxDate, final int calendarField) {

View File

@ -650,6 +650,8 @@ public class DateUtilsTest {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
/** /**
* Tests various values with the round method * Tests various values with the round method
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testRound() throws Exception { public void testRound() throws Exception {
@ -874,6 +876,8 @@ public class DateUtilsTest {
/** /**
* Tests the Changes Made by LANG-346 to the DateUtils.modify() private method invoked * Tests the Changes Made by LANG-346 to the DateUtils.modify() private method invoked
* by DateUtils.round(). * by DateUtils.round().
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testRoundLang346() throws Exception public void testRoundLang346() throws Exception
@ -937,6 +941,8 @@ public class DateUtilsTest {
/** /**
* Tests various values with the trunc method * Tests various values with the trunc method
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testTruncate() throws Exception { public void testTruncate() throws Exception {
@ -1130,6 +1136,8 @@ public class DateUtilsTest {
/** /**
* Tests for LANG-59 * Tests for LANG-59
* *
* @throws java.lang.Exception so we don't have to catch it
*
* see http://issues.apache.org/jira/browse/LANG-59 * see http://issues.apache.org/jira/browse/LANG-59
*/ */
@Test @Test
@ -1219,6 +1227,8 @@ public class DateUtilsTest {
/** /**
* Tests various values with the ceiling method * Tests various values with the ceiling method
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testCeil() throws Exception { public void testCeil() throws Exception {
@ -1469,6 +1479,8 @@ public class DateUtilsTest {
/** /**
* Tests the iterator exceptions * Tests the iterator exceptions
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testIteratorEx() throws Exception { public void testIteratorEx() throws Exception {
@ -1495,6 +1507,8 @@ public class DateUtilsTest {
/** /**
* Tests the calendar iterator for week ranges * Tests the calendar iterator for week ranges
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testWeekIterator() throws Exception { public void testWeekIterator() throws Exception {
@ -1542,6 +1556,8 @@ public class DateUtilsTest {
/** /**
* Tests the calendar iterator for month-based ranges * Tests the calendar iterator for month-based ranges
*
* @throws java.lang.Exception so we don't have to catch it
*/ */
@Test @Test
public void testMonthIterator() throws Exception { public void testMonthIterator() throws Exception {

View File

@ -112,7 +112,7 @@ public class DurationFormatUtilsTest {
} }
/** /**
* Tests that "1 <unit>s" gets converted to "1 <unit>" but that "11 <unit>s" is left alone. * Tests that "1 &lt;unit&gt;s" gets converted to "1 &lt;unit&gt;" but that "11 &lt;unit&gt;s" is left alone.
*/ */
@Test @Test
public void testFormatDurationPluralWords() { public void testFormatDurationPluralWords() {

View File

@ -254,7 +254,7 @@ public class FastDateFormatTest {
* According to LANG-954 (https://issues.apache.org/jira/browse/LANG-954) this is broken in Android 2.1. * According to LANG-954 (https://issues.apache.org/jira/browse/LANG-954) this is broken in Android 2.1.
*/ */
@Test @Test
public void testLang954() throws Exception { public void testLang954() {
final String pattern = "yyyy-MM-dd'T'"; final String pattern = "yyyy-MM-dd'T'";
FastDateFormat.getInstance(pattern); FastDateFormat.getInstance(pattern);
} }

View File

@ -77,6 +77,12 @@ public class FastDateParserTest {
/** /**
* Override this method in derived tests to change the construction of instances * Override this method in derived tests to change the construction of instances
*
* @param format the format string to use
* @param timeZone the time zone to use
* @param locale the locale to use
*
* @return the DateParser instance to use for testing
*/ */
protected DateParser getInstance(final String format, final TimeZone timeZone, final Locale locale) { protected DateParser getInstance(final String format, final TimeZone timeZone, final Locale locale) {
return new FastDateParser(format, timeZone, locale, null); return new FastDateParser(format, timeZone, locale, null);
@ -436,7 +442,7 @@ public class FastDateParserTest {
/** /**
* Test case for {@link FastDateParser#FastDateParser(String, TimeZone, Locale)}. * Test case for {@link FastDateParser#FastDateParser(String, TimeZone, Locale)}.
* @throws ParseException * @throws ParseException so we don't have to catch it
*/ */
@Test @Test
public void testShortDateStyleWithLocales() throws ParseException { public void testShortDateStyleWithLocales() throws ParseException {
@ -453,7 +459,7 @@ public class FastDateParserTest {
/** /**
* Tests that pre-1000AD years get padded with yyyy * Tests that pre-1000AD years get padded with yyyy
* @throws ParseException * @throws ParseException so we don't have to catch it
*/ */
@Test @Test
public void testLowYearPadding() throws ParseException { public void testLowYearPadding() throws ParseException {
@ -471,9 +477,6 @@ public class FastDateParserTest {
assertEquals(cal.getTime(), parser.parse("0999/01/01")); assertEquals(cal.getTime(), parser.parse("0999/01/01"));
} }
/**
* @throws ParseException
*/
@Test @Test
public void testMilleniumBug() throws ParseException { public void testMilleniumBug() throws ParseException {
final DateParser parser = getInstance(DMY_DOT); final DateParser parser = getInstance(DMY_DOT);

View File

@ -62,10 +62,10 @@ public class FastDatePrinterTest {
/** /**
* Override this method in derived tests to change the construction of instances * Override this method in derived tests to change the construction of instances
* @param format * @param format the format string to use
* @param timeZone * @param timeZone the time zone to use
* @param locale * @param locale the locale to use
* @return * @return the DatePrinter to use for testing
*/ */
protected DatePrinter getInstance(final String format, final TimeZone timeZone, final Locale locale) { protected DatePrinter getInstance(final String format, final TimeZone timeZone, final Locale locale) {
return new FastDatePrinter(format, timeZone, locale); return new FastDatePrinter(format, timeZone, locale);