Revision 33729 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/test/java/org/gvsig/installer/lib/impl/creation/MakePluginPackageServiceTest.java
MakePluginPackageServiceTest.java | ||
---|---|---|
1 | 1 |
/* gvSIG. Geographic Information System of the Valencian Government |
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
2 |
*
|
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
|
4 |
* of the Valencian Government (CIT)
|
|
5 |
*
|
|
6 |
* This program is free software; you can redistribute it and/or
|
|
7 |
* modify it under the terms of the GNU General Public License
|
|
8 |
* as published by the Free Software Foundation; either version 2
|
|
9 |
* of the License, or (at your option) any later version.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
19 |
* MA 02110-1301, USA.
|
|
20 |
*
|
|
21 |
*/
|
|
22 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2010 {Prodevelop} {Task}
|
|
26 |
*/
|
|
27 |
|
|
28 | 28 |
package org.gvsig.installer.lib.impl.creation; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
... | ... | |
42 | 42 |
import org.gvsig.installer.lib.impl.InstallerServiceTest; |
43 | 43 |
import org.gvsig.tools.locator.LocatorException; |
44 | 44 |
|
45 |
|
|
46 | 45 |
/** |
47 | 46 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
48 | 47 |
*/ |
49 |
public class MakePluginPackageServiceTest extends InstallerServiceTest{ |
|
50 |
|
|
51 |
@Override |
|
52 |
protected void doSetUp() throws Exception { |
|
53 |
|
|
54 |
} |
|
48 |
public class MakePluginPackageServiceTest extends InstallerServiceTest { |
|
55 | 49 |
|
56 |
public void testReadPlugins() throws LocatorException, MakePluginPackageServiceException, InstallPackageServiceException, IOException{ |
|
57 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
58 |
|
|
59 |
MakePluginPackageService makePluginPackageService = |
|
60 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory); |
|
61 |
|
|
62 |
Assert.assertEquals(3, makePluginPackageService.getPluginPackageCount()); |
|
63 |
|
|
64 |
int pluginsNumber = 0; |
|
65 |
for (int i=0 ; i<3 ; i++){ |
|
66 |
PackageInfo packageInfo = makePluginPackageService.getPluginPackageInfo(i); |
|
67 |
if (packageInfo.getCode().equals("org.gvsig.wms")){ |
|
68 |
assertNotNull(packageInfo.getState()); |
|
69 |
pluginsNumber++; |
|
70 |
}else if (packageInfo.getCode().equals("org.gvsig.wfs")){ |
|
71 |
assertEquals("RC2", packageInfo.getState()); |
|
72 |
pluginsNumber++; |
|
73 |
}else if (packageInfo.getCode().equals("org.gvsig.wcs")){ |
|
74 |
assertEquals("RC1", packageInfo.getState()); |
|
75 |
pluginsNumber++; |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
Assert.assertEquals(3, pluginsNumber); |
|
80 |
} |
|
50 |
@Override |
|
51 |
protected void doSetUp() throws Exception { |
|
81 | 52 |
|
82 |
public void testMakePluginPackage() throws IOException, LocatorException, MakePluginPackageServiceException, InstallPackageServiceException{ |
|
83 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
84 |
File installerFile = super.getTemporalFile(); |
|
85 |
|
|
86 |
|
|
87 |
MakePluginPackageService makePluginPackageService = |
|
88 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory); |
|
89 |
|
|
90 |
PackageInfo packageInfo = makePluginPackageService.getPluginPackageInfo("org.gvsig.wfs"); |
|
91 |
|
|
92 |
assertEquals("1.0.0", packageInfo.getVersion()); |
|
93 |
|
|
94 |
//Change the version to check that the installation process works fine |
|
95 |
packageInfo.setVersion("1.0.1"); |
|
53 |
} |
|
96 | 54 |
|
97 |
//Compress the plugin and create the installer compressed file |
|
98 |
FileOutputStream os = new FileOutputStream(installerFile); |
|
99 |
makePluginPackageService.createPluginPackage(packageInfo, os); |
|
100 |
|
|
101 |
//decompress the plugin and read the plugin information |
|
102 |
InstallPackageService installPackageService = |
|
103 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
|
104 |
|
|
105 |
installPackageService.addBundle(installerFile.toURI()); |
|
106 |
assertEquals(1, installPackageService.getPackageCount()); |
|
107 |
PackageInfo newInstallerInfo = makePluginPackageService.getPluginPackageInfo(0); |
|
108 |
assertEquals("1.0.1", newInstallerInfo.getVersion()); |
|
109 |
} |
|
110 |
|
|
111 |
public void testCreateInstallerWithAntFile() throws IOException, LocatorException, MakePluginPackageServiceException, InstallPackageServiceException{ |
|
112 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
113 |
File installerFile = super.getTemporalFile(); |
|
114 |
|
|
115 |
MakePluginPackageService makePluginPackageService = |
|
116 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory); |
|
117 |
|
|
118 |
PackageInfo packageInfo = makePluginPackageService.getPluginPackageInfo("org.gvsig.wfs"); |
|
119 |
packageInfo.setAnScript(makePluginPackageService.getDefaultAntScript()); |
|
120 |
|
|
121 |
//Compress the plugin and create the installer compressed file |
|
122 |
FileOutputStream os = new FileOutputStream(installerFile); |
|
123 |
makePluginPackageService.createPluginPackage(packageInfo, os); |
|
124 |
|
|
125 |
//decompress the plugin and read the plugin information |
|
126 |
InstallPackageService installPackageService = |
|
127 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
|
128 |
installPackageService.addBundle(installerFile.toURI()); |
|
129 |
assertEquals(1, installPackageService.getPackageCount()); |
|
130 |
PackageInfo newInstallerInfo = makePluginPackageService.getPluginPackageInfo(0); |
|
131 |
assertTrue(newInstallerInfo.getAntScript().startsWith("<project")); |
|
132 |
} |
|
133 |
|
|
134 |
public void testCreateInstallerWithFiles() throws IOException, LocatorException, MakePluginPackageServiceException, InstallPackageServiceException{ |
|
135 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
136 |
File installerFile = super.getTemporalFile(); |
|
137 |
File resource = new File (pluginsDirectory + File.separator + "org.gvsig.wms" + File.separator + "resources2.txt"); |
|
138 |
|
|
139 |
MakePluginPackageService makePluginPackageService = |
|
140 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory); |
|
141 |
|
|
142 |
PackageInfo packageInfo = makePluginPackageService.getPluginPackageInfo("org.gvsig.wcs"); |
|
143 |
packageInfo.addFileToCopy(resource); |
|
144 |
|
|
145 |
//Compress the plugin and create the installer compressed file |
|
146 |
FileOutputStream os = new FileOutputStream(installerFile); |
|
147 |
makePluginPackageService.createPluginPackage(packageInfo, os); |
|
148 |
|
|
149 |
//decompress the plugin and read the plugin information |
|
150 |
InstallPackageService installPackageService = |
|
151 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
|
152 |
installPackageService.addBundle(installerFile.toURI()); |
|
153 |
assertEquals(1, installPackageService.getPackageCount()); |
|
154 |
PackageInfo newInstallerInfo = makePluginPackageService.getPluginPackageInfo(0); |
|
155 |
assertEquals(1, newInstallerInfo.getFileToCopySize()); |
|
156 |
} |
|
55 |
public void testReadPlugins() throws LocatorException, |
|
56 |
MakePluginPackageServiceException, InstallPackageServiceException, |
|
57 |
IOException { |
|
58 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
59 |
|
|
60 |
MakePluginPackageService makePluginPackageService = |
|
61 |
InstallerLocator.getInstallerManager().getMakePluginPackageService( |
|
62 |
pluginsDirectory); |
|
63 |
|
|
64 |
Assert |
|
65 |
.assertEquals(3, makePluginPackageService.getPluginPackageCount()); |
|
66 |
|
|
67 |
int pluginsNumber = 0; |
|
68 |
for (int i = 0; i < 3; i++) { |
|
69 |
PackageInfo packageInfo = |
|
70 |
makePluginPackageService.getPluginPackageInfo(i); |
|
71 |
if (packageInfo.getCode().equals("org.gvsig.wms")) { |
|
72 |
assertNotNull(packageInfo.getState()); |
|
73 |
pluginsNumber++; |
|
74 |
} else |
|
75 |
if (packageInfo.getCode().equals("org.gvsig.wfs")) { |
|
76 |
assertEquals("RC2", packageInfo.getState()); |
|
77 |
pluginsNumber++; |
|
78 |
} else |
|
79 |
if (packageInfo.getCode().equals("org.gvsig.wcs")) { |
|
80 |
assertEquals("RC1", packageInfo.getState()); |
|
81 |
pluginsNumber++; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
Assert.assertEquals(3, pluginsNumber); |
|
86 |
} |
|
87 |
|
|
88 |
public void testMakePluginPackage() throws IOException, LocatorException, |
|
89 |
MakePluginPackageServiceException, InstallPackageServiceException { |
|
90 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
91 |
File installerFile = super.getTemporalFile(); |
|
92 |
|
|
93 |
MakePluginPackageService makePluginPackageService = |
|
94 |
InstallerLocator.getInstallerManager().getMakePluginPackageService( |
|
95 |
pluginsDirectory); |
|
96 |
|
|
97 |
PackageInfo packageInfo = |
|
98 |
makePluginPackageService.getPluginPackageInfo("org.gvsig.wfs"); |
|
99 |
|
|
100 |
assertEquals("1.0.0", packageInfo.getVersion()); |
|
101 |
|
|
102 |
// Change the version to check that the installation process works fine |
|
103 |
packageInfo.setVersion("1.0.1"); |
|
104 |
|
|
105 |
// Compress the plugin and create the installer compressed file |
|
106 |
FileOutputStream os = new FileOutputStream(installerFile); |
|
107 |
makePluginPackageService.createPluginPackage(packageInfo, os); |
|
108 |
|
|
109 |
// decompress the plugin and read the plugin information |
|
110 |
InstallPackageService installPackageService = |
|
111 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
|
112 |
|
|
113 |
installPackageService.addBundle(installerFile.toURI()); |
|
114 |
assertEquals(1, installPackageService.getPackageCount()); |
|
115 |
PackageInfo newInstallerInfo = |
|
116 |
makePluginPackageService.getPluginPackageInfo(0); |
|
117 |
assertEquals("1.0.1", newInstallerInfo.getVersion()); |
|
118 |
} |
|
119 |
|
|
120 |
public void testCreateInstallerWithAntFile() throws IOException, |
|
121 |
LocatorException, MakePluginPackageServiceException, |
|
122 |
InstallPackageServiceException { |
|
123 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
124 |
File installerFile = super.getTemporalFile(); |
|
125 |
|
|
126 |
MakePluginPackageService makePluginPackageService = |
|
127 |
InstallerLocator.getInstallerManager().getMakePluginPackageService( |
|
128 |
pluginsDirectory); |
|
129 |
|
|
130 |
PackageInfo packageInfo = |
|
131 |
makePluginPackageService.getPluginPackageInfo("org.gvsig.wfs"); |
|
132 |
packageInfo.setAnScript(makePluginPackageService.getDefaultAntScript()); |
|
133 |
|
|
134 |
// Compress the plugin and create the installer compressed file |
|
135 |
FileOutputStream os = new FileOutputStream(installerFile); |
|
136 |
makePluginPackageService.createPluginPackage(packageInfo, os); |
|
137 |
|
|
138 |
// decompress the plugin and read the plugin information |
|
139 |
InstallPackageService installPackageService = |
|
140 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
|
141 |
installPackageService.addBundle(installerFile.toURI()); |
|
142 |
assertEquals(1, installPackageService.getPackageCount()); |
|
143 |
PackageInfo newInstallerInfo = |
|
144 |
makePluginPackageService.getPluginPackageInfo(0); |
|
145 |
assertTrue(newInstallerInfo.getAntScript().startsWith("<project")); |
|
146 |
} |
|
147 |
|
|
148 |
public void testCreateInstallerWithFiles() throws IOException, |
|
149 |
LocatorException, MakePluginPackageServiceException, |
|
150 |
InstallPackageServiceException { |
|
151 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
152 |
File installerFile = super.getTemporalFile(); |
|
153 |
File resource = |
|
154 |
new File(pluginsDirectory + File.separator + "org.gvsig.wms" |
|
155 |
+ File.separator + "resources2.txt"); |
|
156 |
|
|
157 |
MakePluginPackageService makePluginPackageService = |
|
158 |
InstallerLocator.getInstallerManager().getMakePluginPackageService( |
|
159 |
pluginsDirectory); |
|
160 |
|
|
161 |
PackageInfo packageInfo = |
|
162 |
makePluginPackageService.getPluginPackageInfo("org.gvsig.wcs"); |
|
163 |
packageInfo.addFileToCopy(resource); |
|
164 |
|
|
165 |
// Compress the plugin and create the installer compressed file |
|
166 |
FileOutputStream os = new FileOutputStream(installerFile); |
|
167 |
makePluginPackageService.createPluginPackage(packageInfo, os); |
|
168 |
|
|
169 |
// decompress the plugin and read the plugin information |
|
170 |
InstallPackageService installPackageService = |
|
171 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
|
172 |
installPackageService.addBundle(installerFile.toURI()); |
|
173 |
assertEquals(1, installPackageService.getPackageCount()); |
|
174 |
PackageInfo newInstallerInfo = |
|
175 |
makePluginPackageService.getPluginPackageInfo(0); |
|
176 |
assertEquals(1, newInstallerInfo.getFileToCopySize()); |
|
177 |
} |
|
157 | 178 |
} |
158 |
|
Also available in: Unified diff