Author: sisbell
Date: Thu Nov 29 14:18:14 2007
New Revision: 599602

URL: http://svn.apache.org/viewvc?rev=599602&view=rev
Log:
Some more tests.

Modified:
    
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/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=599602&r1=599601&r2=599602&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 14:18:14 2007
@@ -1,14 +1,26 @@
 package org.apache.maven.dotnet.compiler.impl;
 
+import java.util.HashSet;
+import java.util.Set;
+import java.io.File;
+
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.model.Build;
+
 import org.apache.maven.dotnet.compiler.DotnetCompilerConfig;
 import org.apache.maven.dotnet.compiler.PlatformUnsupportedException;
-import org.junit.Test;
+import org.apache.maven.dotnet.compiler.ArtifactType;
+import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion;
+import org.apache.maven.dotnet.compiler.ProgrammingLanguage;
+import org.apache.maven.dotnet.compiler.Vendor;
 
-import java.util.HashSet;
-import java.util.Set;
+import org.junit.Test;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.*;
 
 public class DotnetCompilerContextImplTest
 {
@@ -32,26 +44,115 @@
 
     }
 
-    public void testInit()
+    @Test
+    public void testInit_WithModule()
+        throws PlatformUnsupportedException
     {
         DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
         MavenProject project = new MavenProject();
+
         Set<Artifact> dependencyArtifacts = new HashSet<Artifact>();
         project.setDependencyArtifacts( dependencyArtifacts );
+        Artifact artifact = new DefaultArtifact( "groupId", "artifactId", 
VersionRange.createFromVersion( "1.0" ),
+                                                 "compile", "module", null, 
new DefaultArtifactHandler( "module" ),
+                                                 false );
+        dependencyArtifacts.add( artifact );
 
         Build build = new Build();
         build.setDirectory( "" );
         project.setBuild( build );
 
-        DotnetCompilerConfig compilerConfig = 
DotnetCompilerConfig.Factory.createDefaultExecutableConfig();
+        ctx.init( project, getDefaultDotnetCompilerConfig() );
+
+        Set<Artifact> modules = ctx.getModuleDependencies();
+        assertThat( modules.size(), equalTo( 1 ) );
+    }
+
+    @Test
+    public void testInit_WithLibrary()
+        throws PlatformUnsupportedException
+    {
+        DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
+        MavenProject project = new MavenProject();
+
+        Set<Artifact> dependencyArtifacts = new HashSet<Artifact>();
+        project.setDependencyArtifacts( dependencyArtifacts );
+        Artifact artifact = new DefaultArtifact( "groupId", "artifactId", 
VersionRange.createFromVersion( "1.0" ),
+                                                 "compile", "library", null, 
new DefaultArtifactHandler( "library" ),
+                                                 false );
+        dependencyArtifacts.add( artifact );
+
+        Build build = new Build();
+        build.setDirectory( "" );
+        project.setBuild( build );
+
+        ctx.init( project, getDefaultDotnetCompilerConfig() );
+
+        Set<Artifact> libraries = ctx.getLibraryDependencies();
+        assertThat( libraries.size(), equalTo( 1 ) );
+    }
+
+    @Test
+    public void testInit_WithExe()
+        throws PlatformUnsupportedException
+    {
+        DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
+        MavenProject project = new MavenProject();
+
+        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 );
+        dependencyArtifacts.add( artifact );
+
+        Build build = new Build();
+        build.setDirectory( "" );
+        project.setBuild( build );
+
+        ctx.init( project, getDefaultDotnetCompilerConfig() );
+
+        Set<Artifact> libraries = ctx.getLibraryDependencies();
+        assertThat( libraries.size(), equalTo( 1 ) );
+    }
+
+    @Test
+    public void testInit_WithGacGenericAndMicrosoft()
+        throws PlatformUnsupportedException
+    {
+        DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl();
+        MavenProject project = new MavenProject();
+
+        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 );
+        dependencyArtifacts.add( artifact );
+
+        Build build = new Build();
+        build.setDirectory( "" );
+        project.setBuild( build );
+
+        ctx.init( project, getDefaultDotnetCompilerConfig() );
+
+        Set<Artifact> libraries = ctx.getLibraryDependencies();
+        assertThat( libraries.size(), equalTo( 1 ) );
+        ((Artifact) libraries.toArray()[0]).;
+    }
+
+    private static DotnetCompilerConfig getDefaultDotnetCompilerConfig()
+    {
+        DotnetCompilerConfig config = 
DotnetCompilerConfig.Factory.createDefaultExecutableConfig();
+        config.setArtifactType( ArtifactType.LIBRARY );
+        config.setCompilerPlatformVersion( 
DotnetCompilerPlatformVersion.VERSION_2_0_50727 );
+        config.setLocalRepository( new File( "." ) );
+        config.setProgrammingLanguage( ProgrammingLanguage.C_SHARP );
+        config.setSourceDirectory( new File( "." ) );
+        config.setTargetDirectory( new File( "." ) );
+        config.setTestCompile( false );
+        config.setVendor( Vendor.MICROSOFT );
 
-        try
-        {
-            ctx.init( project, compilerConfig );
-        }
-        catch ( PlatformUnsupportedException e )
-        {
-            e.printStackTrace();
-        }
+        return config;
     }
 }


Reply via email to