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/06 20:14:00 UTC
cvs commit: maven-components/maven-model-tools/src/test/org/apache/maven/model DefaultModelMarshallingTest.java DefaultModelMarshallingTest.xml
jvanzyl 2003/12/06 11:14:00
Modified: maven-model-tools maven-model-tools.iws
maven-model-tools/src/java/org/apache/maven/model
DefaultModelMarshaller.java
DefaultModelUnmarshaller.java ModelMarshaller.java
maven-model-tools/src/test/org/apache/maven/model
DefaultModelMarshallingTest.java
DefaultModelMarshallingTest.xml
Log:
o got the coverage up to 80%
o work now to get the rest
Revision Changes Path
1.5 +24 -12 maven-components/maven-model-tools/maven-model-tools.iws
Index: maven-model-tools.iws
===================================================================
RCS file: /home/cvs/maven-components/maven-model-tools/maven-model-tools.iws,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- maven-model-tools.iws 6 Dec 2003 18:07:12 -0000 1.4
+++ maven-model-tools.iws 6 Dec 2003 19:14:00 -0000 1.5
@@ -2,37 +2,49 @@
<project version="3" relativePaths="false">
<component name="FileEditorManager">
<history>
- <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/DefaultModelMarshaller.java" line="470" column="16" vertical-scroll-proportion="0.794964" horizontal-scroll-proportion="0.114832535">
+ <source-position-entry url="file://$PROJECT_DIR$/project.xml" line="68" column="0" vertical-scroll-proportion="0.8645084" horizontal-scroll-proportion="0.0" />
+ <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/ModelMarshaller.java" line="20" column="55" vertical-scroll-proportion="0.28057554" horizontal-scroll-proportion="0.391924" />
+ <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/DefaultModelMarshaller.java" line="291" column="0" vertical-scroll-proportion="0.28657076" horizontal-scroll-proportion="0.0">
<folding>
<element signature="imports" expanded="true" />
</folding>
</source-position-entry>
- <source-position-entry url="file://$PROJECT_DIR$/project.xml" line="68" column="0" vertical-scroll-proportion="0.8645084" horizontal-scroll-proportion="0.0" />
- <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.java" line="20" column="17" vertical-scroll-proportion="-1.7458034" horizontal-scroll-proportion="0.12200957">
+ <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.xml" line="9" column="0" vertical-scroll-proportion="0.14028777" horizontal-scroll-proportion="0.0" />
+ <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.java" line="67" column="38" vertical-scroll-proportion="0.23381294" horizontal-scroll-proportion="0.27272728">
+ <folding>
+ <element signature="imports" expanded="true" />
+ </folding>
+ </source-position-entry>
+ <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/DefaultModelUnmarshaller.java" line="241" column="41" vertical-scroll-proportion="0.45443645" horizontal-scroll-proportion="0.2942584">
<folding>
<element signature="imports" expanded="true" />
</folding>
</source-position-entry>
- <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.xml" line="0" column="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0" />
</history>
<open-files>
- <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/DefaultModelMarshaller.java" line="470" column="16" vertical-scroll-proportion="0.794964" horizontal-scroll-proportion="0.114832535">
+ <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/DefaultModelMarshaller.java" line="291" column="0" vertical-scroll-proportion="0.28657076" horizontal-scroll-proportion="0.0">
<folding>
<element signature="imports" expanded="true" />
</folding>
</source-position-entry>
+ <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/DefaultModelUnmarshaller.java" line="241" column="41" vertical-scroll-proportion="0.45443645" horizontal-scroll-proportion="0.2942584" selected="true">
+ <folding>
+ <element signature="imports" expanded="true" />
+ </folding>
+ </source-position-entry>
+ <source-position-entry url="file://$PROJECT_DIR$/src/java/org/apache/maven/model/ModelMarshaller.java" line="20" column="55" vertical-scroll-proportion="0.28057554" horizontal-scroll-proportion="0.391924" />
<source-position-entry url="file://$PROJECT_DIR$/project.xml" line="68" column="0" vertical-scroll-proportion="0.8645084" horizontal-scroll-proportion="0.0" />
- <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.java" line="20" column="17" vertical-scroll-proportion="-1.7458034" horizontal-scroll-proportion="0.12200957">
+ <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.java" line="67" column="38" vertical-scroll-proportion="0.23381294" horizontal-scroll-proportion="0.27272728">
<folding>
<element signature="imports" expanded="true" />
</folding>
</source-position-entry>
- <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.xml" line="0" column="0" vertical-scroll-proportion="0.0" horizontal-scroll-proportion="0.0" selected="true" />
+ <source-position-entry url="file://$PROJECT_DIR$/src/test/org/apache/maven/model/DefaultModelMarshallingTest.xml" line="9" column="0" vertical-scroll-proportion="0.14028777" horizontal-scroll-proportion="0.0" />
</open-files>
</component>
<component name="ToolWindowManager">
<frame x="-4" y="3" width="1288" height="1025" extended-state="1" />
- <editor active="false" />
+ <editor active="true" />
<layout>
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="4" />
@@ -40,7 +52,7 @@
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="2" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33" order="6" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="sliding" type="sliding" visible="false" weight="0.4" order="0" />
- <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.24959743" order="0" />
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="true" weight="0.24959743" order="0" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.4" order="3" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.25" order="1" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="docked" type="docked" visible="false" weight="0.33039647" order="1" />
@@ -181,9 +193,9 @@
</Update>
<Commit>
<option name="NON_RECURSIVE" value="false" />
- <option name="REVISION_TAG" />
- <option name="LOG_MESSAGE" />
- <option name="ADDITIONAL_OPTIONS" />
+ <option name="REVISION_TAG" value="" />
+ <option name="LOG_MESSAGE" value="o put model xml string in the form the marshaller spits out so i can compare easily." />
+ <option name="ADDITIONAL_OPTIONS" value="" />
</Commit>
<Diff>
<option name="REVISION_TAG" value="HEAD" />
1.2 +47 -73 maven-components/maven-model-tools/src/java/org/apache/maven/model/DefaultModelMarshaller.java
Index: DefaultModelMarshaller.java
===================================================================
RCS file: /home/cvs/maven-components/maven-model-tools/src/java/org/apache/maven/model/DefaultModelMarshaller.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultModelMarshaller.java 1 Sep 2003 16:06:17 -0000 1.1
+++ DefaultModelMarshaller.java 6 Dec 2003 19:14:00 -0000 1.2
@@ -1,16 +1,5 @@
package org.apache.maven.model;
-import org.apache.maven.model.Branch;
-import org.apache.maven.model.Build;
-import org.apache.maven.model.Contributor;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Developer;
-import org.apache.maven.model.License;
-import org.apache.maven.model.MailingList;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Resource;
-import org.apache.maven.model.SourceModification;
-import org.apache.maven.model.Version;
import org.xmlpull.v1.XmlPullParserFactory;
import org.xmlpull.v1.XmlSerializer;
@@ -61,87 +50,87 @@
serializer = factory.newSerializer();
}
- /**
- * Description of the Method
- */
- private void initialize( Writer writer )
+ private void initialize( Writer writer, String indentation, String lineSeparator )
throws IOException
{
- serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", INDENTATION );
- serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", LS );
+ serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", indentation );
+ serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", lineSeparator );
serializer.setOutput( writer );
//serializer.startDocument(ENCODING, STANDALONE);
}
- /**
- * Description of the Method
- */
- public void marshall( Writer pom, Model project )
+ public void marshall( Writer writer, Model model )
throws Exception
{
- initialize( pom );
+ marshall( writer, model, INDENTATION, LS );
+ }
+
+ public void marshall( Writer writer, Model model, String indentation, String lineSeparator )
+ throws Exception
+ {
+ initialize( writer, indentation, lineSeparator );
- serializer.startTag( NAMESPACE, "project" );
+ serializer.startTag( NAMESPACE, "model" );
- marshallString( project.getExtend(), "extend" );
+ marshallString( model.getExtend(), "extend" );
- marshallString( project.getPomVersion(), "pomVersion" );
+ marshallString( model.getPomVersion(), "pomVersion" );
- marshallRequiredString( project.getName(), "name" );
+ marshallRequiredString( model.getName(), "name" );
- marshallString( project.getGroupId(), "groupId" );
+ marshallString( model.getGroupId(), "groupId" );
- marshallString( project.getArtifactId(), "artifactId" );
+ marshallString( model.getArtifactId(), "artifactId" );
- marshallRequiredString( project.getCurrentVersion(), "currentVersion" );
+ marshallRequiredString( model.getCurrentVersion(), "currentVersion" );
- marshallOrganization( project );
+ marshallOrganization( model );
- marshallString( project.getInceptionYear(), "inceptionYear" );
+ marshallString( model.getInceptionYear(), "inceptionYear" );
- marshallString( project.getPackage(), "package" );
+ marshallString( model.getPackage(), "package" );
- marshallString( project.getLogo(), "logo" );
+ marshallString( model.getLogo(), "logo" );
- marshallString( project.getGumpRepositoryId(), "gumpRepositoryId" );
+ marshallString( model.getGumpRepositoryId(), "gumpRepositoryId" );
- marshallString( project.getDescription(), "description" );
+ marshallString( model.getDescription(), "description" );
- marshallRequiredString( project.getShortDescription(), "shortDescription" );
+ marshallRequiredString( model.getShortDescription(), "shortDescription" );
- marshallString( project.getUrl(), "url" );
+ marshallString( model.getUrl(), "url" );
- marshallString( project.getIssueTrackingUrl(), "issueTrackingUrl" );
+ marshallString( model.getIssueTrackingUrl(), "issueTrackingUrl" );
- marshallString( project.getSiteAddress(), "siteAddress" );
+ marshallString( model.getSiteAddress(), "siteAddress" );
- marshallString( project.getSiteDirectory(), "siteDirectory" );
+ marshallString( model.getSiteDirectory(), "siteDirectory" );
- marshallString( project.getDistributionDirectory(), "distributionDirectory" );
+ marshallString( model.getDistributionDirectory(), "distributionDirectory" );
- marshallRepository( project );
+ marshallRepository( model );
- marshallVersions( project );
+ marshallVersions( model );
- marshallBranches( project );
+ marshallBranches( model );
- marshallMailingLists( project );
+ marshallMailingLists( model );
- marshallDevelopers( project );
+ marshallDevelopers( model );
- marshallContributors( project );
+ marshallContributors( model );
- marshallLicenses( project );
+ marshallLicenses( model );
- marshallDependencies( project );
+ marshallDependencies( model );
- marshallBuild( project );
+ marshallBuild( model );
- marshallReports( project );
+ marshallReports( model );
- marshallProperties( project.getProperties() );
+ marshallProperties( model.getProperties() );
- serializer.endTag( NAMESPACE, "project" );
+ serializer.endTag( NAMESPACE, "model" );
serializer.endDocument();
}
@@ -303,26 +292,6 @@
/**
* Description of the Method
*/
- private void marshallContactDetails( Contributor contributor )
- throws IOException
- {
- serializer.startTag( NAMESPACE, "contactDetails" );
-
- marshallRequiredString( contributor.getEmail(), "email" );
- marshallString( contributor.getOrganization(), "organization" );
-
- marshallRoles( contributor.getRoles() );
-
- marshallString( contributor.getUrl(), "url" );
-
- //timezone skipped
-
- serializer.endTag( NAMESPACE, "contactDetails" );
- }
-
- /**
- * Description of the Method
- */
private void marshallRoles( SortedSet roles )
throws IOException
{
@@ -648,4 +617,9 @@
{
return property == null || property.trim().equals( "" );
}
+
+ // ----------------------------------------------------------------------
+ // Lifecylce Management
+ // ----------------------------------------------------------------------
+
}
1.3 +64 -1 maven-components/maven-model-tools/src/java/org/apache/maven/model/DefaultModelUnmarshaller.java
Index: DefaultModelUnmarshaller.java
===================================================================
RCS file: /home/cvs/maven-components/maven-model-tools/src/java/org/apache/maven/model/DefaultModelUnmarshaller.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultModelUnmarshaller.java 9 Oct 2003 10:42:54 -0000 1.2
+++ DefaultModelUnmarshaller.java 6 Dec 2003 19:14:00 -0000 1.3
@@ -197,6 +197,69 @@
}
}
}
+ else if ( parser.getName().equals( "licenses" ) )
+ {
+ while ( parser.nextTag() == XmlPullParser.START_TAG )
+ {
+ if ( parser.getName().equals( "license" ) )
+ {
+ License license = new License();
+ project.addLicense( license );
+
+ while ( parser.nextTag() == XmlPullParser.START_TAG )
+ {
+ if ( parser.getName().equals( "url" ) )
+ {
+ String url = parser.nextText();
+ license.setUrl( url );
+ }
+ else if ( parser.getName().equals( "name" ) )
+ {
+ license.setName( parser.nextText() );
+ }
+ else if ( parser.getName().equals( "distribution" ) )
+ {
+ license.setDistribution( parser.nextText() );
+ }
+ else
+ {
+ parser.nextText();
+ }
+ }
+ }
+ else
+ {
+ parser.nextText();
+ }
+ }
+ }
+ else if ( parser.getName().equals( "branches" ) )
+ {
+ while ( parser.nextTag() == XmlPullParser.START_TAG )
+ {
+ if ( parser.getName().equals( "branch" ) )
+ {
+ Branch branch = new Branch();
+ project.addBranch( branch );
+
+ while ( parser.nextTag() == XmlPullParser.START_TAG )
+ {
+ if ( parser.getName().equals( "tag" ) )
+ {
+ branch.setTag( parser.nextText() );
+ }
+ else
+ {
+ parser.nextText();
+ }
+ }
+ }
+ else
+ {
+ parser.nextText();
+ }
+ }
+ }
else if ( parser.getName().equals( "mailingLists" ) )
{
while ( parser.nextTag() == XmlPullParser.START_TAG )
1.5 +4 -1 maven-components/maven-model-tools/src/java/org/apache/maven/model/ModelMarshaller.java
Index: ModelMarshaller.java
===================================================================
RCS file: /home/cvs/maven-components/maven-model-tools/src/java/org/apache/maven/model/ModelMarshaller.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ModelMarshaller.java 17 Oct 2003 04:04:19 -0000 1.4
+++ ModelMarshaller.java 6 Dec 2003 19:14:00 -0000 1.5
@@ -17,4 +17,7 @@
void marshall( Writer writer, Model project )
throws Exception;
+
+ void marshall( Writer writer, Model project, String indentation, String lineSeparator )
+ throws Exception;
}
1.3 +29 -0 maven-components/maven-model-tools/src/test/org/apache/maven/model/DefaultModelMarshallingTest.java
Index: DefaultModelMarshallingTest.java
===================================================================
RCS file: /home/cvs/maven-components/maven-model-tools/src/test/org/apache/maven/model/DefaultModelMarshallingTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultModelMarshallingTest.java 6 Dec 2003 18:22:54 -0000 1.2
+++ DefaultModelMarshallingTest.java 6 Dec 2003 19:14:00 -0000 1.3
@@ -3,6 +3,7 @@
import org.codehaus.plexus.PlexusTestCase;
import java.io.StringReader;
+import java.io.StringWriter;
public class DefaultModelMarshallingTest
extends PlexusTestCase
@@ -34,11 +35,19 @@
" <siteAddress>maven.apache.org</siteAddress>" +
" <siteDirectory>/www/maven.apache.org/</siteDirectory>" +
" <distributionDirectory>/www/maven.apache.org/builds/</distributionDirectory>" +
+ " <logo>project-logo</logo>" +
" <organization>" +
" <name>Apache Software Foundation</name>" +
" <url>http://apache.org/</url>" +
" <logo>/images/jakarta-logo-blue.gif</logo>" +
" </organization>" +
+ " <licenses> "+
+ " <license>"+
+ " <name>lic-name</name>"+
+ " <url>lic-url</url>"+
+ " <distribution>lic-distribution</distribution>"+
+ " </license>"+
+ " </licenses>"+
" <repository>" +
" <connection>anon-connection</connection>" +
" <developerConnection>developer-connection</developerConnection>" +
@@ -51,6 +60,11 @@
" <tag>MAVEN_1_0_B1</tag>" +
" </version>" +
" </versions>" +
+ " <branches>" +
+ " <branch>" +
+ " <tag>MAVEN_1_0_B1</tag>" +
+ " </branch>" +
+ " </branches>" +
" <mailingLists>" +
" <mailingList>" +
" <name>Maven User List</name>" +
@@ -146,6 +160,21 @@
model = modelUnmarshaller.parse( new StringReader( modelXml ) );
+ checkModel( model );
+
+ StringWriter writer = new StringWriter();
+
+ modelMarshaller.marshall( writer, model, " ", "" );
+
+ writer.close();
+
+ model = modelUnmarshaller.parse( new StringReader( writer.toString() ) );
+
+ checkModel( model );
+ }
+
+ private void checkModel( Model model )
+ {
// ----------------------------------------------------------------------
// Top-level elements
// ----------------------------------------------------------------------
1.2 +5 -0 maven-components/maven-model-tools/src/test/org/apache/maven/model/DefaultModelMarshallingTest.xml
Index: DefaultModelMarshallingTest.xml
===================================================================
RCS file: /home/cvs/maven-components/maven-model-tools/src/test/org/apache/maven/model/DefaultModelMarshallingTest.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultModelMarshallingTest.xml 6 Dec 2003 18:07:12 -0000 1.1
+++ DefaultModelMarshallingTest.xml 6 Dec 2003 19:14:00 -0000 1.2
@@ -5,5 +5,10 @@
<implementation>org.apache.maven.model.DefaultModelUnmarshaller</implementation>
<configuration/>
</component>
+ <component>
+ <role>org.apache.maven.model.ModelMarshaller</role>
+ <implementation>org.apache.maven.model.DefaultModelMarshaller</implementation>
+ <configuration/>
+ </component>
</components>
</configuration>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org