Subversion Repositories DevTools

Rev

Rev 7163 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7163 Rev 7186
Line 1... Line 1...
1
package com.erggroup.buildtool.utf;
1
package com.erggroup.buildtool.utf;
2
 
2
 
3
 
3
 
4
import java.sql.SQLException;
4
import java.sql.SQLException;
5
import java.util.ArrayList;
-
 
6
import java.util.Date;
5
import java.util.Date;
7
import java.util.Iterator;
6
import java.util.Iterator;
8
 
7
 
9
import com.erggroup.buildtool.daemon.BuildDaemon;
8
import com.erggroup.buildtool.daemon.BuildDaemon;
10
import com.erggroup.buildtool.daemon.BuildThread;
9
import com.erggroup.buildtool.daemon.BuildThread;
Line 14... Line 13...
14
import com.erggroup.buildtool.ripple.BuildFile.BuildFileState;
13
import com.erggroup.buildtool.ripple.BuildFile.BuildFileState;
15
import com.erggroup.buildtool.ripple.BuildStandard;
14
import com.erggroup.buildtool.ripple.BuildStandard;
16
import com.erggroup.buildtool.ripple.ReleaseConfig;
15
import com.erggroup.buildtool.ripple.ReleaseConfig;
17
import com.erggroup.buildtool.ripple.ReleaseManager;
16
import com.erggroup.buildtool.ripple.ReleaseManager;
18
import com.erggroup.buildtool.ripple.Package;
17
import com.erggroup.buildtool.ripple.Package;
-
 
18
import com.erggroup.buildtool.ripple.PackageCollection;
19
import com.erggroup.buildtool.ripple.RippleEngine;
19
import com.erggroup.buildtool.ripple.RippleEngine;
20
import com.erggroup.buildtool.ripple.RunLevelData;
20
import com.erggroup.buildtool.ripple.RunLevelData;
21
import com.erggroup.buildtool.ripple.RunLevel.BuildState;
21
import com.erggroup.buildtool.ripple.RunLevel.BuildState;
22
 
22
 
