Author: brett
Date: Wed Feb 26 15:45:02 2014
New Revision: 1572101

URL: http://svn.apache.org/r1572101
Log:
Web reference delete and readd creates two identical webreference nodes in pom 
file instead of adding one.

Submitted by: Adelita Padilla

Modified:
    
incubator/npanday/trunk/dotnet/assemblies/NPanday.Utils/src/main/csharp/PomHelperUtility.cs
    
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebReferenceEventArgs.cs
    
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebServicesReferenceUtils.cs
    
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/test/csharp/MavenCompilePluginConfigurationTest.cs

Modified: 
incubator/npanday/trunk/dotnet/assemblies/NPanday.Utils/src/main/csharp/PomHelperUtility.cs
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.Utils/src/main/csharp/PomHelperUtility.cs?rev=1572101&r1=1572100&r2=1572101&view=diff
==============================================================================
--- 
incubator/npanday/trunk/dotnet/assemblies/NPanday.Utils/src/main/csharp/PomHelperUtility.cs
 (original)
+++ 
incubator/npanday/trunk/dotnet/assemblies/NPanday.Utils/src/main/csharp/PomHelperUtility.cs
 Wed Feb 26 15:45:02 2014
@@ -318,7 +318,6 @@ namespace NPanday.Utils
                 throw new Exception("Pom file not found: " + pomfile.FullName);
             }
 
-
             XmlDocument xmlDocument = new XmlDocument();
             xmlDocument.Load(pomfile.FullName);
             String namespaceUri = xmlDocument.DocumentElement.NamespaceURI;
