Changeset 5450


Ignore:
Timestamp:
Mar 17, 2020, 12:34:13 PM (13 months ago)
Author:
Christian Schulte
Message:

o Updated to remove hard-coded project name from test.

See #122

File:
1 edited

Legend:

Unmodified
Added
Removed
  • jomc-tools/trunk/jomc-cli/src/test/java/org/jomc/tools/cli/test/JomcTest.java

    r5277 r5450  
    7979
    8080    /**
     81     * Constant for the name of the system property holding the project name the test is part of.
     82     * @since 1.11.0
     83     */
     84    private static final String PROJECT_NAME_PROPERTY_NAME = "jomc.test.projectName";
     85
     86    /**
    8187     * Test resources to copy to the resources directory.
    8288     */
     
    97103
    98104    /**
     105     * The project name of the instance.
     106     * @since 1.11.0
     107     */
     108    private String projectName;
     109
     110    /**
    99111     * Gets the output directory of instance.
    100112     *
     
    139151    }
    140152
     153    /**
     154     * Gets the project name of instance.
     155     *
     156     * @return The project name of instance.
     157     *
     158     * @see #setProjectName(java.lang.String)
     159     * @since 1.11.0
     160     */
     161    public final String getProjectName()
     162    {
     163        if ( this.projectName == null )
     164        {
     165            this.projectName = System.getProperty( PROJECT_NAME_PROPERTY_NAME );
     166            assertNotNull( "Expected '" + PROJECT_NAME_PROPERTY_NAME + "' system property not found.",
     167                           this.projectName );
     168
     169        }
     170
     171        return this.projectName;
     172    }
     173
     174    /**
     175     * Sets the project name of instance.
     176     *
     177     * @param value The new project name of instance or {@code null}.
     178     *
     179     * @see #getProjectName()
     180     * @since 1.11.0
     181     */
     182    public final void setProjectName( final String value )
     183    {
     184        this.projectName = value;
     185    }
     186
    141187    @Test
    142188    public final void testNoArguments() throws Exception
     
    210256            "manage-sources", "-sd", '"' + testSourcesDirectory.getAbsolutePath() + '"', "-df",
    211257            '"' + new File( resourcesDirectory, "jomc.xml" ).getAbsolutePath() + '"', "-mn",
    212             "\"JOMC Tools ⁑ CLI\"", "-D", "-ls", "\r\n", "-idt", "\t"
     258            '"' + this.getProjectName() + '"', "-D", "-ls", "\r\n", "-idt", "\t"
    213259        };
    214260
     
    260306        {
    261307            "commit-classes", "-df", '"' + new File( resourcesDirectory, "jomc.xml" ).getAbsolutePath() + '"', "-cd",
    262             '"' + classesDirectory.getAbsolutePath() + '"', "-mn", "\"JOMC Tools ⁑ CLI\"", "-D"
     308            '"' + classesDirectory.getAbsolutePath() + '"', "-mn", '"' + this.getProjectName() + '"', "-D"
    263309        };
    264310
     
    266312        {
    267313            "commit-classes", "-df", '"' + new File( resourcesDirectory, "jomc.xml" ).getAbsolutePath() + '"', "-cd",
    268             '"' + nonExistentDirectory.getAbsolutePath() + '"', "-mn", "\"JOMC Tools ⁑ CLI\"", "-D"
     314            '"' + nonExistentDirectory.getAbsolutePath() + '"', "-mn", '"' + this.getProjectName() + '"', "-D"
    269315        };
    270316
     
    307353        {
    308354            "commit-classes", "-df", '"' + new File( resourcesDirectory, "jomc.xml" ).getAbsolutePath() + '"', "-cd",
    309             '"' + classesDirectory.getAbsolutePath() + '"', "-mn", "\"JOMC Tools ⁑ CLI\"",
     355            '"' + classesDirectory.getAbsolutePath() + '"', "-mn", '"' + this.getProjectName() + '"',
    310356            "-D", "-stylesheet", '"' + new File( resourcesDirectory, "model-relocations.xsl" ).getAbsolutePath() + '"'
    311357        };
     
    344390            "merge-modules", "-df", '"' + new File( resourcesDirectory, "jomc.xml" ).getAbsolutePath() + '"', "-xs",
    345391            '"' + new File( resourcesDirectory, "model-relocations.xsl" ).getAbsolutePath() + '"', "-mn",
    346             "\"JOMC Tools ⁑ CLI\"", "-d", '"' + targetDocument.getAbsolutePath() + '"', "-D"
     392            '"' + this.getProjectName() + '"', "-d", '"' + targetDocument.getAbsolutePath() + '"', "-D"
    347393        };
    348394
     
    351397            "merge-modules", "-df", '"' + new File( resourcesDirectory, "jomc.xml" ).getAbsolutePath() + '"', "-xs",
    352398            '"' + new File( resourcesDirectory, "model-relocations.xsl" ).getAbsolutePath() + '"', "-mn",
    353             "\"JOMC Tools ⁑ CLI\"", "-d", '"' + targetDocument.getAbsolutePath() + '"', "-minc", "\"JOMC Tools ⁑ CLI\"",
    354             "-D"
     399            '"' + this.getProjectName() + '"', "-d", '"' + targetDocument.getAbsolutePath() + '"', "-minc",
     400            '"' + this.getProjectName() + '"', "-D"
    355401        };
    356402
     
    359405            "merge-modules", "-df", '"' + new File( resourcesDirectory, "jomc.xml" ).getAbsolutePath() + '"', "-xs",
    360406            '"' + new File( resourcesDirectory, "model-relocations.xsl" ).getAbsolutePath() + '"', "-mn",
    361             "\"JOMC Tools ⁑ CLI\"", "-d", '"' + targetDocument.getAbsolutePath() + '"', "-mexc", "\"JOMC Tools ⁑ CLI\"",
     407            '"' + this.getProjectName() + '"', "-d", '"' + targetDocument.getAbsolutePath() + '"', "-mexc",
     408            '"' + this.getProjectName() + '"',
    362409            "-D"
    363410        };
     
    372419            "merge-modules", "-df", '"' + new File( resourcesDirectory, "illegal-module-document.xml" ).
    373420            getAbsolutePath() + '"', "-xs", '"' + new File( resourcesDirectory, "model-relocations.xsl" ).
    374             getAbsolutePath() + '"', "-mn", "\"JOMC Tools ⁑ CLI\"", "-d", '"' + targetDocument.getAbsolutePath() + '"',
    375             "-D"
     421            getAbsolutePath() + '"', "-mn", '"' + this.getProjectName() + '"', "-d",
     422            '"' + targetDocument.getAbsolutePath() + '"', "-D"
    376423        };
    377424
     
    453500        {
    454501            "merge-modlets", "-xs", '"' + new File( resourcesDirectory, "modlet-relocations.xsl" ).
    455             getAbsolutePath() + '"', "-mdn", "\"JOMC Tools ⁑ CLI ⁑ Tests\"", "-d",
     502            getAbsolutePath() + '"', "-mdn", '"' + this.getProjectName() + " ⁑ Tests\"", "-d",
    456503            '"' + targetDocument.getAbsolutePath() + '"', "-cp", "."
    457504        };
     
    460507        {
    461508            "merge-modlets", "-xs", '"' + new File( resourcesDirectory, "modlet-relocations.xsl" ).
    462             getAbsolutePath() + '"', "-mdn", "\"JOMC Tools ⁑ CLI ⁑ Tests\"", "-d",
     509            getAbsolutePath() + '"', "-mdn", '"' + this.getProjectName() + " ⁑ Tests\"", "-d",
    463510            '"' + targetDocument.getAbsolutePath() + '"', "-mdinc", "\"JOMC ⁑ Model\"", "-cp", "."
    464511        };
     
    467514        {
    468515            "merge-modlets", "-xs", '"' + new File( resourcesDirectory, "modlet-relocations.xsl" ).
    469             getAbsolutePath() + '"', "-mdn", "\"JOMC Tools ⁑ CLI ⁑ Tests\"", "-d",
     516            getAbsolutePath() + '"', "-mdn", '"' + this.getProjectName() + " ⁑ Tests\"", "-d",
    470517            '"' + targetDocument.getAbsolutePath() + '"',
    471518            "-mdexc", "\"JOMC ⁑ Model" + File.pathSeparatorChar + "JOMC Tools ⁑ Modlet" + File.pathSeparatorChar
     
    485532
    486533        assertNotNull( merged );
    487         assertEquals( "JOMC Tools ⁑ CLI ⁑ Tests", merged.getName() );
     534        assertEquals( this.getProjectName() + " ⁑ Tests", merged.getName() );
    488535        assertNotNull( merged.getSchemas() );
    489536        assertNotNull( merged.getServices() );
     
    500547
    501548        assertNotNull( merged );
    502         assertEquals( "JOMC Tools ⁑ CLI ⁑ Tests", merged.getName() );
     549        assertEquals( this.getProjectName() + " ⁑ Tests", merged.getName() );
    503550        assertNotNull( merged.getSchemas() );
    504551        assertNotNull( merged.getServices() );
     
    514561
    515562        assertNotNull( merged );
    516         assertEquals( "JOMC Tools ⁑ CLI ⁑ Tests", merged.getName() );
     563        assertEquals( this.getProjectName() + " ⁑ Tests", merged.getName() );
    517564        assertNull( merged.getSchemas() );
    518565        assertNull( merged.getServices() );
     
    544591        {
    545592            "show-model", "-cp", '"' + classesDirectory.getAbsolutePath() + '"', "-spec",
    546             "\"JOMC Tools ⁑ CLI ⁑ Command\""
     593            '"' + this.getProjectName() + " ⁑ Command\""
    547594        };
    548595
     
    550597        {
    551598            "show-model", "-cp", '"' + classesDirectory.getAbsolutePath() + '"', "-spec",
    552             "\"JOMC Tools ⁑ CLI ⁑ Command\"", "-d", '"' + targetDocument.getAbsolutePath() + '"'
     599            '"' + this.getProjectName() + " ⁑ Command\"", "-d", '"' + targetDocument.getAbsolutePath() + '"'
    553600        };
    554601
     
    556603        {
    557604            "show-model", "-cp", '"' + classesDirectory.getAbsolutePath() + '"',
    558             "-impl", "\"JOMC Tools ⁑ CLI ⁑ Default show-model Command\""
     605            "-impl", '"' + this.getProjectName() + " ⁑ Default show-model Command\""
    559606        };
    560607
     
    562609        {
    563610            "show-model", "-cp", '"' + classesDirectory.getAbsolutePath() + '"',
    564             "-impl", "\"JOMC Tools ⁑ CLI ⁑ Default show-model Command\"",
     611            "-impl", '"' + this.getProjectName() + " ⁑ Default show-model Command\"",
    565612            "-d", '"' + targetDocument.getAbsolutePath() + '"'
    566613        };
     
    569616        {
    570617            "show-model", "-cp", '"' + classesDirectory.getAbsolutePath() + '"', "-spec",
    571             "\"JOMC Tools ⁑ CLI ⁑ Command\"", "-impl", "\"JOMC Tools ⁑ CLI ⁑ Default show-model Command\""
     618            '"' + this.getProjectName() + " ⁑ Command\"", "-impl",
     619            '"' + this.getProjectName() + " ⁑ Default show-model Command\""
    572620        };
    573621
     
    575623        {
    576624            "show-model", "-cp", '"' + classesDirectory.getAbsolutePath() + '"',
    577             "-spec", "\"JOMC Tools ⁑ CLI ⁑ Command\"",
    578             "-impl", "\"JOMC Tools ⁑ CLI ⁑ Default show-model Command\"", "-d",
     625            "-spec", '"' + this.getProjectName() + " ⁑ Command\"",
     626            "-impl", '"' + this.getProjectName() + " ⁑ Default show-model Command\"", "-d",
    579627            '"' + targetDocument.getAbsolutePath() + '"'
    580628        };
Note: See TracChangeset for help on using the changeset viewer.