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 / execution / InstallPackageServiceTest.java @ 43126
History | View | Annotate | Download (6.08 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.execution; |
||
30 | |||
31 | import java.io.File; |
||
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 InstallPackageServiceTest extends InstallerServiceTest { |
||
49 | |||
50 | @Override
|
||
51 | protected void doSetUp() throws Exception { |
||
52 | // TODO Auto-generated method stub
|
||
53 | |||
54 | } |
||
55 | |||
56 | public void testReadPlugins() throws LocatorException, |
||
57 | MakePluginPackageServiceException, InstallPackageServiceException, |
||
58 | IOException {
|
||
59 | File installersDirectory = super.getInstallersDirectory(); |
||
60 | |||
61 | InstallPackageService installPackageService = InstallerLocator |
||
62 | .getInstallerManager().getInstallPackageService(); |
||
63 | 43126 | jjdelcerro | installPackageService.addBundlesFromDirectory(installersDirectory, null);
|
64 | 40435 | jjdelcerro | |
65 | Assert.assertEquals(3, installPackageService.getPackageCount());
|
||
66 | |||
67 | int pluginsNumber = 0; |
||
68 | for (int i = 0; i < 3; i++) { |
||
69 | PackageInfo packageInfo = installPackageService.getPackageInfo(i); |
||
70 | if (packageInfo.getCode().equals("org.gvsig.plugin1")) { |
||
71 | assertNotNull(packageInfo.getState()); |
||
72 | pluginsNumber++; |
||
73 | } else if (packageInfo.getCode().equals("org.gvsig.plugin2")) { |
||
74 | assertEquals("RC1", packageInfo.getState());
|
||
75 | pluginsNumber++; |
||
76 | } else if (packageInfo.getCode().equals("org.gvsig.plugin3")) { |
||
77 | assertEquals("Testing", packageInfo.getState());
|
||
78 | pluginsNumber++; |
||
79 | } |
||
80 | } |
||
81 | |||
82 | Assert.assertEquals(3, pluginsNumber);
|
||
83 | } |
||
84 | |||
85 | public void testInstallPluginFromApplication() |
||
86 | throws InstallPackageServiceException, IOException, |
||
87 | LocatorException, MakePluginPackageServiceException { |
||
88 | File installersDirectory = super.getInstallersDirectory(); |
||
89 | File applicationDirectory = super.getApplicationDirectory(); |
||
90 | |||
91 | InstallPackageService installerExecutionService = InstallerLocator |
||
92 | .getInstallerManager().getInstallPackageService(); |
||
93 | 43126 | jjdelcerro | installerExecutionService.addBundlesFromDirectory(installersDirectory, null);
|
94 | 40435 | jjdelcerro | |
95 | PackageInfo packageInfo = installerExecutionService |
||
96 | .getPackageInfo("org.gvsig.plugin1");
|
||
97 | installerExecutionService.installPackage(applicationDirectory, |
||
98 | packageInfo); |
||
99 | |||
100 | Assert.assertEquals(3, installerExecutionService.getPackageCount());
|
||
101 | |||
102 | // Reading the excution and check that the file is installed
|
||
103 | MakePluginPackageService installerCreationService = InstallerLocator |
||
104 | .getInstallerManager().getMakePluginPackageService(); |
||
105 | Assert |
||
106 | .assertEquals(4, installerCreationService
|
||
107 | .getPluginPackageCount()); |
||
108 | } |
||
109 | |||
110 | public void testInstallPluginFromExternal() |
||
111 | throws InstallPackageServiceException, IOException, |
||
112 | LocatorException, MakePluginPackageServiceException { |
||
113 | File applicationDirectory = super.getApplicationDirectory(); |
||
114 | File externalInstallationFile = new File(applicationDirectory |
||
115 | .getAbsoluteFile() |
||
116 | + File.separator + "install" + File.separator + "bundle1.zip"); |
||
117 | |||
118 | InstallPackageService installerExecutionService = InstallerLocator |
||
119 | .getInstallerManager().getInstallPackageService(); |
||
120 | 43126 | jjdelcerro | installerExecutionService.addBundle(externalInstallationFile, null);
|
121 | 40435 | jjdelcerro | |
122 | PackageInfo packageInfo = installerExecutionService |
||
123 | .getPackageInfo("org.gvsig.plugin1");
|
||
124 | |||
125 | Assert.assertEquals(3, installerExecutionService.getPackageCount());
|
||
126 | |||
127 | installerExecutionService.installPackage(applicationDirectory, |
||
128 | packageInfo); |
||
129 | |||
130 | // Reading the excution and check that the file is installed
|
||
131 | MakePluginPackageService installerCreationService = InstallerLocator |
||
132 | .getInstallerManager().getMakePluginPackageService(); |
||
133 | Assert |
||
134 | .assertEquals(4, installerCreationService
|
||
135 | .getPluginPackageCount()); |
||
136 | } |
||
137 | |||
138 | // public void testInstallPluginWithAntScript() throws
|
||
139 | // InstallPackageServiceException, LocatorException,
|
||
140 | // MakePluginPackageServiceException, IOException{
|
||
141 | // File applicationDirectory = super.getApplicationDirectory();
|
||
142 | // File installersDirectory = super.getInstallersDirectory();
|
||
143 | // File pluginsDirectory = super.getPluginsDirectory();
|
||
144 | //
|
||
145 | // InstallPackageService installerExecutionService =
|
||
146 | // InstallerLocator.getInstallerManager().getInstallPackageService();
|
||
147 | // installerExecutionService.addBundlesFromDirectory(installersDirectory);
|
||
148 | //
|
||
149 | // PackageInfo packageInfo =
|
||
150 | // installerExecutionService.getPackageInfo("org.gvsig.plugin2");
|
||
151 | //
|
||
152 | // Assert.assertEquals(3, installerExecutionService.getPackageCount());
|
||
153 | //
|
||
154 | // installerExecutionService.installPackage(applicationDirectory,
|
||
155 | // packageInfo);
|
||
156 | //
|
||
157 | // //Reading the excution and check that the file is installed
|
||
158 | // MakePluginPackageService installerCreationService =
|
||
159 | // InstallerLocator.getInstallerManager().getMakePluginPackageService(pluginsDirectory);
|
||
160 | //
|
||
161 | // Assert.assertEquals(5, installerCreationService.getPluginPackageCount());
|
||
162 | // }
|
||
163 | |||
164 | } |