summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Log/Basic_Log_Test/Basic_Log_Test.cpp
blob: e8f5116c435de6c8180f00f952803f218ff1c7bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
#include "Basic_Log_Test.h"

#include "orbsvcs/orbsvcs/Time_Utilities.h"

#include "tao/debug.h"

#include "ace/Get_Opt.h"
#include "ace/Log_Msg.h"
#include "ace/SString.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_unistd.h"

ACE_RCSID (Basic_Log_Test,
           Basic_Log_Test,
           "$Id$")


const char* BasicLog_Test::basic_log_factory_name_= "BasicLogFactory";
const char* BasicLog_Test::naming_sevice_name_ = "NameService";


BasicLog_Test::BasicLog_Test(void)
  : logServiceIor_ (0)
{
}

BasicLog_Test::~BasicLog_Test (void)
{
  this->destroy_log ();
}

int
BasicLog_Test::init (int argc, char *argv[])
{
  this->argc_ = argc;
  this->argv_ = argv;

  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      // Initialize the ORB
      orb_ = CORBA::ORB_init (argc,
                              argv,
                              "internet" ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (TAO_debug_level > 0)
        ACE_DEBUG ((LM_DEBUG,
                    "\nOrb initialized successfully\n"));

      // Parse command line and verify parameters.
      if (this->parse_args () == -1)
        return -1;

      // Initialize the factory
      int init_result = this->init_factory (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (init_result != 0)
        ACE_ERROR_RETURN ((LM_ERROR,
                           " (%P|%t) Unable to initialize naming"
                           "services.\n"),
                          -1);
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "init");
      return -1;
    }
  ACE_ENDTRY;

  ACE_RETURN(0);

}

int
BasicLog_Test::init_factory (ACE_ENV_SINGLE_ARG_DECL)
{

  // Assumpting INS for finding LogServie

  //CORBA::Object_var logging_obj = orb_->resolve_initial_references ("BasicLogFactory",
  //                                                         ACE_TRY_ENV);

  this->resolve_naming_service (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (-1);

  this->resolve_basic_factory (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK_RETURN (-1);

  /*
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
                "\nLoggingService resolved\n"));

  if (CORBA::is_nil (logging_obj.in ()))
    ACE_ERROR_RETURN ((LM_ERROR,
                       "LogService resolved to nil object\n"),
                      -1);
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
                "\nLogService resolved\n"));

  // Narrow the factory and check the success
  factory_ =
    DsLogAdmin::BasicLogFactory::_narrow (logging_obj.in () ACE_ENV_ARG_PARAMETER);

  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
                "\nFactory narrowed\n"));
  if (CORBA::is_nil (factory_.in ()))
    ACE_ERROR_RETURN ((LM_ERROR,
                       "narrow returned nil"n"),
                      -1);
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
                "\nLogger_Factory narrowed\n"));
  */
  // If debugging, get the factory's IOR
  CORBA::String_var str =
    orb_->object_to_string (basicLog_.in()
                            ACE_ENV_ARG_PARAMETER); //Init the Client
  ACE_CHECK_RETURN (-1);

  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
                "The logger IOR is <%s>\n",
                str.in ()));

  return 0;
}

int
BasicLog_Test::test_CreateLog (CORBA::ULongLong maxSize)
{

  ACE_TRY_NEW_ENV
    {
      DsLogAdmin::LogId id;
      basicLog_ = factory_->create(DsLogAdmin::wrap, maxSize, id);
      // @@ Krish, never use != 0 to compare a NIL object reference!!!
      ACE_ASSERT (!CORBA::is_nil (basicLog_.in ()));
      ACE_TRY_CHECK;
      ACE_DEBUG ((LM_DEBUG,
                  "The logger id is %d\n",
                  id));
    }
/*  ACE_CATCH(DsLogAdmin::NoResources, resourceX)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "no resources creating basic log.\n"),
                        -1);
    }
*/
  ACE_CATCH(DsLogAdmin::InvalidThreshold, threshold)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         "invalid threshold creating basic log.\n"),
                        -1);
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION(ACE_ANY_EXCEPTION,"test_CreateLog");
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Caught exception creating log.\n"),
                        -1);
    }
  ACE_ENDTRY;

  ACE_RETURN(0);
}

