KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > tools > jbiplugin > JBIPluginMojoTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: JBIPluginMojoTest.java 11:10:18 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.tools.jbiplugin;
23
24 import java.io.File JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.List JavaDoc;
27
28 import junit.framework.TestCase;
29
30 import org.apache.maven.model.Dependency;
31 import org.apache.maven.plugin.MojoExecutionException;
32 import org.apache.maven.project.MavenProject;
33 import org.objectweb.petals.tools.jbiplugin.mock.ArtifactMock;
34 import org.objectweb.petals.tools.jbiplugin.mock.ArtifactRepositoryMock;
35
36 /**
37  * Test the jbi maven plugin
38  *
39  * @author ddesjardins - eBMWebsourcing
40  */

41 public class JBIPluginMojoTest extends TestCase {
42
43     public void testExecute() throws MojoExecutionException {
44         String JavaDoc baseDir = this.getClass().getResource(".").toString();
45         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
46         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
47         JBIPluginMojo plugin = new JBIPluginMojo();
48         plugin.jbiDirectory = new File JavaDoc(baseDir + "src" + File.separator
49             + "test-data" + File.separator + "conf");
50
51         ArtifactRepositoryMock artifactRepositoryMock = new ArtifactRepositoryMock();
52         artifactRepositoryMock.setBaseDir(baseDir + "src" + File.separator
53             + "test-data" + File.separator + "repository");
54         plugin.localRepository = artifactRepositoryMock;
55
56         MavenProject project = new MavenProject();
57         project.setArtifact(new ArtifactMock());
58         List JavaDoc<Dependency> dependencies = new ArrayList JavaDoc<Dependency>();
59         Dependency dependency = new Dependency();
60         dependency.setArtifactId("test");
61         dependency.setGroupId("test");
62         dependency.setVersion("1.0");
63         dependencies.add(dependency);
64
65         project.setDependencies(dependencies);
66         plugin.toExcludes = "";
67         plugin.project = project;
68         plugin.outputDirectory = new File JavaDoc(baseDir + "target");
69         plugin.jbiName = "test";
70
71         plugin.componentJar = new File JavaDoc(baseDir + "src" + File.separator
72             + "test-data" + File.separator + "component.jar");
73
74         plugin.execute();
75     }
76
77     public void testExecuteWithSubDep() throws MojoExecutionException {
78         String JavaDoc baseDir = new File JavaDoc(".").getAbsolutePath();
79         baseDir = baseDir.substring(0, baseDir.length() - 1);
80         if (!baseDir.endsWith("jbi-plugin" + File.separator)) {
81             baseDir += "tools" + File.separator + "jbi-plugin" + File.separator;
82         }
83         JBIPluginMojo plugin = new JBIPluginMojo();
84         plugin.jbiDirectory = new File JavaDoc(baseDir + "src" + File.separator
85             + "test-data" + File.separator + "conf");
86
87         ArtifactRepositoryMock artifactRepositoryMock = new ArtifactRepositoryMock();
88         artifactRepositoryMock.setBaseDir(baseDir + "src" + File.separator
89             + "test-data" + File.separator + "repository");
90         plugin.localRepository = artifactRepositoryMock;
91
92         MavenProject project = new MavenProject();
93         project.setArtifact(new ArtifactMock());
94         List JavaDoc<Dependency> dependencies = new ArrayList JavaDoc<Dependency>();
95         Dependency dependency = new Dependency();
96         dependency.setArtifactId("test");
97         dependency.setGroupId("test");
98         dependency.setVersion("1.0");
99         dependencies.add(dependency);
100
101         project.setDependencies(dependencies);
102         plugin.project = project;
103         plugin.toExcludes = "";
104         plugin.outputDirectory = new File JavaDoc(baseDir + "target");
105         plugin.jbiName = "test";
106
107         plugin.componentJar = new File JavaDoc(baseDir + "src" + File.separator
108             + "test-data" + File.separator + "component.jar");
109         plugin.includeSubDependencies = true;
110
111         plugin.execute();
112     }
113
114     public void testExecuteUpdateJBI() throws MojoExecutionException {
115         String JavaDoc baseDir = new File JavaDoc(".").getAbsolutePath();
116         baseDir = baseDir.substring(0, baseDir.length() - 1);
117         if (!baseDir.endsWith("jbi-plugin" + File.separator)) {
118             baseDir += "tools" + File.separator + "jbi-plugin" + File.separator;
119         }
120         JBIPluginMojo plugin = new JBIPluginMojo();
121         plugin.jbiDirectory = new File JavaDoc(baseDir + "src" + File.separator
122             + "test-data" + File.separator + "conf");
123
124         ArtifactRepositoryMock artifactRepositoryMock = new ArtifactRepositoryMock();
125         artifactRepositoryMock.setBaseDir(baseDir + "src" + File.separator
126             + "test-data" + File.separator + "repository");
127         plugin.localRepository = artifactRepositoryMock;
128
129         MavenProject project = new MavenProject();
130         project.setArtifact(new ArtifactMock());
131         List JavaDoc<Dependency> dependencies = new ArrayList JavaDoc<Dependency>();
132         Dependency dependency = new Dependency();
133         dependency.setArtifactId("test");
134         dependency.setGroupId("test");
135         dependency.setVersion("1.0");
136         dependencies.add(dependency);
137
138         project.setDependencies(dependencies);
139         plugin.project = project;
140         plugin.toExcludes = "";
141         plugin.updateJBIXml = true;
142         plugin.outputDirectory = new File JavaDoc(baseDir + "target");
143         plugin.jbiName = "test";
144
145         plugin.componentJar = new File JavaDoc(baseDir + "src" + File.separator
146             + "test-data" + File.separator + "component.jar");
147         plugin.includeSubDependencies = true;
148
149         plugin.execute();
150     }
151
152 }
153
Popular Tags