Subversion Repositories DevTools

Rev

Go to most recent revision | 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.daemon.BuildDaemon;
4
 
5
import com.erggroup.buildtool.daemon.BuildThread;
6
import com.erggroup.buildtool.daemon.MasterThread;
7
import com.erggroup.buildtool.daemon.SlaveThread;
8
import com.erggroup.buildtool.ripple.MutableString;
9
import com.erggroup.buildtool.ripple.Package;
10
import com.erggroup.buildtool.ripple.ReleaseManager;
11
 
12
import com.erggroup.buildtool.ripple.RippleEngine;
13
 
14
import java.io.File;
15
import java.io.FileReader;
16
import java.io.FileWriter;
17
import java.io.IOException;
18
 
19
import org.apache.log4j.Logger;
20
import org.apache.log4j.xml.DOMConfigurator;
21
 
22
import org.junit.AfterClass;
23
import org.junit.BeforeClass;
24
import org.junit.After;
25
import org.junit.Before;
26
import org.junit.Test;
27
import org.junit.runner.JUnitCore;
28
import static org.junit.Assert.*;
29
 
30
/**container of Build Daemon test methods
31
 */
32
public class DaemonBuildTestCase
33
{
34
  private static final Logger mLogger = Logger.getLogger(DaemonBuildTestCase.class);
35
 
36
  public DaemonBuildTestCase()
37
  {
38
    mLogger.debug("DaemonBuildTestCase");
39
  }
40
 
41
  /**Test Case main line
42
   */
43
  public static void main(String[] args)
44
  {
45
    DOMConfigurator.configure("utf.xml");
46
    mLogger.debug("main");
47
    JUnitCore.main( "com.erggroup.buildtool.utf.DaemonBuildTestCase" );
48
  }
49
 
50
  /**set up performed prior to any test method
51
   */
52
  @BeforeClass
53
  public static void TestCaseSetUp()
54
  {
55
    mLogger.debug("TestCaseSetUp");
56
  }
57
 
58
  /**tear down performed after test methods
59
   */
60
  @AfterClass
61
  public static void TestCaseTearDown()
62
  {
63
    mLogger.debug("TestCaseTearDown");
64
  }
65
 
66
  /**set up performed prior to each test method
67
   */
68
  @Before
69
  public void TestSetUp()
70
  {
71
    mLogger.debug("TestSetUp");
72
    ReleaseManager.mUseDatabase = false;
73
  }
74
 
75
  /**tear down performed after each test method
76
   */
77
  @After
78
  public void TestTearDown()
79
  {
80
    mLogger.debug("TestTearDown");
81
    ReleaseManager.mUseDatabase = true;
82
    ReleaseManager.mPersistedRunLevelCollection.removeAllElements();
83
  }
84
 
85
  /**test method designed primarily to test the sequence diagram spawn thread
86
   * also tests thread control out of necessity:
87
   *  1 constructs a BuildDaemon object, passing a connectionString of "unit test spawn thread"
88
   *    this utilises the following unit test hooks in the codebase:
89
   *    - BuildDaemon::BuildDaemon connectionString of "unit test spawn thread" exits while forever loop
90
   *    - BuildDaemon constructor, isActive and cleanUp made public for unit test use
91
   *    - ReleaseManager::queryReleaseConfig instantiates 2 ReleaseConfig objects
92
   *      with rcon_id's of 1 and 2, daemon_modes of 'M' and 'S' respectively, and gbebuildfilters of "unit test spawn thread"
93
   *    - MasterThread::run gbebuildfilter of "unit test spawn thread" limits method to sleep in while forever loop
94
   *    - SlaveThread::run gbebuildfilter of "unit test spawn thread" limits method to sleep in while forever loop
95
   *  2 checks the number of threads in the thread group is 3 (mainline thread + MasterThread + SlaveThread)
96
   *  3 checks isActive on the BuildDaemon object returns true when passed an rcon_id of 1
97
   *  4 checks isActive on the BuildDaemon object returns true when passed an rcon_id of 2
98
   *  5 checks isActive on the BuildDaemon object returns false when passed an rcon_id of 3
99
   *  6 calls cleanUp on the BuildDaemon object
100
   *  7 checks the number of threads in the thread group is 1 (mainline thread)
101
   *  8 checks isActive on the BuildDaemon object returns false when passed an rcon_id of 1
102
   *  9 checks isActive on the BuildDaemon object returns false when passed an rcon_id of 2
103
   * 10 checks isActive on the BuildDaemon object returns false when passed an rcon_id of 3
104
   */
105
  @Test
106
  public void TestSpawnThread()
107
  {
108
    mLogger.debug("TestSpawnThread");
109
    BuildDaemon buildDaemon = 
110
      new BuildDaemon("unit test spawn thread", "not used", "not used");
111
    assertTrue(BuildThread.mThreadGroup.activeCount() == 2 );
112
    assertTrue(buildDaemon.isActive(1));
113
    assertTrue(buildDaemon.isActive(2));
114
    assertFalse(buildDaemon.isActive(3));
115
    buildDaemon.cleanUp();
116
    assertTrue(BuildThread.mThreadGroup.activeCount() == 0);
117
    assertFalse(buildDaemon.isActive(1));
118
    assertFalse(buildDaemon.isActive(2));
119
    assertFalse(buildDaemon.isActive(3));
120
  }
121
 
122
  /**test method designed to test the sequence diagram coordinate slave thread:
123
   *  1 constructs a ReleaseManager object, passing a connectionString of "unit test coordinate slave threads"
124
   *  2 constructs a MasterThread object, passing a gbebuildfilter of "unit test coordinate slave threads"
125
   *    this utilises the following unit test hooks in the codebase:
126
   *    - MasterThread constructor made public for unit test use
127
   *    - MasterThread::run gbebuildfilter of "unit test coordinate slave threads" limits method to the sequence diagram
128
   *      interrupts the thread if, on one pass, at least one RunLevel object does not have a run level DB_WAITING
129
   *      exits the while forever loop if, on one pass, all RunLevel objects have a run level DB_WAITING
130
   *    - ReleaseManager::queryRunLevel connectionString of "unit test coordinate slave threads" instantiates 2 RunLevel objects
131
   *      initially with run levels of waiting and idle
132
   *      subsequently with run levels both waiting
133
   *  3 calls run on the MasterThread object
134
   *  4 checks its thread has been interrupted
135
   */
136
  @Test
137
  public void TestCoordinateSlaveThreads()
138
  {
139
    mLogger.debug("TestCoordinateSlaveThreads");
140
    ReleaseManager releaseManager = new ReleaseManager("unit test coordinate slave threads", "not used", "not used");
141
    MasterThread masterThread = new MasterThread(1, 1, "unit test coordinate slave threads");
142
    assertFalse(Thread.currentThread().interrupted());
143
    masterThread.run();
144
    // interrupted checks and importantly clears the interrupted status of this thread for subsequent tests
145
    assertTrue(Thread.currentThread().interrupted());
146
    assertFalse(Thread.currentThread().interrupted());
147
  }
148
 
149
  /**test method designed to test the sequence diagram generate build files
150
   * note does not test the RippleEngine:
151
   *  1 constructs a ReleaseManager object, passing a connectionString of "unit test generate build files"
152
   *  2 constructs a MasterThread object, passing a gbebuildfilter of "unit test generate build files"
153
   *    this utilises the following unit test hooks in the codebase:
154
   *    - MasterThread constructor made public for unit test use
155
   *    - MasterThread::run gbebuildfilter of "unit test generate build files" limits method to the sequence diagram
156
   *      exits the while forever loop
157
   *    - ReleaseManager::queryReleaseConfig instantiates 2 ReleaseConfig objects
158
   *      with rcon_id's of 1 and 2, daemon_modes of 'M' and 'S' respectively, and gbebuildfilters of "unit test spawn thread"
159
   *    - ReleaseManager::updateCurrentRunLevel utilises the public mPersistedRunLevelCollection
160
   *  3 calls run on the MasterThread object
161
   *  4 checks the first persisted run level is DB_ACTIVE
162
   *  5 checks the second persisted run level is DB_ACTIVE
163
   *  6 checks no further run levels were persisted
164
   */
165
  @Test
166
  public void TestGenerateBuildFiles()
167
  {
168
    mLogger.debug("TestGenerateBuildFiles");
169
    ReleaseManager releaseManager = new ReleaseManager("unit test generate build files", "not used", "not used");
170
    MasterThread masterThread = new MasterThread(1, 1, "unit test generate build files");
171
    masterThread.run();
172
    Integer persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 0 );
173
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_ACTIVE );
174
    persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 1 );