int
BasicLog_Test::test_LogAction ()
{
  ACE_TRY_NEW_ENV
    {
      DsLogAdmin::LogId id = basicLog_->id ();

      ACE_DEBUG ((LM_DEBUG, "The log's id is %d\n", id));

      basicLog_->set_log_full_action (DsLogAdmin::halt);

      DsLogAdmin::LogFullActionType logFullAction =
        basicLog_->get_log_full_action ();

      if (logFullAction != DsLogAdmin::halt)
        {
          ACE_ERROR_RETURN((LM_ERROR,
                            "Setting log full action to halt failed\n"),-1);
        }

      ACE_DEBUG ((LM_DEBUG,
                 "The log's full action successfully set to halt\n"));

#ifndef ACE_LACKS_LONGLONG_T
      ACE_DEBUG ((LM_INFO,
                 "The current size %Q, max size %Q\n",
                 basicLog_->get_current_size (),
                 basicLog_->get_max_size()));
#else
      ACE_DEBUG ((LM_DEBUG,
                 "The current size %u , max size %u\n",
                 basicLog_->get_current_size().lo (),
                 basicLog_->get_max_size().lo ()));
#endif

      // make sure that it is full and when writing
      this->write_records (0 ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      ACE_DEBUG ((LM_DEBUG,
                  "Wrote records instead should have thrown exception"));

      basicLog_->set_log_full_action (DsLogAdmin::wrap);
      ACE_ERROR_RETURN((LM_ERROR,"Testing log action halt failed\n"),-1);
    }
  ACE_CATCH(DsLogAdmin::LogFull, xLogFull)
    {
      ACE_DEBUG ((LM_DEBUG,"Correctly caught exception LogFull\n"));

      CORBA::ULongLong nrecords = basicLog_->get_n_records ();

      ACE_DEBUG ((LM_ERROR,
                  "The number of records written was %d\n",
                  ACE_U64_TO_U32 (nrecords)));

      DsLogAdmin::AvailabilityStatus logStatus =
        basicLog_->get_availability_status ();

      if (!logStatus.log_full)
        ACE_ERROR_RETURN ((LM_ERROR,
                           "Failed the log's get_availability_status.\n"),
                          -1);

      ACE_DEBUG ((LM_DEBUG,
                 "Log's availability status correctly set to log_full\n"));

      basicLog_->set_log_full_action (DsLogAdmin::wrap);
      DsLogAdmin::LogFullActionType logFullAction =
        basicLog_->get_log_full_action();

      if (logFullAction != DsLogAdmin::wrap)
        ACE_ERROR_RETURN((LM_ERROR,
                          "Setting log full action to wrap failed\n"),-1);

      ACE_TRY_EX (SECOND)
        {
          int i = this->write_records (0 ACE_ENV_ARG_PARAMETER);
          ACE_TRY_CHECK_EX (SECOND);

          ACE_DEBUG ((LM_DEBUG,"Test to wrap worked. %d written.\n",i));
        }
      ACE_CATCH (DsLogAdmin::LogFull, xLogFull)
        {
          ACE_DEBUG ((LM_ERROR,"Caught exception LogFull.  Fail testing wrapping of the log.\n"));
          return -1;
        }
      ACE_CATCHANY
        {
          ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "test_LogAction");
          return -1;
        }
      ACE_ENDTRY;
    }
  ACE_ENDTRY;

  return 0;
}
/*
int BasicLog_Test::display_records ()
{
  DsLogAdmin::Iterator_var iter_out;
  DsLogAdmin::RecordList_var rec_list =
    basicLog_->query ("TCL", "id > 0", iter_out);

  CORBA::ULong j = 0;
  for (; j < rec_list->length();++j)  //dhanvey added info
#ifndef ACE_LACKS_LONGLONG_T
   ACE_DEBUG ((LM_DEBUG,
               "id = %Q, time= %Q\n",
               rec_list[j].id, rec_list[j].time));
#else
   ACE_DEBUG ((LM_DEBUG,
               "id = %u, time= %u\n",
               rec_list[j].id.lo(), rec_list[j].time.lo()));
#endif

  return 0;

}
*/
int BasicLog_Test::write_records (CORBA::ULongLong numberOfRecords
                                  ACE_ENV_ARG_DECL_NOT_USED)
{
  CORBA::ULongLong numOfRecs = numberOfRecords;
  if (numOfRecs == 0)
    {
      numOfRecs = basicLog_->get_max_size();
    }

#ifndef ACE_LACKS_LONGLONG_T
  ACE_DEBUG ((LM_INFO,"B_test: Write_records: Max size in bytes %Q.\n", numOfRecs));
#else
  ACE_DEBUG ((LM_INFO,"B_test: Write_records: currentsize in bytes %u.\n", numOfRecs.lo()));
#endif

  int i = 0;
  CORBA::ULongLong l = 0;

  if (numOfRecs == 0)
  {
    for (;;)
    {
        DsLogAdmin::Anys record;
        record.length(1);
        ACE_CString str ("For the test of log "
                         "full action, writing test record, ");
        char number[32];
        ACE_OS::sprintf (number, "%d.", i);
        str += number;
        l += str.length ();
        // record owns internal os string
        ++i;
        CORBA::String_var t(str.c_str ());
        record[0] <<= t.in ();
        basicLog_->write_records(record);
    }
  }
  else
  {
    for(l = 0 ; l < numOfRecs ;)
    {
        DsLogAdmin::Anys record;
        record.length(1);
        ACE_CString str ("For the test of log "
                         "full action, writing test record, ");
        char number[32];
        ACE_OS::sprintf (number, "%d.", i);
        str += number;
        l += str.length ();
        // record owns internal os string
        ++i;
        CORBA::String_var t(str.c_str ());
        record[0] <<= t.in ();
        basicLog_->write_records(record);

      }
  }

#ifndef ACE_LACKS_LONGLONG_T
    ACE_DEBUG ((LM_INFO,"B_test: Write_records: currentsize in bytes %Q.\n",
               basicLog_->get_current_size()));
#else
    ACE_DEBUG ((LM_DEBUG,"B_test: Write_records: currentsize in bytes %u.\n",
               basicLog_->get_current_size().lo()));
#endif

//dhanvey
  CORBA::ULongLong nrecords = basicLog_->get_n_records();

  ACE_DEBUG ((LM_ERROR,"The number of records in log is %d\n", ACE_U64_TO_U32(nrecords)));

  ACE_RETURN(nrecords);
}

