!******************************************************************************!
! A test macro for getting the status/key from a very large platinum
! header with large keywords.
!
! Arguments: None
!
! Note: This macro will run a file with large keyword values. This
!       file should be placed in the user's read aux directory. The large platinum
!       file is located on the admin_nextmidas repository under the /test directory.
!       The name of the file is "large_platinum_status_key.tmp"
!
! @bug      NXM-2971 Platinum header with large keyword section never completes
! @since    NeXtMidas 3.7.2
! @author:  Juan J Velasquez
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  res filename large_platinum_status_key.tmp

  res testCases {}
  res testCases.TEST1 {CMD="STATUS/KEY ^filename", &
                      INST="After the filename status information there should &
                            be a complete display of header and keywords. &
                            After verifying this click the pass or fail options"}

  if interAct then
    pipe on
      panel/msgid=MAIN/setup/controls=gc
      gcontrol label macro "MACRO"
      gcontrol menu MAIN "Exit with Status = " "PASS,FAIL" /tleft
      set gc.MAIN.itemColors {PASS=GREEN,FAIL=RED}
      if filename FEXISTS then
        gcontrol text idtext "Instructions" &
          "FOR DEVELOPERS TEST ONLY.\n &
          Please click on the test below. &
          You should see a large file printed to the shell on the &
            right. Please verify that the filename is printed first. &
            In addition, the file should have the header and corresponding keywords printed.\n\n & 
            NOTE: please increase you java maximum heap space to be as large as your &
            input file size.\nTo set the java heap size add the following to your .cshrc script:\n &
            setenv NM_USER_JVM_FLAGS \"-Xms512m -Xmx2g\" " 32 18 /title
      else
        gcontrol text idtext "Instructions" &
           "FOR DEVELOPERS TEST ONLY.\n &
            Please retrieve the large platinum file which is &
            located on the admin_nextmidas repository under the /test directory. &
            The name of the file is \"large_platinum_status_key.tmp.\"\n &
            This file should be placed in the user's read aux directory before &
            running this test" 32 18 /title
      endif
      table testCases GETKEYS/S testNames
      gcontrol menu testid "Test files to STATUS" "^testNames"  /nc=1
      shellgui/id=idshellgui/attach
    pipe off
  endif
endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
!******************************************************************************!
procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if (msg.name EQS "MAIN") then
    assert/text="^reg.main.name: Interactive tests for STATUS" msg.data eqs "PASS"
    pipe stop

  elseif (msg.name EQS "TESTID") then
    ! clear text in SHELLGUI before next test case
    message func=sendx id=idshellgui name="CLEAR"

    res testCase testCases.^{msg.data}

    res gc.idtext.value testCase.inst

    say "nM> ^{testCase.CMD}"
    run testCase.CMD

  else
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  endif
return