10
10
******************************************************************************/
11
11
package org .jboss .tools .intellij .openshift .utils .odo ;
12
12
13
+ import com .intellij .util .io .ZipUtil ;
13
14
import com .redhat .devtools .intellij .common .utils .ExecHelper ;
15
+ import org .apache .commons .io .FileUtils ;
14
16
import org .junit .After ;
17
+ import org .junit .AfterClass ;
15
18
import org .junit .Before ;
19
+ import org .junit .BeforeClass ;
16
20
import org .junit .Test ;
17
21
import org .junit .runner .RunWith ;
18
22
import org .junit .runners .Parameterized ;
19
23
20
24
import java .io .File ;
21
25
import java .io .IOException ;
22
26
import java .net .ServerSocket ;
27
+ import java .nio .file .Path ;
23
28
import java .util .Arrays ;
24
29
import java .util .List ;
25
30
import java .util .concurrent .ExecutionException ;
30
35
31
36
@ RunWith (Parameterized .class )
32
37
public class OdoCliComponentTest extends OdoCliTest {
33
- private static final String COMPONENT_PATH = "src/it/projects/go" ;
38
+ private static final String PROJECT_NAME = "go" ;
39
+ private static final String COMPONENT_PATH = "src/it/projects/" ;
34
40
private final ComponentFeature feature ;
35
41
private String project ;
36
42
private String component ;
37
43
private String service ;
38
- private final String projectPath = new File (COMPONENT_PATH ).getAbsolutePath ();
44
+ private final String projectPath = new File (COMPONENT_PATH + PROJECT_NAME ).getAbsolutePath ();
39
45
40
46
public OdoCliComponentTest (ComponentFeature feature , String label ) {
41
47
this .feature = feature ;
@@ -49,6 +55,18 @@ public static Iterable<Object[]> data() {
49
55
});
50
56
}
51
57
58
+ @ BeforeClass
59
+ public static void initTestProject () throws IOException {
60
+ Path destDir = new File (COMPONENT_PATH ).toPath ();
61
+ Path srcFile = new File (COMPONENT_PATH + PROJECT_NAME + ".zip" ).toPath ();
62
+ ZipUtil .extract (srcFile , destDir , null );
63
+ }
64
+
65
+ @ AfterClass
66
+ public static void deleteTestProject () throws IOException {
67
+ FileUtils .deleteDirectory (new File (COMPONENT_PATH ));
68
+ }
69
+
52
70
@ Before
53
71
public void initTestEnv () throws IOException {
54
72
project = PROJECT_PREFIX + random .nextInt ();
@@ -127,13 +145,16 @@ public void checkCreateComponentAndLinkService() throws IOException, ExecutionEx
127
145
Binding binding = odo .link (projectPath , target );
128
146
assertNotNull (binding );
129
147
List <Binding > bindings = odo .listBindings (projectPath );
148
+ assertNotNull (bindings );
130
149
assertEquals (1 , bindings .size ());
131
- //cleanup
150
+ // cleanup
132
151
odo .deleteBinding (projectPath , binding .getName ());
133
152
bindings = odo .listBindings (projectPath );
153
+ assertNotNull (bindings );
134
154
assertEquals (0 , bindings .size ());
135
155
odo .deleteService (project , deployedService );
136
156
deployedServices = odo .getServices (project );
157
+ assertNotNull (deployedServices );
137
158
assertEquals (0 , deployedServices .size ());
138
159
}
139
160
0 commit comments