root / 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 @ 32563
History | View | Annotate | Download (6.66 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 |
/**
|
47 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
48 |
*/
|
49 |
public class MakePluginPackageServiceTest extends InstallerServiceTest{ |
50 |
|
51 |
@Override
|
52 |
protected void doSetUp() throws Exception { |
53 |
|
54 |
} |
55 |
|
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 |
} |
81 |
|
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");
|
96 |
|
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 resource = new File (File.separator + "gvSIG" + File.separator + "extensiones" + File.separator + "org.gvsig.wms" + File.separator + "resources.txt"); |
136 |
File pluginsDirectory = super.getPluginsDirectory(); |
137 |
File installerFile = super.getTemporalFile(); |
138 |
|
139 |
MakePluginPackageService makePluginPackageService = |
140 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory); |
141 |
|
142 |
PackageInfo packageInfo = makePluginPackageService.getPluginPackageInfo("org.gvsig.wfs");
|
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 |
assertEquals(resource.getAbsolutePath(), newInstallerInfo.getFileToCopyAt(0).getAbsolutePath());
|
157 |
} |
158 |
} |
159 |
|