incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r522343 - in /incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src: main/java/org/apache/maven/dotnet/vendor/ main/java/org/apache/maven/dotnet/vendor/impl/ test/java/org/apache/maven/dotnet/vendor/ test/java/org/apache/maven/dotne...
Date Sun, 25 Mar 2007 20:25:57 GMT
Author: sisbell
Date: Sun Mar 25 13:25:56 2007
New Revision: 522343

URL: http://svn.apache.org/viewvc?view=rev&rev=522343
Log:
More unit tests for dotnet-vendor.

Added:
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorInfoStateTest.java
  (with props)
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorTestFactory.java
  (with props)
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/MatchPolicyFactoryTest.java
  (with props)
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTest.java
  (with props)
Removed:
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTestStub.java
Modified:
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoState.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/SettingsRepository.java
    incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoState.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoState.java?view=diff&rev=522343&r1=522342&r2=522343
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoState.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/VendorInfoState.java
Sun Mar 25 13:25:56 2007
@@ -252,5 +252,5 @@
         {
             return EXIT;
         }
-    }
+    }    
 }

Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/SettingsRepository.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/SettingsRepository.java?view=diff&rev=522343&r1=522342&r2=522343
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/SettingsRepository.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/main/java/org/apache/maven/dotnet/vendor/impl/SettingsRepository.java
Sun Mar 25 13:25:56 2007
@@ -42,7 +42,7 @@
  *
  * @author Shane Isbell
  */
