Skip to content

Commit b5566a5

Browse files
authored
cleanup for Checkstyle/Sonar formatting and Copyright headers in test sources (#88)
1 parent e7d3f57 commit b5566a5

File tree

10 files changed

+243
-210
lines changed

10 files changed

+243
-210
lines changed

imagetool/src/test/java/com/oracle/weblogic/imagetool/api/model/DomainTypeTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
14
package com.oracle.weblogic.imagetool.api.model;
25

36
import org.junit.Test;
@@ -7,7 +10,7 @@
710

811
public class DomainTypeTest {
912

10-
@org.junit.Test
13+
@Test
1114
public void fromValue() {
1215
assertEquals("validate domain type lowercase wls", DomainType.WLS, DomainType.fromValue("wls"));
1316
assertEquals("validate domain type uppercase WLS", DomainType.WLS, DomainType.fromValue("WLS"));

imagetool/src/test/java/com/oracle/weblogic/imagetool/cli/cache/AddEntryTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
14
package com.oracle.weblogic.imagetool.cli.cache;
25

6+
import java.io.ByteArrayOutputStream;
7+
import java.io.PrintStream;
8+
39
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
410
import com.oracle.weblogic.imagetool.cli.WLSCommandLine;
511
import org.junit.After;
612
import org.junit.Before;
713
import org.junit.Test;
814
import picocli.CommandLine;
9-
import java.io.ByteArrayOutputStream;
10-
import java.io.PrintStream;
1115

12-
import static org.junit.Assert.*;
16+
import static org.junit.Assert.assertEquals;
17+
import static org.junit.Assert.assertTrue;
1318

1419
public class AddEntryTest {
1520

@@ -44,9 +49,10 @@ public void testMissingKey() {
4449

4550
@Test
4651
public void testMissingValue() {
47-
WLSCommandLine.call(new AddEntry(), printStream, printStream, CommandLine.Help.Ansi.AUTO, true, true,
48-
"--key", "some_key");
49-
assertTrue(new String(byteArrayOutputStream.toByteArray()).contains("Missing required option '--value=<location>'"));
52+
WLSCommandLine.call(new AddEntry(), printStream, printStream, CommandLine.Help.Ansi.AUTO, true,
53+
true,"--key", "some_key");
54+
assertTrue(new String(byteArrayOutputStream.toByteArray())
55+
.contains("Missing required option '--value=<location>'"));
5056
}
5157

5258
@Test

imagetool/src/test/java/com/oracle/weblogic/imagetool/cli/cache/AddInstallerEntryTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
14
package com.oracle.weblogic.imagetool.cli.cache;
25

6+
import java.io.ByteArrayOutputStream;
7+
import java.io.PrintStream;
8+
39
import com.oracle.weblogic.imagetool.api.model.CommandResponse;
410
import com.oracle.weblogic.imagetool.api.model.InstallerType;
511
import com.oracle.weblogic.imagetool.cli.WLSCommandLine;
612
import org.junit.After;
713
import org.junit.Before;
814
import org.junit.Test;
915
import picocli.CommandLine;
10-
import java.io.ByteArrayOutputStream;
11-
import java.io.PrintStream;
1216

13-
import static org.junit.Assert.*;
17+
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.assertTrue;
1419

1520
public class AddInstallerEntryTest {
1621

imagetool/src/test/java/com/oracle/weblogic/imagetool/impl/meta/FileCacheStoreTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1+
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
3+
14
package com.oracle.weblogic.imagetool.impl.meta;
25

36
import com.oracle.weblogic.imagetool.api.meta.CacheStore;
4-
import com.oracle.weblogic.imagetool.util.Constants;
57
import org.junit.FixMethodOrder;
68
import org.junit.Test;
79
import org.junit.runners.MethodSorters;
810

9-
import java.io.File;
10-
import java.io.IOException;
11-
import java.nio.file.Files;
12-
import java.nio.file.Path;
13-
1411
import static org.junit.Assert.assertEquals;
1512
import static org.junit.Assert.assertNotNull;
1613
import static org.junit.Assert.assertNull;

imagetool/src/test/java/com/oracle/weblogic/imagetool/integration/BaseTest.java

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2-
// Licensed under the Universal Permissive License v 1.0 as shown at
3-
// http://oss.oracle.com/licenses/upl.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
43

54
package com.oracle.weblogic.imagetool.integration;
65

7-
import com.oracle.weblogic.imagetool.integration.utils.ExecCommand;
8-
import com.oracle.weblogic.imagetool.integration.utils.ExecResult;
96
import java.io.File;
107
import java.nio.file.Files;
118
import java.nio.file.Path;
129
import java.nio.file.Paths;
1310
import java.util.logging.Logger;
1411

12+
import com.oracle.weblogic.imagetool.integration.utils.ExecCommand;
13+
import com.oracle.weblogic.imagetool.integration.utils.ExecResult;
14+
1515
public class BaseTest {
1616

1717
protected static final Logger logger = Logger.getLogger(ITImagetool.class.getName());
@@ -38,22 +38,22 @@ protected static void initialize() throws Exception {
3838

3939
projectRoot = System.getProperty("user.dir");
4040

41-
if(System.getenv("WLSIMG_BLDDIR") != null) {
41+
if (System.getenv("WLSIMG_BLDDIR") != null) {
4242
wlsImgBldDir = System.getenv("WLSIMG_BLDDIR");
4343
} else {
4444
wlsImgBldDir = System.getenv("HOME");
4545
}
46-
if(System.getenv("WLSIMG_CACHEDIR") != null) {
46+
if (System.getenv("WLSIMG_CACHEDIR") != null) {
4747
wlsImgCacheDir = System.getenv("WLSIMG_CACHEDIR");
4848
} else {
4949
wlsImgCacheDir = System.getenv("HOME") + FS + "cache";
5050
}
5151

52-
imagetool = "java -cp \"" + getImagetoolHome() + FS + "lib" + FS + "*\" -Djava.util.logging.config.file=" +
53-
getImagetoolHome() + FS + "bin" + FS + "logging.properties com.oracle.weblogic.imagetool.cli.CLIDriver";
52+
imagetool = "java -cp \"" + getImagetoolHome() + FS + "lib" + FS + "*\" -Djava.util.logging.config.file="
53+
+ getImagetoolHome() + FS + "bin" + FS + "logging.properties com.oracle.weblogic.imagetool.cli.CLIDriver";
5454

5555
build_tag = System.getenv("BUILD_TAG");
56-
if(build_tag != null ) {
56+
if (build_tag != null) {
5757
build_tag = build_tag.toLowerCase();
5858
} else {
5959
build_tag = "imagetool";
@@ -78,7 +78,7 @@ protected static void setup() throws Exception {
7878
command = "source " + getImagetoolHome() + FS + "bin" + FS + "setup.sh";
7979
executeNoVerify(command);
8080

81-
if(!(new File(wlsImgBldDir)).exists()) {
81+
if (!(new File(wlsImgBldDir)).exists()) {
8282
logger.info(wlsImgBldDir + " does not exist, creating it");
8383
(new File(wlsImgBldDir)).mkdir();
8484
}
@@ -95,8 +95,8 @@ protected static void cleanup() throws Exception {
9595
// clean up the docker images
9696
command = "docker stop " + dbContainerName;
9797
executeNoVerify(command);
98-
command = "docker rmi -f " + BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " " + ORACLE_DB_IMG + ":" +
99-
ORACLE_DB_IMG_TAG;
98+
command = "docker rmi -f " + BASE_OS_IMG + ":" + BASE_OS_IMG_TAG + " " + ORACLE_DB_IMG + ":"
99+
+ ORACLE_DB_IMG_TAG;
100100
executeNoVerify(command);
101101

102102
command = "docker rmi -f $(docker images | grep " + build_tag + " | tr -s ' ' | cut -d ' ' -f 3)";
@@ -120,23 +120,23 @@ protected static void pullOracleDBDockerImage() throws Exception {
120120
protected static void downloadInstallers(String... installers) throws Exception {
121121
// create the cache dir for downloading installers if not exists
122122
File cacheDir = new File(getInstallerCacheDir());
123-
if( !cacheDir.exists()) {
123+
if (!cacheDir.exists()) {
124124
cacheDir.mkdir();
125125
}
126126

127127
boolean missingInstaller = false;
128128
StringBuffer errorMsg = new StringBuffer();
129129
errorMsg.append("The test installers are missing. Please download: \n");
130130
// check the required installer is downloaded
131-
for(String installer : installers) {
131+
for (String installer : installers) {
132132
File installFile = new File(getInstallerCacheDir() + FS + installer);
133-
if(!installFile.exists()) {
133+
if (!installFile.exists()) {
134134
missingInstaller = true;
135-
errorMsg.append( " " + installer + "\n");
135+
errorMsg.append(" " + installer + "\n");
136136
}
137137
}
138138
errorMsg.append("and put them in " + getInstallerCacheDir());
139-
if(missingInstaller) {
139+
if (missingInstaller) {
140140
throw new Exception(errorMsg.toString());
141141
}
142142
}
@@ -168,23 +168,23 @@ protected static void executeNoVerify(String command) throws Exception {
168168
}
169169

170170
protected void verifyResult(ExecResult result, String matchString) throws Exception {
171-
if(result.exitValue() != 0 || !result.stdout().contains(matchString)) {
171+
if (result.exitValue() != 0 || !result.stdout().contains(matchString)) {
172172
throw new Exception("verifying test result failed.");
173173
}
174174
}
175175

176176
protected void verifyExitValue(ExecResult result, String command) throws Exception {
177-
if(result.exitValue() != 0) {
177+
if (result.exitValue() != 0) {
178178
logger.info(result.stderr());
179179
throw new Exception("executing the following command failed: " + command);
180180
}
181181
}
182182

183183
protected void verifyDockerImages(String imageTag) throws Exception {
184184
// verify the docker image is created
185-
ExecResult result = ExecCommand.exec("docker images | grep " + build_tag + " | grep " + imageTag +
186-
"| wc -l");
187-
if(Integer.parseInt(result.stdout().trim()) != 1) {
185+
ExecResult result = ExecCommand.exec("docker images | grep " + build_tag + " | grep " + imageTag
186+
+ "| wc -l");
187+
if (Integer.parseInt(result.stdout().trim()) != 1) {
188188
throw new Exception("wls docker image is not created as expected");
189189
}
190190
}
@@ -205,14 +205,14 @@ protected ExecResult listItemsInCache() throws Exception {
205205
}
206206

207207
protected ExecResult addInstallerToCache(String type, String version, String path) throws Exception {
208-
String command = imagetool + " cache addInstaller --type " + type + " --version " + version +
209-
" --path " + path;
208+
String command = imagetool + " cache addInstaller --type " + type + " --version " + version
209+
+ " --path " + path;
210210
return executeAndVerify(command, false);
211211
}
212212

213213
protected ExecResult addPatchToCache(String type, String patchId, String version, String path) throws Exception {
214-
String command = imagetool + " cache addPatch --type " + type + " --patchId " + patchId + "_" +
215-
version + " --path " + path;
214+
String command = imagetool + " cache addPatch --type " + type + " --patchId " + patchId + "_"
215+
+ version + " --path " + path;
216216
return executeAndVerify(command, false);
217217
}
218218

@@ -236,9 +236,9 @@ protected void createDBContainer() throws Exception {
236236
logger.info("Creating an Oracle db docker container ...");
237237
String command = "docker rm -f " + dbContainerName;
238238
ExecCommand.exec(command);
239-
command = "docker run -d --name " + dbContainerName + " --env=\"DB_PDB=InfraPDB1\"" +
240-
" --env=\"DB_DOMAIN=us.oracle.com\" --env=\"DB_BUNDLE=basic\" " + ORACLE_DB_IMG + ":" +
241-
ORACLE_DB_IMG_TAG;
239+
command = "docker run -d --name " + dbContainerName + " --env=\"DB_PDB=InfraPDB1\""
240+
+ " --env=\"DB_DOMAIN=us.oracle.com\" --env=\"DB_BUNDLE=basic\" " + ORACLE_DB_IMG + ":"
241+
+ ORACLE_DB_IMG_TAG;
242242
ExecCommand.exec(command);
243243

244244
// wait for the db is ready
@@ -268,10 +268,10 @@ private static void pullDockerImage(String imagename, String imagetag) throws Ex
268268
ExecCommand.exec("docker pull " + imagename + ":" + imagetag);
269269

270270
// verify the docker image is pulled
271-
ExecResult result = ExecCommand.exec("docker images | grep " + imagename + " | grep " +
272-
imagetag + "| wc -l");
271+
ExecResult result = ExecCommand.exec("docker images | grep " + imagename + " | grep "
272+
+ imagetag + "| wc -l");
273273
String resultString = result.stdout();
274-
if(Integer.parseInt(resultString.trim()) != 1) {
274+
if (Integer.parseInt(resultString.trim()) != 1) {
275275
throw new Exception("docker image " + imagename + ":" + imagetag + " is not pulled as expected."
276276
+ " Expected 1 image, found " + resultString);
277277
}

0 commit comments

Comments
 (0)