175
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_ACTIVE );
176
    boolean caughtOOB = false;
177
 
178
    try
179
    {
180
      persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 2 );
181
    }
182
    catch( ArrayIndexOutOfBoundsException e )
183
    {
184
      caughtOOB = true;
185
    }
186
 
187
    assertTrue(caughtOOB);
188
  }
189
 
190
  /**test method designed to test the sequence diagram consume build files
191
   *  1 constructs a ReleaseManager object, passing a connectionString of "unit test consume build files"
192
   *  2 constructs a SlaveThread object, passing a gbebuildfilter of "unit test consume build files"
193
   *    this utilises the following unit test hooks in the codebase:
194
   *    - SlaveThread constructor made public for unit test use
195
   *    - SlaveThread::run gbebuildfilter of "unit test consume build files" limits method to the sequence diagram
196
   *      interrupts the thread if, on one pass, the current build file string is empty
197
   *      exits the while forever loop
198
   *    - ReleaseManager::queryRunLevel
199
   *      initially returns an empty current build file string
200
   *      subsequently returns a "unit test build file content" current build file string
201
   *  3 calls run on the SlaveThread object
202
   */
203
  @Test
204
  public void TestConsumeBuildFiles()
205
  {
206
    mLogger.debug("TestConsumeBuildFiles");
207
    ReleaseManager releaseManager = new ReleaseManager("unit test consume build files", "not used", "not used");
208
    SlaveThread slaveThread = new SlaveThread(1, 1, "unit test consume build files");
209
    assertFalse(Thread.currentThread().interrupted());
210
    slaveThread.run();
211
  }