-public class SettingsRepository
+public final class SettingsRepository
     implements Repository
 {
 

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorInfoStateTest.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorInfoStateTest.java?view=auto&rev=522343
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorInfoStateTest.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorInfoStateTest.java
Sun Mar 25 13:25:56 2007
@@ -0,0 +1,141 @@
+package org.apache.maven.dotnet.vendor;
+
+import junit.framework.TestCase;
+
+public class VendorInfoStateTest
+    extends TestCase
+{
+
+    public void testMTT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MICROSOFT,
"2.0.50727", "2.0.50727" ) );
+        assert(VendorInfoState.MTT.equals( vendorInfoState));
+    }
+
+    public void testMFT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MICROSOFT,
null, "2.0.50727" ) );
+        assert(VendorInfoState.MFT.equals( vendorInfoState));
+    }
+
+    public void testMFF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MICROSOFT,
null, null ) );
+        assert(VendorInfoState.MFF.equals( vendorInfoState));
+    }
+
+    public void testMTF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MICROSOFT,
"2.0.50727", null ) );
+        assert(VendorInfoState.MTF.equals( vendorInfoState));
+    }
+
+    public void testNTT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18",
"2.0.50727" ) );
+        assert(VendorInfoState.NTT.equals( vendorInfoState));
+    }
+
+    public void testNFT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MONO, null,
"2.0.50727" ) );
+        assert(VendorInfoState.NFT.equals( vendorInfoState));
+    }
+
+    public void testNFF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MONO, null,
null ) );
+        assert(VendorInfoState.NFF.equals( vendorInfoState));
+    }
+
+    public void testNTF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18",
null ) );
+        assert(VendorInfoState.NTF.equals( vendorInfoState));
+    }
+
+    public void testGTT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.DOTGNU,
"0.7.2", "2.0.50727" ) );
+        assert(VendorInfoState.GTT.equals( vendorInfoState));
+    }
+
+    public void testGFT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.DOTGNU,
null, "2.0.50727" ) );
+        assert(VendorInfoState.GFT.equals( vendorInfoState));
+    }
+
+    public void testGFF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.DOTGNU,
null, null ) );
+        assert(VendorInfoState.GFF.equals( vendorInfoState));
+    }
+
+    public void testGTF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.DOTGNU,
"0.7.2", null ) );
+        assert(VendorInfoState.GTF.equals( vendorInfoState));
+    }
+
+    public void testFTT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( null, "0.7.2",
"2.0.50727" ) );
+        assert(VendorInfoState.FTT.equals( vendorInfoState));
+    }
+
+    public void testFFT()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo(null, null, "2.0.50727"
) );
+        assert(VendorInfoState.FFT.equals( vendorInfoState));
+    }
+
+    public void testFFF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( null, null, null
) );
+        assert(VendorInfoState.FFF.equals( vendorInfoState));
+    }
+
+    public void testFTF()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( null, "0.7.2",
null ) );
+        assert(VendorInfoState.FTF.equals( vendorInfoState));
+    }
+
+    public void testGFT_WithEmptyStrings()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.DOTGNU,
"", "2.0.50727" ) );
+        assert(VendorInfoState.GFT.equals( vendorInfoState));
+    }
+
+    public void testGFF_WithEmptyStrings()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.DOTGNU,
"", "" ) );
+        assert(VendorInfoState.GFF.equals( vendorInfoState));
+    }
+
+    public void testGTF_WithEmptyStrings()
+    {
+        VendorInfoState vendorInfoState =
+            VendorInfoState.NULL.getState(VendorTestFactory.getVendorInfo( Vendor.DOTGNU,
"0.7.2", "" ) );
+        assert(VendorInfoState.GTF.equals( vendorInfoState));
+    }
+}

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

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorTestFactory.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorTestFactory.java?view=auto&rev=522343
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorTestFactory.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/VendorTestFactory.java
Sun Mar 25 13:25:56 2007
@@ -0,0 +1,37 @@
+package org.apache.maven.dotnet.vendor;
+
+import org.apache.maven.dotnet.model.settings.DefaultSetup;
+
+import java.io.File;
+import java.util.List;
+
+public class VendorTestFactory
+{
+    public 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;
+    }
+
+    public static VendorInfo getVendorInfo( Vendor vendor, String vendorVersion, String frameworkVersion,
+                                            List<File> executablePaths )
+    {
+        VendorInfo vendorInfo = getVendorInfo(vendor, vendorVersion, frameworkVersion);
+        vendorInfo.setExecutablePaths( executablePaths );
+
+        return vendorInfo;
+    }
+
+    public 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/VendorTestFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/MatchPolicyFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/MatchPolicyFactoryTest.java?view=auto&rev=522343
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/MatchPolicyFactoryTest.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/MatchPolicyFactoryTest.java
Sun Mar 25 13:25:56 2007
@@ -0,0 +1,73 @@
+package org.apache.maven.dotnet.vendor.impl;
+
+import junit.framework.TestCase;
+import org.codehaus.plexus.logging.console.ConsoleLogger;
+import org.codehaus.plexus.logging.Logger;
+import org.apache.maven.dotnet.vendor.VendorInfoMatchPolicy;
+import org.apache.maven.dotnet.vendor.VendorInfo;
+import org.apache.maven.dotnet.vendor.VendorTestFactory;
+import org.apache.maven.dotnet.vendor.Vendor;
+
+public class MatchPolicyFactoryTest
+    extends TestCase
+{
+    private MatchPolicyFactory matchPolicyFactory;
+
+    private Logger logger;
+
+    public void setUp()
+    {
+        matchPolicyFactory = new MatchPolicyFactory();
+        logger = new ConsoleLogger( Logger.LEVEL_WARN, "test" );
+        matchPolicyFactory.init( logger );
+    }
+
+    public void testCreateVendorNamePolicy()
+    {
+        VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createVendorNamePolicy( "MICROSOFT"
);
+        assertTrue( matchPolicy.match( VendorTestFactory.getVendorInfo( Vendor.MICROSOFT,
"", "" ) ) );
+        assertFalse( matchPolicy.match( VendorTestFactory.getVendorInfo( Vendor.MONO, "",
"" ) ) );
+    }
+
+    public void testCreateVendorVersionPolicy()
+    {
+        VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createVendorVersionPolicy(
"1.1.18" );
+        assertTrue( matchPolicy.match( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18",
"" ) ) );
+        assertFalse( matchPolicy.match( VendorTestFactory.getVendorInfo( Vendor.MONO, "2.1.18",
"" ) ) );
+    }
+
+    public void testCreateFrameworkVersionPolicy()
+    {
+        VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createFrameworkVersionPolicy(
"2.0.50727" );
+        assertTrue( matchPolicy.match( VendorTestFactory.getVendorInfo( Vendor.MONO, "",
"2.0.50727" ) ) );
+        assertFalse( matchPolicy.match( VendorTestFactory.getVendorInfo( Vendor.MONO, "",
"1.1.4322" ) ) );
+    }
+
+    public void testCreateFrameworkVersionPolicy_WithNullValue()
+    {
+        VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createFrameworkVersionPolicy(
"2.0.50727" );
+        assertFalse( matchPolicy.match( VendorTestFactory.getVendorInfo( Vendor.MONO, "",
null ) ) );
+    }
+
+    public void testCreateIsDefaultPolicy_WithNullVendorInfo()
+    {
+        VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createVendorIsDefaultPolicy();
+        assertFalse( matchPolicy.match( null ) );
+    }
+
+    public void testCreateIsDefaultPolicy_False()
+    {
+        VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createVendorIsDefaultPolicy();
+        VendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
+        vendorInfo.setDefault( false );
+        assertFalse( matchPolicy.match( vendorInfo ) );
+    }
+
+    public void testCreateIsDefaultPolicy_True()
+    {
+        VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createVendorIsDefaultPolicy();
+        VendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
+        vendorInfo.setDefault( true );
+        assertTrue( matchPolicy.match( vendorInfo ) );
+    }
+}

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