@@ -342,7 +341,7 @@ namespace NPanday.Utils
 
                 if (!serializer.CanDeserialize(reader))
                 {
-                    throw new Exception(string.Format("Pom File ({0}) Reading 
Error, Pom File might contain invalid or deformed data", pomfile.FullName));
+                    throw new Exception(string.Format("Pom File ({0}) Reading 
Error, Pom File might contain invalid or malformed data", pomfile.FullName));
                 }
 
                 model = 
(NPanday.Model.Pom.Model)serializer.Deserialize(reader);
@@ -1044,7 +1043,7 @@ namespace NPanday.Utils
                     if 
("org.apache.npanday.plugins".Equals(plugin.groupId.ToLower(), 
StringComparison.InvariantCultureIgnoreCase)
                         && 
"maven-compile-plugin".Equals(plugin.artifactId.ToLower(), 
StringComparison.InvariantCultureIgnoreCase))
                     {
-                        if (plugin.configuration == null && 
plugin.configuration.Any == null)
+                        if (plugin.configuration == null || 
plugin.configuration.Any == null)
                         {
                             break;
                         }
@@ -1065,7 +1064,7 @@ namespace NPanday.Utils
                                     {
                                         XmlNode node = 
xmlDocument.CreateNode(XmlNodeType.Element, n.Name, 
@"http://maven.apache.org/POM/4.0.0";);
 
-                                        node.InnerText = n.InnerText;
+                                        node.InnerText = 
n.InnerText.Replace("\\","/");
                                         if 
((!elem.InnerXml.Contains(node.InnerText)) && 
(!node.InnerText.Contains(".disco")))
                                         {
                                             elem.AppendChild(node);

Modified: 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebReferenceEventArgs.cs
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebReferenceEventArgs.cs?rev=1572101&r1=1572100&r2=1572101&view=diff
==============================================================================
--- 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebReferenceEventArgs.cs
 (original)
+++ 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebReferenceEventArgs.cs
 Wed Feb 26 15:45:02 2014
@@ -88,14 +88,16 @@ namespace NPanday.VisualStudio.Addin
                 {
                     string projectPath = 
Path.GetDirectoryName(Path.GetDirectoryName(this.referenceDirectory));
                     
-                    this.wsdlUrl = 
WebServicesReferenceUtils.GetWsdlUrl(WebServicesReferenceUtils.GetReferenceFile(this.referenceDirectory));
-                    this.wsdlFile = 
WebServicesReferenceUtils.GetWsdlFile(this.referenceDirectory);
-                    this.wsdlFile = 
this.wsdlFile.Substring(projectPath.Length+1);
-
+                    if (!string.IsNullOrEmpty(projectPath))
+                    {
+                        this.wsdlUrl = 
WebServicesReferenceUtils.GetWsdlUrl(WebServicesReferenceUtils.GetReferenceFile(this.referenceDirectory));
+                        this.wsdlFile = 
WebServicesReferenceUtils.GetWsdlFile(this.referenceDirectory);
+                        this.wsdlFile = 
this.wsdlFile.Substring(projectPath.Length+1);
+                    }
                 }
             }
         }
 
        
     }
-}
\ No newline at end of file
+}

Modified: 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebServicesReferenceUtils.cs
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebServicesReferenceUtils.cs?rev=1572101&r1=1572100&r2=1572101&view=diff
==============================================================================
--- 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebServicesReferenceUtils.cs
 (original)
+++ 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/WebServicesReferenceUtils.cs
 Wed Feb 26 15:45:02 2014
@@ -22,6 +22,7 @@ using System;
 using System.Collections.Generic;
 using System.Text;
 using System.IO;
+using System.Threading;
 using System.Xml.XPath;
 using System.Windows.Forms;
 
@@ -32,16 +33,18 @@ namespace NPanday.VisualStudio.Addin
         public static string GetReferenceFile(string referenceDirectory)
         {
             string fname = "";
-            foreach (string f in Directory.GetFiles(referenceDirectory))
+            if (!string.IsNullOrEmpty(referenceDirectory))
             {
-                string fext = Path.GetExtension(f).ToLower();
-                if (fext.Equals(".map", 
StringComparison.InvariantCultureIgnoreCase) || fext.Equals(".discomap", 
StringComparison.InvariantCultureIgnoreCase)
-                    || fext.Equals(".svcmap", 
StringComparison.InvariantCultureIgnoreCase))
+                foreach (string f in Directory.GetFiles(referenceDirectory))
                 {
-                    fname = f;
-                    break;
+                    string fext = Path.GetExtension(f).ToLower();
+                    if (fext.Equals(".map", 
StringComparison.InvariantCultureIgnoreCase) || fext.Equals(".discomap", 
StringComparison.InvariantCultureIgnoreCase)
+                        || fext.Equals(".svcmap", 
StringComparison.InvariantCultureIgnoreCase))
+                    {
+                        fname = f;
+                        break;
+                    }
                 }
-
             }
             return fname;
         }
@@ -49,15 +52,18 @@ namespace NPanday.VisualStudio.Addin
         public static string GetWsdlFile(string referenceDirectory)
         {
             string fname = "";
-            foreach (string f in Directory.GetFiles(referenceDirectory))
+            if (!string.IsNullOrEmpty(referenceDirectory))
             {
-                string fext = Path.GetExtension(f).ToLower();
-                if (fext.Equals(".wsdl", 
StringComparison.InvariantCultureIgnoreCase))
+                foreach (string f in Directory.GetFiles(referenceDirectory))
                 {
-                    fname = f;
-                    break;
-                }
+                    string fext = Path.GetExtension(f).ToLower();
+                    if (fext.Equals(".wsdl", 
StringComparison.InvariantCultureIgnoreCase))
+                    {
+                        fname = f;
+                        break;
+                    }
 
+                }
             }
             return fname;
         }

Modified: 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/test/csharp/MavenCompilePluginConfigurationTest.cs
URL: 
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/test/csharp/MavenCompilePluginConfigurationTest.cs?rev=1572101&r1=1572100&r2=1572101&view=diff
==============================================================================
--- 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/test/csharp/MavenCompilePluginConfigurationTest.cs
 (original)
+++ 
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/test/csharp/MavenCompilePluginConfigurationTest.cs
 Wed Feb 26 15:45:02 2014
@@ -59,6 +59,16 @@ namespace NPanday.VisualStudio.Addin_Tes
         }
 
         [Test]
+        public void AddDuplicateMavenCompilePluginConfigurationTest()
+        {
+            Assert.AreEqual(1, GetIncludedSourceCount(pomPath));
+
+            
pomCopy.AddMavenCompilePluginConfiguration("org.apache.npanday.plugins", 
"maven-compile-plugin", "includeSources", "includeSource", 
"Settings.Designer.cs");
+
+            Assert.AreEqual(1, GetIncludedSourceCount(pomPath)); 
+        }
+        
+        [Test]
         public void RenameMavenCompilePluginConfigurationTest()
         {
             
pomCopy.RenameMavenCompilePluginConfiguration("org.apache.npanday.plugins", 
"maven-compile-plugin", "includeSources", "includeSource", 
"IISHandler1.cs","IISHandlerRenamed.cs");
@@ -76,5 +86,23 @@ namespace NPanday.VisualStudio.Addin_Tes
             File.Delete(pomCopyPath);
         }
 
+        private int GetIncludedSourceCount(String pom)
+        {
+            int ctr = 0;
+            String line;
+            StreamReader strm = new StreamReader(pom);
+
+            while ((line = strm.ReadLine()) != null)
+            {
+                if 
(line.ToString().Contains("<includeSource>Settings.Designer.cs</includeSource>"))
+                {
+                    ctr++;
+                }
+           }
+
+            strm.Close();
+            return ctr;
+        }
+
     }
 }


Reply via email to