You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/07/28 10:11:22 UTC

svn commit: r798439 - in /maven/plugins/trunk/maven-eclipse-plugin/src: main/java/org/apache/maven/plugin/eclipse/LinkedResource.java test/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriterTest.java

Author: bentmann
Date: Tue Jul 28 08:11:22 2009
New Revision: 798439

URL: http://svn.apache.org/viewvc?rev=798439&view=rev
Log:
o Set svn:eol-style=native

Modified:
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java   (contents, props changed)
    maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriterTest.java   (contents, props changed)

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java?rev=798439&r1=798438&r2=798439&view=diff
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java Tue Jul 28 08:11:22 2009
@@ -1,154 +1,154 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.maven.plugin.eclipse;
-
-import org.codehaus.plexus.util.xml.XMLWriter;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-
-/**
- * Represents a LinkedResources section in the <code>.project</code> file.
- * 
- * @author <a href="mailto:ashoknanw@gmail.com">Ashokkumar Sankaran</a>
- */
-public class LinkedResource
-{
-    /** Resource name */
-    private String name;
-
-    /** Type */
-    private String type;
-
-    /** Resource location */
-    private String location;
-
-    public String getName()
-    {
-        return name;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-
-    public String getType()
-    {
-        return type;
-    }
-
-    public void setType( String type )
-    {
-        this.type = type;
-    }
-
-    public String getLocation()
-    {
-        return location;
-    }
-
-    public void setLocation( String location )
-    {
-        this.location = location;
-    }
-
-    /**
-     * Default constructor
-     */
-    public LinkedResource()
-    {
-        super();
-    }
-
-    /**
-     * Creates a LinkedResource from a DOM subtree
-     * <p>
-     * The subtree must represent a &lt;linkedResources&gt; section from an Eclipse .project file
-     * 
-     * @param node DOM node
-     */
-    public LinkedResource( Xpp3Dom node )
-    {
-        Xpp3Dom nameNode = node.getChild( "name" );
-
-        if ( nameNode == null )
-        {
-            throw new IllegalArgumentException( "No name node." );
-        }
-
-        name = nameNode.getValue();
-
-        Xpp3Dom typeNode = node.getChild( "type" );
-
-        if ( typeNode == null )
-        {
-            throw new IllegalArgumentException( "No type node." );
-        }
-
-        type = typeNode.getValue();
-
-        Xpp3Dom locationNode = node.getChild( "location" );
-
-        if ( locationNode == null )
-        {
-            throw new IllegalArgumentException( "No location node." );
-        }
-
-        location = locationNode.getValue();
-    }
-
-    public void print( XMLWriter writer )
-    {
-        writer.startElement( "link" );
-
-        writer.startElement( "name" );
-        writer.writeText( name );
-        writer.endElement(); // name
-
-        writer.startElement( "type" );
-        writer.writeText( type );
-        writer.endElement(); // type
-
-        writer.startElement( "location" );
-        writer.writeText( location );
-        writer.endElement(); // location
-        writer.endElement();// link
-    }
-
-    public boolean equals( Object obj )
-    {
-        if ( obj instanceof LinkedResource )
-        {
-            LinkedResource b = (LinkedResource) obj;
-
-            return name.equals( b.name ) && ( type == null ? b.type == null : type.equals( b.type ) )
-                && ( location == null ? b.location == null : location.equals( b.location ) );
-        }
-        else
-        {
-            return false;
-        }
-    }
-
-    public int hashCode()
-    {
-        return name.hashCode() + ( type == null ? 0 : 13 * type.hashCode() )
-            + ( location == null ? 0 : 17 * location.hashCode() );
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.plugin.eclipse;
+
+import org.codehaus.plexus.util.xml.XMLWriter;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+/**
+ * Represents a LinkedResources section in the <code>.project</code> file.
+ * 
+ * @author <a href="mailto:ashoknanw@gmail.com">Ashokkumar Sankaran</a>
+ */
+public class LinkedResource
+{
+    /** Resource name */
+    private String name;
+
+    /** Type */
+    private String type;
+
+    /** Resource location */
+    private String location;
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    public String getLocation()
+    {
+        return location;
+    }
+
+    public void setLocation( String location )
+    {
+        this.location = location;
+    }
+
+    /**
+     * Default constructor
+     */
+    public LinkedResource()
+    {
+        super();
+    }
+
+    /**
+     * Creates a LinkedResource from a DOM subtree
+     * <p>
+     * The subtree must represent a &lt;linkedResources&gt; section from an Eclipse .project file
+     * 
+     * @param node DOM node
+     */
+    public LinkedResource( Xpp3Dom node )
+    {
+        Xpp3Dom nameNode = node.getChild( "name" );
+
+        if ( nameNode == null )
+        {
+            throw new IllegalArgumentException( "No name node." );
+        }
+
+        name = nameNode.getValue();
+
+        Xpp3Dom typeNode = node.getChild( "type" );
+
+        if ( typeNode == null )
+        {
+            throw new IllegalArgumentException( "No type node." );
+        }
+
+        type = typeNode.getValue();
+
+        Xpp3Dom locationNode = node.getChild( "location" );
+
+        if ( locationNode == null )
+        {
+            throw new IllegalArgumentException( "No location node." );
+        }
+
+        location = locationNode.getValue();
+    }
+
+    public void print( XMLWriter writer )
+    {
+        writer.startElement( "link" );
+
+        writer.startElement( "name" );
+        writer.writeText( name );
+        writer.endElement(); // name
+
+        writer.startElement( "type" );
+        writer.writeText( type );
+        writer.endElement(); // type
+
+        writer.startElement( "location" );
+        writer.writeText( location );
+        writer.endElement(); // location
+        writer.endElement();// link
+    }
+
+    public boolean equals( Object obj )
+    {
+        if ( obj instanceof LinkedResource )
+        {
+            LinkedResource b = (LinkedResource) obj;
+
+            return name.equals( b.name ) && ( type == null ? b.type == null : type.equals( b.type ) )
+                && ( location == null ? b.location == null : location.equals( b.location ) );
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    public int hashCode()
+    {
+        return name.hashCode() + ( type == null ? 0 : 13 * type.hashCode() )
+            + ( location == null ? 0 : 17 * location.hashCode() );
+    }
+}

Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/LinkedResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriterTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriterTest.java?rev=798439&r1=798438&r2=798439&view=diff
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriterTest.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriterTest.java Tue Jul 28 08:11:22 2009
@@ -1,134 +1,134 @@
-package org.apache.maven.plugin.eclipse.writers;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.eclipse.writers.testutils.TestEclipseWriterConfig;
-import org.apache.maven.plugin.logging.SystemStreamLog;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.shared.tools.easymock.TestFileManager;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
-import org.codehaus.plexus.util.xml.XMLWriter;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
-import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-import org.jdom.JDOMException;
-import junit.framework.TestCase;
-
-public class EclipseProjectWriterTest
-    extends TestCase
-{
-    private TestFileManager fileManager = new TestFileManager( "EclipseProjectWriter.unitTest.", "" );
-
-    public EclipseProjectWriterTest( String name )
-    {
-        super( name );
-    }
-
-    protected void setUp()
-        throws Exception
-    {
-
-    }
-
-    protected void tearDown()
-        throws Exception
-    {
-        fileManager.cleanUp();
-    }
-
-    public void testWrite_preservingLinkedResources()
-        throws MojoExecutionException, JDOMException, IOException, XmlPullParserException
-    {
-
-        // create the config and the logger
-        TestEclipseWriterConfig config = new TestEclipseWriterConfig();
-        TestLog log = new TestLog();
-
-        // setup the eclipse project
-        File basedir = fileManager.createTempDir();
-        config.setProjectBaseDir( basedir );
-        config.setEclipseProjectDirectory( basedir );
-        config.setEclipseProjectName( "test-project" );
-        MavenProject project = new MavenProject();
-        config.setProject( project );
-        EclipseProjectWriter projectWriter = new EclipseProjectWriter();
-        // create the .project file and start writing the contents
-        File dotProject = new File( config.getEclipseProjectDirectory(), ".project" );
-        Writer w = new OutputStreamWriter( new FileOutputStream( dotProject ), "UTF-8" );
-        XMLWriter writer = new PrettyPrintXMLWriter( w );
-
-        writer.startElement( "projectDescription" );
-
-        writer.startElement( "name" );
-        writer.writeText( "test-project" );
-        writer.endElement();// name
-
-        writer.startElement( "linkedResources" );
-        writer.startElement( "link" );
-
-        writer.startElement( "name" );
-        writer.writeText( "linkTest" );
-        writer.endElement();// name
-
-        writer.startElement( "type" );
-        writer.writeText( "2" );
-        writer.endElement();// type
-
-        writer.startElement( "location" );
-        writer.writeText( basedir + "/dummyName" );
-        writer.endElement(); // location
-
-        writer.endElement();// link
-        writer.endElement();// linkedResources
-        writer.endElement();// projectDescription
-
-        IOUtil.close( w );
-        // parse the file we just created in order to keep manually-added linkedResources
-        // pre setup
-        Reader reader = null;
-        reader = new InputStreamReader( new FileInputStream( dotProject ), "UTF-8" );
-        Xpp3Dom dom = Xpp3DomBuilder.build( reader );
-        Xpp3Dom linkedResourcesElement = dom.getChild( "linkedResources" );
-        Xpp3Dom[] existingLinks = linkedResourcesElement.getChildren( "link" );
-        String existingName = existingLinks[0].getChild( "name" ).getValue();
-        String existingType = existingLinks[0].getChild( "type" ).getValue();
-        String existingLocation = existingLinks[0].getChild( "location" ).getValue();
-        reader.close();
-        // call the projectwriter to write the .project file
-        projectWriter.init( log, config );
-        projectWriter.write();
-        // post check..compare the pre values to make sure the writer preserves the LinkedResources
-        reader = new InputStreamReader( new FileInputStream( dotProject ), "UTF-8" );
-        Xpp3Dom linkedResourcesElement1 = dom.getChild( "linkedResources" );
-        assertNotNull( "No linkedResources present", linkedResourcesElement1 );
-        Xpp3Dom[] currentLinks = linkedResourcesElement.getChildren( "link" );
-        String currentName = existingLinks[0].getChild( "name" ).getValue();
-        String currentType = existingLinks[0].getChild( "type" ).getValue();
-        String currentLocation = existingLinks[0].getChild( "location" ).getValue();
-        assertEquals( "link name is not equal", existingName, currentName );
-        assertEquals( "link type is not equal", existingType, currentType );
-        assertEquals( "link location is not equal", existingLocation, currentLocation );
-
-        reader.close();
-
-    }
-
-    private static final class TestLog
-        extends SystemStreamLog
-    {
-        public boolean isDebugEnabled()
-        {
-            return true;
-        }
-    }
-
-}
+package org.apache.maven.plugin.eclipse.writers;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.writers.testutils.TestEclipseWriterConfig;
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.tools.easymock.TestFileManager;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+import org.jdom.JDOMException;
+import junit.framework.TestCase;
+
+public class EclipseProjectWriterTest
+    extends TestCase
+{
+    private TestFileManager fileManager = new TestFileManager( "EclipseProjectWriter.unitTest.", "" );
+
+    public EclipseProjectWriterTest( String name )
+    {
+        super( name );
+    }
+
+    protected void setUp()
+        throws Exception
+    {
+
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+        fileManager.cleanUp();
+    }
+
+    public void testWrite_preservingLinkedResources()
+        throws MojoExecutionException, JDOMException, IOException, XmlPullParserException
+    {
+
+        // create the config and the logger
+        TestEclipseWriterConfig config = new TestEclipseWriterConfig();
+        TestLog log = new TestLog();
+
+        // setup the eclipse project
+        File basedir = fileManager.createTempDir();
+        config.setProjectBaseDir( basedir );
+        config.setEclipseProjectDirectory( basedir );
+        config.setEclipseProjectName( "test-project" );
+        MavenProject project = new MavenProject();
+        config.setProject( project );
+        EclipseProjectWriter projectWriter = new EclipseProjectWriter();
+        // create the .project file and start writing the contents
+        File dotProject = new File( config.getEclipseProjectDirectory(), ".project" );
+        Writer w = new OutputStreamWriter( new FileOutputStream( dotProject ), "UTF-8" );
+        XMLWriter writer = new PrettyPrintXMLWriter( w );
+
+        writer.startElement( "projectDescription" );
+
+        writer.startElement( "name" );
+        writer.writeText( "test-project" );
+        writer.endElement();// name
+
+        writer.startElement( "linkedResources" );
+        writer.startElement( "link" );
+
+        writer.startElement( "name" );
+        writer.writeText( "linkTest" );
+        writer.endElement();// name
+
+        writer.startElement( "type" );
+        writer.writeText( "2" );
+        writer.endElement();// type
+
+        writer.startElement( "location" );
+        writer.writeText( basedir + "/dummyName" );
+        writer.endElement(); // location
+
+        writer.endElement();// link
+        writer.endElement();// linkedResources
+        writer.endElement();// projectDescription
+
+        IOUtil.close( w );
+        // parse the file we just created in order to keep manually-added linkedResources
+        // pre setup
+        Reader reader = null;
+        reader = new InputStreamReader( new FileInputStream( dotProject ), "UTF-8" );
+        Xpp3Dom dom = Xpp3DomBuilder.build( reader );
+        Xpp3Dom linkedResourcesElement = dom.getChild( "linkedResources" );
+        Xpp3Dom[] existingLinks = linkedResourcesElement.getChildren( "link" );
+        String existingName = existingLinks[0].getChild( "name" ).getValue();
+        String existingType = existingLinks[0].getChild( "type" ).getValue();
+        String existingLocation = existingLinks[0].getChild( "location" ).getValue();
+        reader.close();
+        // call the projectwriter to write the .project file
+        projectWriter.init( log, config );
+        projectWriter.write();
+        // post check..compare the pre values to make sure the writer preserves the LinkedResources
+        reader = new InputStreamReader( new FileInputStream( dotProject ), "UTF-8" );
+        Xpp3Dom linkedResourcesElement1 = dom.getChild( "linkedResources" );
+        assertNotNull( "No linkedResources present", linkedResourcesElement1 );
+        Xpp3Dom[] currentLinks = linkedResourcesElement.getChildren( "link" );
+        String currentName = existingLinks[0].getChild( "name" ).getValue();
+        String currentType = existingLinks[0].getChild( "type" ).getValue();
+        String currentLocation = existingLinks[0].getChild( "location" ).getValue();
+        assertEquals( "link name is not equal", existingName, currentName );
+        assertEquals( "link type is not equal", existingType, currentType );
+        assertEquals( "link location is not equal", existingLocation, currentLocation );
+
+        reader.close();
+
+    }
+
+    private static final class TestLog
+        extends SystemStreamLog
+    {
+        public boolean isDebugEnabled()
+        {
+            return true;
+        }
+    }
+
+}

Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native