Ignore:
Timestamp:
2017-08-22T22:26:32+02:00 (7 years ago)
Author:
Don-vip
Message:

see #15182 - deprecate all Main logging methods and introduce suitable replacements in Logging for most of them

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/MainTest.java

    r12564 r12620  
    3232import org.openstreetmap.josm.io.OnlineResource;
    3333import org.openstreetmap.josm.testutils.JOSMTestRules;
     34import org.openstreetmap.josm.tools.Logging;
    3435import org.openstreetmap.josm.tools.Shortcut;
    3536
     
    6364    /**
    6465     * Unit tests on log messages.
     66     * @deprecated to remove end of 2017
    6567     */
    6668    @Test
    6769    @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
     70    @Deprecated
    6871    public void testLogs() {
    6972
     
    122125                f.get();
    123126            } catch (InterruptedException | ExecutionException e) {
    124                 Main.error(e);
     127                Logging.error(e);
    125128            }
    126129        }
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandlerTest.java

    r10945 r12620  
    1515import org.junit.Rule;
    1616import org.junit.Test;
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.data.Bounds;
    1918import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2019import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.tools.Logging;
    2121
    2222import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    120120    @Test
    121121    public void testRunExceptionFuture() {
    122         Main.clearLastErrorAndWarnings();
     122        Logging.clearLastErrorAndWarnings();
    123123        new PostDownloadHandler(null, newFuture("testRunExceptionFuture")).run();
    124         assertTrue(Main.getLastErrorAndWarnings().toString(),
    125                 Main.getLastErrorAndWarnings().contains("E: java.util.concurrent.ExecutionException: testRunExceptionFuture"));
     124        assertTrue(Logging.getLastErrorAndWarnings().toString(),
     125                Logging.getLastErrorAndWarnings().contains("E: java.util.concurrent.ExecutionException: testRunExceptionFuture"));
    126126    }
    127127
     
    131131    @Test
    132132    public void testRunNoError() {
    133         Main.clearLastErrorAndWarnings();
     133        Logging.clearLastErrorAndWarnings();
    134134        new PostDownloadHandler(newTask(Collections.emptyList()), newFuture(null)).run();
    135         assertTrue(Main.getLastErrorAndWarnings().toString(), Main.getLastErrorAndWarnings().isEmpty());
     135        assertTrue(Logging.getLastErrorAndWarnings().toString(), Logging.getLastErrorAndWarnings().isEmpty());
    136136    }
    137137
     
    141141    @Test
    142142    public void testRunOneError() {
    143         Main.clearLastErrorAndWarnings();
     143        Logging.clearLastErrorAndWarnings();
    144144        new PostDownloadHandler(newTask(Collections.singletonList(new Object())), newFuture(null)).run();
    145         assertTrue(Main.getLastErrorAndWarnings().toString(), Main.getLastErrorAndWarnings().isEmpty());
     145        assertTrue(Logging.getLastErrorAndWarnings().toString(), Logging.getLastErrorAndWarnings().isEmpty());
    146146    }
    147147
     
    151151    @Test
    152152    public void testRunMultipleErrors() {
    153         Main.clearLastErrorAndWarnings();
     153        Logging.clearLastErrorAndWarnings();
    154154        new PostDownloadHandler(newTask(Arrays.asList("foo", new Exception("bar"), new Object())), newFuture(null)).run();
    155         assertTrue(Main.getLastErrorAndWarnings().toString(),
    156                 Main.getLastErrorAndWarnings().contains("E: java.lang.Exception: bar"));
     155        assertTrue(Logging.getLastErrorAndWarnings().toString(),
     156                Logging.getLastErrorAndWarnings().contains("E: java.lang.Exception: bar"));
    157157    }
    158158}
  • trunk/test/unit/org/openstreetmap/josm/data/cache/HostLimitQueueTest.java

    r11458 r12620  
    1414import org.junit.Rule;
    1515import org.junit.Test;
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.tools.Logging;
    1818import org.openstreetmap.josm.tools.Utils;
    1919
     
    6464                Thread.sleep(1000);
    6565            } catch (InterruptedException e) {
    66                 Main.trace(e);
     66                Logging.trace(e);
    6767            } finally {
    6868                this.counter.incrementAndGet();
  • trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java

    r11479 r12620  
    1414import org.junit.Rule;
    1515import org.junit.Test;
    16 import org.openstreetmap.josm.Main;
    1716import org.openstreetmap.josm.data.cache.ICachedLoaderListener.LoadResult;
    1817import org.openstreetmap.josm.testutils.JOSMTestRules;
     18import org.openstreetmap.josm.tools.Logging;
    1919
    2020import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    121121                } catch (InterruptedException e1) {
    122122                    // do nothing, still wait
    123                     Main.trace(e1);
     123                    Logging.trace(e1);
    124124                }
    125125            }
     
    143143                } catch (InterruptedException e1) {
    144144                    // do nothing, wait
    145                     Main.trace(e1);
     145                    Logging.trace(e1);
    146146                }
    147147            }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java

    r12035 r12620  
    1313import org.junit.Rule;
    1414import org.junit.Test;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.data.coor.LatLon;
     
    4847            fail("Should have thrown an IllegalArgumentException as we gave a null argument.");
    4948        } catch (IllegalArgumentException e) {
    50             Main.trace(e);
     49            Logging.trace(e);
    5150            // Was expected
    5251        }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java

    r12033 r12620  
    1717import org.junit.Rule;
    1818import org.junit.Test;
    19 import org.openstreetmap.josm.Main;
    2019import org.openstreetmap.josm.data.Bounds;
    2120import org.openstreetmap.josm.data.coor.LatLon;
     
    2322import org.openstreetmap.josm.gui.DefaultNameFormatter;
    2423import org.openstreetmap.josm.testutils.JOSMTestRules;
     24import org.openstreetmap.josm.tools.Logging;
    2525
    2626import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    5050            Assert.fail("Should have thrown an IllegalArgumentException as we gave a null argument.");
    5151        } catch (IllegalArgumentException e) {
    52             Main.trace(e);
     52            Logging.trace(e);
    5353            // Was expected
    5454        }
     
    7676            Assert.fail("Should have thrown an IllegalArgumentException as we gave a too long value.");
    7777        } catch (IllegalArgumentException e) {
    78             Main.trace(e);
     78            Logging.trace(e);
    7979            // Was expected
    8080        }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryWayTest.java

    r10945 r12620  
    1313import org.junit.Rule;
    1414import org.junit.Test;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1716import org.openstreetmap.josm.data.osm.User;
    1817import org.openstreetmap.josm.gui.DefaultNameFormatter;
    1918import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.tools.Logging;
    2020
    2121import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    8383        } catch (IndexOutOfBoundsException e) {
    8484            // OK
    85             Main.trace(e);
     85            Logging.trace(e);
    8686        }
    8787
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTest.java

    r11621 r12620  
    3030import org.junit.Before;
    3131import org.junit.Test;
    32 import org.openstreetmap.josm.Main;
    3332import org.openstreetmap.josm.data.validation.routines.DomainValidator.ArrayType;
     33import org.openstreetmap.josm.tools.Logging;
    3434
    3535/**
     
    342342        } catch (IllegalArgumentException iae) {
    343343            // expected
    344             Main.debug(iae.getMessage());
     344            Logging.debug(iae.getMessage());
    345345        }
    346346        try {
     
    349349        } catch (IllegalArgumentException iae) {
    350350            // expected
    351             Main.debug(iae.getMessage());
     351            Logging.debug(iae.getMessage());
    352352        }
    353353        try {
     
    356356        } catch (IllegalArgumentException iae) {
    357357            // expected
    358             Main.debug(iae.getMessage());
     358            Logging.debug(iae.getMessage());
    359359        }
    360360        try {
     
    363363        } catch (IllegalArgumentException iae) {
    364364            // expected
    365             Main.debug(iae.getMessage());
     365            Logging.debug(iae.getMessage());
    366366        }
    367367    }
     
    431431        } catch (IllegalStateException ise) {
    432432            // expected
    433             Main.debug(ise.getMessage());
     433            Logging.debug(ise.getMessage());
    434434        }
    435435    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java

    r11621 r12620  
    4848
    4949import org.junit.Test;
    50 import org.openstreetmap.josm.Main;
     50import org.openstreetmap.josm.tools.Logging;
    5151
    5252import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    8484            timestamp = download(txtFile, "http://data.iana.org/TLD/tlds-alpha-by-domain.txt", 0L);
    8585        } catch (ConnectException e) {
    86             Main.error(e);
     86            Logging.error(e);
    8787            // Try again one more time in case of random network issue
    8888            timestamp = download(txtFile, "http://data.iana.org/TLD/tlds-alpha-by-domain.txt", 0L);
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/RegexValidatorTest.java

    r10378 r12620  
    2727
    2828import org.junit.Test;
    29 import org.openstreetmap.josm.Main;
     29import org.openstreetmap.josm.tools.Logging;
    3030
    3131/**
     
    244244        } catch (PatternSyntaxException e) {
    245245            // expected
    246             Main.debug(e.getMessage());
     246            Logging.debug(e.getMessage());
    247247        }
    248248    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r11493 r12620  
    1919import org.junit.Rule;
    2020import org.junit.Test;
    21 import org.openstreetmap.josm.Main;
    2221import org.openstreetmap.josm.TestUtils;
    2322import org.openstreetmap.josm.command.ChangePropertyCommand;
     
    3837import org.openstreetmap.josm.io.OsmReader;
    3938import org.openstreetmap.josm.testutils.JOSMTestRules;
     39import org.openstreetmap.josm.tools.Logging;
    4040
    4141import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    185185        }
    186186        for (String msg : assertionErrors) {
    187             Main.error(msg);
     187            Logging.error(msg);
    188188        }
    189189        assertTrue("not all assertions included in the tests are met", assertionErrors.isEmpty());
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModelTest.java

    r10962 r12620  
    2020import org.junit.Rule;
    2121import org.junit.Test;
    22 import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.data.osm.Node;
    2423import org.openstreetmap.josm.data.osm.Way;
    2524import org.openstreetmap.josm.testutils.DatasetFactory;
    2625import org.openstreetmap.josm.testutils.JOSMTestRules;
     26import org.openstreetmap.josm.tools.Logging;
    2727
    2828import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    360360        } catch (IllegalArgumentException e) {
    361361            // OK
    362             Main.trace(e);
     362            Logging.trace(e);
    363363        }
    364364
     
    368368        } catch (IllegalArgumentException e) {
    369369            // OK
    370             Main.trace(e);
     370            Logging.trace(e);
    371371        }
    372372    }
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeItemTest.java

    r10962 r12620  
    88import org.junit.Rule;
    99import org.junit.Test;
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.data.osm.Node;
    1211import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
    1312import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.tools.Logging;
    1414
    1515import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    9494        } catch (IllegalArgumentException e) {
    9595            // OK
    96             Main.trace(e);
     96            Logging.trace(e);
    9797        }
    9898    }
     
    141141        } catch (IllegalStateException e) {
    142142            // OK
    143             Main.trace(e);
     143            Logging.trace(e);
    144144        }
    145145    }
     
    154154        } catch (IllegalArgumentException e) {
    155155            // OK
    156             Main.trace(e);
     156            Logging.trace(e);
    157157        }
    158158    }
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java

    r12214 r12620  
    2222import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
    2323import org.openstreetmap.josm.tools.ImageProvider;
     24import org.openstreetmap.josm.tools.Logging;
    2425import org.xml.sax.SAXException;
    2526
     
    6768            } catch (IOException e) {
    6869                try {
    69                     Main.warn(e);
     70                    Logging.warn(e);
    7071                    // try again in case of temporary network error
    7172                    testPresets(allMessages, source);
     
    9596        Collection<TaggingPreset> presets = TaggingPresetReader.readAll(source.url, true);
    9697        assertFalse(presets.isEmpty());
    97         Collection<String> errorsAndWarnings = Main.getLastErrorAndWarnings();
     98        Collection<String> errorsAndWarnings = Logging.getLastErrorAndWarnings();
    9899        boolean error = false;
    99100        for (String message : errorsAndWarnings) {
     
    108109        System.out.println(error ? " => KO" : " => OK");
    109110        if (error) {
    110             Main.clearLastErrorAndWarnings();
     111            Logging.clearLastErrorAndWarnings();
    111112        }
    112113    }
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java

    r11324 r12620  
    2828import org.openstreetmap.josm.JOSMFixture;
    2929import org.openstreetmap.josm.Main;
     30import org.openstreetmap.josm.tools.Logging;
    3031
    3132import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    6364                    RemoteControl.getRemoteControlDir()).resolve(RemoteControlHttpsServer.KEYSTORE_FILENAME));
    6465        } catch (IOException e) {
    65             Main.error(e);
     66            Logging.error(e);
    6667        }
    6768    }
  • trunk/test/unit/org/openstreetmap/josm/tools/OsmUrlToBoundsTest.java

    r12090 r12620  
    55import org.junit.Rule;
    66import org.junit.Test;
    7 import org.openstreetmap.josm.Main;
    87import org.openstreetmap.josm.data.Bounds;
    98import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    9998            } catch (IllegalArgumentException e) {
    10099                // Ignore. check if bounds is null after
    101                 Main.trace(e);
     100                Logging.trace(e);
    102101            }
    103102            Assert.assertEquals(item.url, item.bounds, bounds);
  • trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java

    r11160 r12620  
    7070                fail("Expected IOException");
    7171            } catch (IOException e) {
    72                 Main.info(e.getMessage());
     72                Logging.info(e.getMessage());
    7373            }
    7474        }
  • trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java

    r10378 r12620  
    6060                fail("Expected KeyStoreException");
    6161            } catch (KeyStoreException e) {
    62                 Main.info(e.getMessage());
     62                Logging.info(e.getMessage());
    6363            }
    6464        }
     
    7878                fail("Expected KeyStoreException");
    7979            } catch (KeyStoreException e) {
    80                 Main.info(e.getMessage());
     80                Logging.info(e.getMessage());
    8181            }
    8282        }
     
    9999                fail("Expected KeyStoreException");
    100100            } catch (KeyStoreException e) {
    101                 Main.info(e.getMessage());
     101                Logging.info(e.getMessage());
    102102            }
    103103        }
     
    125125                fail("Expected IOException");
    126126            } catch (IOException e) {
    127                 Main.info(e.getMessage());
     127                Logging.info(e.getMessage());
    128128            }
    129129        }
Note: See TracChangeset for help on using the changeset viewer.