int
BasicLog_Test::test_adminState()
{
  ACE_DECLARE_NEW_CORBA_ENV;

  basicLog_->set_administrative_state(DsLogAdmin::locked);
  ACE_TRY
    {
      this->write_records(0 ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      ACE_ERROR_RETURN((LM_ERROR,"Setting administrative state to lock failed.  DsLogAdmin::LogLocked not thrown.\n"),-1);

    }
  ACE_CATCH(DsLogAdmin::LogLocked, xLocked)
    {
      ACE_DEBUG ((LM_DEBUG,"Setting administrative state to lock succeeded.  DsLogAdmin::LogLocked was caught.\n"));
    }
  ACE_CATCHANY
    {
      basicLog_->set_administrative_state(DsLogAdmin::unlocked);
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "test_adminState");
      ACE_ERROR_RETURN((LM_ERROR,"Setting administrative state to lock failed. Exception throw.\n"),-1);
    }
  ACE_ENDTRY;

  basicLog_->set_administrative_state(DsLogAdmin::unlocked);
  ACE_TRY_EX(SECOND)
    {
      this->write_records(0 ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK_EX (SECOND);
      ACE_DEBUG ((LM_DEBUG,"Setting administrative state to succeeded.  DsLogAdmin::LogLocked not thrown.\n"));
      ACE_RETURN(0);

    }
  ACE_CATCH(DsLogAdmin::LogLocked, xLocked)
    {
      ACE_DEBUG ((LM_DEBUG,"Setting administrative state to lock faild.  DsLogAdmin::LogLocked was caught.\n"));
    }
  ACE_ENDTRY;
  ACE_RETURN(0);
}


int
BasicLog_Test::test_logSize (void)
{
  ACE_DECLARE_NEW_CORBA_ENV;

  ACE_TRY
    {
      basicLog_->set_max_size (1);
      ACE_TRY_CHECK;

      ACE_ERROR_RETURN ((LM_ERROR,
                         "Setting max size less than current size failed.\n"
                         "DsLogAdmin::InvalidParam not thrown.\n"),
                       -1);
    }
  ACE_CATCH(DsLogAdmin::InvalidParam, xParam)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "Setting max size less than current size succeeded.\n"
                  "DsLogAdmin::InvalidParam caught.\n"));
    }
  ACE_ENDTRY;

  ACE_TRY_EX(SECOND)
    {
      basicLog_->set_max_size (10000);

      CORBA::ULongLong nrecords = basicLog_->get_n_records ();
      int i = this->write_records (0 ACE_ENV_ARG_PARAMETER);

      ACE_TRY_CHECK_EX (SECOND);
      ACE_DEBUG ((LM_DEBUG,
                  "Increasing max size succeeded. Old record count, %d."
                  "New record count, %d\n",
                  ACE_U64_TO_U32(nrecords),
                  i));
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "test_logSize");
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Increasing max size failed. Exception thrown.\n"),
                        -1);
    }
  ACE_ENDTRY;
  ACE_RETURN(0);
}

