1
+ // Copyright (c) 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2
+ // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3
+
4
+ package com .oracle .weblogic .imagetool .util ;
5
+
6
+ import java .io .File ;
7
+ import java .io .IOException ;
8
+ import java .io .StringWriter ;
9
+ import java .util .Arrays ;
10
+
11
+ import com .github .mustachejava .DefaultMustacheFactory ;
12
+ import com .github .mustachejava .Mustache ;
13
+ import com .github .mustachejava .MustacheFactory ;
14
+ import com .oracle .weblogic .imagetool .api .model .DomainType ;
15
+ import org .junit .Test ;
16
+
17
+ import static org .junit .Assert .assertTrue ;
18
+
19
+ public class DockerfileBuilderTest {
20
+
21
+ /**
22
+ * Catch mismatched start/end tags and missing mustache braces.
23
+ * @throws IOException if file read fails for mustache file.
24
+ */
25
+ @ Test
26
+ public void validateMustacheAliases () throws IOException {
27
+ DockerfileOptions dockerfileOptions = new DockerfileOptions ()
28
+ .setPatchingEnabled ()
29
+ .setOPatchPatchingEnabled ()
30
+ .setWdtEnabled ()
31
+ .setWdtDomainType (DomainType .WLS )
32
+ .setWdtModels (Arrays .asList ("model1.yaml" , "model2.yaml" ))
33
+ .setPackageInstaller (Constants .YUM );
34
+
35
+ MustacheFactory mf = new DefaultMustacheFactory (new File ("src/main/resources/docker-files" ));
36
+ Mustache mustache = mf .compile ("Create_Image.mustache" );
37
+ //mustache.execute(new PrintWriter(System.out), dockerfileOptions).flush();
38
+ mustache .execute (new StringWriter (), dockerfileOptions ).flush ();
39
+ assertTrue (true );
40
+ }
41
+
42
+ @ Test
43
+ public void setPackageInstaller () {
44
+ DockerfileOptions options = new DockerfileOptions ().setPackageInstaller (Constants .YUM );
45
+ assertTrue ("Failed to set YUM installer" , options .useYum );
46
+
47
+ options = new DockerfileOptions ().setPackageInstaller (Constants .APTGET );
48
+ assertTrue ("Failed to set 'APTGET' installer" , options .useAptGet );
49
+
50
+ options = new DockerfileOptions ().setPackageInstaller (Constants .ZYPPER );
51
+ assertTrue ("Failed to set 'ZYPPER' installer" , options .useZypper );
52
+ }
53
+ }
0 commit comments