Skip to content

Commit 6c6b8f4

Browse files
Jira wdt 83 enhance discovery system tests (#603)
* Fix java.lang.Boolean issues for ActiveDirectoryAuthenticator * Test parsing
1 parent 3614c41 commit 6c6b8f4

File tree

2 files changed

+95
-4
lines changed

2 files changed

+95
-4
lines changed

system-test/src/test/java/oracle/weblogic/deploy/integration/BaseTest.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
// Copyright 2019, 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 http://oss.oracle.com/licenses/upl.
33

44
package oracle.weblogic.deploy.integration;
55

66
import java.io.File;
7+
import java.io.BufferedReader;
8+
import java.io.FileReader;
79
import java.nio.file.Files;
810
import java.nio.file.Path;
911
import java.nio.file.Paths;
12+
import java.util.ArrayList;
13+
import java.util.List;
1014
import java.util.logging.Logger;
1115
import oracle.weblogic.deploy.integration.utils.ExecCommand;
1216
import oracle.weblogic.deploy.integration.utils.ExecResult;
@@ -245,6 +249,33 @@ protected String getDBContainerIP() throws Exception {
245249
return dbhost;
246250
}
247251

252+
protected void verifyModelFileContents(String modelFileName, List<String> textToFind) throws Exception {
253+
BufferedReader model = inputYaml(modelFileName);
254+
List<String> checkList = new ArrayList(textToFind);
255+
while (model.ready()) {
256+
String nextLine = model.readLine();
257+
if (nextLine != null) {
258+
for (String textLine : textToFind) {
259+
if (nextLine.indexOf(textLine) >=0 ) {
260+
checkList.remove(textLine);
261+
break;
262+
}
263+
}
264+
}
265+
}
266+
if (checkList.size() > 0) {
267+
for (String leftover : checkList) {
268+
System.err.println("Model file did not contain " + leftover);
269+
}
270+
throw new Exception("Model file did not contain expected results");
271+
}
272+
}
273+
274+
protected BufferedReader inputYaml(String yamlFileName) throws Exception {
275+
File model = new File(yamlFileName);
276+
return new BufferedReader(new FileReader(model));
277+
}
278+
248279
private static ExecResult executeAndVerify(String command, boolean isRedirectToOut) throws Exception {
249280
logger.info("Executing command: " + command);
250281
ExecResult result = ExecCommand.exec(command, isRedirectToOut);

system-test/src/test/java/oracle/weblogic/deploy/integration/ITWdt.java

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

@@ -14,11 +14,12 @@
1414
import org.junit.Test;
1515
import org.junit.rules.TestWatcher;
1616
import org.junit.runner.Description;
17+
import java.util.ArrayList;
18+
import java.util.List;
1719
import java.nio.file.Files;
1820
import java.nio.file.Path;
1921
import java.nio.file.Paths;
2022
import java.nio.file.StandardCopyOption;
21-
2223
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
2324
public 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

Comments
 (0)