Subversion Repositories DevTools

Rev

Rev 864 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.erggroup.buildtool.utf;

import com.erggroup.buildtool.escrow.ESCROWBuild;
import com.erggroup.buildtool.ripple.ReleaseManager;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

import org.junit.Test;
import org.junit.runner.JUnitCore;
import static org.junit.Assert.*;

public class ESCROWBuildTestCase
{
  private static final Logger mLogger = Logger.getLogger(DaemonBuildTestCase.class);

  /**constructor
   */
  public ESCROWBuildTestCase()
  {
    mLogger.debug("ESCROWBuildTestCase");
  }

  /**Test Case main line
   */
  public static void main(String[] args)
  {
    DOMConfigurator.configure("utf.xml");
    mLogger.debug("main");
    JUnitCore.main( "com.erggroup.buildtool.utf.ESCROWBuildTestCase" );
  }

  /**test method designed to test sequence diagram escrow build
   * 1 instructs all ReleaseManager objects not to use the database
   *   under this circumstance, the ReleaseManager generates the following packages:
   *   CotsWithFunnyVersion
   *   NotInAnyWayReproducible
   *   CommonDependency
   *   SolarisCentricProduct
   *   LinuxCentricProduct
   *   Win32CentricProduct
   *   GenericProduct
   *   AdvisoryDependency
   * 2 constructs an ESCROWBuild object
   * 3 calls main on the ESCROWBuild object with args -c "not_used" -u "not used" -p "not used" -b 99999
   * 4 checks the ESCROWBuild generates a build1.xml that matches expected1.xml
   *   this file reports the following packages are not reproducible:
   *   NotInAnyWayReproducible
   *   this file reports the following packages are not reproducible on build platforms associated with this baseline:
   *   Win32CentricProduct
   *   this file contains build information for the following packages:
   *   CotsWithFunnyVersion
   *   LinuxCentricProduct
   *   AdvisoryDependency
   * 5 checks the ESCROWBuild generates a build2.xml that matches expected2.xml
   *   this file contains build information for the following packages:
   *   CommonDependency
   *   SolarisCentricProduct
   *   GenericProduct
   */
  @Test
  public void TestESCROWBuild()
  {
    mLogger.debug("TestESCROWBuild");
    ReleaseManager.mUseDatabase = false;
    String args[] = {"-c", "not used", "-u", "not used", "-p", "not used", "-b", "99999"};
    ESCROWBuild.main(args);
    File cwd = new File( "." );
    boolean caughtException = false;
    
    try
    {
      File expected1 = new File(cwd, "expected1.xml");
      FileReader expected1Reader = new FileReader(expected1);
      char[] expected1Content = new char[(int)expected1.length()];
      expected1Reader.read(expected1Content);
      expected1Reader.close();
      String readExpected1Content = new String(expected1Content);
      File buildFile1 = new File(cwd, "build1.xml");
      FileReader buildFile1Reader = new FileReader(buildFile1);
      char[] buildFile1Content = new char[(int)buildFile1.length()];
      buildFile1Reader.read(buildFile1Content);
      buildFile1Reader.close();
      String readBuildFile1Content = new String(buildFile1Content);
      assertTrue( readExpected1Content.compareTo( readBuildFile1Content ) == 0 );

      File expected2 = new File(cwd, "expected2.xml");
      FileReader expected2Reader = new FileReader(expected2);
      char[] expected2Content = new char[(int)expected2.length()];
      expected2Reader.read(expected2Content);
      expected2Reader.close();
      String readExpected2Content = new String(expected2Content);
      File buildFile2 = new File(cwd, "build2.xml");
      FileReader buildFile2Reader = new FileReader(buildFile2);
      char[] buildFile2Content = new char[(int)buildFile2.length()];
      buildFile2Reader.read(buildFile2Content);
      buildFile2Reader.close();
      String readBuildFile2Content = new String(buildFile2Content);
      assertTrue( readExpected2Content.compareTo( readBuildFile2Content ) == 0 );

      File expected3 = new File(cwd, "expected3.xml");
      FileReader expected3Reader = new FileReader(expected3);
      char[] expected3Content = new char[(int)expected3.length()];
      expected3Reader.read(expected3Content);
      expected3Reader.close();
      String readExpected3Content = new String(expected3Content);
      File buildFile3 = new File(cwd, "build3.xml");
      FileReader buildFile3Reader = new FileReader(buildFile3);
      char[] buildFile3Content = new char[(int)buildFile3.length()];
      buildFile3Reader.read(buildFile3Content);
      buildFile3Reader.close();
      String readBuildFile3Content = new String(buildFile3Content);
      assertTrue( readExpected3Content.compareTo( readBuildFile3Content ) == 0 );
    }
    catch( IOException e )
    {
      caughtException = true;
    }
    assertTrue(!caughtException);
  }
}