212
 
213
  /**test method designed to test the sequence diagram allowed to proceed
214
   *  1 constructs a ReleaseManager object, passing a connectionString of "unit test allowed to proceed"
215
   *  2 constructs a MasterThread object, passing a gbebuildfilter of "unit test allowed to proceed"
216
   *    this utilises the following unit test hooks in the codebase:
217
   *    - MasterThread constructor made public for unit test use
218
   *    - MasterThread::run gbebuildfilter of "unit test allowed to proceed" limits method to the sequence diagram
219
   *      exits the while forever loop
220
   *    - ReleaseManager::queryReleaseConfig, queryRunLevelSchedule, queryDirectedRunLevel methods return true
221
   *    - ReleaseManager::updateCurrentRunLevel utilises the public mPersistedRunLevelCollection
222
   *  3 calls run on the MasterThread object
223
   *  4 checks the first persisted run level is DB_IDLE
816 mhunt 224
   *  5 checks the third persisted run level is DB_WAITING
225
   *  6 checks no further run levels were persisted
814 mhunt 226
   */
227
  @Test
228
  public void TestAllowedToProceed()
229
  {
230
    mLogger.debug("TestAllowedToProceed");
231
    ReleaseManager releaseManager = new ReleaseManager("unit test allowed to proceed", "not used", "not used");
232
    MasterThread masterThread = new MasterThread(1, 1, "unit test allowed to proceed");
233
    masterThread.run();
234
    Integer persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 0 );
235
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_IDLE );
236
    persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 1 );
237
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_WAITING );
238
    boolean caughtOOB = false;
239
 
240
    try
241
    {
242
      persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 3 );
243
    }
244
    catch( ArrayIndexOutOfBoundsException e )
245
    {
246
      caughtOOB = true;
247
    }
248
 
249
    assertTrue(caughtOOB);
250
  }
251
 
