!******************************************************************************!
! Tests for allowing wildcard (*) at end of directory (path) in CLASSPATH,
! which new tool support added in Java 6.
!
! @bug     2770 Tests NM_BOOT_CP_APPEND using wildcard (*)
! @author  Doug Siamon / Neon Ngo
! @since   NeXtMidas 3.4.0
!******************************************************************************!
startmacro

  ! This test confirms that the Runtime Option NM_BOOT_CP_APPEND may contain a CLASSPATH
  ! with a wild card (*) at end of directory.  In order to verify this,  a new shell is
  ! launched (test_classpath_wildcard.sh) that will isolate the environmental 
  ! settings.  Specifically, setting NM_BOOT_CP_APPEND with a directory 
  ! containing a test jar using "*".  The shell will then invoke another
  ! NeXtMidas test macro that simply invokes a method contained in the test jar.
  ! The method prints to stdout an expected message.

  ! Since 3.8.0
  if ^{env.NMROOT} EQS "classpath:" then
    info "SKIPPING ^reg.main.name since batch files can not be executed from within a JAR - &
          copying the batch files out requires a major rewrite, since this passes in NMROOT to the scripts &
          and NMROOT is uses both to find the jars and to locate the scripts"
    stop
  endif

  if ENV.OSTYPE EQS "UNIX" then
    os/stdout=myout/stderr=myerr ^{env.NMROOT}/nxm/sys/test/test_classpath_wildcard.sh ^{env.NMROOT}
  elseif ENV.OSNAME EQSS "Windows" then
    os/stdout=myout/stderr=myerr ^{env.NMROOT}/nxm/sys/test/test_classpath_wildcard.bat
  else 
    info "No ^reg.main.name tests for OS type = ^env.ostype"
  endif

  invoke containsExpectedOutput myout.contains("Hello World - Test Class Path")
  if containsExpectedOutput isFalse then
    warn "=== ^reg.main.name: test failed: stdout (in MYOUT) and stderr (in MYERR) ==="
    res my*
  endif

  file name dir (path,to,jars,dir) "*"
  assert/text="Load/run class from TestClassPath.jar included via wildcard (e.g. ^dir) in NM_BOOT_CP_APPEND environment variable" containsExpectedOutput

endmacro