Added: incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTest.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTest.java?view=auto&rev=522343
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTest.java
(added)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/SettingsRepositoryTest.java
Sun Mar 25 13:25:56 2007
@@ -0,0 +1,75 @@
+package org.apache.maven.dotnet.vendor.impl;
+
+import junit.framework.TestCase;
+
+import java.lang.reflect.Field;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.File;
+
+import org.apache.maven.dotnet.model.settings.DefaultSetup;
+import org.apache.maven.dotnet.model.settings.Framework;
+import org.apache.maven.dotnet.model.settings.Vendor;
+import org.apache.maven.dotnet.vendor.VendorTestFactory;
+import org.apache.maven.dotnet.PlatformUnsupportedException;
+
+public class SettingsRepositoryTest
+    extends TestCase
+{
+    public void testGetInstallRoot()
+    {
+        DefaultSetup defaultSetup = VendorTestFactory.getDefaultSetup( "MICROSOFT", "2.0.50727",
"2.0.50727" );
+
+        //Supported Types
+        List<Vendor> vendors = new ArrayList<Vendor>();
+        Vendor vendor = new Vendor();
+        vendor.setVendorName("MICROSOFT");
+        vendor.setVendorVersion("2.0.50727");
+
+        Framework framework = new Framework();
+        framework.setFrameworkVersion("2.0.50727");
+        framework.setInstallRoot("C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727");
+        framework.setSdkInstallRoot("C:\\Program Files\\Microsoft.NET\\SDK\\v2.0");
+        vendor.addFramework( framework );
+
+        vendors.add( vendor );
+
+        SettingsRepository settingsRepository = Factory.createSettingsRepository( vendors,
defaultSetup );
+        try
+        {
+            File installRoot = settingsRepository.getInstallRootFor(  "MICROSOFT", "2.0.50727",
"2.0.50727");
+            assertEquals( new File("C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727"),
installRoot );
+        }
+        catch ( PlatformUnsupportedException e )
+        {
+            fail("Unsupported Platform: Message = " + e.getMessage());
+        }
+    }
+
+    private static class Factory
+    {
+        static SettingsRepository createSettingsRepository( List<Vendor> vendors, DefaultSetup
defaultSetup )
+        {
+            SettingsRepository settingsRepository = new SettingsRepository();
+            try
+            {
+                Field defaultSetupField = settingsRepository.getClass().getDeclaredField(
"defaultSetup" );
+                defaultSetupField.setAccessible( true );
+                defaultSetupField.set( settingsRepository, defaultSetup );
+
+                Field vendorsField = settingsRepository.getClass().getDeclaredField( "vendors"
);
+                vendorsField.setAccessible( true );
+                vendorsField.set( settingsRepository, vendors );
+            }
+            catch ( NoSuchFieldException e )
+            {
+                e.printStackTrace();
+            }
+            catch ( IllegalAccessException e )
+            {
+                e.printStackTrace();
+            }
+            return settingsRepository;
+        }
+    }
+}

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

Modified: 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=diff&rev=522343&r1=522342&r2=522343
==============================================================================
--- incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
(original)
+++ incubator/nmaven/branches/SI_XPT/components/dotnet-vendor/src/test/java/org/apache/maven/dotnet/vendor/impl/VendorInfoTransitionRuleFactoryTest.java
Sun Mar 25 13:25:56 2007
@@ -6,12 +6,14 @@
 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.vendor.VendorTestFactory;
 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;
+import java.lang.reflect.Field;
 
 public class VendorInfoTransitionRuleFactoryTest
     extends TestCase
@@ -19,17 +21,17 @@
     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" ) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322"
) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727"
) );
 
         VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
-            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
+            VendorTestFactory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
 
         VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNTF();
-        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, "1.1.18", null );
+        VendorInfo vendorInfo = VendorTestFactory.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( "Incorrect Vendor", Vendor.MONO, vendorInfo.getVendor() );
         assertEquals( "2.0.50727", vendorInfo.getFrameworkVersion() );
         assertEquals( "1.1.18", vendorInfo.getVendorVersion() );
     }
@@ -37,14 +39,14 @@
     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" ) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322"
) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727"
) );
 
         VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
-            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
+            VendorTestFactory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
 
         VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFF();
-        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, null );
+        VendorInfo vendorInfo = VendorTestFactory.getVendorInfo( Vendor.MONO, null, null
);
         VendorInfoState vendorInfoState = rule.process( vendorInfo );
         assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.POST_PROCESS
);
         assertEquals( Vendor.MONO, vendorInfo.getVendor() );
