From nmaven-commits-return-589-apmail-incubator-nmaven-commits-archive=incubator.apache.org@incubator.apache.org Thu Nov 29 22:18:42 2007 Return-Path: Delivered-To: apmail-incubator-nmaven-commits-archive@locus.apache.org Received: (qmail 72517 invoked from network); 29 Nov 2007 22:18:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Nov 2007 22:18:42 -0000 Received: (qmail 51760 invoked by uid 500); 29 Nov 2007 22:18:30 -0000 Delivered-To: apmail-incubator-nmaven-commits-archive@incubator.apache.org Received: (qmail 51727 invoked by uid 500); 29 Nov 2007 22:18:30 -0000 Mailing-List: contact nmaven-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: nmaven-dev@incubator.apache.org Delivered-To: mailing list nmaven-commits@incubator.apache.org Received: (qmail 51718 invoked by uid 99); 29 Nov 2007 22:18:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Nov 2007 14:18:30 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Nov 2007 22:18:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 961461A9832; Thu, 29 Nov 2007 14:18:18 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r599602 - /incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java Date: Thu, 29 Nov 2007 22:18:18 -0000 To: nmaven-commits@incubator.apache.org From: sisbell@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071129221818.961461A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 dependencyArtifacts = new HashSet(); 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 modules = ctx.getModuleDependencies(); + assertThat( modules.size(), equalTo( 1 ) ); + } + + @Test + public void testInit_WithLibrary() + throws PlatformUnsupportedException + { + DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl(); + MavenProject project = new MavenProject(); + + Set dependencyArtifacts = new HashSet(); + 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 libraries = ctx.getLibraryDependencies(); + assertThat( libraries.size(), equalTo( 1 ) ); + } + + @Test + public void testInit_WithExe() + throws PlatformUnsupportedException + { + DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl(); + MavenProject project = new MavenProject(); + + Set dependencyArtifacts = new HashSet(); + 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 libraries = ctx.getLibraryDependencies(); + assertThat( libraries.size(), equalTo( 1 ) ); + } + + @Test + public void testInit_WithGacGenericAndMicrosoft() + throws PlatformUnsupportedException + { + DotnetCompilerContextImpl ctx = new DotnetCompilerContextImpl(); + MavenProject project = new MavenProject(); + + Set dependencyArtifacts = new HashSet(); + 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 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; } }