svn-gvsig-desktop / tags / v2_0_0_Build_2021 / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.impl / src / test / java / org / gvsig / installer / lib / impl / creation / MakePluginPackageServiceTest.java @ 34107
History | View | Annotate | Download (7.27 KB)
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 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 {Prodevelop} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.installer.lib.impl.creation; |
29 |
|
30 |
import java.io.File; |
31 |
import java.io.FileOutputStream; |
32 |
import java.io.IOException; |
33 |
|
34 |
import junit.framework.Assert; |
35 |
|
36 |
import org.gvsig.installer.lib.api.InstallerLocator; |
37 |
import org.gvsig.installer.lib.api.PackageInfo; |
38 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
39 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
40 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
41 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
42 |
import org.gvsig.installer.lib.impl.InstallerServiceTest; |
43 |
import org.gvsig.tools.locator.LocatorException; |
44 |
|
45 |
/**
|
46 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
47 |
*/
|
48 |
public class MakePluginPackageServiceTest extends InstallerServiceTest { |
49 |
|
50 |
@Override
|
51 |
protected void doSetUp() throws Exception { |
52 |
|
53 |
} |
54 |
|
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.createPackageSet(packageInfo, os); |
108 |
|
109 |
// decompress the plugin and read the plugin information
|
110 |
InstallPackageService installPackageService = |
111 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
112 |
|
113 |
installPackageService.addBundle(installerFile); |
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.createPackageSet(packageInfo, os); |
137 |
|
138 |
// decompress the plugin and read the plugin information
|
139 |
InstallPackageService installPackageService = |
140 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
141 |
installPackageService.addBundle(installerFile); |
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.createPackageSet(packageInfo, os); |
168 |
|
169 |
// decompress the plugin and read the plugin information
|
170 |
InstallPackageService installPackageService = |
171 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
172 |
installPackageService.addBundle(installerFile); |
173 |
assertEquals(1, installPackageService.getPackageCount());
|
174 |
PackageInfo newInstallerInfo = |
175 |
makePluginPackageService.getPluginPackageInfo(0);
|
176 |
assertEquals(1, newInstallerInfo.getFileToCopySize());
|
177 |
} |
178 |
} |