252
  /**test method designed to test the sequence diagram not allowed to proceed
253
   *  1 constructs a ReleaseManager object, passing a connectionString of "unit test not allowed to proceed"
254
   *  2 constructs a MasterThread object, passing a gbebuildfilter of "unit test not allowed to proceed"
255
   *    this utilises the following unit test hooks in the codebase:
256
   *    - MasterThread constructor made public for unit test use
257
   *    - MasterThread::run gbebuildfilter of "unit test not allowed to proceed" limits method to the sequence diagram
258
   *      exits the while forever loop
259
   *    - ReleaseManager::queryReleaseConfig method returns true
260
   *    - ReleaseManager::queryRunLevelSchedule method returns false
261
   *    - ReleaseManager::updateCurrentRunLevel utilises the public mPersistedRunLevelCollection
262
   *  3 calls run on the MasterThread object
263
   *  4 checks the first persisted run level is DB_IDLE
816 mhunt 264
   *  5 checks the third persisted run level is DB_PAUSED
265
   *  6 checks no further run levels were persisted
814 mhunt 266
   * nb cannot check only one thread is running,
267
   * a Timer thread, though having run to completion, may still be "active"
268
   */
269
  @Test
270
  public void TestNotAllowedToProceed()
271
  {
272
    mLogger.debug("TestNotAllowedToProceed");
273
    ReleaseManager releaseManager = new ReleaseManager("unit test not allowed to proceed", "not used", "not used");
274
    MasterThread masterThread = new MasterThread(1, 1, "unit test not allowed to proceed");
275
    masterThread.run();
276
    Integer persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 0 );
277
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_IDLE );
278
    persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 1 );
279
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_PAUSED );
280
    boolean caughtOOB = false;
281
 
282
    try
283
    {
284
      persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 3 );
285
    }
286
    catch( ArrayIndexOutOfBoundsException e )
287
    {
288
      caughtOOB = true;
289
    }
290
 
291
    assertTrue(caughtOOB);
292
  }
293
 
294
  /**test method designed to test the sequence diagram exit
295
   *  1 constructs a ReleaseManager object, passing a connectionString of "unit test exit"
296
   *  2 constructs a MasterThread object, passing a gbebuildfilter of "unit test exit"
297
   *    this utilises the following unit test hooks in the codebase:
298
   *    - MasterThread constructor made public for unit test use
299
   *    - MasterThread::run gbebuildfilter of "unit test exit" limits method to the sequence diagram
300
   *    - ReleaseManager::queryReleaseConfig method returns false
301
   *    - ReleaseManager::updateCurrentRunLevel utilises the public mPersistedRunLevelCollection
302
   *  3 calls run on the MasterThread object
303
   *  4 checks the first persisted run level is DB_IDLE
304
   *  5 checks no further run levels were persisted
305
   */
306
  @Test
307
  public void TestExit()
308
  {
309
    mLogger.debug("TestExit");
310
    ReleaseManager releaseManager = new ReleaseManager("unit test exit", "not used", "not used");
311
    MasterThread masterThread = new MasterThread(1, 1, "unit test exit");
312
    masterThread.run();
313
    Integer persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 0 );
314
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_IDLE );
315
 
316
    boolean caughtOOB = false;
317
 
318
    try
319
    {
320
      persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 2 );
321
    }
322
    catch( ArrayIndexOutOfBoundsException e )
323
    {
324
      caughtOOB = true;
325
    }
326
 
327
    assertTrue(caughtOOB);
328
  }
329
 
330
  /**test method designed to test the sequence diagram check environment
331
   *  1 constructs a ReleaseManager object, passing a connectionString of "unit check environment"
332
   *  2 constructs a MasterThread object, passing a gbebuildfilter of "unit check environment"
333
   *    this utilises the following unit test hooks in the codebase:
334
   *    - MasterThread constructor made public for unit test use
335
   *    - MasterThread::run gbebuildfilter of "unit test check environment" limits method to the sequence diagram
336
   *      exits the while forever loop
337
   *    - MasterThread::housekeep method does not call deleteDirectory
338
   *    - MasterThread::hasSufficientDiskSpace initially returns false, then true
339
   *    - ReleaseManager::updateCurrentRunLevel utilises the public mPersistedRunLevelCollection
340
   *  3 calls run on the MasterThread object
341
   *  4 checks the first persisted run level is DB_CANNOT_CONTINUE
342
   *  5 checks the next persisted run level is DB_ACTIVE
343
   *  6 checks no further run levels were persisted
344
   */
