svn-gvsig-desktop / 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 / execution / InstallPackageServiceTest.java @ 32563
History | View | Annotate | Download (6.12 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.execution; |
29 |
|
30 |
import java.io.File; |
31 |
import java.io.IOException; |
32 |
|
33 |
import junit.framework.Assert; |
34 |
|
35 |
import org.gvsig.installer.lib.api.InstallerLocator; |
36 |
import org.gvsig.installer.lib.api.PackageInfo; |
37 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
38 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
39 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
40 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
41 |
import org.gvsig.installer.lib.impl.InstallerServiceTest; |
42 |
import org.gvsig.tools.locator.LocatorException; |
43 |
|
44 |
/**
|
45 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
46 |
*/
|
47 |
public class InstallPackageServiceTest extends InstallerServiceTest{ |
48 |
|
49 |
@Override
|
50 |
protected void doSetUp() throws Exception { |
51 |
// TODO Auto-generated method stub
|
52 |
|
53 |
} |
54 |
|
55 |
public void testReadPlugins() throws LocatorException, MakePluginPackageServiceException, InstallPackageServiceException, IOException{ |
56 |
File installersDirectory = super.getInstallersDirectory(); |
57 |
|
58 |
InstallPackageService installPackageService = |
59 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
60 |
installPackageService.addBundlesFromDirectory(installersDirectory); |
61 |
|
62 |
Assert.assertEquals(3, installPackageService.getPackageCount());
|
63 |
|
64 |
int pluginsNumber = 0; |
65 |
for (int i=0 ; i<3 ; i++){ |
66 |
PackageInfo packageInfo = installPackageService.getPackageInfo(i); |
67 |
if (packageInfo.getCode().equals("org.gvsig.plugin1")){ |
68 |
assertNotNull(packageInfo.getState()); |
69 |
pluginsNumber++; |
70 |
}else if (packageInfo.getCode().equals("org.gvsig.plugin2")){ |
71 |
assertEquals("RC1", packageInfo.getState());
|
72 |
pluginsNumber++; |
73 |
}else if (packageInfo.getCode().equals("org.gvsig.plugin3.zip")){ |
74 |
assertEquals("Testing", packageInfo.getState());
|
75 |
pluginsNumber++; |
76 |
} |
77 |
} |
78 |
|
79 |
Assert.assertEquals(3, pluginsNumber);
|
80 |
} |
81 |
|
82 |
public void testInstallPluginFromApplication() throws InstallPackageServiceException, IOException, LocatorException, MakePluginPackageServiceException{ |
83 |
File installersDirectory = super.getInstallersDirectory(); |
84 |
File pluginsDirectory = super.getPluginsDirectory(); |
85 |
File applicationDirectory = super.getApplicationDirectory(); |
86 |
|
87 |
InstallPackageService installerExecutionService = |
88 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
89 |
installerExecutionService.addBundlesFromDirectory(installersDirectory); |
90 |
|
91 |
PackageInfo packageInfo = installerExecutionService.getPackageInfo("org.gvsig.plugin1");
|
92 |
installerExecutionService.installPackage(applicationDirectory, packageInfo); |
93 |
|
94 |
Assert.assertEquals(3, installerExecutionService.getPackageCount());
|
95 |
|
96 |
//Reading the excution and check that the file is installed
|
97 |
MakePluginPackageService installerCreationService = |
98 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory); |
99 |
Assert.assertEquals(4, installerCreationService.getPluginPackageCount());
|
100 |
} |
101 |
|
102 |
|
103 |
public void testInstallPluginFromExternal() throws InstallPackageServiceException, IOException, LocatorException, MakePluginPackageServiceException{ |
104 |
File applicationDirectory = super.getApplicationDirectory(); |
105 |
File externalInstallationFile = new File(applicationDirectory.getAbsoluteFile() + File.separator + "install" + File.separator + "installer1.zip"); |
106 |
File pluginsDirectory = super.getPluginsDirectory(); |
107 |
|
108 |
InstallPackageService installerExecutionService = |
109 |
InstallerLocator.getInstallerManager().getInstallPackageService(); |
110 |
installerExecutionService.addBundle(externalInstallationFile.toURI()); |
111 |
|
112 |
PackageInfo packageInfo = installerExecutionService.getPackageInfo("org.gvsig.plugin1");
|
113 |
|
114 |
Assert.assertEquals(3, installerExecutionService.getPackageCount());
|
115 |
|
116 |
installerExecutionService.installPackage(applicationDirectory, packageInfo); |
117 |
|
118 |
//Reading the excution and check that the file is installed
|
119 |
MakePluginPackageService installerCreationService = |
120 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory); |
121 |
Assert.assertEquals(4, installerCreationService.getPluginPackageCount());
|
122 |
} |
123 |
|
124 |
// public void testInstallPluginWithAntScript() throws InstallPackageServiceException, LocatorException, MakePluginPackageServiceException, IOException{
|
125 |
// File applicationDirectory = super.getApplicationDirectory();
|
126 |
// File installersDirectory = super.getInstallersDirectory();
|
127 |
// File pluginsDirectory = super.getPluginsDirectory();
|
128 |
//
|
129 |
// InstallPackageService installerExecutionService =
|
130 |
// InstallerLocator.getInstallerManager().getInstallPackageService();
|
131 |
// installerExecutionService.addBundlesFromDirectory(installersDirectory);
|
132 |
//
|
133 |
// PackageInfo packageInfo = installerExecutionService.getPackageInfo("org.gvsig.plugin2");
|
134 |
//
|
135 |
// Assert.assertEquals(3, installerExecutionService.getPackageCount());
|
136 |
//
|
137 |
// installerExecutionService.installPackage(applicationDirectory, packageInfo);
|
138 |
//
|
139 |
// //Reading the excution and check that the file is installed
|
140 |
// MakePluginPackageService installerCreationService =
|
141 |
// InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory);
|
142 |
//
|
143 |
// Assert.assertEquals(5, installerCreationService.getPluginPackageCount());
|
144 |
// }
|
145 |
|
146 |
} |
147 |
|