1- // Copyright 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
1+ // Copyright 2019, 2020, Oracle Corporation and/or its affiliates.
22// Licensed under the Universal Permissive License v 1.0 as shown at
33// http://oss.oracle.com/licenses/upl.
44
1414import org .junit .Test ;
1515import org .junit .rules .TestWatcher ;
1616import org .junit .runner .Description ;
17+ import java .util .ArrayList ;
18+ import java .util .List ;
1719import java .nio .file .Files ;
1820import java .nio .file .Path ;
1921import java .nio .file .Paths ;
2022import java .nio .file .StandardCopyOption ;
21-
2223@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
2324public class ITWdt extends BaseTest {
2425
@@ -392,10 +393,24 @@ public void testFDiscoverDomainWithRequiredArgument() throws Exception {
392393 // verify model file
393394 String expectedModelFile = System .getProperty ("java.io.tmpdir" ) + FS + "model" + FS + "restrictedJRFD1.yaml" ;
394395 verifyModelFile (expectedModelFile );
396+ verifyFDiscoverDomainWithRequiredArgument (expectedModelFile );
397+ System .out .println ("model file=" + expectedModelFile );
395398
396399 logTestEnd (testMethodName );
397400 }
398401
402+ private void verifyFDiscoverDomainWithRequiredArgument (String expectedModelFile ) throws Exception {
403+ List <String > checkContents = new ArrayList <>();
404+ checkContents .add ("domainInfo:" );
405+ checkContents .add ("AdminUserName: '--FIX ME--'" );
406+ checkContents .add ("CoherenceClusterSystemResource: defaultCoherenceCluster" );
407+ checkContents .add ("PublicAddress: kubernetes" );
408+ checkContents .add ("Trust Service Identity Asserter:" );
409+ checkContents .add ("appDeployments:" );
410+ checkContents .add ("SourcePath: 'wlsdeploy/applications/simple-app.war'" );
411+ verifyModelFileContents (expectedModelFile , checkContents );
412+ }
413+
399414 /**
400415 * test discoverDomain.sh with -model_file argument
401416 * @throws Exception - if any error occurs
@@ -421,6 +436,40 @@ public void testGDiscoverDomainWithModelFile() throws Exception {
421436
422437 logTestEnd (testMethodName );
423438 }
439+ /**
440+ * test discoverDomain.sh with -variable_file argument
441+ * @throws Exception - if any error occurs
442+ */
443+ @ Test
444+ public void testGDiscoverDomainWithVariableFile () throws Exception {
445+ String testMethodName = new Object () {}.getClass ().getEnclosingMethod ().getName ();
446+ logTestBegin (testMethodName );
447+
448+ String discoveredArchive = System .getProperty ("java.io.tmpdir" ) + FS + "discoveredArchive.zip" ;
449+ String discoveredModelFile = System .getProperty ("java.io.tmpdir" ) + FS + "discoveredRestrictedJRFD1.yaml" ;
450+ String discoveredVaribleFile = System .getProperty ("java.io.tmpdir" ) + FS + "discoveredRestrictedJRFD1.properties" ;
451+ String cmd = discoverDomainScript + " -oracle_home " + mwhome_12213 + " -domain_home " +
452+ domainParent12213 + FS + "restrictedJRFD1 -archive_file " + discoveredArchive +
453+ " -model_file " + discoveredModelFile + " -variable_file " + discoveredVaribleFile ;
454+
455+ logger .info ("executing command: " + cmd );
456+ ExecResult result = ExecCommand .exec (cmd );
457+
458+ verifyResult (result , "discoverDomain.sh completed successfully" );
459+
460+ // verify model file and variable file
461+ verifyModelFile (discoveredModelFile );
462+ verifyModelFile (discoveredVaribleFile );
463+ verifyGDiscoverDomainWithVariableFile (discoveredModelFile );
464+
465+ logTestEnd (testMethodName );
466+ }
467+
468+ private void verifyGDiscoverDomainWithVariableFile (String expectedModelFile ) throws Exception {
469+ List <String > checkContents = new ArrayList <>();
470+ checkContents .add ("AdminUserName: '@@PROP:AdminUserName@@'" );
471+ verifyModelFileContents (expectedModelFile , checkContents );
472+ }
424473
425474 /**
426475 * test discoverDomain.sh with -domain_type as JRF
@@ -444,10 +493,21 @@ public void testHDiscoverDomainJRFDomainType() throws Exception {
444493
445494 // verify model file
446495 verifyModelFile (discoveredModelFile );
447-
496+ verifyHDiscoverDomainJRFDomainType ( discoveredModelFile );
448497 logTestEnd (testMethodName );
449498 }
450499
500+ private void verifyHDiscoverDomainJRFDomainType (String expectedModelFile ) throws Exception {
501+ List <String > checkContents = new ArrayList <>();
502+ checkContents .add ("AWT Application Context Startup Class" );
503+ try {
504+ verifyModelFileContents (expectedModelFile , checkContents );
505+ throw new Exception ("JRF blacklist components found in model file" );
506+ } catch (Exception e ) {
507+ // empty this is expected result
508+ }
509+ }
510+
451511 /**
452512 * test updateDomain.sh, update the domain to set the number of dynamic servers to 4
453513 * @throws Exception - if any error occurs
0 commit comments