345
  @Test
346
  public void TestCheckEnvironment()
347
  {
348
    mLogger.debug("TestCheckEnvironment");
349
    ReleaseManager releaseManager = new ReleaseManager("unit test check environment", "not used", "not used");
350
    MasterThread masterThread = new MasterThread(1, 1, "unit test check environment");
351
    masterThread.run();
352
    Integer persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 0 );
353
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_CANNOT_CONTINUE );
354
    persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 1 );
355
    assertTrue( persistedRunLevel.intValue() == ReleaseManager.DB_ACTIVE );
356
    boolean caughtOOB = false;
357
 
358
    try
359
    {
360
      persistedRunLevel = (Integer)ReleaseManager.mPersistedRunLevelCollection.get( 2 );
361
    }
362
    catch( ArrayIndexOutOfBoundsException e )
363
    {
364
      caughtOOB = true;
365
    }
366
 
367
    assertTrue(caughtOOB);
368
  }
369
 
370
  /**test method designed to test the ripple engine
371
   *  1 constructs a ReleaseManager object with connection string "iteration1"
372
   *  2 constructs a RippleEngine object
373
   *  3 calls planRelease on the RippleEngine object
374
   *  4 calls getFirstBuildFileContent
375
   *  5 checks it returns true
376
   *  6 writes the content to "daemon1.xml"
377
   *  7 checks the content matches the content in "expecteddaemon1.xml"
378
   *  8 calls getNextBuildFileContent
379
   *  9 checks it returns false
380
   * 10 constructs a ReleaseManager object with connection string "iteration2"
381
   * 11 calls planRelease on the RippleEngine object
382
   * 12 calls getFirstBuildFileContent
383
   * 13 checks it returns true
384
   * 14 writes the content to "daemon2.xml"
385
   * 15 checks the content matches the content in "expecteddaemon2.xml"
386
   * 16 calls getNextBuildFileContent
387
   * 17 checks it returns false
388
   * 18 steps 10 to 17 are repeated for iteration3,4,5 and 6
389
   * 19 constructs a ReleaseManager object with connection string "iteration7"
390
   * 20 calls planRelease on the RippleEngine object
391
   * 21 calls getFirstBuildFileContent
392
   * 22 checks it returns true (a benign build file content)
393
   */
394
  @Test
395
  public void TestPlanRelease()
