org.joda.time.field
Class TestUnsupportedDateTimeField

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.joda.time.field.TestUnsupportedDateTimeField
All Implemented Interfaces:
junit.framework.Test

public class TestUnsupportedDateTimeField
extends junit.framework.TestCase

This class is a JUnit test to test only the UnsupportedDateTimeField class. This set of test cases exercises everything described in the Javadoc for this class.

Author:
Jeremy R. Rickard

Constructor Summary
TestUnsupportedDateTimeField()
           
 
Method Summary
protected  void setUp()
           
static junit.framework.TestSuite suite()
           
 void testAlwaysFalseReturnTypes()
          As this is an unsupported date/time field, some normal methods will always return false, as they are not supported.
 void testDelegatedMethods()
          As this is an unsupported date/time field, many normal methods are unsupported.
 void testDifferentDurationReturnDifferentObjects()
          This test exercises the logic in UnsupportedDateTimeField.getInstance.
 void testMethodsThatShouldAlwaysReturnNull()
          According to the JavaDocs, there are two methods that should always return null.
 void testNullValuesToGetInstanceThrowsException()
          Passing null values into UnsupportedDateTimeField.getInstance() should throw an IllegalArguementsException
 void testPublicGetNameMethod()
          The getName() method should return the same value as the getName() method of the DateTimeFieldType that was used to create the instance.
 void testToString()
          The toString method should return a suitable debug message (not null).
 void testUnsupportedMethods()
          As this is an unsupported date/time field, many normal methods are unsupported and throw an UnsupportedOperationException.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestUnsupportedDateTimeField

public TestUnsupportedDateTimeField()
Method Detail

suite

public static junit.framework.TestSuite suite()

setUp

protected void setUp()
              throws Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

testNullValuesToGetInstanceThrowsException

public void testNullValuesToGetInstanceThrowsException()
Passing null values into UnsupportedDateTimeField.getInstance() should throw an IllegalArguementsException


testDifferentDurationReturnDifferentObjects

public void testDifferentDurationReturnDifferentObjects()
This test exercises the logic in UnsupportedDateTimeField.getInstance. If getInstance() is invoked twice with: - the same DateTimeFieldType - different duration fields Then the field returned in the first invocation should not be equal to the field returned by the second invocation. In otherwords, the generated instance should be the same for a unique pairing of DateTimeFieldType/DurationField


testPublicGetNameMethod

public void testPublicGetNameMethod()
The getName() method should return the same value as the getName() method of the DateTimeFieldType that was used to create the instance.


testAlwaysFalseReturnTypes

public void testAlwaysFalseReturnTypes()
As this is an unsupported date/time field, some normal methods will always return false, as they are not supported. Verify that each method correctly returns null.


testMethodsThatShouldAlwaysReturnNull

public void testMethodsThatShouldAlwaysReturnNull()
According to the JavaDocs, there are two methods that should always return null. * getRangeDurationField() * getLeapDurationField() Ensure that these are in fact null.


testUnsupportedMethods

public void testUnsupportedMethods()
As this is an unsupported date/time field, many normal methods are unsupported and throw an UnsupportedOperationException. Verify that each method correctly throws this exception. * add(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) * addWrapField(long instant, int value) * addWrapField(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) * addWrapPartial(ReadablePartial instant, int fieldIndex, int[] values, int valueToAdd) * get(long instant) * getAsShortText(int fieldValue, Locale locale) * getAsShortText(long instant) * getAsShortText(long instant, Locale locale) * getAsShortText(ReadablePartial partial, int fieldValue, Locale locale) * getAsShortText(ReadablePartial partial, Locale locale) * getAsText(int fieldValue, Locale locale) * getAsText(long instant) * getAsText(long instant, Locale locale) * getAsText(ReadablePartial partial, int fieldValue, Locale locale) * getAsText(ReadablePartial partial, Locale locale) * getLeapAmount(long instant) * getMaximumShortTextLength(Locale locale) * getMaximumTextLength(Locale locale) * getMaximumValue() * getMaximumValue(long instant) * getMaximumValue(ReadablePartial instant) * getMaximumValue(ReadablePartial instant, int[] values) * getMinimumValue() * getMinimumValue(long instant) * getMinimumValue(ReadablePartial instant) * getMinimumValue(ReadablePartial instant, int[] values) * isLeap(long instant) * remainder(long instant) * roundCeiling(long instant) * roundFloor(long instant) * roundHalfCeiling(long instant) * roundHalfEven(long instant) * roundHalfFloor(long instant) * set(long instant, int value) * set(long instant, String text) * set(long instant, String text, Locale locale) * set(ReadablePartial instant, int fieldIndex, int[] values, int newValue) * set(ReadablePartial instant, int fieldIndex, int[] values, String text, Locale locale)


testDelegatedMethods

public void testDelegatedMethods()
As this is an unsupported date/time field, many normal methods are unsupported. Some delegate and can possibly throw an UnsupportedOperationException or have a valid return. Verify that each method correctly throws this exception when appropriate and delegates correctly based on the Duration used to get the instance.


testToString

public void testToString()
The toString method should return a suitable debug message (not null). Ensure that the toString method returns a string with length greater than 0 (and not null)



Copyright © 2002-2013 Joda.org. All Rights Reserved.