Changeset 1751 in josm


Ignore:
Timestamp:
2009-07-08T22:06:58+02:00 (15 years ago)
Author:
Gubaer
Message:

patch by dmuecke - improved unit tests and test targets in build.xml

Location:
trunk
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/build.xml

    r1683 r1751  
    11<project name="josm" default="dist" basedir=".">
     2        <property name="test.dir" value="test" />
     3        <property name="src.dir" value="src" />
     4        <property name="build.dir" value="build"/>
    25
    36        <!-- Java classpath addition (all jar files to compile tests with this) -->
     
    912
    1013        <target name="dist" depends="compile">
    11                
     14
    1215                <exec append="false" output="REVISION" executable="svn" failifexecutionfails="false">
    1316                        <env key="LANG" value="C"/>
     
    3942                        <zipfileset dir="images" prefix="images" />
    4043                        <zipfileset src="lib/josm-translation.jar" />
    41                        
    42                         <!-- All jar files necessary to run only JOSM (no tests) -->                   
     44
     45                        <!-- All jar files necessary to run only JOSM (no tests) -->
    4346                        <zipfileset src="lib/gettext-commons-0.9.6.jar" />
    4447                        <zipfileset src="lib/metadata-extractor-2.3.1-nosun.jar" />
     
    7780        </target>
    7881
     82        <path id="test.classpath">
     83                <fileset dir="${test.dir}/lib">
     84                        <include name="**/*.jar"/>
     85                </fileset>
     86                <fileset dir="lib">
     87                        <include name="**/*.jar"/>
     88                </fileset>
     89        </path>
     90
     91        <target name="test-init">
     92                <mkdir dir="${test.dir}/${build.dir}" />
     93                <mkdir dir="${test.dir}/report" />
     94        </target>
     95
     96        <target name="test-clean">
     97                <delete dir="${test.dir}/${build.dir}"/>
     98                <delete dir="${test.dir}/report"/>
     99        </target>
     100
     101        <target name="test-compile" depends="test-init">
     102                <javac srcdir="${src.dir}:${test.dir}/unit" classpathref="test.classpath" destdir="${test.dir}/${build.dir}"
     103                                target="1.5" source="1.5" debug="on" encoding="UTF-8">
     104                        <compilerarg value="-Xlint:deprecation"/>
     105                </javac>
     106        </target>
     107
     108    <target name="test" depends="test-compile">
     109        <junit printsummary="yes">
     110                <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/>
     111            <classpath>
     112                <path refid="test.classpath"/>
     113                <pathelement path="${test.dir}/${build.dir}"/>
     114                <pathelement path="${test.dir}/config"/>
     115            </classpath>
     116            <formatter type="plain"/>
     117            <batchtest fork="no" todir="${test.dir}/report">
     118                <fileset dir="${test.dir}/unit" includes="**/*.java"/>
     119            </batchtest>
     120        </junit>
     121    </target>
    79122
    80123</project>
  • trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeVisitorTest.java

    r1750 r1751  
    3333    @BeforeClass
    3434    static public void init() {
    35         testProperties = new Properties();
    36 
    37         // load properties
    38         //
    39         try {
    40             testProperties.load(MergeVisitorTest.class.getResourceAsStream("/test-unit-env.properties"));
    41         } catch(Exception e){
    42             logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
    43             fail(MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
     35
     36        if(System.getProperty("josm.home") == null){
     37            testProperties = new Properties();
     38
     39            // load properties
     40            //
     41            try {
     42                testProperties.load(MergeVisitorTest.class.getResourceAsStream("/test-unit-env.properties"));
     43            } catch(Exception e){
     44                logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
     45                fail(MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
     46            }
     47
     48            // check josm.home
     49            //
     50            String josmHome = testProperties.getProperty("josm.home");
     51            if (josmHome == null) {
     52                fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
     53            } else {
     54                File f = new File(josmHome);
     55                if (! f.exists() || ! f.canRead()) {
     56                    fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));
     57                }
     58            }
     59            System.setProperty("josm.home", josmHome);
    4460        }
    45 
    46         // check josm.home
    47         //
    48         String josmHome = testProperties.getProperty("josm.home");
    49         if (josmHome == null) {
    50             fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
    51         } else {
    52             File f = new File(josmHome);
    53             if (! f.exists() || ! f.canRead()) {
    54                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));
    55             }
    56         }
    57         System.setProperty("josm.home", josmHome);
    5861        Main.pleaseWaitDlg = new PleaseWaitDialog(null);
    5962        Main.pref.init(false);
     
    6568    /**
    6669     * two identical nodes, even in id and version. No confict expected.
    67      * 
     70     *
    6871     * Can happen if data is loaded in two layers and then merged from one layer
    6972     * on the other.
     
    104107     * two  nodes, my is unmodified, their is updated and has a higher version
    105108     * => their version is going to be the merged version
    106      * 
     109     *
    107110     */
    108111    @Test
     
    143146     * node with same id, my is modified, their has a higher version
    144147     * => results in a conflict
    145      * 
     148     *
    146149     * Use case: node which is modified locally and updated by another mapper on
    147150     * the server
     
    181184     * node with same id, my is deleted, their has a higher version
    182185     * => results in a conflict
    183      * 
     186     *
    184187     * Use case: node which is deleted locally and updated by another mapper on
    185188     * the server
     
    217220     * My node is visible, their version has a higher version and is not visible
    218221     * => create a conflict
    219      * 
     222     *
    220223     */
    221224    @Test
     
    251254     * My node is deleted, their node has the same id and version and is not deleted.
    252255     * => mine has precedence
    253      * 
     256     *
    254257     */
    255258    @Test
     
    281284    /**
    282285     * My and their node are new but semantically equal. My node is deleted.
    283      * 
     286     *
    284287     * => create a conflict
    285      * 
     288     *
    286289     */
    287290    @Test
     
    309312    /**
    310313     * My and their node are new but semantically equal. Both are deleted.
    311      * 
     314     *
    312315     * => take mine
    313      * 
     316     *
    314317     */
    315318    @Test
     
    339342     * their node is not visible and doesn't exist in my data set
    340343     * => ignore their node
    341      * 
     344     *
    342345     */
    343346    @Test
     
    372375     * their node has no assigned id (id == 0) and is semantically equal to one of my
    373376     * nodes with id == 0
    374      * 
     377     *
    375378     * => merge it onto my node.
    376      * 
     379     *
    377380     */
    378381    @Test
     
    422425    /**
    423426     * my node is incomplete, their node is complete
    424      * 
     427     *
    425428     * => merge it onto my node. My node becomes complete
    426      * 
     429     *
    427430     */
    428431    @Test
     
    461464     * their way has a higher version and different tags. the nodes are the same. My
    462465     * way is not modified. Merge is possible. No conflict.
    463      * 
     466     *
    464467     * => merge it onto my way.
    465      * 
     468     *
    466469     */
    467470    @Test
     
    531534     * their way has a higher version and different tags. And it has more nodes. Two
    532535     * of the existing nodes are modified.
    533      * 
     536     *
    534537     * => merge it onto my way, no conflict
    535      * 
     538     *
    536539     */
    537540    @Test
     
    605608    /**
    606609     * their way has a higher version and different nodes. My way is modified.
    607      * 
     610     *
    608611     * => merge it onto my way not possbile, conflict
    609      * 
     612     *
    610613     */
    611614    @Test
     
    681684    /**
    682685     * their way is not visible anymore.
    683      * 
     686     *
    684687     * => conflict
    685      * 
     688     *
    686689     */
    687690    @Test
     
    731734     * my and  their way are semantically equal. so technical attributes of
    732735     * their way can be merged on my way. No conflict.
    733      * 
    734      * 
    735      * 
     736     *
     737     *
     738     *
    736739     */
    737740    @Test
     
    795798     * my and  their way are semantically equal. so technical attributes of
    796799     * their way can be merged on my way. No conflict.
    797      * 
     800     *
    798801     */
    799802    @Test
Note: See TracChangeset for help on using the changeset viewer.