Author: brett
Date: Wed Jan 4 11:48:24 2012
New Revision: 1227127
URL: http://svn.apache.org/viewvc?rev=1227127&view=rev
Log:
[NPANDAY-519] make the project importer tests not depend on what's installed on
the system so they pass more consistently (and faster!)
Added:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractAzureImportTest.cs
(with props)
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AbstractPomConverter.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractProjectImportTest.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportMultipleRolesTest.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportOneWebRoleTest.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportWorkerRoleTest.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/NPanday.ProjectImporterEngine-Test.csproj
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithMultipleRoles/HelloWorld_WorkerRole/pom.test
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithWorkerRole/HelloWorld_WorkerRole/pom.test
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AbstractPomConverter.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AbstractPomConverter.cs?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AbstractPomConverter.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/main/csharp/Converter/Algorithms/AbstractPomConverter.cs
Wed Jan 4 11:48:24 2012
@@ -75,6 +75,7 @@ namespace NPanday.ProjectImporter.Conver
}
protected NPanday.Model.Pom.Model model;
+ private static List<Artifact.Artifact> testingArtifacts;
public NPanday.Model.Pom.Model Model
{
@@ -83,9 +84,7 @@ namespace NPanday.ProjectImporter.Conver
public AbstractPomConverter(ProjectDigest projectDigest, string
mainPomFile, NPanday.Model.Pom.Model parent, string groupId)
{
-
artifactContext = new ArtifactContext();
- this.localArtifacts =
artifactContext.GetArtifactRepository().GetArtifacts();
this.projectDigest = projectDigest;
this.mainPomFile = mainPomFile;
this.parent = parent;
@@ -99,6 +98,12 @@ namespace NPanday.ProjectImporter.Conver
this.model.build = new NPanday.Model.Pom.Build();
this.missingReferences = new List<Reference>();
+
+ // TODO: this is a hack because of bad design. The things that
talk to the local repository should be pulled out of here, and able to be
stubbed/mocked instead
+ if (testingArtifacts != null)
+ {
+ this.localArtifacts = testingArtifacts;
+ }
}
#region AddEmbeddedResources
@@ -463,6 +468,7 @@ namespace NPanday.ProjectImporter.Conver
refDependency.groupId = reference.Name;
refDependency.artifactId = reference.Name;
refDependency.version = reference.Version;
+ refDependency.type = "dotnet-library";
}
if (!("library".Equals(refDependency.type,
StringComparison.OrdinalIgnoreCase)
@@ -734,15 +740,15 @@ namespace NPanday.ProjectImporter.Conver
refs =
GacUtility.GetInstance().GetAssemblyInfo(reference.Name, reference.Version,
null);
System.Reflection.Assembly a =
System.Reflection.Assembly.ReflectionOnlyLoad(new
System.Reflection.AssemblyName(refs[0]).FullName);
-
+
Dependency refDependency = new Dependency();
refDependency.artifactId = reference.Name;
refDependency.groupId = reference.Name;
refDependency.type = GacUtility.GetNPandayGacType(a,
reference.PublicKeyToken);
-
+
refDependency.version = reference.Version ?? "1.0.0.0";
-
+
if (reference.PublicKeyToken != null)
{
refDependency.classifier = reference.PublicKeyToken;
@@ -750,13 +756,12 @@ namespace NPanday.ProjectImporter.Conver
else
{
int start = a.FullName.IndexOf("PublicKeyToken=");
- int length = (a.FullName.Length)-start;
- refDependency.classifier =
a.FullName.Substring(start,length);
+ int length = (a.FullName.Length) - start;
+ refDependency.classifier = a.FullName.Substring(start,
length);
refDependency.classifier =
refDependency.classifier.Replace("PublicKeyToken=", "");
}
return refDependency;
-
}
bool isPathReference = false;
@@ -828,6 +833,12 @@ namespace NPanday.ProjectImporter.Conver
Artifact.Artifact
GetArtifactFromRepoUsingEmbeddedAssemblyVersionNumber(Reference reference)
{
+ if (localArtifacts == null)
+ {
+ // TODO: this is a horribly slow operation on the local
repository. We should consider alternatives (e.g. maven repository index, cache
+ querying remote repos)
+ localArtifacts =
artifactContext.GetArtifactRepository().GetArtifacts();
+ }
+
foreach (Artifact.Artifact artifact in localArtifacts)
{
if (artifact.ArtifactId.Equals(reference.Name,
StringComparison.OrdinalIgnoreCase)
@@ -949,6 +960,11 @@ namespace NPanday.ProjectImporter.Conver
return string.Join(",", defines.ToArray());
}
- }
+ // useful for unit testing rather than grabbing them from the local
repository
+ public static void UseTestingArtifacts(List<Artifact.Artifact>
artifacts)
+ {
+ testingArtifacts = artifacts;
+ }
+ }
}
Added:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractAzureImportTest.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractAzureImportTest.cs?rev=1227127&view=auto
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractAzureImportTest.cs
(added)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractAzureImportTest.cs
Wed Jan 4 11:48:24 2012
@@ -0,0 +1,36 @@
+//
+// 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.
+//
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NPanday.ProjectImporter.ImporterTests
+{
+ public abstract class AbstractAzureImportTest : AbstractProjectImportTest
+ {
+ public override List<Artifact.Artifact> GetTestArtifacts()
+ {
+ List<Artifact.Artifact> artifacts = new List<Artifact.Artifact>();
+
artifacts.Add(createArtifact("Microsoft.WindowsAzure.Diagnostics"));
+
artifacts.Add(createArtifact("Microsoft.WindowsAzure.ServiceRuntime"));
+
artifacts.Add(createArtifact("Microsoft.WindowsAzure.StorageClient",
"1.1.0.0"));
+ return artifacts;
+ }
+ }
+}
Propchange:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractAzureImportTest.cs
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractProjectImportTest.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractProjectImportTest.cs?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractProjectImportTest.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AbstractProjectImportTest.cs
Wed Jan 4 11:48:24 2012
@@ -18,13 +18,10 @@
//
using System;
using System.Collections.Generic;
-using System.Reflection;
-using System.Text;
using System.IO;
using NUnit.Framework;
-using NPanday.ProjectImporter;
namespace NPanday.ProjectImporter.ImporterTests
{
@@ -57,6 +54,8 @@ namespace NPanday.ProjectImporter.Import
[TestFixtureSetUp]
public void ShouldBeAbleImportProject()
{
+
NPanday.ProjectImporter.Converter.Algorithms.AbstractPomConverter.UseTestingArtifacts(GetTestArtifacts());
+
// would be nicer if this could just be a setup check that ran
first - if this method weren't a setup itself
CheckFrameworkVersion();
@@ -167,5 +166,25 @@ namespace NPanday.ProjectImporter.Import
{
// designed to override
}
+
+ public virtual List<Artifact.Artifact> GetTestArtifacts()
+ {
+ return new List<Artifact.Artifact>();
+ }
+
+ protected Artifact.Artifact createArtifact(string name, string version)
+ {
+ Artifact.Artifact artifact = new Artifact.Artifact();
+ artifact.GroupId = name;
+ artifact.ArtifactId = name;
+ artifact.Version = version;
+ artifact.Extension = "dll";
+ return artifact;
+ }
+
+ protected Artifact.Artifact createArtifact(string name)
+ {
+ return createArtifact(name, "1.0.0.0");
+ }
}
}
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportMultipleRolesTest.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportMultipleRolesTest.cs?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportMultipleRolesTest.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportMultipleRolesTest.cs
Wed Jan 4 11:48:24 2012
@@ -24,7 +24,7 @@ using NUnit.Framework;
namespace NPanday.ProjectImporter.ImporterTests
{
[TestFixture]
- public class AzureImportMultipleRolesTest : AbstractProjectImportTest
+ public class AzureImportMultipleRolesTest : AbstractAzureImportTest
{
public override void CheckFrameworkVersion()
{
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportOneWebRoleTest.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportOneWebRoleTest.cs?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportOneWebRoleTest.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportOneWebRoleTest.cs
Wed Jan 4 11:48:24 2012
@@ -24,7 +24,7 @@ using NUnit.Framework;
namespace NPanday.ProjectImporter.ImporterTests
{
[TestFixture]
- public class AzureImportOneWebRoleTest : AbstractProjectImportTest
+ public class AzureImportOneWebRoleTest : AbstractAzureImportTest
{
public override void CheckFrameworkVersion()
{
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportWorkerRoleTest.cs
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportWorkerRoleTest.cs?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportWorkerRoleTest.cs
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/ImporterTests/AzureImportWorkerRoleTest.cs
Wed Jan 4 11:48:24 2012
@@ -24,7 +24,7 @@ using NUnit.Framework;
namespace NPanday.ProjectImporter.ImporterTests
{
[TestFixture]
- public class AzureImportWorkerRoleTest : AbstractProjectImportTest
+ public class AzureImportWorkerRoleTest : AbstractAzureImportTest
{
public override void CheckFrameworkVersion()
{
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/NPanday.ProjectImporterEngine-Test.csproj
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/NPanday.ProjectImporterEngine-Test.csproj?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/NPanday.ProjectImporterEngine-Test.csproj
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/csharp/NPanday.ProjectImporterEngine-Test.csproj
Wed Jan 4 11:48:24 2012
@@ -48,6 +48,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ImporterTests\AbstractProjectImportTest.cs" />
+ <Compile Include="ImporterTests\AbstractAzureImportTest.cs" />
<Compile Include="ImporterTests\ComReferenceNormalProjectTest.cs" />
<Compile Include="ImporterTests\AzureImportOneWebRoleTest.cs" />
<Compile Include="ImporterTests\AzureImportWorkerRoleTest.cs" />
@@ -72,6 +73,10 @@
<Compile Include="ImporterTests\WebSiteWithCSharpProjectFile.cs" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference
Include="..\..\..\..\..\NPanday.Artifact\src\main\csharp\NPanday.Artifact.csproj">
+ <Project>{701803D4-90F5-44D7-919D-4844FEB7F936}</Project>
+ <Name>NPanday.Artifact</Name>
+ </ProjectReference>
<ProjectReference
Include="..\..\..\..\..\NPanday.Utils\src\main\csharp\NPanday.Utils.csproj">
<Project>{CAA4864F-F4C8-4024-8535-8B8C112307CE}</Project>
<Name>NPanday.Utils</Name>
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithMultipleRoles/HelloWorld_WorkerRole/pom.test
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithMultipleRoles/HelloWorld_WorkerRole/pom.test?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithMultipleRoles/HelloWorld_WorkerRole/pom.test
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithMultipleRoles/HelloWorld_WorkerRole/pom.test
Wed Jan 4 11:48:24 2012
@@ -46,19 +46,19 @@
</build>
<dependencies>
<dependency>
- <groupId>Microsoft.WindowsAzure</groupId>
+ <groupId>Microsoft.WindowsAzure.Diagnostics</groupId>
<artifactId>Microsoft.WindowsAzure.Diagnostics</artifactId>
<version>1.0.0.0</version>
<type>dotnet-library</type>
</dependency>
<dependency>
- <groupId>Microsoft.WindowsAzure</groupId>
+ <groupId>Microsoft.WindowsAzure.ServiceRuntime</groupId>
<artifactId>Microsoft.WindowsAzure.ServiceRuntime</artifactId>
<version>1.0.0.0</version>
<type>dotnet-library</type>
</dependency>
<dependency>
- <groupId>Microsoft.WindowsAzure</groupId>
+ <groupId>Microsoft.WindowsAzure.StorageClient</groupId>
<artifactId>Microsoft.WindowsAzure.StorageClient</artifactId>
<version>1.1.0.0</version>
<type>dotnet-library</type>
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithWorkerRole/HelloWorld_WorkerRole/pom.test
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithWorkerRole/HelloWorld_WorkerRole/pom.test?rev=1227127&r1=1227126&r2=1227127&view=diff
==============================================================================
---
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithWorkerRole/HelloWorld_WorkerRole/pom.test
(original)
+++
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Engine/src/test/resource/NPANDAY_480_CloudServiceWithWorkerRole/HelloWorld_WorkerRole/pom.test
Wed Jan 4 11:48:24 2012
@@ -46,19 +46,19 @@
</build>
<dependencies>
<dependency>
- <groupId>Microsoft.WindowsAzure</groupId>
+ <groupId>Microsoft.WindowsAzure.Diagnostics</groupId>
<artifactId>Microsoft.WindowsAzure.Diagnostics</artifactId>
<version>1.0.0.0</version>
<type>dotnet-library</type>
</dependency>
<dependency>
- <groupId>Microsoft.WindowsAzure</groupId>
+ <groupId>Microsoft.WindowsAzure.ServiceRuntime</groupId>
<artifactId>Microsoft.WindowsAzure.ServiceRuntime</artifactId>
<version>1.0.0.0</version>
<type>dotnet-library</type>
</dependency>
<dependency>
- <groupId>Microsoft.WindowsAzure</groupId>
+ <groupId>Microsoft.WindowsAzure.StorageClient</groupId>
<artifactId>Microsoft.WindowsAzure.StorageClient</artifactId>
<version>1.1.0.0</version>
<type>dotnet-library</type>