Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.erggroup.buildtool.utf;import java.sql.SQLException;import java.util.ArrayList;import java.util.Date;import java.util.Iterator;import com.erggroup.buildtool.daemon.BuildDaemon;import com.erggroup.buildtool.daemon.BuildThread;import com.erggroup.buildtool.daemon.MasterThread;import com.erggroup.buildtool.daemon.SlaveThread;import com.erggroup.buildtool.ripple.BuildFile;import com.erggroup.buildtool.ripple.BuildFile.BuildFileState;import com.erggroup.buildtool.ripple.BuildStandard;import com.erggroup.buildtool.ripple.ReleaseConfig;import com.erggroup.buildtool.ripple.ReleaseManager;import com.erggroup.buildtool.ripple.Package;import com.erggroup.buildtool.ripple.RippleEngine;import com.erggroup.buildtool.ripple.RunLevelData;import com.erggroup.buildtool.ripple.RunLevel.BuildState;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.After;import org.junit.Before;import org.junit.Test;import org.junit.runner.JUnitCore;import static org.junit.Assert.*;/*** container of Build Daemon test methods*/public class DaemonBuildTestCase2{private static final Logger mLogger = LoggerFactory.getLogger(DaemonBuildTestCase2.class);myReleaseManager releaseManager = null;RippleEngine rippleEngine = null;ArrayList<Package> testPackageCollection = new ArrayList<Package>();/*** Init the package set*/public void initTestPackages(String setName){releaseManager.initTestPackages(rippleEngine, testPackageCollection, setName);}/** Create a WIP for a package in the Release* This will mark it as directlyPlanned* @param newPvId* @param alias*/private Package createWip(int newPvId, String alias) {Package wip = ReleaseManager.NULL_PACKAGE;for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); ){Package p = it.next();if ( p.mAlias.compareTo( alias ) == 0 ){wip = new Package(newPvId, p);wip.mDirectlyPlanned = true;testPackageCollection.add(wip);break;}}return wip;}/** Create a basic package**/private Package createPackage(int idx, String pName) {Package p = new Package(idx, idx * 100, pName, "1.0.0000", ".cr", pName + ".cr" , "CC::/vob/"+pName+".WIP", 'b', 'P');BuildStandard bs = new BuildStandard(rippleEngine, "Linux", "Java 1.6");p.mBuildStandardCollection.add(bs);return p;}/** Subclass and override key methods so that the test can control* the data being used*/public class myReleaseManager extends ReleaseManagerUtf{public myReleaseManager(final String connectionString, final String username, final String password){super(connectionString, username, password);mLogger.error("Test {}", connectionString);}public myReleaseManager(){super();}@Overridepublic void queryPackageVersions(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception{// Filter for the packages that are in the releasefor (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); ){Package p = it.next();if (!p.mDirectlyPlanned && p.mTestBuildInstruction == 0 && p.mForcedRippleInstruction == 0){p.mIsNotReleased = false;p.mBuildTime = 90;packageCollection.add(p);}}}@Overridepublic void queryWips(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception{// Filter for the packages that are WIPsfor (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); ){Package p = it.next();if (p.mDirectlyPlanned ){p.mIsNotReleased = true;p.mDirectlyPlanned = true;p.mBuildReason = BuildReason.NewVersion;p.mBuildTime = 100;packageCollection.add(p);}}}@Overridepublic void queryTest(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception{// Filter for the packages that are TEST buildsfor (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); ){Package p = it.next();if (p.mTestBuildInstruction != 0 ){p.mIsNotReleased = true;p.mDirectlyPlanned = false;p.mBuildReason = BuildReason.Test;packageCollection.add(p);}}}@Overridepublic void queryRipples(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception{// Filter for the packages that are forced Ripplesfor (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); ){Package p = it.next();if (p.mForcedRippleInstruction != 0){p.mIsNotReleased = true;p.mDirectlyPlanned = false;p.mBuildReason = BuildReason.Ripple;p.mBuildTime = 3;packageCollection.add(p);}}}/** Build a single package collection* It will be split up when requested by the classes under test** @param packageCollection*/private void initTestPackages(RippleEngine rippleEngine, ArrayList<Package> packageCollection, String setName){packageCollection.clear();/* A basic set of packages* All buildable*/Package p1 = createPackage(1, "p1");Package p2 = createPackage(2, "p2");Package p3 = createPackage(3, "p3");Package p4 = createPackage(4, "p4");Package p5 = createPackage(5, "p5");Package p6 = createPackage(6, "p6");Package p7 = createPackage(7, "p7");packageCollection.add(p1);packageCollection.add(p2);packageCollection.add(p3);packageCollection.add(p4);packageCollection.add(p5);packageCollection.add(p6);packageCollection.add(p7);p2.addDependency(p1);p3.addDependency(p1);p4.addDependency(p2).addDependency(p3);p5.addDependency(p2).addDependency(p4);p6.addDependency(p3).addDependency(p4);p7.addDependency(p5).addDependency(p6);}}public DaemonBuildTestCase2(){mLogger.debug("DaemonBuildTestCase2");}/*** Test Case main line*/public static void main(String[] args){mLogger.debug("main");JUnitCore.main("com.erggroup.buildtool.utf.DaemonBuildTestCase2");}/*** set up performed prior to any test method*/@BeforeClasspublic static void TestCaseSetUp(){mLogger.debug("TestCaseSetUp");}/*** tear down performed after test methods*/@AfterClasspublic static void TestCaseTearDown(){mLogger.debug("TestCaseTearDown");}/*** set up performed prior to each test method*/@Beforepublic void TestSetUp(){mLogger.debug("TestSetUp");System.setProperty("vix.utf.name", "DaemonBuildTestCase2");Package.mGenericMachtype = "win32";Package.mGbeDpkg = ".";}/*** tear down performed after each test method*/@Afterpublic void TestTearDown(){mLogger.debug("TestTearDown");}/*** I'm guessing as to the function of this test* Test for:* Circular dependencies* Build Dependency not in the release* Package has no build environment* Package not built for configured platforms* A package is selected to be built**/@Testpublic void TestPlanRelease_1(){mLogger.debug("TestPlanRelease - Iteration 1");System.out.println("TestPlanRelease - Iteration 1");releaseManager = new myReleaseManager("iteration1", "not used", "not used");rippleEngine = new RippleEngine(releaseManager, 11111, true);try{rippleEngine.collectMetaData();// Generate basic test set and then tweak for this testinitTestPackages(releaseManager.mConnectionString);createWip(2000, "p1.cr");rippleEngine.planRelease(false);}catch (Exception e){}boolean rv;BuildFile buildFile;buildFile = rippleEngine.getFirstBuildFileContent();assertTrue(buildFile != null);assertTrue(buildFile.state != BuildFileState.Dummy);assertTrue(buildFile.state != BuildFileState.Empty);rv = Utilities.checkBuildfile(buildFile.content, "ripple1");assertTrue(rv);buildFile = rippleEngine.getNextBuildFileContent();assertTrue(buildFile != null);assertTrue(buildFile.state == BuildFileState.Empty);}}