396
  {
397
    mLogger.debug("TestPlanRelease");
398
    ReleaseManager releaseManager = 
399
      new ReleaseManager("iteration1", "not used", "not used");
400
 
401
    RippleEngine rippleEngine = new RippleEngine(releaseManager, 11111, true);
402
    // this is all the MasterThread does
403
    try
404
    {
405
      rippleEngine.planRelease();
406
    }
407
    catch(Exception e)
408
    {
409
    }
410
 
411
    String ExpectedBuildFileContent = new String();
412
    MutableString buildFileContent = new MutableString();
413
    boolean moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
414
    assertTrue(moreBuildFiles);
415
 
416
    // persist the generated build file content to daemon1.xml for visibility
417
    File cwd = new File( "." );
418
    String buildFileName = new String("daemon1.xml");
419
    try
420
    {
421
      File buildFile = new File(cwd, buildFileName);
422
      FileWriter buildFileWriter = new FileWriter(buildFile);
423
      buildFileWriter.write(buildFileContent.value);
424
      buildFileWriter.close();
425
      File expectedBuildFile = new File(cwd, "expecteddaemon1.xml");
426
      FileReader expectedBuildFileReader = new FileReader(expectedBuildFile);
427
      char[] expectedBuildFileContent = new char[(int)expectedBuildFile.length()];
428
      expectedBuildFileReader.read(expectedBuildFileContent);
429
      expectedBuildFileReader.close();
430
      String temp = new String(expectedBuildFileContent);
431
      ExpectedBuildFileContent = temp;
432
    }
433
    catch( IOException e )
434
    {
435
      System.out.println("DaemonBuildTestCase::TestPlanRelease caught IOException");
436
    }
437
 
438
    assertTrue(buildFileContent.value.compareTo(ExpectedBuildFileContent) == 0);
439
    moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
440
    assertFalse(moreBuildFiles);
441
 
442
    releaseManager = 
443
      new ReleaseManager("iteration2", "not used", "not used");
444
 
445
    // this is all the MasterThread does
446
    try
447
    {
448
      rippleEngine.planRelease();
449
    }
450
    catch(Exception e)
451
    {
452
    }
453
 
454
    moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
455
    assertTrue(moreBuildFiles);
456
 
457
    // persist the generated build file content to daemon1.xml for visibility
458
    buildFileName = new String("daemon2.xml");
459
    try
460
    {
461
      File buildFile = new File(cwd, buildFileName);
462
      FileWriter buildFileWriter = new FileWriter(buildFile);
463
      buildFileWriter.write(buildFileContent.value);
464
      buildFileWriter.close();
465
      File expectedBuildFile = new File(cwd, "expecteddaemon2.xml");
466
      FileReader expectedBuildFileReader = new FileReader(expectedBuildFile);
467
      char[] expectedBuildFileContent = new char[(int)expectedBuildFile.length()];
468
      expectedBuildFileReader.read(expectedBuildFileContent);
469
      expectedBuildFileReader.close();
470
      String temp = new String(expectedBuildFileContent);
471
      ExpectedBuildFileContent = temp;
472
    }
473
    catch( IOException e )
474
    {
475
      System.out.println("DaemonBuildTestCase::TestPlanRelease caught IOException");
476
    }
477
 
478
    assertTrue(buildFileContent.value.compareTo(ExpectedBuildFileContent) == 0);
479
    moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
480
    assertFalse(moreBuildFiles);
481
 
482
    releaseManager = 
483
      new ReleaseManager("iteration3", "not used", "not used");
484
 
485
    // this is all the MasterThread does
486
    try
487
    {
488
      rippleEngine.planRelease();
489
    }
490
    catch(Exception e)
491
    {
492
    }
493
 
494
    moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
495
    assertTrue(moreBuildFiles);
496
 
497
    // persist the generated build file content to daemon1.xml for visibility
498
    buildFileName = new String("daemon3.xml");
499
    try
500
    {
501
      File buildFile = new File(cwd, buildFileName);
502
      FileWriter buildFileWriter = new FileWriter(buildFile);
503
      buildFileWriter.write(buildFileContent.value);
504
      buildFileWriter.close();
505
      File expectedBuildFile = new File(cwd, "expecteddaemon3.xml");
506
      FileReader expectedBuildFileReader = new FileReader(expectedBuildFile);
507
      char[] expectedBuildFileContent = new char[(int)expectedBuildFile.length()];
508
      expectedBuildFileReader.read(expectedBuildFileContent);
509
      expectedBuildFileReader.close();
510
      String temp = new String(expectedBuildFileContent);
511
      ExpectedBuildFileContent = temp;
512
    }
513
    catch( IOException e )
514
    {
515
      System.out.println("DaemonBuildTestCase::TestPlanRelease caught IOException");
516
    }
517
 
518
    assertTrue(buildFileContent.value.compareTo(ExpectedBuildFileContent) == 0);
519
    moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
520
    assertFalse(moreBuildFiles);
521
 
522
    releaseManager = 
523
      new ReleaseManager("iteration4", "not used", "not used");
524
 
525
    // this is all the MasterThread does
526
    try
527
    {
528
      rippleEngine.planRelease();
529
    }
530
    catch(Exception e)
531
    {
532
    }
533
 
534
    moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
535
    assertTrue(moreBuildFiles);
536
 
537
    // persist the generated build file content to daemon1.xml for visibility
538
    buildFileName = new String("daemon4.xml");
539
    try
540
    {
541
      File buildFile = new File(cwd, buildFileName);
542
      FileWriter buildFileWriter = new FileWriter(buildFile);
543
      buildFileWriter.write(buildFileContent.value);
544
      buildFileWriter.close();
545
      File expectedBuildFile = new File(cwd, "expecteddaemon4.xml");
546
      FileReader expectedBuildFileReader = new FileReader(expectedBuildFile);
547
      char[] expectedBuildFileContent = new char[(int)expectedBuildFile.length()];
548
      expectedBuildFileReader.read(expectedBuildFileContent);
549
      expectedBuildFileReader.close();
550
      String temp = new String(expectedBuildFileContent);
551
      ExpectedBuildFileContent = temp;
552
    }
553
    catch( IOException e )
554
    {
555
      System.out.println("DaemonBuildTestCase::TestPlanRelease caught IOException");
556
    }
557
 
558
    assertTrue(buildFileContent.value.compareTo(ExpectedBuildFileContent) == 0);
559
    moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
560
    assertFalse(moreBuildFiles);
561
 
562
    releaseManager = 
563
      new ReleaseManager("iteration5", "not used", "not used");
564
 
565
    // this is all the MasterThread does
566
    try
567
    {
568
      rippleEngine.planRelease();
569
    }
570
    catch(Exception e)
571
    {
572
    }
573
 
574
    moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
575
    assertTrue(moreBuildFiles);
576
 
577
    // persist the generated build file content to daemon1.xml for visibility
578
    buildFileName = new String("daemon5.xml");
579
    try
580
    {
581
      File buildFile = new File(cwd, buildFileName);
582
      FileWriter buildFileWriter = new FileWriter(buildFile);
583
      buildFileWriter.write(buildFileContent.value);
584
      buildFileWriter.close();
585
      File expectedBuildFile = new File(cwd, "expecteddaemon5.xml");
586
      FileReader expectedBuildFileReader = new FileReader(expectedBuildFile);
587
      char[] expectedBuildFileContent = new char[(int)expectedBuildFile.length()];
588
      expectedBuildFileReader.read(expectedBuildFileContent);
589
      expectedBuildFileReader.close();
590
      String temp = new String(expectedBuildFileContent);
591
      ExpectedBuildFileContent = temp;
592
    }
593
    catch( IOException e )
594
    {
595
      System.out.println("DaemonBuildTestCase::TestPlanRelease caught IOException");
596
    }
597
 
598
    assertTrue(buildFileContent.value.compareTo(ExpectedBuildFileContent) == 0);
599
    moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
600
    assertFalse(moreBuildFiles);
601
 
602
    releaseManager = 
603
      new ReleaseManager("iteration6", "not used", "not used");
604
 
605
    // this is all the MasterThread does
606
    try
607
    {
608
      rippleEngine.planRelease();
609
    }
610
    catch(Exception e)
611
    {
612
    }
613
 
614
    moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
615
    assertTrue(moreBuildFiles);
616
 
617
    // persist the generated build file content to daemon1.xml for visibility
618
    buildFileName = new String("daemon6.xml");
619
    try
620
    {
621
      File buildFile = new File(cwd, buildFileName);
622
      FileWriter buildFileWriter = new FileWriter(buildFile);
623
      buildFileWriter.write(buildFileContent.value);
624
      buildFileWriter.close();
625
      File expectedBuildFile = new File(cwd, "expecteddaemon6.xml");
626
      FileReader expectedBuildFileReader = new FileReader(expectedBuildFile);
627
      char[] expectedBuildFileContent = new char[(int)expectedBuildFile.length()];
628
      expectedBuildFileReader.read(expectedBuildFileContent);
629
      expectedBuildFileReader.close();
630
      String temp = new String(expectedBuildFileContent);
631
      ExpectedBuildFileContent = temp;
632
    }
633
    catch( IOException e )
634
    {
635
      System.out.println("DaemonBuildTestCase::TestPlanRelease caught IOException");
636
    }
637
 
638
    assertTrue(buildFileContent.value.compareTo(ExpectedBuildFileContent) == 0);
639
    moreBuildFiles = rippleEngine.getNextBuildFileContent(buildFileContent);
640
    assertFalse(moreBuildFiles);
641
 
642
    releaseManager = 
643
      new ReleaseManager("iteration7", "not used", "not used");
644
 
645
    // this is all the MasterThread does
646
    try
647
    {
648
      rippleEngine.planRelease();
649
    }
650
    catch(Exception e)
651
    {
652
    }
653
 
654
    moreBuildFiles = rippleEngine.getFirstBuildFileContent(buildFileContent);
655
    assertTrue(moreBuildFiles);
656
  }
657
}