Author: sisbell
Date: Thu Nov 29 19:25:44 2007
New Revision: 599688

URL: http://svn.apache.org/viewvc?rev=599688&view=rev
Log:
Added additional tests to check that gac assemblies are handled.

Modified:
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
    
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java?rev=599688&r1=599687&r2=599688&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java
 Thu Nov 29 19:25:44 2007
@@ -16,7 +16,7 @@
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.logging.Logger;
 
-public class DotnetCompilerContextImpl
+public final class DotnetCompilerContextImpl
     implements DotnetCompilerContext
 
 {
@@ -47,6 +47,8 @@
 
     private Set<File> win32resources;
 
+    private boolean assemblyExistsCheck = true;
+
 
     public Set<String> getCoreAssemblyNames()
     {
@@ -106,14 +108,14 @@
     public void init( MavenProject project, CompilerConfig compilerConfig )
         throws PlatformUnsupportedException
     {
-        if(project == null)
+        if ( project == null )
         {
-            throw new IllegalArgumentException("NMAVEN-061-000: mavenProject");
+            throw new IllegalArgumentException( "NMAVEN-061-000: mavenProject" 
);
         }
 
-        if(compilerConfig == null)
+        if ( compilerConfig == null )
         {
-            throw new IllegalArgumentException("NMAVEN-061-001: 
compilerConfig");
+            throw new IllegalArgumentException( "NMAVEN-061-001: 
compilerConfig" );
         }
 
         this.project = project;
@@ -236,6 +238,16 @@
         }
     }
 
+    protected void turnOffAssemblyExistsCheck()
+    {
+        this.assemblyExistsCheck = false;
+    }
+
+    protected void turnOnAssemblyExistsCheck()
+    {
+        this.assemblyExistsCheck = true;
+    }
+
     private static String getGacRootForMono()
         throws PlatformUnsupportedException
     {
@@ -273,12 +285,13 @@
         }
     }
 
-    private static void setArtifactGacFile( String gacRoot, Artifact artifact )
+    private void setArtifactGacFile( String gacRoot, Artifact artifact )
         throws PlatformUnsupportedException
     {
         File gacFile = new File( gacRoot, artifact.getArtifactId() + 
File.separator + artifact.getVersion() + "__" +
             artifact.getClassifier() + File.separator + 
artifact.getArtifactId() + ".dll" );
-        if ( !gacFile.exists() )
+
+        if ( assemblyExistsCheck && !gacFile.exists() )
         {
             throw new PlatformUnsupportedException(
                 "NMAVEN-061-004: Could not find GAC dependency: File = " + 
gacFile.getAbsolutePath() );

Modified: 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java?rev=599688&r1=599687&r2=599688&view=diff
==============================================================================
--- 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
 (original)
+++ 
incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java
 Thu Nov 29 19:25:44 2007
@@ -20,6 +20,10 @@
 
 import org.junit.Test;
 import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.*;
+import org.hamcrest.Matcher;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.CoreMatchers;
 import static org.junit.Assert.*;
 
 public class DotnetCompilerContextImplTest
@@ -102,8 +106,7 @@
         Set<Artifact> dependencyArtifacts = new HashSet<Artifact>();
         project.setDependencyArtifacts( dependencyArtifacts );
         Artifact artifact = new DefaultArtifact( "groupId", "artifactId", 
VersionRange.createFromVersion( "1.0" ),
-                                                 "compile", "exe", null, new 
DefaultArtifactHandler( "exe" ),
-                                                 false );
+                                                 "compile", "exe", null, new 
DefaultArtifactHandler( "exe" ), false );
         dependencyArtifacts.add( artifact );
 
         Build build = new Build();
@@ -126,19 +129,35 @@
         Set<Artifact> dependencyArtifacts = new HashSet<Artifact>();
         project.setDependencyArtifacts( dependencyArtifacts );
         Artifact artifact = new DefaultArtifact( "groupId", "artifactId", 
VersionRange.createFromVersion( "1.0" ),
-                                                 "compile", "gac_generic", 
null, new DefaultArtifactHandler( "library" ),
-                                                 false );
+                                                 "compile", "gac_generic", 
null,
+                                                 new DefaultArtifactHandler( 
"library" ), false );
         dependencyArtifacts.add( artifact );
 
         Build build = new Build();
         build.setDirectory( "" );
         project.setBuild( build );
 
+        ctx.turnOffAssemblyExistsCheck();
+
         ctx.init( project, getDefaultDotnetCompilerConfig() );
 
         Set<Artifact> libraries = ctx.getLibraryDependencies();
         assertThat( libraries.size(), equalTo( 1 ) );
-        ((Artifact) libraries.toArray()[0]).;
+        assertThat( ( (Artifact) libraries.toArray()[0] 
).getFile().getAbsolutePath(),
+                    CoreMatchers.allOf( new BaseMatcher()
+                    {
+                        private String containsString = 
"assembly\\GAC_MSIL\\artifactId\\1.0__null\\artifactId.dll";
+
+                        public boolean matches( Object object )
+                        {
+                            return ( (String) object ).contains( 
containsString );
+                        }
+
+                        public void describeTo( org.hamcrest.Description 
description )
+                        {
+                            description.appendText( "Start With = " + 
containsString );
+                        }
+                    } ) );
     }
 
     private static DotnetCompilerConfig getDefaultDotnetCompilerConfig()


Reply via email to