incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r521968 - in /incubator/nmaven/branches/SI_XPT/components/dotnet-vendor: ./ src/main/java/org/apache/maven/dotnet/vendor/ src/main/java/org/apache/maven/dotnet/vendor/impl/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apach...
Date Sat, 24 Mar 2007 02:52:37 GMT
Author: sisbell
Date: Fri Mar 23 19:52:36 2007
New Revision: 521968

URL: http://svn.apache.org/viewvc?view=rev&rev=521968
Log:
Added unit tests to test transition rules. Fixed a number of bugs.

Added:
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/RepositoryRegistryTestStub.java
  (with props)
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTestStub.java
  (with props)
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoRepositoryTestStub.java
  (with props)
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
  (with props)
Modified:
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/pom.xml
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoRepository.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/StateMachineProcessorImpl.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactory.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VersionMatcher.java

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/pom.xml
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/pom.xml?view=diff&rev=521968&r1=521967&r2=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/pom.xml (original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/pom.xml Fri Mar 23 19:52:36
2007
@@ -25,4 +25,29 @@
       <version>0.14-SNAPSHOT</version>
     </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <aggregate>true</aggregate>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptor>src/assembly/src.xml</descriptor>
+          <outputDirectory>src/target</outputDirectory>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoRepository.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoRepository.java?view=diff&rev=521968&r1=521967&r2=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoRepository.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoRepository.java
Fri Mar 23 19:52:36 2007
@@ -92,6 +92,13 @@
     File getInstallRootFor( VendorInfo vendorInfo )
         throws PlatformUnsupportedException;
 
+    /**
+     *  Returns file pointing to the .NET SDK installation root used for compiling artifacts.
+     *
+     * @param vendorInfo the vendor info
+     * @return file pointing to the .NET SDK installation root used for compiling artifacts
+     * @throws PlatformUnsupportedException
+     */
     File getSdkInstallRootFor( VendorInfo vendorInfo )
         throws PlatformUnsupportedException;
 

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/StateMachineProcessorImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/StateMachineProcessorImpl.java?view=diff&rev=521968&r1=521967&r2=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/StateMachineProcessorImpl.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/StateMachineProcessorImpl.java
Fri Mar 23 19:52:36 2007
@@ -35,7 +35,7 @@
  *
  * @author Shane Isbell
  */
-public class StateMachineProcessorImpl
+public final class StateMachineProcessorImpl
     implements StateMachineProcessor, LogEnabled, Initializable
 {
 

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactory.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactory.java?view=diff&rev=521968&r1=521967&r2=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactory.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactory.java
Fri Mar 23 19:52:36 2007
@@ -41,13 +41,6 @@
 final class VendorInfoTransitionRuleFactory
 {
 
-    /**
-     * A registry component of repository (config) files
-     */
-    private RepositoryRegistry repositoryRegistry;
-
-    private SettingsRepository settingsRepository;
-
     private VendorInfoRepository vendorInfoRepository;
 
     /**
@@ -65,14 +58,17 @@
      */
     private String defaultFrameworkVersion;
 
-    private List<VendorInfo> vendorInfos;
-
     /**
      * A logger for writing log messages
      */
     private Logger logger;
 
     /**
+     * A version matcher
+     */
+    VersionMatcher versionMatcher;
+
+    /**
      * Default constructor
      */
     VendorInfoTransitionRuleFactory()
@@ -90,7 +86,6 @@
     void init( RepositoryRegistry repositoryRegistry, VendorInfoRepository vendorInfoRepository,
Logger logger )
         throws InitializationException
     {
-        this.repositoryRegistry = repositoryRegistry;
         this.vendorInfoRepository = vendorInfoRepository;
         this.logger = logger;
         if ( repositoryRegistry == null )
@@ -98,12 +93,11 @@
             throw new InitializationException( "NMAVEN-103-000: Unable to find the repository
registry" );
         }
 
-        settingsRepository = (SettingsRepository) repositoryRegistry.find( "nmaven-settings"
);
+        SettingsRepository settingsRepository = (SettingsRepository) repositoryRegistry.find(
"nmaven-settings" );
         if ( settingsRepository == null )
         {
             throw new InitializationException(
                 "NMAVEN-103-001: Settings Repository is null. Aborting initialization of
VendorInfoTranstionRuleFactory" );
-
         }
 
         try
@@ -117,7 +111,7 @@
         }
         defaultVendorVersion = settingsRepository.getDefaultSetup().getVendorVersion().trim();
         defaultFrameworkVersion = settingsRepository.getDefaultSetup().getFrameworkVersion().trim();
-        vendorInfos = settingsRepository.getVendorInfos();
+        this.versionMatcher = new VersionMatcher();
     }
 
     VendorInfoTransitionRule createPostProcessRule()
@@ -127,8 +121,8 @@
             public VendorInfoState process( VendorInfo vendorInfo )
             {
                 logger.debug( "NMAVEN-103-034: Entering State = Post Process" );
-                if ( (vendorInfo.getExecutablePaths() == null ||
-                    vendorInfo.getExecutablePaths().size() == 0) && vendorInfoRepository.exists()
)
+                if ( ( vendorInfo.getExecutablePaths() == null || vendorInfo.getExecutablePaths().size()
== 0 ) &&
+                    vendorInfoRepository.exists() )
                 {
                     File sdkInstallRoot = null;
                     try
@@ -256,10 +250,10 @@
             public VendorInfoState process( VendorInfo vendorInfo )
             {
                 logger.debug( "NMAVEN-103-007: Entering State = NFT" );
-                if ( vendorInfo.getFrameworkVersion().equals( defaultFrameworkVersion ) )
+                if ( vendorInfo.getFrameworkVersion().equals( defaultFrameworkVersion ) &&
+                    vendorInfo.getVendor().equals( defaultVendor ) )
                 {
                     vendorInfo.setVendorVersion( defaultVendorVersion );
-                    vendorInfo.setVendor( defaultVendor );
                     return VendorInfoState.NTT;
                 }
                 else
@@ -267,29 +261,60 @@
                     List<VendorInfo> v = vendorInfoRepository.getVendorInfosFor( vendorInfo,
true );
                     if ( !v.isEmpty() )
                     {
+                        Set<String> vendorVersions = new HashSet<String>();
                         for ( VendorInfo vi : v )
                         {
-                            if ( vi.getFrameworkVersion().equals( vendorInfo.getFrameworkVersion()
) )
+                           if ( vi.getFrameworkVersion().equals( vendorInfo.getFrameworkVersion()
) )
                             {
-                                vendorInfo.setVendorVersion( vi.getVendorVersion() );
-                                vendorInfo.setVendor( vi.getVendor() );
-                                return VendorInfoState.NTT;
+                                vendorVersions.add( vi.getVendorVersion() );
                             }
                         }
-                        return createVendorInfoSetterForNFT_NoSettings().process( vendorInfo
);
+
+                        if ( vendorVersions.size() > 0 )
+                        {
+                            try
+                            {
+                                vendorInfo.setVendorVersion(
+                                    vendorInfoRepository.getMaxVersion( vendorVersions )
);
+                            }
+                            catch ( InvalidVersionFormatException e )
+                            {
+                                logger.warn( "NMAVEN-103-039: Bad nmaven-settings.xml file",
e );
+                                return createVendorInfoSetterForNFT_NoSettings().process(
vendorInfo );
+                            }
+                            return VendorInfoState.NTT;
+                        }
+                        else
+                        {
+                           return createVendorInfoSetterForNFT_NoSettings().process( vendorInfo
);
+                        }
                     }
                     else
                     {
                         v = vendorInfoRepository.getVendorInfosFor( vendorInfo, false );
+                        Set<String> vendorVersions = new HashSet<String>();
                         for ( VendorInfo vi : v )
                         {
-                            if ( vi.getFrameworkVersion().equals( vendorInfo.getFrameworkVersion()
) )
+                           if ( vi.getFrameworkVersion().equals( vendorInfo.getFrameworkVersion()
) )
                             {
-                                vendorInfo.setVendorVersion( vi.getVendorVersion() );
-                                vendorInfo.setVendor( vi.getVendor() );
-                                return VendorInfoState.NTT;
+                                vendorVersions.add( vi.getVendorVersion() );
                             }
                         }
+
+                        if ( vendorVersions.size() > 0 )
+                        {
+                            try
+                            {
+                                vendorInfo.setVendorVersion(
+                                    vendorInfoRepository.getMaxVersion( vendorVersions )
);
+                            }
+                            catch ( InvalidVersionFormatException e )
+                            {
+                                logger.warn( "NMAVEN-103-040: Bad nmaven-settings.xml file",
e );
+                                return createVendorInfoSetterForNFT_NoSettings().process(
vendorInfo );
+                            }
+                            return VendorInfoState.NTT;
+                        }
                         return createVendorInfoSetterForNFT_NoSettings().process( vendorInfo
);
                     }
                 }
@@ -328,30 +353,64 @@
                     List<VendorInfo> v = vendorInfoRepository.getVendorInfosFor( vendorInfo,
true );
                     if ( !v.isEmpty() )
                     {
+                        Set<String> frameworkVersions = new HashSet<String>();
                         for ( VendorInfo vi : v )
                         {
                             if ( vi.getVendorVersion().equals( vendorInfo.getVendorVersion()
) )
                             {
-                                vendorInfo.setFrameworkVersion( vi.getFrameworkVersion()
);
-                                vendorInfo.setVendor( vi.getVendor() );
-                                return VendorInfoState.NTT;
+                                frameworkVersions.add( vi.getFrameworkVersion() );
+                            }
+                        }
+
+                        if ( frameworkVersions.size() > 0 )
+                        {
+                            try
+                            {
+                                vendorInfo.setFrameworkVersion(
+                                    vendorInfoRepository.getMaxVersion( frameworkVersions
) );
+                            }
+                            catch ( InvalidVersionFormatException e )
+                            {
+                                logger.warn( "NMAVEN-103-037: Bad nmaven-settings.xml file",
e );
+                                return createVendorInfoSetterForNTF_NoSettings().process(
vendorInfo );
                             }
+                            return VendorInfoState.NTT;
+                        }
+                        else
+                        {
+                            return createVendorInfoSetterForNTF_NoSettings().process( vendorInfo
);
                         }
-                        return createVendorInfoSetterForNTF_NoSettings().process( vendorInfo
);
                     }
                     else
                     {
                         v = vendorInfoRepository.getVendorInfosFor( vendorInfo, false );
+                        Set<String> frameworkVersions = new HashSet<String>();
                         for ( VendorInfo vi : v )
                         {
                             if ( vi.getVendorVersion().equals( vendorInfo.getVendorVersion()
) )
                             {
-                                vendorInfo.setFrameworkVersion( vi.getFrameworkVersion()
);
-                                vendorInfo.setVendor( vi.getVendor() );
-                                return VendorInfoState.NTT;
+                                frameworkVersions.add( vi.getFrameworkVersion() );
+                            }
+                        }
+
+                        if ( frameworkVersions.size() > 0 )
+                        {
+                            try
+                            {
+                                vendorInfo.setFrameworkVersion(
+                                    vendorInfoRepository.getMaxVersion( frameworkVersions
) );
+                            }
+                            catch ( InvalidVersionFormatException e )
+                            {
+                                logger.warn( "NMAVEN-103-038: Bad nmaven-settings.xml file",
e );
+                                return createVendorInfoSetterForNTF_NoSettings().process(
vendorInfo );
                             }
+                            return VendorInfoState.NTT;
+                        }
+                        else
+                        {
+                            return createVendorInfoSetterForNTF_NoSettings().process( vendorInfo
);
                         }
-                        return createVendorInfoSetterForNTF_NoSettings().process( vendorInfo
);
                     }
                 }
             }

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VersionMatcher.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VersionMatcher.java?view=diff&rev=521968&r1=521967&r2=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VersionMatcher.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/VersionMatcher.java
Fri Mar 23 19:52:36 2007
@@ -127,12 +127,32 @@
         while ( i.hasNext() )
         {
             String testValue = (String) i.next();
-            if ( isGreaterThan( testValue, maxVersion ) )
+            if ( isGreaterThan(maxVersion, testValue ) )
             {
                 maxVersion = testValue;
             }
         }
         return maxVersion;
+    }
+
+    String getMinVersion( Set<String> versions )
+        throws InvalidVersionFormatException
+    {
+        if ( versions.isEmpty() )
+        {
+            return null;
+        }
+        Iterator i = versions.iterator();
+        String minVersion = (String) i.next();
+        while ( i.hasNext() )
+        {
+            String testValue = (String) i.next();
+            if ( isGreaterThan( testValue, minVersion ) )
+            {
+                minVersion = testValue;
+            }
+        }
+        return minVersion;
     }
 
     /**

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/RepositoryRegistryTestStub.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/RepositoryRegistryTestStub.java?view=auto&rev=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/RepositoryRegistryTestStub.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/RepositoryRegistryTestStub.java
Fri Mar 23 19:52:36 2007
@@ -0,0 +1,72 @@
+package org.apache.maven.dotnet.vendor.impl;
+
+import org.apache.maven.dotnet.registry.RepositoryRegistry;
+import org.apache.maven.dotnet.registry.RepositoryLoader;
+import org.apache.maven.dotnet.registry.RegistryLoader;
+import org.apache.maven.dotnet.registry.Repository;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Set;
+
+final class RepositoryRegistryTestStub
+    implements RepositoryRegistry
+{
+    private SettingsRepository settingsRepository;
+
+    public boolean isEmpty()
+    {
+        return false;
+    }
+
+    public synchronized void setRepositoryLoader( RepositoryLoader loader )
+    {
+    }
+
+    public synchronized void setRegistryLoader( RegistryLoader loader )
+    {
+    }
+
+    public synchronized void loadFromInputStream( InputStream inputStream )
+        throws IOException
+    {
+    }
+
+    public synchronized void loadFromFile( String fileName )
+        throws IOException
+    {
+    }
+
+    public synchronized void loadFromResource( String fileName, Class sourceClass )
+        throws IOException
+    {
+    }
+
+    public synchronized void addRepository( String name, Repository repository )
+    {
+    }
+
+    public synchronized Repository find( String name )
+    {
+        return settingsRepository;
+    }
+
+    public synchronized void removeRepository( String name )
+    {
+    }
+
+    public synchronized Set getRepositoryNames()
+    {
+        return null;
+    }
+
+    public synchronized void empty()
+    {
+    }
+
+    void setSettingRepository(SettingsRepository settingsRepository)
+    {
+        this.settingsRepository = settingsRepository;
+    }
+}

Propchange: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/RepositoryRegistryTestStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTestStub.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTestStub.java?view=auto&rev=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTestStub.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTestStub.java
Fri Mar 23 19:52:36 2007
@@ -0,0 +1,18 @@
+package org.apache.maven.dotnet.vendor.impl;
+
+import org.apache.maven.dotnet.model.settings.DefaultSetup;
+
+final class SettingsRepositoryTestStub extends SettingsRepository
+{
+    private DefaultSetup defaultSetup;
+
+    DefaultSetup getDefaultSetup()
+    {
+        return defaultSetup;
+    }
+
+    void setDefaultSetup(DefaultSetup defaultSetup)
+    {
+        this.defaultSetup = defaultSetup;
+    }
+}

Propchange: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTestStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoRepositoryTestStub.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoRepositoryTestStub.java?view=auto&rev=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoRepositoryTestStub.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoRepositoryTestStub.java
Fri Mar 23 19:52:36 2007
@@ -0,0 +1,63 @@
+package org.apache.maven.dotnet.vendor.impl;
+
+import org.apache.maven.dotnet.vendor.VendorInfoRepository;
+import org.apache.maven.dotnet.vendor.VendorInfo;
+import org.apache.maven.dotnet.vendor.InvalidVersionFormatException;
+
+import org.apache.maven.dotnet.PlatformUnsupportedException;
+
+import java.io.File;
+import java.util.List;
+import java.util.Set;
+import java.util.ArrayList;
+
+public class VendorInfoRepositoryTestStub
+    implements VendorInfoRepository
+{
+
+    private List<VendorInfo> vendorInfos;
+
+    public boolean exists()
+    {
+        return true;
+    }
+
+    public File getInstallRootFor( VendorInfo vendorInfo )
+        throws PlatformUnsupportedException
+    {
+        return null;
+    }
+
+    public File getSdkInstallRootFor( VendorInfo vendorInfo )
+        throws PlatformUnsupportedException
+    {
+        return null;
+    }
+
+    public List<VendorInfo> getVendorInfos()
+    {
+        return new ArrayList<VendorInfo>();
+    }
+
+    public String getMaxVersion( Set<String> versions )
+        throws InvalidVersionFormatException
+    {
+        return new VersionMatcher().getMaxVersion( versions );
+    }
+
+    public List<VendorInfo> getVendorInfosFor( String vendorName, String vendorVersion,
String frameworkVersion,
+                                               boolean isDefault )
+    {
+        return new ArrayList<VendorInfo>();
+    }
+
+    public List<VendorInfo> getVendorInfosFor( VendorInfo vendorInfo, boolean isDefault
)
+    {
+        return vendorInfos;
+    }
+
+    void setVendorInfos( List<VendorInfo> vendorInfos )
+    {
+        this.vendorInfos = vendorInfos;
+    }
+}

Propchange: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoRepositoryTestStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java?view=auto&rev=521968
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
Fri Mar 23 19:52:36 2007
@@ -0,0 +1,164 @@
+package org.apache.maven.dotnet.vendor.impl;
+
+import junit.framework.TestCase;
+import org.apache.maven.dotnet.InitializationException;
+import org.apache.maven.dotnet.vendor.VendorInfoTransitionRule;
+import org.apache.maven.dotnet.vendor.VendorInfo;
+import org.apache.maven.dotnet.vendor.VendorInfoState;
+import org.apache.maven.dotnet.vendor.Vendor;
+import org.apache.maven.dotnet.model.settings.DefaultSetup;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.logging.Logger;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class VendorInfoTransitionRuleFactoryTest
+    extends TestCase
+{
+    public void testNTF()
+    {
+        List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322" ) );
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
+
+        VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
+            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
+
+        VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNTF();
+        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, "1.1.18", null );
+        VendorInfoState vendorInfoState = rule.process( vendorInfo );
+        assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.NTT );
+        assertEquals( Vendor.MONO, vendorInfo.getVendor() );
+        assertEquals( "2.0.50727", vendorInfo.getFrameworkVersion() );
+        assertEquals( "1.1.18", vendorInfo.getVendorVersion() );
+    }
+
+    public void testNFF()
+    {
+        List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322" ) );
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
+
+        VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
+            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
+
+        VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFF();
+        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, null );
+        VendorInfoState vendorInfoState = rule.process( vendorInfo );
+        assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.POST_PROCESS
);
+        assertEquals( Vendor.MONO, vendorInfo.getVendor() );
+        assertEquals( "2.0.50727", vendorInfo.getFrameworkVersion() );
+        assertEquals( "1.1.18", vendorInfo.getVendorVersion() );
+    }
+
+    public void testNFF_MatchDefaultVendor()
+    {
+        List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322" ) );
+
+        VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
+            Factory.getDefaultSetup( "MONO", "1.1.18", "1.1.4322" ), vendorInfoList );
+
+        VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFF();
+        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, null );
+        VendorInfoState vendorInfoState = rule.process( vendorInfo );
+        assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.POST_PROCESS
);
+        assertEquals( Vendor.MONO, vendorInfo.getVendor() );
+        assertEquals( "1.1.4322", vendorInfo.getFrameworkVersion() );
+        assertEquals( "1.1.18", vendorInfo.getVendorVersion() );
+    }
+
+    public void testNFT()
+    {
+        List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.13", "2.0.50727" ) );
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
+
+        VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
+            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
+
+        VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFT();
+        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, "2.0.50727" );
+        VendorInfoState vendorInfoState = rule.process( vendorInfo );
+        assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.NTT );
+        assertEquals( Vendor.MONO, vendorInfo.getVendor() );
+        assertEquals( "2.0.50727", vendorInfo.getFrameworkVersion() );
+        assertEquals( "1.1.18", vendorInfo.getVendorVersion() );
+    }
+
+    public void testNFT_WithMatchingDefault()
+    {
+        List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
+        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
+
+        VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
+            Factory.getDefaultSetup( "MONO", "1.1.18", "2.0.50727" ), vendorInfoList );
+
+        VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFT();
+        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, "2.0.50727" );
+        VendorInfoState vendorInfoState = rule.process( vendorInfo );
+        assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.NTT );
+        assertEquals( Vendor.MONO, vendorInfo.getVendor() );
+        assertEquals( "2.0.50727", vendorInfo.getFrameworkVersion() );
+        assertEquals( "1.1.18", vendorInfo.getVendorVersion() );
+    }
+
+    public void testNFT_CantFindMatchingVendorInfo()
+    {
+        VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
+            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), new ArrayList<VendorInfo>()
);
+
+        VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFT();
+        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, "2.0.50727" );
+        VendorInfoState vendorInfoState = rule.process( vendorInfo );
+        assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.POST_PROCESS
);
+    }
+
+    private static class Factory
+    {
+        static VendorInfoTransitionRuleFactory getVendorInfoTransitionRuleFactory( DefaultSetup
defaultSetup,
+                                                                                   List<VendorInfo>
vendorInfos )
+        {
+            SettingsRepositoryTestStub settingsRepository = new SettingsRepositoryTestStub();
+            settingsRepository.setDefaultSetup( defaultSetup );
+
+            RepositoryRegistryTestStub repositoryRegistry = new RepositoryRegistryTestStub();
+            repositoryRegistry.setSettingRepository( settingsRepository );
+
+            VendorInfoRepositoryTestStub vendorInfoRepository = new VendorInfoRepositoryTestStub();
+            vendorInfoRepository.setVendorInfos( vendorInfos );
+
+            VendorInfoTransitionRuleFactory factory = new VendorInfoTransitionRuleFactory();
+            try
+            {
+                factory.init( repositoryRegistry, vendorInfoRepository,
+                              new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
+            }
+            catch ( InitializationException e )
+            {
+                e.printStackTrace();
+            }
+            return factory;
+        }
+
+        static VendorInfo getVendorInfo( Vendor vendor, String vendorVersion, String frameworkVersion
)
+        {
+            VendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
+            vendorInfo.setVendor( vendor );
+            vendorInfo.setFrameworkVersion( frameworkVersion );
+            vendorInfo.setVendorVersion( vendorVersion );
+            return vendorInfo;
+        }
+
+        static DefaultSetup getDefaultSetup( String vendorName, String vendorVersion, String
frameworkVersion )
+        {
+            DefaultSetup defaultSetup = new DefaultSetup();
+            defaultSetup.setVendorName( vendorName );
+            defaultSetup.setVendorVersion( vendorVersion );
+            defaultSetup.setFrameworkVersion( frameworkVersion );
+            return defaultSetup;
+        }
+    }
+}

Propchange: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message