int
BasicLog_Test::test_logCompaction(CORBA::ULong lifeExpectancy)
{
  ACE_DECLARE_NEW_CORBA_ENV;

  CORBA::ULongLong old_n_records = basicLog_->get_n_records ();
  if (old_n_records <= 0)
    {
      ACE_TRY
        {
          this->write_records (0 ACE_ENV_ARG_PARAMETER);
          ACE_TRY_CHECK;
        }
      ACE_CATCHANY
        {
          ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "test_logCompaction");
          ACE_ERROR_RETURN ((LM_ERROR,
                             "Caught exception trying to write records "
                             "for test_logCompaction.\n"),
                            -1);
        }
      ACE_ENDTRY;
    }

  CORBA::ULong old_max_life = basicLog_->get_max_record_life ();

  ACE_TRY_EX(SECOND)
    {
      basicLog_->set_max_record_life (lifeExpectancy);
      // @@: need to modify set_max_record_life
      ACE_TRY_CHECK_EX (SECOND);
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "test_logCompaction");
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Caught exception setting max record life "
                         "test_logCompaction.\n"),
                        -1);
    }
  ACE_ENDTRY;

  ACE_OS::sleep (lifeExpectancy + 1); // make sure the records have aged.
  CORBA::ULongLong new_n_records = basicLog_->get_n_records ();
  basicLog_->set_max_record_life (old_max_life);

  ACE_DEBUG ((LM_ERROR,
              "The number of records in log is %d\n",
              ACE_U64_TO_U32 (new_n_records)));

  if (new_n_records != 0)
    {
      ACE_ERROR_RETURN((LM_ERROR,
                        "Log compaction failed, because %d records remain.\n",
                        ACE_U64_TO_U32 (new_n_records)),
                       -1 );
    }

  return 0;
}

