Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
814 mhunt 1
package com.erggroup.buildtool.utf;
2
 
3
import com.erggroup.buildtool.escrow.ESCROWBuild;
4
import com.erggroup.buildtool.ripple.ReleaseManager;
5
 
6
import java.io.File;
7
import java.io.FileReader;
8
import java.io.IOException;
9
 
10
import org.apache.log4j.Logger;
11
import org.apache.log4j.xml.DOMConfigurator;
12
 
13
import org.junit.Test;
14
import org.junit.runner.JUnitCore;
15
import static org.junit.Assert.*;
16
 
17
public class ESCROWBuildTestCase
18
{
19
  private static final Logger mLogger = Logger.getLogger(DaemonBuildTestCase.class);
20
 
21
  /**constructor
22
   */
23
  public ESCROWBuildTestCase()
24
  {
25
    mLogger.debug("ESCROWBuildTestCase");
26
  }
27
 
28
  /**Test Case main line
29
   */
30
  public static void main(String[] args)
31
  {
32
    DOMConfigurator.configure("utf.xml");
33
    mLogger.debug("main");
34
    JUnitCore.main( "com.erggroup.buildtool.utf.ESCROWBuildTestCase" );
35
  }
36
 
37
  /**test method designed to test sequence diagram escrow build
38
   * 1 instructs all ReleaseManager objects not to use the database
39
   *   under this circumstance, the ReleaseManager generates the following packages:
40
   *   CotsWithFunnyVersion
41
   *   NotInAnyWayReproducible
42
   *   CommonDependency
43
   *   SolarisCentricProduct
44
   *   LinuxCentricProduct
45
   *   Win32CentricProduct
46
   *   GenericProduct
47
   *   AdvisoryDependency
48
   * 2 constructs an ESCROWBuild object
49
   * 3 calls main on the ESCROWBuild object with args -c "not_used" -u "not used" -p "not used" -b 99999
50
   * 4 checks the ESCROWBuild generates a build1.xml that matches expected1.xml
51
   *   this file reports the following packages are not reproducible:
52
   *   NotInAnyWayReproducible
53
   *   this file reports the following packages are not reproducible on build platforms associated with this baseline:
54
   *   Win32CentricProduct
55
   *   this file contains build information for the following packages:
56
   *   CotsWithFunnyVersion
57
   *   LinuxCentricProduct
58
   *   AdvisoryDependency
59
   * 5 checks the ESCROWBuild generates a build2.xml that matches expected2.xml
60
   *   this file contains build information for the following packages:
61
   *   CommonDependency
62
   *   SolarisCentricProduct
63
   *   GenericProduct
64
   */
65
  @Test
66
  public void TestESCROWBuild()
67
  {
68
    mLogger.debug("TestESCROWBuild");
69
    ReleaseManager.mUseDatabase = false;
70
    String args[] = {"-c", "not used", "-u", "not used", "-p", "not used", "-b", "99999"};
864 mhunt 71
    ESCROWBuild.main(args);
814 mhunt 72
    File cwd = new File( "." );
73
    boolean caughtException = false;
74
 
75
    try
76
    {
77
      File expected1 = new File(cwd, "expected1.xml");
78
      FileReader expected1Reader = new FileReader(expected1);
79
      char[] expected1Content = new char[(int)expected1.length()];
80
      expected1Reader.read(expected1Content);
81
      expected1Reader.close();
82
      String readExpected1Content = new String(expected1Content);
83
      File buildFile1 = new File(cwd, "build1.xml");
84
      FileReader buildFile1Reader = new FileReader(buildFile1);
85
      char[] buildFile1Content = new char[(int)buildFile1.length()];
86
      buildFile1Reader.read(buildFile1Content);
87
      buildFile1Reader.close();
88
      String readBuildFile1Content = new String(buildFile1Content);
89
      assertTrue( readExpected1Content.compareTo( readBuildFile1Content ) == 0 );
90
 
91
      File expected2 = new File(cwd, "expected2.xml");
92
      FileReader expected2Reader = new FileReader(expected2);
93
      char[] expected2Content = new char[(int)expected2.length()];
94
      expected2Reader.read(expected2Content);
95
      expected2Reader.close();
96
      String readExpected2Content = new String(expected2Content);
97
      File buildFile2 = new File(cwd, "build2.xml");
98
      FileReader buildFile2Reader = new FileReader(buildFile2);
99
      char[] buildFile2Content = new char[(int)buildFile2.length()];
100
      buildFile2Reader.read(buildFile2Content);
101
      buildFile2Reader.close();
102
      String readBuildFile2Content = new String(buildFile2Content);
103
      assertTrue( readExpected2Content.compareTo( readBuildFile2Content ) == 0 );
862 mhunt 104
 
105
      File expected3 = new File(cwd, "expected3.xml");
106
      FileReader expected3Reader = new FileReader(expected3);
107
      char[] expected3Content = new char[(int)expected3.length()];
108
      expected3Reader.read(expected3Content);
109
      expected3Reader.close();
110
      String readExpected3Content = new String(expected3Content);
111
      File buildFile3 = new File(cwd, "build3.xml");
112
      FileReader buildFile3Reader = new FileReader(buildFile3);
113
      char[] buildFile3Content = new char[(int)buildFile3.length()];
114
      buildFile3Reader.read(buildFile3Content);
115
      buildFile3Reader.close();
116
      String readBuildFile3Content = new String(buildFile3Content);
117
      assertTrue( readExpected3Content.compareTo( readBuildFile3Content ) == 0 );
814 mhunt 118
    }
119
    catch( IOException e )
120
    {
121
      caughtException = true;
122
    }
123
    assertTrue(!caughtException);
124
  }
125
}