KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > jbi > management > task > DeployAndListServiceAssemblyTasksTest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.jbi.management.task;
18
19 import java.io.File JavaDoc;
20 import java.net.URL JavaDoc;
21
22 import org.apache.servicemix.jbi.util.FileUtil;
23 import org.apache.tools.ant.Project;
24
25 /**
26  *
27  * InstallComponentTaskTest
28  */

29 public class DeployAndListServiceAssemblyTasksTest extends JbiTaskSupport {
30
31     private static final String JavaDoc XML_OUTPUT_PROPERTY = "test.xml.output";
32
33     private DeployServiceAssemblyTask deployServiceAssembliesTask;
34
35     private File JavaDoc rootDir = new File JavaDoc("target/testWDIR");
36
37     private ListServiceAssembliesTask listServiceAssembliesTask;
38
39     private Project project = new Project();
40
41     /*
42      * @see TestCase#setUp()
43      */

44     protected void setUp() throws Exception JavaDoc {
45         FileUtil.deleteFile(rootDir);
46         this.container.setRootDir(rootDir.getPath());
47         super.setUp();
48         deployServiceAssembliesTask = new DeployServiceAssemblyTask() {
49         };
50         deployServiceAssembliesTask.setProject(new Project());
51         deployServiceAssembliesTask.init();
52
53         listServiceAssembliesTask = new ListServiceAssembliesTask();
54         listServiceAssembliesTask.setProject(project);
55         listServiceAssembliesTask.init();
56     }
57
58     /*
59      * @see TestCase#tearDown()
60      */

61     protected void tearDown() throws Exception JavaDoc {
62         deployServiceAssembliesTask.close();
63         super.tearDown();
64     }
65
66     public void testInstallationAndList() throws Exception JavaDoc {
67         URL JavaDoc url = getClass().getClassLoader().getResource(
68                 "org/apache/servicemix/jbi/installation/testassembly.jar");
69
70         listServiceAssembliesTask.setServiceAssemblyName("sa");
71         listServiceAssembliesTask.setXmlOutput(XML_OUTPUT_PROPERTY);
72         listServiceAssembliesTask.execute();
73
74         System.out.println(project.getProperty(XML_OUTPUT_PROPERTY));
75         
76         if (url != null) {
77             String JavaDoc file = url.getFile();
78             deployServiceAssembliesTask.setFile(file);
79             deployServiceAssembliesTask.init();
80             deployServiceAssembliesTask.execute();
81             File JavaDoc testFile = new File JavaDoc(rootDir, "service-assemblies"
82                     + File.separator + "sa");
83             assertTrue(testFile.exists());
84         }
85
86         listServiceAssembliesTask.setServiceAssemblyName("sa");
87         listServiceAssembliesTask.setXmlOutput(XML_OUTPUT_PROPERTY);
88         listServiceAssembliesTask.execute();
89
90         System.out.println(project.getProperty(XML_OUTPUT_PROPERTY));
91
92         FileUtil.deleteFile(rootDir);
93
94     }
95 }
96
Popular Tags