//use ACE_U64_TO_U32 to convert ULongLong to ULong in call to this function
//Writes and retrieves numberOfrecordsToWrite records.
int
BasicLog_Test::test_retrieval (CORBA::ULong /* numberOfRecordsToWrite */)
{
  int rc = 0;

  if (!rc)
    {
      ACE_DEBUG ((LM_ERROR,"Test of retrieval: succeeded.\n"));
    }

  return rc;
}



int
BasicLog_Test::test_query(CORBA::ULong numberOfRecordsToWrite)
{
    // save for compares
    DsLogAdmin::Anys infos(numberOfRecordsToWrite);
    return -1;
}


int
BasicLog_Test::parse_args (void)
{
  ACE_Get_Opt get_opts (argc_, argv_, "di");
  int c;

  while ((c = get_opts ()) != -1)
    switch (c)
      {
      case 'd':  // debug flag
        TAO_debug_level++;
        break;
      case '?':
      default:
        ACE_ERROR_RETURN ((LM_ERROR,
                           "usage:  %s"
                           " [-d]"
                           "\n"
                           "    -d: increase debug level\n",
                           this->argv_ [0]),
                          -1);
      }

  // Indicates successful parsing of command line.
  return 0;
}

void
BasicLog_Test::resolve_naming_service (ACE_ENV_SINGLE_ARG_DECL)
{
  CORBA::Object_var naming_obj =
    this->orb_->resolve_initial_references (naming_sevice_name_
                                            ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  // Need to check return value for errors.
  if (CORBA::is_nil (naming_obj.in ()))
    ACE_THROW (CORBA::UNKNOWN ());

  this->naming_context_ =
    CosNaming::NamingContext::_narrow (naming_obj.in () ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
}

void
BasicLog_Test::resolve_basic_factory (ACE_ENV_SINGLE_ARG_DECL)
{
  CosNaming::Name name (1);
  name.length (1);
  name[0].id = CORBA::string_dup (basic_log_factory_name_);

  CORBA::Object_var obj =
    this->naming_context_->resolve (name ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;

  this->factory_ =
    DsLogAdmin::BasicLogFactory::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
  ACE_CHECK;
}

void
BasicLog_Test::destroy_log()
{
  ACE_TRY_NEW_ENV
    {
      if (!CORBA::is_nil(basicLog_.in ()))
        {
          basicLog_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
          ACE_TRY_CHECK;

          basicLog_ = DsLogAdmin::BasicLog::_nil ();
        }
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Destroying log");
    }
  ACE_ENDTRY;
}

int BasicLog_Test::test_log_destroy (void)
{

  ACE_DEBUG ((LM_ERROR, "Testing destroy log\n"));
  this->basicLog_->destroy ();

  ACE_TRY_NEW_ENV
    {
      this->write_records (1 ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
      ACE_DEBUG ((LM_INFO, "Wrote to log\n"));
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Destroying log");
      ACE_DEBUG ((LM_ERROR,
                  "Test of destroy log succeeded and caught exception.\n"));
      return 0;
    }
  ACE_ENDTRY;
  ACE_ERROR_RETURN ((LM_ERROR,
                     "Test of destroy log failed and no exception thrown.\n"),
                    -1);
}

int
BasicLog_Test::test_week_mask (void)
{
  DsLogAdmin::WeekMask masks;
  masks.length (1);

  masks[0].days =
    DsLogAdmin::Monday
    | DsLogAdmin::Tuesday
    | DsLogAdmin::Wednesday
    | DsLogAdmin::Friday
    | DsLogAdmin::Saturday;

  masks[0].intervals.length(1);

  masks[0].intervals[0].start.hour = (CORBA::Short) 13;

  masks[0].intervals[0].start.minute = (CORBA::Short) 30;
  masks[0].intervals[0].stop.hour = (CORBA::Short) 14;
  masks[0].intervals[0].stop.minute = (CORBA::Short) 30;

  this->basicLog_->set_week_mask (masks);

  return 0;
}


int BasicLog_Test::delete_records (CORBA::ULongLong /* numberOfRecords */)
{
  ACE_DECLARE_NEW_CORBA_ENV;

#ifndef ACE_LACKS_LONGLONG_T
  ACE_DEBUG ((LM_INFO,
              " before delete -- curr size %Q, max %Q\n",
              basicLog_->get_current_size (),
              basicLog_->get_max_size()));
#else
  ACE_DEBUG ((LM_DEBUG,
              "2ndThe current size %u , max size %u\n",
              basicLog_->get_current_size().lo(),
              basicLog_->get_max_size().lo()));
#endif

  CORBA::ULongLong nrecords = basicLog_->get_n_records ();

  ACE_DEBUG ((LM_ERROR,
              "The number of records was %d\n",
              ACE_U64_TO_U32 (nrecords)));

  CORBA::Long retVal =
    basicLog_->delete_records ("TCL", "id >= 0" ACE_ENV_ARG_PARAMETER);

  ACE_DEBUG ((LM_DEBUG,
              "Number of records in Log after delete = %d\n",
              retVal));

#ifndef ACE_LACKS_LONGLONG_T
  ACE_DEBUG ((LM_INFO,
              " after delete -- curr size %Q, max %Q\n",
              basicLog_->get_current_size (),
              basicLog_->get_max_size ()));
#else
  ACE_DEBUG ((LM_DEBUG,
              "2ndThe current size %u , max size %u\n",
              basicLog_->get_current_size ().lo (),
              basicLog_->get_max_size ().lo ()));
#endif

  nrecords = basicLog_->get_n_records ();

  ACE_DEBUG ((LM_ERROR,
              "The number of records is %d\n",
              ACE_U64_TO_U32 (nrecords)));

return 0;
}

int
BasicLog_Test::test_capacity_alarm_threshold (void)
{

  //basicLog_->set_log_full_action(DsLogAdmin::halt);

  DsLogAdmin::CapacityAlarmThresholdList list;
  list.length(0);

  basicLog_->set_capacity_alarm_thresholds (list);

  ACE_DECLARE_NEW_CORBA_ENV;

  list.length (1);
  list[0] = 200;

  ACE_TRY
    {
      basicLog_->set_capacity_alarm_thresholds (list);
      ACE_TRY_CHECK;
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Setting an invalid alarm threshold failed.  "
                         "DsLogAdmin::InvalidThreshold not thrown.\n"),
                        -1);
    }
  ACE_CATCH(DsLogAdmin::InvalidThreshold, xParam)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "Setting an invalid alarm threshold succeeded.  "
                  "DsLogAdmin::InvalidThreshold caught.\n"));
    }
  ACE_ENDTRY;

  list.length (2);
  list[0] = 70;
  list[1] = 20;

  ACE_TRY_EX(SECOND)
    {
      basicLog_->set_capacity_alarm_thresholds (list);
      ACE_TRY_CHECK_EX (SECOND);
      ACE_ERROR_RETURN ((LM_ERROR,
                         "Setting an invalid alarm threshold failed.  "
                         "DsLogAdmin::InvalidThreshold not thrown.\n"),
                       -1);
    }
  ACE_CATCH(DsLogAdmin::InvalidThreshold, xParam)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "Setting an invalid alarm threshold succeeded.  "
                  "DsLogAdmin::InvalidThreshold caught.\n"));
    }
  ACE_ENDTRY;

  list.length (2);
  list[0] = 20;
  list[1] = 70;

  basicLog_->set_capacity_alarm_thresholds (list);

  CORBA::ULongLong nrecords = basicLog_->get_n_records();

  ACE_DEBUG ((LM_ERROR,
              "The number of records is %d\n",
              ACE_U64_TO_U32(nrecords)));

  this->write_records (0 ACE_ENV_ARG_PARAMETER);

  return 0;

}