23
import org.slf4j.Logger;
23
import org.slf4j.Logger;
Line 37... Line 37...
37
public class DaemonBuildTestCase
37
public class DaemonBuildTestCase
38
{
38
{
39
    private static final Logger mLogger = LoggerFactory.getLogger(DaemonBuildTestCase.class);
39
    private static final Logger mLogger = LoggerFactory.getLogger(DaemonBuildTestCase.class);
40
    myReleaseManager            releaseManager = null;
40
    myReleaseManager            releaseManager = null;
41
    RippleEngine                rippleEngine   = null;
41
    RippleEngine                rippleEngine   = null;
42
    ArrayList<Package> testPackageCollection   = new ArrayList<Package>();
42
    PackageCollection testPackageCollection   = new PackageCollection();
-
 
43
    PackageCollection testPackageCollectionWip   = new PackageCollection();
43
    
44
    
44
    /**
45
    /**
45
     * Init the package set
46
     * Init the package set
46
     */
47
     */
47
    public void initTestPackages(String setName)
48
    public void initTestPackages(String setName)
Line 54... Line 55...
54
     * @param newPvId
55
     * @param newPvId
55
     * @param alias
56
     * @param alias
56
     */
57
     */
57
    private Package createWip(int newPvId, String alias) {
58
    private Package createWip(int newPvId, String alias) {
58
 
59
 
-
 
60
    	Package wip = testPackageCollection.contains(alias);
-
 
61
    	if (wip == null)
-
 
62
    	{
59
        Package wip = ReleaseManager.NULL_PACKAGE;
63
    		wip = ReleaseManager.NULL_PACKAGE;
-
 
64
    	}
-
 
65
    	else
-
 
66
    	{
-
 
67
            wip = new Package(newPvId, wip);
-
 
68
            wip.mDirectlyPlanned = true;
-
 
69
            testPackageCollectionWip.add(wip);
-
 
70
    	}
60
 
71
 
61
        for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
-
 
62
        {
-
 
63
            Package p = it.next();
-
 
64
 
-
 
65
            if ( p.mAlias.compareTo( alias ) == 0 )
-
 
66
            {
-
 
67
                wip = new Package(newPvId, p);
-
 
68
                wip.mDirectlyPlanned = true;
-
 
69
                testPackageCollection.add(wip);
-
 
70
                break;
-
 
71
            }
-
 
72
        }
-
 
73
        return wip;
72
        return wip;
74
    }
73
    }
75
 
74
 
76
    
75
    
77
       
76
       
Line 92... Line 91...
92
		{
91
		{
93
			super();
92
			super();
94
		}
93
		}
95
		
94
		
96
		@Override
95
		@Override
97
		public void queryPackageVersions(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
96
		public void queryPackageVersions(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
98
		{
97
		{
99
		 
98
		 
100
		    //    Filter for the packages that are in the release
99
		    //    Filter for the packages that are in the release
101
		    for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
100
		    for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
102
	        {
101
	        {
Line 111... Line 110...
111
	        }
110
	        }
112
 
111
 
113
		}
112
		}
114
		
113
		
115
		@Override
114
		@Override
116
        public void queryWips(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
115
        public void queryWips(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
117
        {
116
        {
118
            //    Filter for the packages that are WIPs
117
            //    Filter for the packages that are WIPs
119
            for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
118
            for (Iterator<Package> it = testPackageCollectionWip.iterator(); it.hasNext(); )
120
            {
119
            {
121
                Package p = it.next();
120
                Package p = it.next();
122
                if (p.mDirectlyPlanned )
121
                if (p.mDirectlyPlanned )
123
                {
122
                {
124
                    p.mIsNotReleased = true;
123
                    p.mIsNotReleased = true;
Line 131... Line 130...
131
            }
130
            }
132
 
131
 
133
        }
132
        }
134
		
133
		
135
		@Override
134
		@Override
136
        public void queryTest(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
135
        public void queryTest(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
137
        {
136
        {
138
		    //    Filter for the packages that are TEST builds
137
		    //    Filter for the packages that are TEST builds
139
            for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
138
            for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
140
            {
139
            {
141
    		    Package p = it.next();
140
    		    Package p = it.next();
Line 149... Line 148...
149
            }
148
            }
150
            
149
            
151
        }
150
        }
152
		
151
		
153
		@Override
152
		@Override
154
        public void queryRipples(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
153
        public void queryRipples(RippleEngine rippleEngine, PackageCollection packageCollection, int baseline) throws SQLException, Exception
155
        {
154
        {
156
		    //    Filter for the packages that are forced Ripples
155
		    //    Filter for the packages that are forced Ripples
157
            for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
156
            for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
158
            {		    
157
            {		    
159
    		    Package p = it.next();
158
    		    Package p = it.next();
Line 238... Line 237...
238
		 /** Build a single package collection
237
		 /** Build a single package collection
239
		     * It will be split up when requested by the classes under test 
238
		     * It will be split up when requested by the classes under test 
240
		     * 
239
		     * 
241
		     * @param packageCollection
240
		     * @param packageCollection
242
		     */
241
		     */
243
		    private void initTestPackages(RippleEngine rippleEngine, ArrayList<Package> packageCollection, String setName)
242
		    private void initTestPackages(RippleEngine rippleEngine, PackageCollection packageCollection, String setName)
244
		    {
243
		    {
245
		        packageCollection.clear();
244
		        packageCollection.clear();
246
 
245
 
247
		        /* a highly unlikely set of packages
246
		        /* a highly unlikely set of packages
248
		         * planned info
247
		         * planned info
Line 1091... Line 1090...
1091
		         
1090
		         
1092
		         // Insert sequence for later sorting
1091
		         // Insert sequence for later sorting
1093
		         Package.setSequence(packageCollection);
1092
		         Package.setSequence(packageCollection);
1094
	        
1093
	        
1095
		    }
1094
		    }
1096
		 
-
 
1097
	}
1095
	}
1098
 
1096
 
1099
 
1097
 
1100
    public DaemonBuildTestCase()
1098
    public DaemonBuildTestCase()
1101
    {
1099
    {
Line 1691... Line 1689...
1691
        buildFile = rippleEngine.getNextBuildFileContent();
1689
        buildFile = rippleEngine.getNextBuildFileContent();
1692
        assertTrue(buildFile != null);
1690
        assertTrue(buildFile != null);
1693
        assertTrue(buildFile.state == BuildFileState.Empty);
1691
        assertTrue(buildFile.state == BuildFileState.Empty);
1694
    }
1692
    }
1695
 
1693
 
1696
 
-
 
1697
    /**
-
 
1698
     * test method designed to test ripple field limits
-
 
1699
     * 1 tests applyPV returns 1 for package with version a.b.1.2.0
-
 
1700
     */
-
 
1701
    @Test
-
 
1702
    public void TestRippleFieldLimits()
-
 
1703
    {
-
 
1704
        ReleaseManager rm = new myReleaseManager();
-
 
1705
        // for test purposes, p.mId will contain the return value of applyPV
-
 
1706
        // test applyPV returns 1 and leaves mVersion alone
-
 
1707
        Package p = new Package(rm, "a.b.1.2.0", 255, 255, 255, 255);
-
 
1708
        assertTrue(p.getId() == 1);
-
 
1709
        assertTrue(p.getVersion().compareTo("a.b.1.2.0") == 0);
-
 
1710
 
-
 
1711
        // test applyPV returns 2 and leaves mVersion alone
-
 
1712
        p = new Package(rm, "1.0.0000", 0, 0, 0, 0);
-
 
1713
        assertTrue(p.getId() == 2);
-
 
1714
        assertTrue(p.getVersion().compareTo("1.0.0000") == 0);
-
 
1715
 
-
 
1716
        // test applyPV returns 2 and leaves mVersion alone
-
 
1717
        p = new Package(rm, "1.0.0009", 0, 0, 0, 9);
-
 
1718
        assertTrue(p.getId() == 2);
-
 
1719
        assertTrue(p.getVersion().compareTo("1.0.0009") == 0);
-
 
1720
 
-
 
1721
        // test applyPV returns 2 and leaves mVersion alone
-
 
1722
        p = new Package(rm, "1.0.9000", 0, 0, 9, 0);
-
 
1723
        assertTrue(p.getId() == 2);
-
 
1724
        assertTrue(p.getVersion().compareTo("1.0.9000") == 0);
-
 
1725
 
-
 
1726
        // test applyPV returns 2 and leaves mVersion alone
-
 
1727
        p = new Package(rm, "1.9.0000", 0, 9, 0, 0);
-
 
1728
        assertTrue(p.getId() == 2);
-
 
1729
        assertTrue(p.getVersion().compareTo("1.9.0000") == 0);
-
 
1730
 
-
 
1731
        // test applyPV returns 2 and leaves mVersion alone
-
 
1732
        p = new Package(rm, "1.0.0000", 1, 0, 0, 0);
-
 
1733
        assertTrue(p.getId() == 2);
-
 
1734
        assertTrue(p.getVersion().compareTo("1.0.0000") == 0);
-
 
1735
 
-
 
1736
        // test applyPV returns 2 and leaves mVersion alone - wince style limits
-
 
1737
        p = new Package(rm, "9.9.9000", 9, 9, 9, 0);
-
 
1738
        assertTrue(p.getId() == 2);
-
 
1739
        assertTrue(p.getVersion().compareTo("9.9.9000") == 0);
-
 
1740
 
-
 
1741
        // test applyPV returns 0 and sets mNextVersion from 8.8.8000 to 8.8.9000 and does not change mVersion
-
 
1742
        p = new Package(rm, "8.8.8000", 9, 9, 9, 0);
-
 
1743
        assertTrue(p.getId() == 0);
-
 
1744
        assertTrue(p.getVersion().compareTo("8.8.8000") == 0);
-
 
1745
        assertTrue(p.getNextVersion().compareTo("8.8.9000") == 0);
-
 
1746
 
-
 
1747
        // test applyPV returns 0 and sets mNextVersion from 8.8.9000 to 8.9.0000
-
 
1748
        p = new Package(rm, "8.8.9000", 9, 9, 9, 0);
-
 
1749
        assertTrue(p.getId() == 0);
-
 
1750
        assertTrue(p.getVersion().compareTo("8.8.9000") == 0);
-
 
1751
        assertTrue(p.getNextVersion().compareTo("8.9.0000") == 0);
-
 
1752
 
-
 
1753
        // test applyPV returns 0 and sets mNextVersion from 8.9.9000 to 9.0.0000
-
 
1754
        p = new Package(rm, "8.9.9000", 9, 9, 9, 0);
-
 
1755
        assertTrue(p.getId() == 0);
-
 
1756
        assertTrue(p.getVersion().compareTo("8.9.9000") == 0);
-
 
1757
        assertTrue(p.getNextVersion().compareTo("9.0.0000") == 0);
-
 
1758
 
-
 
1759
        // test applyPV returns 2 and leaves mVersion alone - mos style limits
-
 
1760
        p = new Package(rm, "99.99.0000", 99, 99, 0, 0);
-
 
1761
        assertTrue(p.getId() == 2);
-
 
1762
        assertTrue(p.getVersion().compareTo("99.99.0000") == 0);
-
 
1763
 
-
 
1764
        // test applyPV returns 0 and sets mNextVersion from 98.98.0000 to 98.99.0000
-
 
1765
        p = new Package(rm, "98.98.0000", 99, 99, 0, 0);
-
 
1766
        assertTrue(p.getId() == 0);
-
 
1767
        assertTrue(p.getVersion().compareTo("98.98.0000") == 0);
-
 
1768
        assertTrue(p.getNextVersion().compareTo("98.99.0000") == 0);
-
 
1769
 
-
 
1770
        // test applyPV returns 0 and sets mNextVersion from 98.99.0000 to 99.0.0000
-
 
1771
        p = new Package(rm, "98.99.0000", 99, 99, 0, 0);
-
 
1772
        assertTrue(p.getId() == 0);
-
 
1773
        assertTrue(p.getVersion().compareTo("98.99.0000") == 0);
-
 
1774
        assertTrue(p.getNextVersion().compareTo("99.0.0000") == 0);
-
 
1775
 
-
 
1776
    }
-
 
1777
 
-
 
1778
    /**
-
 
1779
     * test method designed to ripple of COTS packages
-
 
1780
     * 1 tests applyPV returns 1 for package with version a.b.1.2.0
-
 
1781
     */
-
 
1782
    @Test
-
 
1783
    public void TestCotsRipples()
-
 
1784
    {
-
 
1785
        ReleaseManager rm = new myReleaseManager();
-
 
1786
        // for test purposes, p.mId will contain the return value of applyPV
-
 
1787
        // test applyPV returns 1 and leaves mVersion alone
-
 
1788
 
-
 
1789
        mLogger.debug("TestCotsRipples: willNotRipple.cots");
-
 
1790
        Package p = new Package(rm, "willNotRipple.cots", 255, 255, 255, 255);
-
 
1791
        assertTrue(p.getId() == 1);
-
 
1792
        assertTrue(p.getVersion().compareTo("willNotRipple") == 0);
-
 
1793
 
-
 
1794
        mLogger.debug("TestCotsRipples: willRipple.0000.cots");
-
 
1795
        p = new Package(rm, "willRipple.0000.cots", 255, 255, 255, 255);
-
 
1796
        assertTrue(p.getId() == 0);
-
 
1797
        assertTrue(p.getVersion().compareTo("willRipple.0000") == 0);
-
 
1798
        assertTrue(p.getNextVersion().compareTo("willRipple.1000") == 0);
-
 
1799
 
-
 
1800
        mLogger.debug("TestCotsRipples: willNotRipple.000.cots");
-
 
1801
        p = new Package(rm, "willNotRipple.000.cots", 255, 255, 255, 255);
-
 
1802
        assertTrue(p.getId() == 1);
-
 
1803
        assertTrue(p.getVersion().compareTo("willNotRipple.000") == 0);
-
 
1804
 
-
 
1805
    }
-
 
1806
 
-
 
1807
}
1694
}