Changeset 10103 in josm


Ignore:
Timestamp:
2016-04-03T15:42:30+02:00 (4 years ago)
Author:
Don-vip
Message:

add more unit tests

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/help/HelpContentReaderException.java

    r6987 r10103  
    55    private int responseCode;
    66
    7     public HelpContentReaderException(String message, Throwable cause) {
    8         super(message, cause);
    9     }
    10 
     7    /**
     8     * Constructs a new {@code HelpContentReaderException}.
     9     * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
     10     */
    1111    public HelpContentReaderException(String message) {
    1212        super(message);
    1313    }
    1414
     15    /**
     16     * Constructs a new {@code HelpContentReaderException}.
     17     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
     18     *        (A <tt>null</tt> value is permitted, and indicates that the cause is nonexistent or unknown.)
     19     */
    1520    public HelpContentReaderException(Throwable cause) {
    1621        super(cause);
  • trunk/src/org/openstreetmap/josm/gui/help/MissingHelpContentException.java

    r6987 r10103  
    22package org.openstreetmap.josm.gui.help;
    33
     4/**
     5 * Exception thrown when help content is missing.
     6 * @since 2308
     7 */
    48public class MissingHelpContentException extends HelpContentReaderException {
    59
    6     public MissingHelpContentException(String message, Throwable cause) {
    7         super(message, cause);
    8     }
    9 
     10    /**
     11     * Constructs a new {@code MissingHelpContentException}.
     12     * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
     13     */
    1014    public MissingHelpContentException(String message) {
    1115        super(message);
    1216    }
    13 
    14     public MissingHelpContentException(Throwable cause) {
    15         super(cause);
    16     }
    1717}
  • trunk/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java

    r9669 r10103  
    1515public class HelpBrowserTest {
    1616
    17     private static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help";
    18     private static final String URL_2 = "https://josm.openstreetmap.de/wiki/Introduction";
    19     private static final String URL_3 = "https://josm.openstreetmap.de/javadoc";
     17    static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help";
     18    static final String URL_2 = "https://josm.openstreetmap.de/wiki/Introduction";
     19    static final String URL_3 = "https://josm.openstreetmap.de/javadoc";
    2020
    2121    /**
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/audio/AudioPreferenceTest.java

    r9973 r10103  
    77import org.junit.Test;
    88import org.openstreetmap.josm.JOSMFixture;
     9import org.openstreetmap.josm.Main;
    910import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
    1011
     
    3536    @Test
    3637    public void testAddGui() {
     38        Main.pref.put("audio.menuinvisible", true);
     39        PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null);
     40        Main.pref.put("audio.menuinvisible", false);
    3741        PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null);
    3842    }
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r9739 r10103  
    44import static org.junit.Assert.assertEquals;
    55
     6import java.text.DateFormat;
    67import java.util.Date;
    78import java.util.TimeZone;
    89
     10import org.junit.BeforeClass;
    911import org.junit.Test;
     12import org.openstreetmap.josm.JOSMFixture;
    1013import org.openstreetmap.josm.tools.UncheckedParseException;
    1114
     
    1417 */
    1518public class DateUtilsTest {
     19
     20    /**
     21     * Setup test.
     22     */
     23    @BeforeClass
     24    public static void setUp() {
     25        JOSMFixture.createUnitTestFixture().init();
     26    }
    1627
    1728    /**
     
    8697        assertEquals(1453694709400L, DateUtils.fromString("2016-01-25T04:05:09.400Z").getTime());
    8798    }
     99
     100    /**
     101     * Unit test of {@link DateUtils#fromTimestamp} method.
     102     */
     103    @Test
     104    public void testFromTimestamp() {
     105        assertEquals("1970-01-01T00:00:00Z", DateUtils.fromTimestamp(0));
     106        assertEquals("2001-09-09T01:46:40Z", DateUtils.fromTimestamp(1000000000));
     107        assertEquals("2038-01-19T03:14:07Z", DateUtils.fromTimestamp(Integer.MAX_VALUE));
     108    }
     109
     110    /**
     111     * Unit test of {@link DateUtils#formatTime} method.
     112     */
     113    @Test
     114    public void testFormatTime() {
     115        assertEquals("1:00 AM", DateUtils.formatTime(new Date(123), DateFormat.SHORT));
     116        assertEquals("1:00:00 AM CET", DateUtils.formatTime(new Date(123), DateFormat.LONG));
     117    }
    88118}
Note: See TracChangeset for help on using the changeset viewer.