You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by vs...@apache.org on 2005/08/07 02:07:54 UTC

svn commit: r230612 - in /maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src: main/java/org/apache/maven/report/projectinfo/ test/projects/project-info-reports-plugin-test11/

Author: vsiveton
Date: Sat Aug  6 17:07:50 2005
New Revision: 230612

URL: http://svn.apache.org/viewcvs?rev=230612&view=rev
Log:
MNG-695: Added more tests on anonymousConnection, devConnection and scmUrl to prevent NPE. Added the test case num 11.

Added:
    maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/test/projects/project-info-reports-plugin-test11/
    maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/test/projects/project-info-reports-plugin-test11/pom.xml   (with props)
Modified:
    maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java

Modified: maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java?rev=230612&r1=230611&r2=230612&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java (original)
+++ maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/ScmReport.java Sat Aug  6 17:07:50 2005
@@ -196,6 +196,19 @@
             anonymousConnection = scm.getConnection();
             devConnection = scm.getDeveloperConnection();
 
+            if ( StringUtils.isEmpty( anonymousConnection ) &&
+                StringUtils.isEmpty( devConnection ) &&
+                StringUtils.isEmpty( scm.getUrl() ) )
+            {
+                startSection( getTitle() );
+
+                paragraph( getBundle( locale ).getString( "report.scm.noscm" ) );
+
+                endSection();
+
+                return;
+            }
+            
             ScmRepository anonymousRepository = getScmRepository( anonymousConnection );
             ScmRepository devRepository = getScmRepository( devConnection );
 
@@ -264,7 +277,7 @@
         {
             startSection( getBundle( locale ).getString( "report.scm.webaccess.title" ) );
 
-            if ( scmUrl == null )
+            if ( StringUtils.isEmpty( scmUrl ) )
             {
                 paragraph( getBundle( locale ).getString( "report.scm.webaccess.nourl" ) );
             }
@@ -288,7 +301,8 @@
         {
             if ( ( isScmSystem( anonymousRepository, "clearcase" ) )
                 || ( isScmSystem( anonymousRepository, "perforce" ) )
-                || ( isScmSystem( anonymousRepository, "starteam" ) ) )
+                || ( isScmSystem( anonymousRepository, "starteam" ) ) 
+                || ( StringUtils.isEmpty( anonymousConnection ) ) )
             {
                 return;
             }
@@ -313,6 +327,11 @@
             {
                 paragraph( getBundle( locale ).getString( "report.scm.anonymousaccess.general.intro" ) );
 
+                if ( anonymousConnection.length() < 4 )
+                {
+                    throw new IllegalArgumentException( "The source repository connection is too short." );
+                }
+
                 verbatimText( anonymousConnection.substring( 4 ) );
             }
 
@@ -326,6 +345,11 @@
          */
         private void renderDeveloperAccessSection( ScmRepository devRepository )
         {
+            if ( StringUtils.isEmpty( devConnection ) )
+            {
+                return;
+            }
+            
             startSection( getBundle( locale ).getString( "report.scm.devaccess.title" ) );
 
             if ( ( devRepository != null ) && ( isScmSystem( devRepository, "clearcase" ) ) )
@@ -365,6 +389,11 @@
             {
                 paragraph( getBundle( locale ).getString( "report.scm.devaccess.general.intro" ) );
 
+                if ( devConnection.length() < 4 )
+                {
+                    throw new IllegalArgumentException( "The source repository connection is too short." );
+                }
+
                 verbatimText( devConnection.substring( 4 ) );
             }
 
@@ -622,7 +651,7 @@
          */
         public ScmRepository getScmRepository( String scmUrl )
         {
-            if ( scmUrl == null )
+            if ( StringUtils.isEmpty( scmUrl ) )
             {
                 return null;
             }

Added: maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/test/projects/project-info-reports-plugin-test11/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/test/projects/project-info-reports-plugin-test11/pom.xml?rev=230612&view=auto
==============================================================================
--- maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/test/projects/project-info-reports-plugin-test11/pom.xml (added)
+++ maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/test/projects/project-info-reports-plugin-test11/pom.xml Sat Aug  6 17:07:50 2005
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+ -->
+
+<project>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.report.projectinfo.test11</groupId>
+  <artifactId>project-info-reports-plugin-test11</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <inceptionYear>2005</inceptionYear>
+  <name>Maven ProjectInfo Report Test11</name>
+  <description>MNG-695 developerConnection is empty</description>
+  <url>http://maven.apache.org</url>
+  <scm>
+    <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-plugins/dist</connection>
+    <developerConnection/>
+    <url>http://cvs.apache.org/</url>
+  </scm>
+  <developers>
+    <developer>
+      <id>vsiveton</id>
+      <name>Vincent Siveton</name>
+      <email>vsiveton@apache.org</email>
+      <organization>Apache Software Foundation</organization>
+      <roles>
+        <role>Java Developer</role>
+      </roles>
+      <timezone>-5</timezone>
+    </developer>
+  </developers>
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-project-info-reports-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+</project>

Propchange: maven/components/trunk/maven-plugins/maven-project-info-reports-plugin/src/test/projects/project-info-reports-plugin-test11/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native



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