svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.impl / src / test / java / org / gvsig / installer / lib / impl / creation / MakePluginPackageServiceTest.java @ 43126
History | View | Annotate | Download (6.38 KB)
1 | 40560 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40560 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | *
|
||
6 | 40435 | jjdelcerro | * This program is free software; you can redistribute it and/or
|
7 | * modify it under the terms of the GNU General Public License
|
||
8 | 40560 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * of the License, or (at your option) any later version.
|
10 | 40560 | jjdelcerro | *
|
11 | 40435 | jjdelcerro | * 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 | 40560 | jjdelcerro | *
|
16 | 40435 | jjdelcerro | * 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 | 40560 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 40435 | jjdelcerro | * MA 02110-1301, USA.
|
20 | 40560 | jjdelcerro | *
|
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
24 | /*
|
||
25 | * AUTHORS (In addition to CIT):
|
||
26 | * 2010 {Prodevelop} {Task}
|
||
27 | */
|
||
28 | |||
29 | package org.gvsig.installer.lib.impl.creation; |
||
30 | |||
31 | import java.io.File; |
||
32 | import java.io.FileOutputStream; |
||
33 | import java.io.IOException; |
||
34 | |||
35 | import junit.framework.Assert; |
||
36 | |||
37 | import org.gvsig.installer.lib.api.InstallerLocator; |
||
38 | import org.gvsig.installer.lib.api.PackageInfo; |
||
39 | import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
||
40 | import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
||
41 | import org.gvsig.installer.lib.api.execution.InstallPackageService; |
||
42 | import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
||
43 | import org.gvsig.installer.lib.impl.InstallerServiceTest; |
||
44 | import org.gvsig.tools.locator.LocatorException; |
||
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, |
||
57 | MakePluginPackageServiceException, InstallPackageServiceException, |
||
58 | IOException {
|
||
59 | |||
60 | MakePluginPackageService makePluginPackageService = InstallerLocator |
||
61 | .getInstallerManager().getMakePluginPackageService(); |
||
62 | |||
63 | Assert |
||
64 | .assertEquals(3, makePluginPackageService
|
||
65 | .getPluginPackageCount()); |
||
66 | |||
67 | int pluginsNumber = 0; |
||
68 | for (int i = 0; i < 3; i++) { |
||
69 | PackageInfo packageInfo = makePluginPackageService |
||
70 | .getPluginPackageInfo(i); |
||
71 | if (packageInfo.getCode().equals("org.gvsig.wms")) { |
||
72 | assertNotNull(packageInfo.getState()); |
||
73 | pluginsNumber++; |
||
74 | } else if (packageInfo.getCode().equals("org.gvsig.wfs")) { |
||
75 | assertEquals("RC2", packageInfo.getState());
|
||
76 | pluginsNumber++; |
||
77 | } else if (packageInfo.getCode().equals("org.gvsig.wcs")) { |
||
78 | assertEquals("RC1", packageInfo.getState());
|
||
79 | pluginsNumber++; |
||
80 | } |
||
81 | } |
||
82 | |||
83 | Assert.assertEquals(3, pluginsNumber);
|
||
84 | } |
||
85 | |||
86 | public void testMakePluginPackage() throws IOException, LocatorException, |
||
87 | MakePluginPackageServiceException, InstallPackageServiceException { |
||
88 | File installerFile = super.getTemporalFile(); |
||
89 | |||
90 | MakePluginPackageService makePluginPackageService = InstallerLocator |
||
91 | .getInstallerManager().getMakePluginPackageService(); |
||
92 | |||
93 | PackageInfo packageInfo = makePluginPackageService |
||
94 | .getPluginPackageInfo("org.gvsig.wfs");
|
||
95 | |||
96 | assertEquals("1.0.0", packageInfo.getVersion());
|
||
97 | |||
98 | // Change the version to check that the installation process works fine
|
||
99 | packageInfo.setVersion("1.0.1");
|
||
100 | |||
101 | // Compress the plugin and create the installer compressed file
|
||
102 | FileOutputStream os = new FileOutputStream(installerFile); |
||
103 | makePluginPackageService.createPackageSet(packageInfo, os); |
||
104 | |||
105 | // decompress the plugin and read the plugin information
|
||
106 | InstallPackageService installPackageService = InstallerLocator |
||
107 | .getInstallerManager().getInstallPackageService(); |
||
108 | |||
109 | 43126 | jjdelcerro | installPackageService.addBundle(installerFile, null);
|
110 | 40435 | jjdelcerro | assertEquals(1, installPackageService.getPackageCount());
|
111 | PackageInfo newInstallerInfo = makePluginPackageService |
||
112 | .getPluginPackageInfo(0);
|
||
113 | assertEquals("1.0.1", newInstallerInfo.getVersion());
|
||
114 | } |
||
115 | |||
116 | public void testCreateInstallerWithAntFile() throws IOException, |
||
117 | LocatorException, MakePluginPackageServiceException, |
||
118 | InstallPackageServiceException { |
||
119 | File installerFile = super.getTemporalFile(); |
||
120 | |||
121 | MakePluginPackageService makePluginPackageService = InstallerLocator |
||
122 | .getInstallerManager().getMakePluginPackageService(); |
||
123 | |||
124 | PackageInfo packageInfo = makePluginPackageService |
||
125 | .getPluginPackageInfo("org.gvsig.wfs");
|
||
126 | packageInfo |
||
127 | .setAntScript(makePluginPackageService.getDefaultAntScript()); |
||
128 | |||
129 | // Compress the plugin and create the installer compressed file
|
||
130 | FileOutputStream os = new FileOutputStream(installerFile); |
||
131 | makePluginPackageService.createPackageSet(packageInfo, os); |
||
132 | |||
133 | // decompress the plugin and read the plugin information
|
||
134 | InstallPackageService installPackageService = InstallerLocator |
||
135 | .getInstallerManager().getInstallPackageService(); |
||
136 | 43126 | jjdelcerro | installPackageService.addBundle(installerFile, null);
|
137 | 40435 | jjdelcerro | assertEquals(1, installPackageService.getPackageCount());
|
138 | PackageInfo newInstallerInfo = makePluginPackageService |
||
139 | .getPluginPackageInfo(0);
|
||
140 | assertTrue(newInstallerInfo.getAntScript().startsWith("<project"));
|
||
141 | } |
||
142 | |||
143 | public void testCreateInstallerWithFiles() throws IOException, |
||
144 | LocatorException, MakePluginPackageServiceException, |
||
145 | InstallPackageServiceException { |
||
146 | File pluginsDirectory = super.getPluginsDirectory(); |
||
147 | File installerFile = super.getTemporalFile(); |
||
148 | File resource = new File(pluginsDirectory + File.separator |
||
149 | + "org.gvsig.wms" + File.separator + "resources2.txt"); |
||
150 | |||
151 | MakePluginPackageService makePluginPackageService = InstallerLocator |
||
152 | .getInstallerManager().getMakePluginPackageService(); |
||
153 | |||
154 | PackageInfo packageInfo = makePluginPackageService |
||
155 | .getPluginPackageInfo("org.gvsig.wcs");
|
||
156 | packageInfo.getFilesToCopy().add(resource); |
||
157 | |||
158 | // Compress the plugin and create the installer compressed file
|
||
159 | FileOutputStream os = new FileOutputStream(installerFile); |
||
160 | makePluginPackageService.createPackageSet(packageInfo, os); |
||
161 | |||
162 | // decompress the plugin and read the plugin information
|
||
163 | InstallPackageService installPackageService = InstallerLocator |
||
164 | .getInstallerManager().getInstallPackageService(); |
||
165 | 43126 | jjdelcerro | installPackageService.addBundle(installerFile, null);
|
166 | 40435 | jjdelcerro | assertEquals(1, installPackageService.getPackageCount());
|
167 | PackageInfo newInstallerInfo = makePluginPackageService |
||
168 | .getPluginPackageInfo(0);
|
||
169 | assertEquals(1, newInstallerInfo.getFilesToCopy().size());
|
||
170 | } |
||
171 | } |