You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by jv...@apache.org on 2003/12/08 23:14:57 UTC

cvs commit: maven-components/maven-project/src/test/org/apache/maven/project child-with-bogus-parent.xml DefaultProjectBuilderTest.java fully-populated-child.xml project.xml

jvanzyl     2003/12/08 14:14:57

  Modified:    maven-project/src/java/org/apache/maven/project
                        DefaultProjectBuilder.java Project.java
               maven-project/src/test/org/apache/maven/project
                        DefaultProjectBuilderTest.java
                        fully-populated-child.xml project.xml
  Added:       maven-project/src/test/org/apache/maven/project
                        child-with-bogus-parent.xml
  Log:
  o adding more tests and have intentially left a failing test case so
    i remember where i am.
  
    test failure occurs when the project is manipulated directly where a
    value is set which is delegated to the model but values are
    retrieved from the interpolated model. So we can either interpolate
    on the fly or push the set value into the underlying model and
    interpolate the value and insert that into the stored interpolated
    model. Dynamic approach is probably the better of the two approaches
    but I'm going to leave it for now.
  
  Revision  Changes    Path
  1.15      +3 -18     maven-components/maven-project/src/java/org/apache/maven/project/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-project/src/java/org/apache/maven/project/DefaultProjectBuilder.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DefaultProjectBuilder.java	8 Dec 2003 21:23:48 -0000	1.14
  +++ DefaultProjectBuilder.java	8 Dec 2003 22:14:57 -0000	1.15
  @@ -93,18 +93,6 @@
   
           reader.close();
   
  -
  -        // We do not want to do POM interpolation in properties files but maven.final.name is
  -        // baked into the driver.properties file. So we'll leave its default value but we will
  -        // place the real value in here because we are not interpolating the POM into properties.
  -        String mavenFinalName = (String) properties.get( "maven.final.name" );
  -
  -        if ( mavenFinalName != null && mavenFinalName.indexOf( "${" ) >= 0 )
  -        {
  -            model.getId();
  -            properties.put( "maven.final.name", model.getArtifactId() + "-" + model.getVersion() );
  -        }
  -
           // 3)
           String modelToExtend = model.getExtend();
   
  @@ -120,10 +108,7 @@
               {
                   parent = build( parentModel );
   
  -                if ( parent != null )
  -                {
  -                    parentPoms.put( parentModel.getCanonicalPath(), parent );
  -                }
  +                parentPoms.put( parentModel.getCanonicalPath(), parent );
   
                   project.setParent( parent );
               }
  @@ -390,7 +375,7 @@
        * @param file Propertie file to load.
        * @return The loaded Properties.
        */
  -    public static Properties loadProperties( File file )
  +    public Properties loadProperties( File file )
       {
           try
           {
  @@ -410,7 +395,7 @@
        * @param is InputStream from which load properties.
        * @return The loaded Properties.
        */
  -    public static Properties loadProperties( InputStream is )
  +    public Properties loadProperties( InputStream is )
       {
           try
           {
  
  
  
  1.12      +9 -9      maven-components/maven-project/src/java/org/apache/maven/project/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-project/src/java/org/apache/maven/project/Project.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Project.java	8 Dec 2003 21:23:48 -0000	1.11
  +++ Project.java	8 Dec 2003 22:14:57 -0000	1.12
  @@ -248,12 +248,12 @@
       // Delegate to the model
       // ----------------------------------------------------------------------
   
  -    public void setPomVersion( String pomVersion )
  +    public void setModelVersion( String pomVersion )
       {
           getModel().setModelVersion( pomVersion );
       }
   
  -    public String getPomVersion()
  +    public String getModelVersion()
       {
           return getInterpolatedModel().getModelVersion();
       }
  @@ -293,9 +293,14 @@
           return getInterpolatedModel().getName();
       }
   
  -    public void setCurrentVersion( String currentVersion )
  +    public void setVersion( String version )
       {
  -        getModel().setVersion( currentVersion );
  +        getModel().setVersion( version );
  +    }
  +
  +    public String getVersion()
  +    {
  +        return getInterpolatedModel().getVersion();
       }
   
       public void setInceptionYear( String inceptionYear )
  @@ -366,11 +371,6 @@
       public String getDistributionDirectory()
       {
           return getInterpolatedModel().getDistributionDirectory();
  -    }
  -
  -    public String getVersion()
  -    {
  -        return getInterpolatedModel().getVersion();
       }
   
       public void setShortDescription( String shortDescription )
  
  
  
  1.9       +50 -4     maven-components/maven-project/src/test/org/apache/maven/project/DefaultProjectBuilderTest.java
  
  Index: DefaultProjectBuilderTest.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-project/src/test/org/apache/maven/project/DefaultProjectBuilderTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultProjectBuilderTest.java	8 Dec 2003 21:23:48 -0000	1.8
  +++ DefaultProjectBuilderTest.java	8 Dec 2003 22:14:57 -0000	1.9
  @@ -48,13 +48,19 @@
       {
           File f = new File( basedir, "src/test/org/apache/maven/project/project.xml" );
   
  -        assertTrue( "Test project.xml file doesn't exist!", f.exists() );
  +        assertTrue( "Test file project.xml file doesn't exist!", f.exists() );
   
           Project project = projectBuilder.build( f );
   
           testModelMapping( project.getModel() );
   
           assertEquals( "foo", project.getProperty( "maven.final.name" ) );
  +
  +        assertNotNull( project.getModelSource() );
  +
  +        project.setModelVersion( "4" );
  +
  +        assertEquals( "4", project.getModelVersion() );
       }
   
       public void testModelInheritanceWhereChildInheritsEverything()
  @@ -62,7 +68,7 @@
       {
           File f = new File( basedir, "src/test/org/apache/maven/project/child.xml" );
   
  -        assertTrue( "Test child.xml file doesn't exist!", f.exists() );
  +        assertTrue( "Test file child.xml file doesn't exist!", f.exists() );
   
           Project project = projectBuilder.build( f );
   
  @@ -71,6 +77,8 @@
           testModelMapping( project.getModel() );
   
           testProjectFieldRetrieval( project );
  +
  +        assertNotNull( project.getParent() );
       }
   
       public void testModelInheritanceWhereChildInheritsNothing()
  @@ -78,7 +86,7 @@
       {
           File f = new File( basedir, "src/test/org/apache/maven/project/fully-populated-child.xml" );
   
  -        assertTrue( "Test fully-populated-child.xml file doesn't exist!", f.exists() );
  +        assertTrue( "Test file fully-populated-child.xml file doesn't exist!", f.exists() );
   
           Project project = projectBuilder.build( f );
   
  @@ -89,6 +97,44 @@
           testProjectFieldRetrieval( project );
       }
   
  +    public void testModelInheritanceWhereSpecifiedParentIsBogus()
  +        //throws Exception
  +    {
  +        File f = new File( basedir, "src/test/org/apache/maven/project/child-with-bogus-parent.xml" );
  +
  +        assertTrue( "Test file child-with-bogus-parent.xml file doesn't exist!", f.exists() );
  +
  +        try
  +        {
  +            projectBuilder.build( f );
  +
  +            fail( "Exception should be thrown because parent model doesn't exist." );
  +        }
  +        catch ( Exception e )
  +        {
  +            // do nothing.
  +        }
  +    }
  +
  +    public void testMalformedModel()
  +        throws Exception
  +    {
  +        File f = new File( basedir, "src/test/org/apache/maven/project/bad-project.xml" );
  +
  +        assertTrue( "Test file bad-project.xml file doesn't exist!", f.exists() );
  +
  +        try
  +        {
  +            projectBuilder.build( f );
  +
  +            fail( "Exception should be caught." );
  +        }
  +        catch ( Exception e )
  +        {
  +            // do nothing.
  +        }
  +    }
  +
       public void testModelMapping( Model model )
           throws Exception
       {
  @@ -272,7 +318,7 @@
           // Top-level elements
           // ----------------------------------------------------------------------
   
  -        assertEquals( "3", project.getPomVersion() );
  +        assertEquals( "3", project.getModelVersion() );
   
           assertEquals( "maven", project.getGroupId() );
   
  
  
  
  1.2       +6 -0      maven-components/maven-project/src/test/org/apache/maven/project/fully-populated-child.xml
  
  Index: fully-populated-child.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-project/src/test/org/apache/maven/project/fully-populated-child.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- fully-populated-child.xml	8 Dec 2003 21:23:48 -0000	1.1
  +++ fully-populated-child.xml	8 Dec 2003 22:14:57 -0000	1.2
  @@ -37,6 +37,12 @@
       </version>
     </versions>
   
  +  <branches>
  +    <branch>
  +      <tag>tag</tag>
  +    </branch>
  +  </branches>
  +
     <mailingLists>
       <mailingList>
         <name>Maven User List</name>
  
  
  
  1.3       +6 -0      maven-components/maven-project/src/test/org/apache/maven/project/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-project/src/test/org/apache/maven/project/project.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.xml	8 Dec 2003 05:09:11 -0000	1.2
  +++ project.xml	8 Dec 2003 22:14:57 -0000	1.3
  @@ -36,6 +36,12 @@
       </version>
     </versions>
   
  +  <branches>
  +    <branch>
  +      <tag>tag</tag>
  +    </branch>
  +  </branches>
  +
     <mailingLists>
       <mailingList>
         <name>Maven User List</name>
  
  
  
  1.1                  maven-components/maven-project/src/test/org/apache/maven/project/child-with-bogus-parent.xml
  
  Index: child-with-bogus-parent.xml
  ===================================================================
  <project>
    <extend>${basedir}/bogus.xml</extend>
  </project>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org