@@ -55,14 +57,14 @@
     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" ) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727"
) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "1.1.4322"
) );
 
         VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
-            Factory.getDefaultSetup( "MONO", "1.1.18", "1.1.4322" ), vendorInfoList );
+            VendorTestFactory.getDefaultSetup( "MONO", "1.1.18", "1.1.4322" ), vendorInfoList
);
 
         VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFF();
-        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, null );
+        VendorInfo vendorInfo = VendorTestFactory.getVendorInfo( Vendor.MONO, null, null
);
         VendorInfoState vendorInfoState = rule.process( vendorInfo );
         assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.POST_PROCESS
);
         assertEquals( Vendor.MONO, vendorInfo.getVendor() );
@@ -73,14 +75,14 @@
     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" ) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.13", "2.0.50727"
) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727"
) );
 
         VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
-            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
+            VendorTestFactory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), vendorInfoList
);
 
         VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFT();
-        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, "2.0.50727" );
+        VendorInfo vendorInfo = VendorTestFactory.getVendorInfo( Vendor.MONO, null, "2.0.50727"
);
         VendorInfoState vendorInfoState = rule.process( vendorInfo );
         assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.NTT );
         assertEquals( Vendor.MONO, vendorInfo.getVendor() );
@@ -91,13 +93,13 @@
     public void testNFT_WithMatchingDefault()
     {
         List<VendorInfo> vendorInfoList = new ArrayList<VendorInfo>();
-        vendorInfoList.add( Factory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727" ) );
+        vendorInfoList.add( VendorTestFactory.getVendorInfo( Vendor.MONO, "1.1.18", "2.0.50727"
) );
 
         VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
-            Factory.getDefaultSetup( "MONO", "1.1.18", "2.0.50727" ), vendorInfoList );
+            VendorTestFactory.getDefaultSetup( "MONO", "1.1.18", "2.0.50727" ), vendorInfoList
);
 
         VendorInfoTransitionRule rule = factory.createVendorInfoSetterForNFT();
-        VendorInfo vendorInfo = Factory.getVendorInfo( Vendor.MONO, null, "2.0.50727" );
+        VendorInfo vendorInfo = VendorTestFactory.getVendorInfo( Vendor.MONO, null, "2.0.50727"
);
         VendorInfoState vendorInfoState = rule.process( vendorInfo );
         assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.NTT );
         assertEquals( Vendor.MONO, vendorInfo.getVendor() );
@@ -108,10 +110,10 @@
     public void testNFT_CantFindMatchingVendorInfo()
     {
         VendorInfoTransitionRuleFactory factory = Factory.getVendorInfoTransitionRuleFactory(
-            Factory.getDefaultSetup( "MICROSOFT", "2.0.50727", "2.0.50727" ), new ArrayList<VendorInfo>()
);
+            VendorTestFactory.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" );
+        VendorInfo vendorInfo = VendorTestFactory.getVendorInfo( Vendor.MONO, null, "2.0.50727"
);
         VendorInfoState vendorInfoState = rule.process( vendorInfo );
         assertEquals( "Incorrect Vendor State", vendorInfoState, VendorInfoState.POST_PROCESS
);
     }
@@ -121,9 +123,21 @@
         static VendorInfoTransitionRuleFactory getVendorInfoTransitionRuleFactory( DefaultSetup
defaultSetup,
                                                                                    List<VendorInfo>
vendorInfos )
         {
-            SettingsRepositoryTestStub settingsRepository = new SettingsRepositoryTestStub();
-            settingsRepository.setDefaultSetup( defaultSetup );
-
+            SettingsRepository settingsRepository = new SettingsRepository();
+            try
+            {
+                Field field = settingsRepository.getClass().getDeclaredField( "defaultSetup"
);
+                field.setAccessible( true );
+                field.set( settingsRepository, defaultSetup );
+            }
+            catch ( NoSuchFieldException e )
+            {
+                e.printStackTrace();
+            }
+            catch ( IllegalAccessException e )
+            {
+                e.printStackTrace();
+            }
             RepositoryRegistryTestStub repositoryRegistry = new RepositoryRegistryTestStub();
             repositoryRegistry.setSettingRepository( settingsRepository );
 
@@ -134,31 +148,13 @@
             try
             {
                 factory.init( repositoryRegistry, vendorInfoRepository,
-                              new ConsoleLogger( Logger.LEVEL_DEBUG, "test" ) );
+                              new ConsoleLogger( Logger.LEVEL_INFO, "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;
         }
     }
 }



Mime
View raw message