Skip to content

Package: DeploymentContext

DeploymentContext

nameinstructionbranchcomplexitylinemethod
DeploymentContext(TestDescriptor, ApplicationContainer, WsTool)
M: 52 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
getResources()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
prepare(boolean)
M: 44 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Distribution License v. 1.0, which is available at
6: * http://www.eclipse.org/org/documents/edl-v10.php.
7: *
8: * SPDX-License-Identifier: BSD-3-Clause
9: */
10:
11: package com.sun.xml.ws.test.container;
12:
13: import com.sun.istack.NotNull;
14: import com.sun.xml.ws.test.model.TestDescriptor;
15: import com.sun.xml.ws.test.model.TestService;
16: import com.sun.xml.ws.test.tool.WsTool;
17: import com.sun.xml.ws.test.util.FileUtil;
18: import junit.framework.TestCase;
19:
20: import java.io.File;
21: import java.util.Collections;
22: import java.util.HashMap;
23: import java.util.Map;
24:
25: /**
26: * State of running {@link TestDescriptor} execution.
27: *
28: * {@link TestCase}s that work on the same {@link TestDescriptor}
29: * shares this object to communicate information between them.
30: *
31: * @author Kohsuke Kawaguchi
32: */
33: public class DeploymentContext {
34:
35: /**
36: * The test descriptor that governs all the deployed services.
37: */
38: public final @NotNull TestDescriptor descriptor;
39:
40: /**
41: * Container where services are deployed.
42: */
43: public final @NotNull ApplicationContainer container;
44:
45: /**
46: * {@link WsTool} tool to be used.
47: */
48: public final @NotNull WsTool wsimport;
49:
50: /**
51: * Which service is deployed where?
52: */
53: public final Map<TestService,DeployedService> services;
54:
55: /**
56: * {@link ClassLoader} that loads all the generated client artifacts.
57: * This is used to run client tests.
58: */
59: public ClassLoader clientClassLoader;
60:
61: /**
62: * Work directory top.
63: *
64: * <p>
65: * During test execution, this directory can be used as a temporary directory
66: * to store various temporary artifacts.
67: *
68: * <p>
69: * If you store something in the working directory, be sure to first create
70: * a sub-directory, to avoid colliding with other parts of the harness
71: * that uses the work directory.
72: */
73: public final File workDir;
74:
75: private File resources = null;
76:
77: public DeploymentContext(TestDescriptor descriptor, ApplicationContainer container, WsTool wsimport) {
78: this.descriptor = descriptor;
79: this.container = container;
80: this.wsimport = wsimport;
81:
82: // create workspace
83: this.workDir = new File(descriptor.home,"work");
84:
85: // create DeployedService objects
86: Map<TestService,DeployedService> services = new HashMap<TestService, DeployedService>();
87:• for (TestService svc : descriptor.services) {
88: services.put(svc, new DeployedService(this,svc));
89: }
90: this.services = Collections.unmodifiableMap(services);
91: }
92:
93: /**
94: * Creates working directories.
95: *
96: * @param clean
97: * if true, all the previous left-over files in the working directory
98: * will be deleted.
99: */
100: public void prepare(boolean clean) {
101:• if(clean) {
102: FileUtil.deleteRecursive(workDir);
103: }
104: workDir.mkdirs();
105:• if (descriptor.resources != null) {
106: resources = new File(workDir, "resources");
107: FileUtil.copyDir(descriptor.resources, resources, null);
108: }
109:
110:• for (DeployedService ds : services.values()) {
111: ds.prepare();
112: }
113: }
114:
115: public File getResources() {
116: return resources;
117: }
118: }