Changeset 34669 in osm


Ignore:
Timestamp:
2018-09-23T21:35:17+02:00 (6 years ago)
Author:
donvip
Message:

see #josm16769 - add unit tests for JMapViewer

Location:
applications/viewer/jmapviewer
Files:
10 added
4 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer

    • Property svn:ignore
      •  

        old new  
        99javadoc
        1010spotbugs-jmapviewer.xml
         11report
         12bintest
  • applications/viewer/jmapviewer/.classpath

    r32677 r34669  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
     4        <classpathentry kind="src" output="bintest" path="test">
     5                <attributes>
     6                        <attribute name="test" value="true"/>
     7                </attributes>
     8        </classpathentry>
    49        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
     10        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    511        <classpathentry kind="output" path="bin"/>
    612</classpath>
  • applications/viewer/jmapviewer/build.xml

    r34124 r34669  
    11<?xml version="1.0" encoding="UTF-8" standalone="no"?>
    2 <project default="all" name="jmapviewer" xmlns:if="ant:if" xmlns:unless="ant:unless">
     2<project default="all" name="jmapviewer" xmlns:jacoco="antlib:org.jacoco.ant" xmlns:if="ant:if" xmlns:unless="ant:unless">
    33
    4         <property name="java.lang.version" value="1.8" />
    5         <!-- For Java9-specific stuff -->
    6         <condition property="isJava9">
    7                 <matches string="${ant.java.version}" pattern="(1.)?(9|1[0-9])" />
    8         </condition>
     4    <property name="java.lang.version" value="1.8" />
     5    <dirname property="base.dir" file="${ant.file.jmapviewer}"/>
     6    <property name="tools.dir" location="${base.dir}/tools"/>
     7    <property name="jacoco.includes" value="org.openstreetmap.gui.jmapviewer.*" />
     8    <property name="jacoco.inclbootstrapclasses" value="false" />
     9    <property name="jacoco.inclnolocationclasses" value="false" />
     10    <!-- For Java specific stuff by version -->
     11    <condition property="isJava9"><matches string="${ant.java.version}" pattern="(1.)?(9|1[0-9])" /></condition>
     12    <condition property="isJava10"><matches string="${ant.java.version}" pattern="1[0-9]" /></condition>
     13    <condition property="isJava11"><matches string="${ant.java.version}" pattern="1[1-9]" /></condition>
     14    <condition property="isJava12"><matches string="${ant.java.version}" pattern="1[2-9]" /></condition>
     15    <condition property="isJava13"><matches string="${ant.java.version}" pattern="1[3-9]" /></condition>
     16    <!-- Disable jacoco on Java 13+, see https://github.com/jacoco/jacoco/pull/738 -->
     17    <condition property="coverageByDefault">
     18        <not>
     19            <isset property="isJava13"/>
     20        </not>
     21    </condition>
     22    <path id="test.classpath">
     23        <fileset dir="${tools.dir}/testlib">
     24            <include name="**/*.jar"/>
     25        </fileset>
     26        <pathelement location="bin"/>
     27    </path>
    928
    10         <target name="all" depends="clean,build,svn_info,pack,create_run_jar,spotbugs,checkstyle,javadoc,create_release_zip,create_source_release_zip" />
     29    <target name="all" depends="clean,build,test,svn_info,pack,create_run_jar,spotbugs,checkstyle,javadoc,create_release_zip,create_source_release_zip" />
    1130
    12         <target name="clean">
    13                 <mkdir dir="bin" />
    14                 <delete>
    15                         <fileset dir="bin">
    16                                 <include name="**" />
    17                         </fileset>
    18                         <fileset dir="." includes="*.jar"/>
    19                 </delete>
    20         </target>
     31    <target name="clean">
     32        <mkdir dir="bin" />
     33        <mkdir dir="bintest" />
     34        <mkdir dir="javadoc" />
     35        <mkdir dir="report" />
     36        <delete>
     37            <fileset dir="bin">
     38                <include name="**" />
     39            </fileset>
     40            <fileset dir="bintest">
     41                <include name="**" />
     42            </fileset>
     43            <fileset dir="javadoc">
     44                <include name="**" />
     45            </fileset>
     46            <fileset dir="report">
     47                <include name="**" />
     48            </fileset>
     49            <fileset dir="." includes="*.jar,*.exec"/>
     50        </delete>
     51    </target>
    2152
    22         <target name="build">
    23                 <javac srcdir="src" destdir="bin" source="${java.lang.version}" target="${java.lang.version}" debug="true" includeantruntime="false" encoding="UTF-8">
    24                         <include name="org/openstreetmap/gui/jmapviewer/**" />
    25                 </javac>
     53    <target name="build" depends="clean">
     54        <javac srcdir="src" destdir="bin" source="${java.lang.version}" target="${java.lang.version}" debug="true" includeantruntime="false" encoding="UTF-8">
     55            <include name="org/openstreetmap/gui/jmapviewer/**" />
     56        </javac>
    2657
    27                 <copy todir="bin">
    28                         <fileset dir="src">
    29                                 <include name="**/*.png" />
    30                         </fileset>
    31                 </copy>
    32         </target>
     58        <copy todir="bin">
     59            <fileset dir="src">
     60                <include name="**/*.png" />
     61            </fileset>
     62        </copy>
     63    </target>
    3364
    3465    <target name="svn_info" description="Get SVN info for use in JAR/ZIP filenames.">
     
    3970        </exec>
    4071    </target>
    41        
    42         <target name="pack" depends="build">
    43                 <!-- Create the JAR file containing the compiled class files -->
    44                 <jar destfile="JMapViewer.jar" filesetmanifest="mergewithoutmain">
    45                         <fileset dir="bin" includes="**/jmapviewer/**" />
    46                 </jar>
    47                 <!-- Create the JAR file containing the source java files -->
    48                 <jar destfile="JMapViewer_src.jar" filesetmanifest="mergewithoutmain">
    49                         <fileset dir="src" includes="**/jmapviewer/**" />
    50                 </jar>
    51         </target>
    52        
    53         <!-- if you want to build outside of svn, use "ant clean build [pack]" -->
    54        
    55         <target name="create_run_jar" description="Create a JAR file that can be used to execute the JMapViewer demo app. Requires JMapViewer.jar to be present.">
    56                 <jar destfile="JMapViewer_Demo.jar" filesetmanifest="mergewithoutmain">
    57                         <manifest>
    58                                 <attribute name="Main-Class" value="org.openstreetmap.gui.jmapviewer.Demo" />
    59                                 <attribute name="Class-Path" value="JMapViewer.jar" />
    60                         </manifest>
    61                 </jar>
    62         </target>
     72   
     73    <target name="pack" depends="build">
     74        <!-- Create the JAR file containing the compiled class files -->
     75        <jar destfile="JMapViewer.jar" filesetmanifest="mergewithoutmain">
     76            <fileset dir="bin" includes="**/jmapviewer/**" />
     77        </jar>
     78        <!-- Create the JAR file containing the source java files -->
     79        <jar destfile="JMapViewer_src.jar" filesetmanifest="mergewithoutmain">
     80            <fileset dir="src" includes="**/jmapviewer/**" />
     81        </jar>
     82    </target>
     83   
     84    <!-- if you want to build outside of svn, use "ant clean build [pack]" -->
     85   
     86    <target name="create_run_jar" description="Create a JAR file that can be used to execute the JMapViewer demo app. Requires JMapViewer.jar to be present.">
     87        <jar destfile="JMapViewer_Demo.jar" filesetmanifest="mergewithoutmain">
     88            <manifest>
     89                <attribute name="Main-Class" value="org.openstreetmap.gui.jmapviewer.Demo" />
     90                <attribute name="Class-Path" value="JMapViewer.jar" />
     91            </manifest>
     92        </jar>
     93    </target>
    6394
    64         <target name="create_release_zip" description="Create a release zip file containing the binary and source jar files as well as the demo starter">
    65                 <zip basedir="." destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}.zip">
    66                         <include name="JMapViewer*.jar" />
    67                         <include name="Readme.txt" />
    68                         <include name="Gpl.txt" />
    69                 </zip>
    70                 <delete>
    71                         <fileset dir="." includes="JMapViewer*.jar"/>
    72                 </delete>
    73         </target>
    74        
    75         <target name="create_source_release_zip" description="Create a release zip file containing the source files">
    76                 <zip destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}-Source.zip">
    77                         <zipfileset file="Readme.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
    78                         <zipfileset file="build.xml" prefix="jmapviewer-${svnReleaseVersion}"/>
    79                         <zipfileset file="Gpl.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
    80                         <zipfileset dir="src" includes="**/jmapviewer/**" prefix="jmapviewer-${svnReleaseVersion}/src"/>
    81                 </zip>
    82         </target>
     95    <target name="create_release_zip" description="Create a release zip file containing the binary and source jar files as well as the demo starter">
     96        <zip basedir="." destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}.zip">
     97            <include name="JMapViewer*.jar" />
     98            <include name="Readme.txt" />
     99            <include name="Gpl.txt" />
     100        </zip>
     101        <delete>
     102            <fileset dir="." includes="JMapViewer*.jar"/>
     103        </delete>
     104    </target>
     105   
     106    <target name="create_source_release_zip" description="Create a release zip file containing the source files">
     107        <zip destfile="releases/${svnReleaseVersion}/JMapViewer-${svnReleaseVersion}-Source.zip">
     108            <zipfileset file="Readme.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
     109            <zipfileset file="build.xml" prefix="jmapviewer-${svnReleaseVersion}"/>
     110            <zipfileset file="Gpl.txt" prefix="jmapviewer-${svnReleaseVersion}"/>
     111            <zipfileset dir="src" includes="**/jmapviewer/**" prefix="jmapviewer-${svnReleaseVersion}/src"/>
     112        </zip>
     113    </target>
    83114
    84115    <target name="checkstyle">
    85116        <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
    86                 classpath="tools/checkstyle/checkstyle-all.jar"/>
     117            classpath="tools/checkstyle/checkstyle-all.jar"/>
    87118        <checkstyle config="tools/checkstyle/jmapviewer_checks.xml">
    88119            <fileset dir="${basedir}/src" includes="**/*.java" />
     
    93124    <target name="spotbugs" depends="pack">
    94125        <taskdef name="spotbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
    95                 classpath="tools/spotbugs/spotbugs-ant.jar"/>
     126            classpath="tools/spotbugs/spotbugs-ant.jar"/>
    96127        <path id="spotbugs-classpath">
    97128            <fileset dir="tools/spotbugs/">
     
    110141    </target>
    111142
    112         <target name="javadoc">
     143    <target name="javadoc">
    113144        <javadoc destdir="javadoc"
    114145                sourcepath="src"
     
    127158    </target>
    128159
     160    <target name="test" depends="clean, build">
     161        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="${tools.dir}/jacocoant.jar" />
     162        <javac srcdir="test" destdir="bintest"
     163            target="${java.lang.version}" source="${java.lang.version}" debug="on"
     164            includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8">
     165            <compilerarg value="-Xlint:all"/>
     166            <compilerarg value="-Xlint:-serial"/>
     167            <classpath>
     168                <path refid="test.classpath"/>
     169            </classpath>
     170        </javac>
     171        <jacoco:coverage enabled="@{coverage}" includes="${jacoco.includes}"
     172            inclbootstrapclasses="${jacoco.inclbootstrapclasses}" inclnolocationclasses="${jacoco.inclnolocationclasses}">
     173            <junit printsummary="yes" fork="true" forkmode="once">
     174                <jvmarg value="-Dfile.encoding=UTF-8"/>
     175                <classpath>
     176                    <path refid="test.classpath"/>
     177                    <pathelement location="bintest"/>
     178                </classpath>
     179                <formatter type="plain"/>
     180                <formatter type="xml"/>
     181                <batchtest fork="yes" todir="report">
     182                    <fileset dir="bintest" includes="**/*Test.class"/>
     183                </batchtest>
     184            </junit>
     185        </jacoco:coverage>
     186    </target>
     187
    129188</project>
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java

    r33973 r34669  
    8383    /**
    8484     * @return default tile size, for this tile source
    85      * TODO: @since
    8685     */
    8786    int getDefaultTileSize();
Note: See TracChangeset for help on using the changeset viewer.