Changeset 7068 in josm for trunk/test


Ignore:
Timestamp:
2014-05-06T01:24:41+02:00 (10 years ago)
Author:
Don-vip
Message:

test cleanup

Location:
trunk/test
Files:
8 added
5 deleted
16 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/test/config/unit-josm.home

    • Property svn:ignore
      •  

        old new  
        11cache
         2preferences.xml_backup
         3preferences.xml_tmp
         4preferences.xml
  • trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    r7040 r7068  
    1010import java.io.FileOutputStream;
    1111import java.io.IOException;
    12 import java.io.InputStream;
    1312import java.io.OutputStreamWriter;
    1413import java.io.PrintWriter;
     
    1615import java.util.ArrayList;
    1716import java.util.HashSet;
    18 import java.util.Properties;
    1917import java.util.Set;
    20 import java.util.logging.Level;
    2118import java.util.logging.Logger;
    2219
     
    2421import org.junit.BeforeClass;
    2522import org.junit.Test;
     23import org.openstreetmap.josm.JOSMFixture;
    2624import org.openstreetmap.josm.Main;
    2725import org.openstreetmap.josm.data.coor.LatLon;
     
    4038import org.openstreetmap.josm.tools.Utils;
    4139
     40/**
     41 * Reads primitives referring to a particular primitive (ways including a node, relations referring to a relation)
     42 * @since 1806
     43 */
    4244public class OsmServerBackreferenceReaderTest {
    4345    static private final Logger logger = Logger.getLogger(OsmServerBackreferenceReader.class.getName());
     
    4749            if (("node-" + i).equals(n.get("name"))) return n;
    4850        }
     51        fail("Cannot find node "+i);
    4952        return null;
    5053    }
    51 
    5254
    5355    protected static Way lookupWay(DataSet ds, int i) {
     
    5557            if (("way-" + i).equals(w.get("name"))) return w;
    5658        }
     59        fail("Cannot find way "+i);
    5760        return null;
    5861    }
     
    6265            if (("relation-" + i).equals(r.get("name"))) return r;
    6366        }
     67        fail("Cannot find relation "+i);
    6468        return null;
    6569    }
     
    107111        }
    108112    }
    109 
    110113
    111114    protected static DataSet buildTestDataSet() {
     
    137140    }
    138141
    139     static Properties testProperties;
    140142    static DataSet testDataSet;
    141143
    142144    @BeforeClass
    143     public static void  init() throws OsmTransferException {
     145    public static void init() throws OsmTransferException {
    144146        logger.info("initializing ...");
    145         testProperties = new Properties();
    146 
    147         // load properties
    148         //
    149         try (InputStream is = MultiFetchServerObjectReaderTest.class.getResourceAsStream("/test-functional-env.properties")) {
    150             if (is == null) {
    151                 throw new IOException();
    152             }
    153             testProperties.load(is);
    154         } catch(IOException e){
    155             logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties"));
    156             fail(MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties"));
    157         }
    158 
    159         // check josm.home
    160         //
    161         String josmHome = testProperties.getProperty("josm.home");
    162         if (josmHome == null) {
    163             fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
    164         } else {
    165             File f = new File(josmHome);
    166             if (! f.exists() || ! f.canRead()) {
    167                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));
    168             }
    169         }
    170 
    171         // check temp output dir
    172         //
    173         String tempOutputDir = testProperties.getProperty("test.functional.tempdir");
    174         if (tempOutputDir == null) {
    175             fail(MessageFormat.format("property ''{0}'' not set in test environment", "test.functional.tempdir"));
    176         } else {
    177             File f = new File(tempOutputDir);
    178             if (! f.exists() || ! f.isDirectory() || ! f.canWrite()) {
    179                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing, not a directory, or not writeable", "test.functional.tempdir", tempOutputDir));
    180             }
    181         }
    182 
    183 
    184         // init preferences
    185         //
    186         System.setProperty("josm.home", josmHome);
    187         Main.pref.init(false);
     147
     148        JOSMFixture.createFunctionalTestFixture().init();
     149
    188150        // don't use atomic upload, the test API server can't cope with large diff uploads
    189151        //
    190152        Main.pref.put("osm-server.atomic-upload", false);
    191153        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    192 
    193         File dataSetCacheOutputFile = new File(tempOutputDir, MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
    194 
    195         // make sure we don't upload to production
    196         //
    197         String url = OsmApi.getOsmApi().getBaseUrl().toLowerCase().trim();
    198         if (url.startsWith("http://www.openstreetmap.org") || url.startsWith("http://api.openstreetmap.org")
    199             || url.startsWith("https://www.openstreetmap.org") || url.startsWith("https://api.openstreetmap.org")) {
    200             fail(MessageFormat.format("configured url ''{0}'' seems to be a productive url, aborting.", url));
    201         }
    202 
    203         String p = System.getProperties().getProperty("useCachedDataset");
     154        Main.logLevel = 4;
     155
     156        File dataSetCacheOutputFile = new File(System.getProperty("java.io.tmpdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
     157
     158        String p = System.getProperty("useCachedDataset");
    204159        if (p != null && Boolean.parseBoolean(p.trim().toLowerCase())) {
    205160            logger.info(MessageFormat.format("property ''{0}'' set, using cached dataset", "useCachedDataset"));
     
    239194    @Before
    240195    public void setUp() throws IOException, IllegalDataException {
    241         File f = new File(testProperties.getProperty("test.functional.tempdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
     196        File f = new File(System.getProperty("java.io.tmpdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
    242197        logger.info(MessageFormat.format("reading cached dataset ''{0}''", f.toString()));
    243198        ds = new DataSet();
  • trunk/test/performance/org/openstreetmap/josm/data/osm/RoundingPerformanceTest.java

    r4573 r7068  
     1// License: GPL. For details, see LICENSE file.
    12package org.openstreetmap.josm.data.osm;
     3
     4import static org.junit.Assert.assertTrue;
    25
    36import org.junit.Test;
     
    58import org.openstreetmap.josm.data.coor.LatLonTest;
    69
    7 import static org.junit.Assert.assertTrue;
     10public class RoundingPerformanceTest {
    811
    9 public class RoundingPerformanceTest extends LatLonTest {
    10    
    1112    private static double oldRoundToOsmPrecision(double value) {
    1213        return Math.round(value / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION; // Old method, causes rounding errors, but efficient
     
    1819        long start = System.nanoTime();
    1920        for (int i = 0; i < n; i++) {
    20             for (double value : sampleValues) {
     21            for (double value : LatLonTest.SAMPLE_VALUES) {
    2122                oldRoundToOsmPrecision(value);
    2223            }
     
    2526        long oldTime = end-start;
    2627        System.out.println("Old time: "+oldTime/1000000.0 + " ms");
    27        
     28
    2829        start = System.nanoTime();
    2930        for (int i = 0; i < n; i++) {
    30             for (double value : sampleValues) {
     31            for (double value : LatLonTest.SAMPLE_VALUES) {
    3132                LatLon.roundToOsmPrecision(value);
    3233            }
     
    3536        long newTime = end-start;
    3637        System.out.println("New time: "+newTime/1000000.0 + " ms");
    37        
     38
    3839        assertTrue(newTime <= oldTime*10);
    3940    }
  • trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java

    r7065 r7068  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.data.osm;
     2package org.openstreetmap.josm.data.osm.visitor.paint;
    33
    44import java.awt.Graphics2D;
     
    1111import org.openstreetmap.josm.Main;
    1212import org.openstreetmap.josm.data.Bounds;
     13import org.openstreetmap.josm.data.osm.DataSet;
    1314import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
    1415import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
     
    1920import org.openstreetmap.josm.io.OsmReader;
    2021
    21 public class MapPaintVisitorPerformanceTest {
     22public class StyledMapRendererPerformanceTest {
    2223
    2324    private static final int IMG_WIDTH = 1400;
     
    5455
    5556        // Warm up
    56         new MapPaintVisitorPerformanceTest().testRestrictionSmall();
    57         new MapPaintVisitorPerformanceTest().testCity();
     57        new StyledMapRendererPerformanceTest().testRestrictionSmall();
     58        new StyledMapRendererPerformanceTest().testCity();
    5859    }
    5960
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy

    r7065 r7068  
    1 
    21// License: GPL. For details, see LICENSE file.
    3 package mapcss.performance;
     2package org.openstreetmap.josm.gui.mappaint.mapcss;
    43
    54import static org.junit.Assert.*
     
    1615import org.openstreetmap.josm.gui.layer.OsmDataLayer
    1716import org.openstreetmap.josm.gui.mappaint.MapPaintStyles
    18 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource
    1917import org.openstreetmap.josm.gui.preferences.SourceEntry
    2018import org.openstreetmap.josm.io.OsmReader
    2119
    2220/**
    23  * This performance tests measures the time for a full run of MapPaintVisitor.visitAll()
     21 * This performance test measures the time for a full run of MapPaintVisitor.visitAll()
    2422 * against a test data set using a test style.
    25  * 
     23 *
    2624 */
    27 class PerformanceTest {
     25class MapCSSPerformanceTest {
    2826
    2927    /* ------------------------ configuration section  ---------------------------- */
    3028    /**
    31     * The path to the JOSM home environment
    32     */
    33    def static JOSM_HOME="/my/josm/home/dir"
    34    
    35    /**
    36     * The path to the style file used for rendering.
    37     */
    38    def static STYLE_FILE="/my/test-style.mapcss"
     29     * The path to the JOSM home environment
     30     */
     31    def static JOSM_HOME="test/config/performance-josm.home"
    3932
    40    /**
    41     * The data file to be rendered
    42     */
    43    def static DATA_FILE = "/my/test-data.osm"
    44     /* ------------------------ / configuration section  ---------------------------- */     
    45    
     33    /**
     34     * The path to the style file used for rendering.
     35     */
     36    def static STYLE_FILE="styles/standard/elemstyles.mapcss"
     37
     38    /**
     39     * The data file to be rendered
     40     */
     41    def static DATA_FILE = "/my/test-data.osm"
     42    /* ------------------------ / configuration section  ---------------------------- */
     43
    4644    def DataSet ds
    47    
     45
    4846    def static boolean checkTestEnvironment() {
    4947          File f = new File(JOSM_HOME)
    5048          if  (!f.isDirectory() || !f.exists()) {
    51               fail("JOSM_HOME refers to '${JOSM_HOME}. This is either not a directory or doesn't exist.\nPlease update configuration settings in the unit test file.")             
     49              fail("JOSM_HOME refers to '${JOSM_HOME}. This is either not a directory or doesn't exist.\nPlease update configuration settings in the unit test file.")
    5250          }
    53          
     51
    5452          f = new File(STYLE_FILE);
    5553          if ( !f.isFile() || ! f.exists()) {
    5654              fail("STYLE_FILE refers to '${STYLE_FILE}. This is either not a file or doesn't exist.\nPlease update configuration settings in the unit test file.")
    5755          }
    58          
     56
    5957          f = new File(DATA_FILE);
    6058          if ( !f.isFile() || ! f.exists()) {
     
    6260          }
    6361    }
    64    
     62
    6563    @BeforeClass
    6664    public static void createJOSMFixture(){
     
    6967        MainApplication.main(new String[0])
    7068    }
    71    
     69
    7270    def timed(Closure c){
    7371        long before = System.currentTimeMillis()
     
    7674        return after - before
    7775    }
    78    
     76
    7977    def  loadStyle() {
    8078        print "Loading style '$STYLE_FILE' ..."
     
    9593        println "DONE"
    9694    }
    97    
     95
    9896    def loadData() {
    9997        print "Loading data file '$DATA_FILE' ..."
     
    105103        println "DONE"
    106104    }
    107    
     105
    108106    @Test
    109107    public void measureTimeForStylePreparation() {
    110108        loadStyle()
    111109        loadData()
    112        
     110
    113111        def mv = Main.map.mapView
    114        
     112
    115113        BufferedImage img = mv.createImage(mv.getWidth(), mv.getHeight())
    116114        Graphics2D g = img.createGraphics()
    117115        g.setClip(0,0, mv.getWidth(), mv.getHeight())
    118         def visitor = new StyledMapRenderer()
    119         visitor.setNavigatableComponent(Main.map.mapView)
    120         visitor.setGraphics(g)
     116        def visitor = new StyledMapRenderer(g, Main.map.mapView, false)
    121117
    122118        print "Rendering ..."
     
    128124        println "style file: ${STYLE_FILE}"
    129125        println ""
    130         println "Rendering took $time ms."       
     126        println "Rendering took $time ms."
    131127    }
    132128}
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r7065 r7068  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap.josm.fixtures;
     2package org.openstreetmap.josm;
    33
    44import static org.junit.Assert.fail;
     
    66import java.io.File;
    77import java.text.MessageFormat;
    8 import java.util.Properties;
    9 import java.util.logging.Level;
    108import java.util.logging.Logger;
    119
    12 import org.openstreetmap.josm.Main;
    1310import org.openstreetmap.josm.data.projection.Projections;
    1411import org.openstreetmap.josm.io.OsmApi;
     
    1916
    2017    static public JOSMFixture createUnitTestFixture() {
    21         return new JOSMFixture("/test-unit-env.properties");
     18        return new JOSMFixture("test/config/unit-josm.home");
    2219    }
    2320
    2421    static public JOSMFixture createFunctionalTestFixture() {
    25         return new JOSMFixture("/test-functional-env.properties");
     22        return new JOSMFixture("test/config/functional-josm.home");
    2623    }
    2724
    28     private Properties testProperties;
    29     private String testPropertiesResourceName;
     25    static public JOSMFixture createPerformanceTestFixture() {
     26        return new JOSMFixture("test/config/performance-josm.home");
     27    }
    3028
    31     public JOSMFixture(String testPropertiesResourceName) {
    32         this.testPropertiesResourceName = testPropertiesResourceName;
     29    private final String josmHome;
     30
     31    public JOSMFixture(String josmHome) {
     32        this.josmHome = josmHome;
    3333    }
    3434
    3535    public void init() {
    36         testProperties = new Properties();
    37 
    38         // load properties
    39         //
    40         try {
    41             testProperties.load(JOSMFixture.class.getResourceAsStream(testPropertiesResourceName));
    42         } catch(Exception e){
    43             logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", testPropertiesResourceName));
    44             fail(MessageFormat.format("failed to load property file ''{0}''. \nMake sure the path ''$project_root/test/config'' is on the classpath.", testPropertiesResourceName));
    45         }
    4636
    4737        // check josm.home
    4838        //
    49         String josmHome = testProperties.getProperty("josm.home");
    5039        if (josmHome == null) {
    5140            fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
     
    5342            File f = new File(josmHome);
    5443            if (! f.exists() || ! f.canRead()) {
    55                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable.\nEdit ''{2}'' and update the value ''josm.home''. ", "josm.home", josmHome,testPropertiesResourceName ));
     44                fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable.", "josm.home", josmHome));
    5645            }
    5746        }
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r7065 r7068  
    11// License: GPL. For details, see LICENSE file.
    2 package org.openstreetmap;
     2package org.openstreetmap.josm;
    33
    44import static org.hamcrest.CoreMatchers.is;
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.groovy

    r6597 r7068  
    11package org.openstreetmap.josm.actions
    22
    3 import org.openstreetmap.TestUtils
    43import org.openstreetmap.josm.Main
     4import org.openstreetmap.josm.TestUtils;
    55import org.openstreetmap.josm.actions.search.SearchCompiler
    66import org.openstreetmap.josm.data.osm.Relation
  • trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java

    r6226 r7068  
    66import org.junit.Test;
    77
    8 /**
    9  * @author Vincent
    10  *
    11  */
    128public class LatLonTest {
    139
    14     protected static final double[] sampleValues = new double[]{
     10    public static final double[] SAMPLE_VALUES = new double[]{
    1511            -180.0, -179.9, -179.6, -179.5, -179.4, -179.1, -179.0, -100.0, -99.9, -10.0, -9.9, -1.0, -0.1,
    1612            180.0,  179.9,  179.6,  179.5,  179.4,  179.1,  179.0,  100.0,  99.9,  10.0,  9.9,  1.0,  0.1,
     
    2016            100.12, 100.123, 100.1234, 100.12345, 100.123456, 100.1234567
    2117           };
    22    
     18
    2319    /**
    2420     * Test of {@link LatLon#roundToOsmPrecisionStrict}
     
    2622    @Test
    2723    public void testRoundToOsmPrecisionStrict() {
    28        
    29         for (double value : sampleValues) {
     24
     25        for (double value : SAMPLE_VALUES) {
    3026            assertEquals(LatLon.roundToOsmPrecisionStrict(value), value, 0);
    3127        }
    32        
     28
    3329        assertEquals(LatLon.roundToOsmPrecisionStrict(0.0), 0.0, 0);
    3430        assertEquals(LatLon.roundToOsmPrecisionStrict(-0.0), 0.0, 0);
    35        
     31
    3632        assertEquals(LatLon.roundToOsmPrecisionStrict(0.12345678),  0.1234568, 0);
    3733        assertEquals(LatLon.roundToOsmPrecisionStrict(0.123456789), 0.1234568, 0);
     
    7672        assertEquals(LatLon.roundToOsmPrecisionStrict(99.9999999),  99.9999999, 0);
    7773    }
    78    
     74
    7975    /**
    8076     * Test of {@link LatLon#toIntervalLon}
     
    107103    @Test
    108104    public void testEquals() {
    109         for (int i = 1; i < sampleValues.length; i++) {
    110             LatLon a = new LatLon(sampleValues[i-1], sampleValues[i]);
    111             LatLon b = new LatLon(sampleValues[i-1], sampleValues[i]);
     105        for (int i = 1; i < SAMPLE_VALUES.length; i++) {
     106            LatLon a = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]);
     107            LatLon b = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]);
    112108            assertEquals(a, b);
    113109        }
     
    119115    @Test
    120116    public void testHashCode() {
    121         for (int i = 1; i < sampleValues.length; i++) {
    122             LatLon a = new LatLon(sampleValues[i-1], sampleValues[i]);
    123             LatLon b = new LatLon(sampleValues[i-1], sampleValues[i]);
     117        for (int i = 1; i < SAMPLE_VALUES.length; i++) {
     118            LatLon a = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]);
     119            LatLon b = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]);
    124120            assertEquals(a.hashCode(), b.hashCode());
    125121        }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/LanesTest.groovy

    r6647 r7068  
    11package org.openstreetmap.josm.data.validation.tests
    22
    3 import org.openstreetmap.TestUtils
     3import org.openstreetmap.josm.TestUtils;
    44
    55class LanesTest extends GroovyTestCase {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r7065 r7068  
    1313import java.util.Map;
    1414
    15 import org.junit.Before;
     15import org.junit.BeforeClass;
    1616import org.junit.Test;
    17 import org.openstreetmap.TestUtils;
    1817import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.TestUtils;
    1919import org.openstreetmap.josm.command.ChangePropertyCommand;
    2020import org.openstreetmap.josm.data.osm.Node;
     
    3131     * Setup test.
    3232     */
    33     @Before
    34     public void setUp() throws Exception {
     33    @BeforeClass
     34    public static void setUp() {
    3535        Main.initApplicationPreferences();
    3636    }
  • trunk/test/unit/org/openstreetmap/josm/gui/JosmUserIdentityManagerTest.groovy

    r2690 r7068  
    22package org.openstreetmap.josm.gui;
    33
    4 import org.junit.BeforeClass;
    5 import org.junit.Test
    6 import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.osm.UserInfo;
    8 import org.openstreetmap.josm.fixtures.JOSMFixture;
    9 
    10 import static org.junit.Assert.*;
     4import static org.junit.Assert.*
     5
     6import org.junit.BeforeClass
     7import org.junit.Test
     8import org.openstreetmap.josm.JOSMFixture
     9import org.openstreetmap.josm.Main
     10import org.openstreetmap.josm.data.osm.UserInfo
    1111
    1212class JosmUserIdentityManagerTest {
    13        
     13
    1414        final shouldFail = new GroovyTestCase().&shouldFail
    15        
     15
    1616        private static JOSMFixture josmFixture
    17        
     17
    1818        @BeforeClass
    1919        public static void initTestCase() {
    2020            josmFixture = JOSMFixture.createFunctionalTestFixture()
    2121        }
    22        
     22
    2323        @Test
    2424        public void test_SingletonAccess() {
    25                
    26                 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()             
     25
     26                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
    2727
    2828                // created ?
    2929                assert im != null
    30                
    31                 // registered as listener ? 
     30
     31                // registered as listener ?
    3232                assert Main.pref.@listeners.contains(im)
    33                
     33
    3434                JosmUserIdentityManager im2 = JosmUserIdentityManager.getInstance()
    3535
    3636                // only one instance
    37                 assert im == im2               
    38         }
    39        
     37                assert im == im2
     38        }
     39
    4040        @Test
    4141        public void test_setAnonymouse() {
    4242                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
    43                
     43
    4444                im.setPartiallyIdentified "test"
    4545                im.setAnonymous()
    46                                
     46
    4747                assert im.isAnonymous()
    4848                assert ! im.isPartiallyIdentified()
    4949                assert ! im.isFullyIdentified()
    50                
     50
    5151                assert im.getUserId() == 0
    5252                assert im.getUserName() == null
    5353                assert im.getUserInfo() == null
    5454        }
    55        
     55
    5656        @Test
    5757        public void test_setPartiallyIdentified() {
    5858                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
    59                
     59
    6060                im.setPartiallyIdentified "test"
    61                
     61
    6262                shouldFail(IllegalArgumentException) {
    6363                    im.setPartiallyIdentified null
    6464                }
    65                
     65
    6666                shouldFail(IllegalArgumentException) {
    6767                        im.setPartiallyIdentified ""
    6868                }
    69                
     69
    7070                shouldFail(IllegalArgumentException) {
    7171                        im.setPartiallyIdentified "  \t  "
    7272                }
    73                
     73
    7474                im.setPartiallyIdentified "test"
    75                
     75
    7676                assert ! im.isAnonymous()
    7777                assert im.isPartiallyIdentified()
    7878                assert ! im.isFullyIdentified()
    79                
     79
    8080                assert im.getUserId() == 0
    8181                assert im.getUserName() == "test"
    8282                assert im.getUserInfo() == null
    8383        }
    84        
    85        
     84
     85
    8686        @Test
    8787        public void test_setFullyIdentified() {
     
    8989
    9090                UserInfo userInfo = new UserInfo(id: 1, description: "a description")
    91                
     91
    9292                im.setFullyIdentified "test", userInfo
    93                
     93
    9494                shouldFail(IllegalArgumentException) {
    9595                        im.setFullyIdentified null, userInfo
     
    104104                        im.setFullyIdentified "test", null
    105105                }
    106                
     106
    107107                im.setFullyIdentified "test", userInfo
    108                
     108
    109109                assert ! im.isAnonymous()
    110110                assert ! im.isPartiallyIdentified()
    111111                assert im.isFullyIdentified()
    112                
     112
    113113                assert im.getUserId() == 1
    114114                assert im.getUserName() == "test"
    115115                assert im.getUserInfo() == userInfo
    116116        }
    117        
     117
    118118        /**
    119119         * Preferences include neither an url nor a user name => we have
    120          * an anonymous user 
    121          */
    122         @Test 
     120         * an anonymous user
     121         */
     122        @Test
    123123        public void initFromPreferences_1() {
    124124                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
    125                
    126                 // reset it 
    127                 im.@userName = null
    128                 im.@userInfo = null
    129                
     125
     126                // reset it
     127                im.@userName = null
     128                im.@userInfo = null
     129
    130130                Main.pref.put "osm-server.url", null
    131131                Main.pref.put "osm-server.username", null
    132                
    133                 im.initFromPreferences()
    134                
    135                 assert im.isAnonymous()
    136         }
    137        
     132
     133                im.initFromPreferences()
     134
     135                assert im.isAnonymous()
     136        }
     137
    138138        /**
    139139         * Preferences include neither an url nor a user name => we have
    140          * an annoymous user 
    141          */
    142         @Test 
     140         * an annoymous user
     141         */
     142        @Test
    143143        public void initFromPreferences_2() {
    144144                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
    145                
    146                 // reset it 
    147                 im.@userName = null
    148                 im.@userInfo = null
    149                
     145
     146                // reset it
     147                im.@userName = null
     148                im.@userInfo = null
     149
    150150                // for this test we disable the listener
    151151                Main.pref.removePreferenceChangeListener im
    152                
    153                 Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
    154                 Main.pref.put "osm-server.username", null
    155                
    156                 im.initFromPreferences()
    157                
    158                 assert im.isAnonymous()
    159         }
    160        
    161         /**
    162          * Preferences include an user name => we have a partially identified user 
    163          */
    164         @Test 
     152
     153                Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
     154                Main.pref.put "osm-server.username", null
     155
     156                im.initFromPreferences()
     157
     158                assert im.isAnonymous()
     159        }
     160
     161        /**
     162         * Preferences include an user name => we have a partially identified user
     163         */
     164        @Test
    165165        public void initFromPreferences_3() {
    166166                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
     
    169169                Main.pref.removePreferenceChangeListener im
    170170
    171                 // reset it 
    172                 im.@userName = null
    173                 im.@userInfo = null
    174                
     171                // reset it
     172                im.@userName = null
     173                im.@userInfo = null
     174
    175175                Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
    176176                Main.pref.put "osm-server.username", "test"
    177                
    178                 im.initFromPreferences()
    179                
    180                 assert im.isPartiallyIdentified()
    181         }
    182        
     177
     178                im.initFromPreferences()
     179
     180                assert im.isPartiallyIdentified()
     181        }
     182
    183183        /**
    184184         * Preferences include an user name which is different from the current
    185185         * user name and we are currently fully identifed => josm user becomes
    186          * partially identified 
    187          */
    188         @Test 
     186         * partially identified
     187         */
     188        @Test
    189189        public void initFromPreferences_4() {
    190190                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
     
    194194
    195195                im.setFullyIdentified "test1", new UserInfo(id: 1)
    196                
     196
    197197                Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
    198198                Main.pref.put "osm-server.username", "test2"
    199                
    200                 im.initFromPreferences()
    201                
    202                 assert im.isPartiallyIdentified()
    203         }
    204        
     199
     200                im.initFromPreferences()
     201
     202                assert im.isPartiallyIdentified()
     203        }
     204
    205205        /**
    206206         * Preferences include an user name which is the same as the current
     
    208208         * fully identified
    209209         */
    210         @Test 
     210        @Test
    211211        public void initFromPreferences_5() {
    212212                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
     
    214214        // for this test we disable the listener
    215215                Main.pref.removePreferenceChangeListener im
    216        
     216
    217217                im.setFullyIdentified "test1", new UserInfo(id: 1)
    218                
     218
    219219                Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
    220220                Main.pref.put "osm-server.username", "test1"
    221                
    222                 im.initFromPreferences()
    223                
     221
     222                im.initFromPreferences()
     223
    224224                assert im.isFullyIdentified()
    225225        }
    226        
    227         @Test 
     226
     227        @Test
    228228        public void apiUrlChanged() {
    229229                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
    230                
    231                 // make sure im is a preference change listener 
     230
     231                // make sure im is a preference change listener
    232232                Main.pref.addPreferenceChangeListener im
    233                
    234                 // reset it 
    235                 im.@userName = null
    236                 im.@userInfo = null
    237                                
    238                 Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
    239                 assert im.isAnonymous()
    240                
     233
     234                // reset it
     235                im.@userName = null
     236                im.@userInfo = null
     237
     238                Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
     239                assert im.isAnonymous()
     240
    241241         Main.pref.put "osm-server.url", null
    242242         assert im.isAnonymous()
    243                
    244                 // reset it 
     243
     244                // reset it
    245245                im.@userName = "test"
    246246                im.@userInfo = null
    247                
    248                 Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
    249                 assert im.isPartiallyIdentified()
    250                 assert im.getUserName() == "test"
    251                
     247
     248                Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
     249                assert im.isPartiallyIdentified()
     250                assert im.getUserName() == "test"
     251
    252252                Main.pref.put "osm-server.url", null
    253253                assert im.isAnonymous()
    254                
    255                 // reset it 
     254
     255                // reset it
    256256                im.@userName = "test"
    257257                im.@userInfo = new UserInfo(id:1)
    258                
    259                 Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
    260                 assert im.isPartiallyIdentified()
    261                 assert im.getUserName() == "test"
    262                
    263                 // reset it 
     258
     259                Main.pref.put "osm-server.url", "http://api.openstreetmap.org"
     260                assert im.isPartiallyIdentified()
     261                assert im.getUserName() == "test"
     262
     263                // reset it
    264264                im.@userName = "test"
    265265                im.@userInfo = new UserInfo(id:1)
    266                
    267                
     266
     267
    268268                Main.pref.put "osm-server.url", null
    269                 assert im.isAnonymous()                         
    270         }
    271        
    272         @Test 
     269                assert im.isAnonymous()
     270        }
     271
     272        @Test
    273273        public void userNameChanged() {
    274274                JosmUserIdentityManager im = JosmUserIdentityManager.getInstance()
    275                
    276                 // make sure im is a preference change listener 
     275
     276                // make sure im is a preference change listener
    277277                Main.pref.addPreferenceChangeListener im
    278                
    279                 // reset it 
    280                 im.@userName = null
    281                 im.@userInfo = null
    282                
     278
     279                // reset it
     280                im.@userName = null
     281                im.@userInfo = null
     282
    283283                Main.pref.put "osm-server.username", "test"
    284284                assert im.isPartiallyIdentified()
    285285                assert im.getUserName() == "test"
    286                
    287                 Main.pref.put "osm-server.username", null
    288                 assert im.isAnonymous()
    289                
    290                 // reset it 
     286
     287                Main.pref.put "osm-server.username", null
     288                assert im.isAnonymous()
     289
     290                // reset it
    291291                im.@userName = "test1"
    292292                im.@userInfo = null
    293                
     293
    294294                Main.pref.put "osm-server.username", "test2"
    295295                assert im.isPartiallyIdentified()
    296296                assert im.getUserName() == "test2"
    297                
    298                 Main.pref.put "osm-server.username", null
    299                 assert im.isAnonymous()
    300                
    301                 // reset it 
     297
     298                Main.pref.put "osm-server.username", null
     299                assert im.isAnonymous()
     300
     301                // reset it
    302302                im.@userName = "test1"
    303303                im.@userInfo = new UserInfo(id:1)
    304                
     304
    305305                Main.pref.put "osm-server.username", "test2"
    306306                assert im.isPartiallyIdentified()
    307307                assert im.getUserName() == "test2"
    308                
    309                 // reset it 
     308
     309                // reset it
    310310                im.@userName = "test1"
    311311                im.@userInfo = new UserInfo(id:1)
    312                
    313                
    314                 Main.pref.put "osm-server.username", null
    315                 assert im.isAnonymous()             
     312
     313
     314                Main.pref.put "osm-server.username", null
     315                assert im.isAnonymous()
    316316        }
    317317}
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy

    r3991 r7068  
    33
    44import org.junit.*
    5 import org.openstreetmap.josm.fixtures.JOSMFixture;
     5import org.openstreetmap.josm.JOSMFixture;
    66import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
    77import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy;
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy

    r4074 r7068  
    44
    55import org.junit.*
    6 import org.openstreetmap.josm.fixtures.JOSMFixture
     6import org.openstreetmap.josm.JOSMFixture;
    77import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy
    88import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.groovy

    r4069 r7068  
    77
    88import org.junit.*
     9import org.openstreetmap.josm.JOSMFixture;
    910import org.openstreetmap.josm.data.coor.LatLon
    1011import org.openstreetmap.josm.data.osm.DataSet
     
    1314import org.openstreetmap.josm.data.osm.RelationMember
    1415import org.openstreetmap.josm.data.osm.Way
    15 import org.openstreetmap.josm.fixtures.JOSMFixture
    1616import org.openstreetmap.josm.gui.mappaint.Environment
    1717import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.groovy

    r4074 r7068  
    55
    66import org.junit.*
     7import org.openstreetmap.josm.JOSMFixture;
    78import org.openstreetmap.josm.data.coor.LatLon
    89import org.openstreetmap.josm.data.osm.DataSet
     
    1011import org.openstreetmap.josm.data.osm.Relation
    1112import org.openstreetmap.josm.data.osm.RelationMember
    12 import org.openstreetmap.josm.fixtures.JOSMFixture
    1313import org.openstreetmap.josm.gui.mappaint.Environment
    1414import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy

    r4074 r7068  
    55
    66import org.junit.*
     7import org.openstreetmap.josm.JOSMFixture;
    78import org.openstreetmap.josm.data.coor.LatLon
    89import org.openstreetmap.josm.data.osm.DataSet
     
    1011import org.openstreetmap.josm.data.osm.Relation
    1112import org.openstreetmap.josm.data.osm.RelationMember
    12 import org.openstreetmap.josm.fixtures.JOSMFixture
    1313import org.openstreetmap.josm.gui.mappaint.Environment
    1414import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy

    r7066 r7068  
    55import org.junit.Before
    66import org.junit.Test
    7 import org.openstreetmap.TestUtils
    87import org.openstreetmap.josm.Main
     8import org.openstreetmap.josm.TestUtils;
    99import org.openstreetmap.josm.data.coor.LatLon
    1010import org.openstreetmap.josm.data.osm.DataSet
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ParsingLinkSelectorTest.groovy

    r4074 r7068  
    55
    66import org.junit.*
    7 import org.openstreetmap.josm.fixtures.JOSMFixture
     7import org.openstreetmap.josm.JOSMFixture;
    88
    99
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java

    r6881 r7068  
    1313import org.junit.BeforeClass;
    1414import org.junit.Test;
    15 import org.openstreetmap.TestUtils;
    1615import org.openstreetmap.josm.Main;
     16import org.openstreetmap.josm.TestUtils;
    1717import org.openstreetmap.josm.tools.Utils;
    1818import org.xml.sax.SAXException;
Note: See TracChangeset for help on using the changeset viewer.