Revision 37599 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
MakePluginPackageServiceTest.java | ||
---|---|---|
47 | 47 |
*/ |
48 | 48 |
public class MakePluginPackageServiceTest extends InstallerServiceTest { |
49 | 49 |
|
50 |
@Override
|
|
51 |
protected void doSetUp() throws Exception {
|
|
50 |
@Override
|
|
51 |
protected void doSetUp() throws Exception {
|
|
52 | 52 |
|
53 |
}
|
|
53 |
}
|
|
54 | 54 |
|
55 |
public void testReadPlugins() throws LocatorException,
|
|
56 |
MakePluginPackageServiceException, InstallPackageServiceException,
|
|
57 |
IOException {
|
|
58 |
File pluginsDirectory = super.getPluginsDirectory();
|
|
55 |
public void testReadPlugins() throws LocatorException,
|
|
56 |
MakePluginPackageServiceException, InstallPackageServiceException,
|
|
57 |
IOException {
|
|
58 |
File pluginsDirectory = super.getPluginsDirectory();
|
|
59 | 59 |
|
60 |
MakePluginPackageService makePluginPackageService =
|
|
61 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(
|
|
62 |
pluginsDirectory);
|
|
60 |
MakePluginPackageService makePluginPackageService = InstallerLocator
|
|
61 |
.getInstallerManager().getMakePluginPackageService(
|
|
62 |
pluginsDirectory);
|
|
63 | 63 |
|
64 |
Assert |
|
65 |
.assertEquals(3, makePluginPackageService.getPluginPackageCount()); |
|
64 |
Assert |
|
65 |
.assertEquals(3, makePluginPackageService |
|
66 |
.getPluginPackageCount()); |
|
66 | 67 |
|
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 |
} |
|
68 |
int pluginsNumber = 0; |
|
69 |
for (int i = 0; i < 3; i++) { |
|
70 |
PackageInfo packageInfo = makePluginPackageService |
|
71 |
.getPluginPackageInfo(i); |
|
72 |
if (packageInfo.getCode().equals("org.gvsig.wms")) { |
|
73 |
assertNotNull(packageInfo.getState()); |
|
74 |
pluginsNumber++; |
|
75 |
} else if (packageInfo.getCode().equals("org.gvsig.wfs")) { |
|
76 |
assertEquals("RC2", packageInfo.getState()); |
|
77 |
pluginsNumber++; |
|
78 |
} else if (packageInfo.getCode().equals("org.gvsig.wcs")) { |
|
79 |
assertEquals("RC1", packageInfo.getState()); |
|
80 |
pluginsNumber++; |
|
81 |
} |
|
82 |
} |
|
84 | 83 |
|
85 |
Assert.assertEquals(3, pluginsNumber);
|
|
86 |
}
|
|
84 |
Assert.assertEquals(3, pluginsNumber);
|
|
85 |
}
|
|
87 | 86 |
|
88 |
public void testMakePluginPackage() throws IOException, LocatorException,
|
|
89 |
MakePluginPackageServiceException, InstallPackageServiceException {
|
|
90 |
File pluginsDirectory = super.getPluginsDirectory();
|
|
91 |
File installerFile = super.getTemporalFile();
|
|
87 |
public void testMakePluginPackage() throws IOException, LocatorException,
|
|
88 |
MakePluginPackageServiceException, InstallPackageServiceException {
|
|
89 |
File pluginsDirectory = super.getPluginsDirectory();
|
|
90 |
File installerFile = super.getTemporalFile();
|
|
92 | 91 |
|
93 |
MakePluginPackageService makePluginPackageService =
|
|
94 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(
|
|
95 |
pluginsDirectory);
|
|
92 |
MakePluginPackageService makePluginPackageService = InstallerLocator
|
|
93 |
.getInstallerManager().getMakePluginPackageService(
|
|
94 |
pluginsDirectory);
|
|
96 | 95 |
|
97 |
PackageInfo packageInfo =
|
|
98 |
makePluginPackageService.getPluginPackageInfo("org.gvsig.wfs");
|
|
96 |
PackageInfo packageInfo = makePluginPackageService
|
|
97 |
.getPluginPackageInfo("org.gvsig.wfs");
|
|
99 | 98 |
|
100 |
assertEquals("1.0.0", packageInfo.getVersion());
|
|
99 |
assertEquals("1.0.0", packageInfo.getVersion());
|
|
101 | 100 |
|
102 |
// Change the version to check that the installation process works fine
|
|
103 |
packageInfo.setVersion("1.0.1");
|
|
101 |
// Change the version to check that the installation process works fine
|
|
102 |
packageInfo.setVersion("1.0.1");
|
|
104 | 103 |
|
105 |
// Compress the plugin and create the installer compressed file
|
|
106 |
FileOutputStream os = new FileOutputStream(installerFile);
|
|
107 |
makePluginPackageService.createPackageSet(packageInfo, os);
|
|
104 |
// Compress the plugin and create the installer compressed file
|
|
105 |
FileOutputStream os = new FileOutputStream(installerFile);
|
|
106 |
makePluginPackageService.createPackageSet(packageInfo, os);
|
|
108 | 107 |
|
109 |
// decompress the plugin and read the plugin information
|
|
110 |
InstallPackageService installPackageService =
|
|
111 |
InstallerLocator.getInstallerManager().getInstallPackageService();
|
|
108 |
// decompress the plugin and read the plugin information
|
|
109 |
InstallPackageService installPackageService = InstallerLocator
|
|
110 |
.getInstallerManager().getInstallPackageService();
|
|
112 | 111 |
|
113 |
installPackageService.addBundle(installerFile);
|
|
114 |
assertEquals(1, installPackageService.getPackageCount());
|
|
115 |
PackageInfo newInstallerInfo =
|
|
116 |
makePluginPackageService.getPluginPackageInfo(0);
|
|
117 |
assertEquals("1.0.1", newInstallerInfo.getVersion());
|
|
118 |
}
|
|
112 |
installPackageService.addBundle(installerFile);
|
|
113 |
assertEquals(1, installPackageService.getPackageCount());
|
|
114 |
PackageInfo newInstallerInfo = makePluginPackageService
|
|
115 |
.getPluginPackageInfo(0);
|
|
116 |
assertEquals("1.0.1", newInstallerInfo.getVersion());
|
|
117 |
}
|
|
119 | 118 |
|
120 |
public void testCreateInstallerWithAntFile() throws IOException,
|
|
121 |
LocatorException, MakePluginPackageServiceException,
|
|
122 |
InstallPackageServiceException {
|
|
123 |
File pluginsDirectory = super.getPluginsDirectory();
|
|
124 |
File installerFile = super.getTemporalFile();
|
|
119 |
public void testCreateInstallerWithAntFile() throws IOException,
|
|
120 |
LocatorException, MakePluginPackageServiceException,
|
|
121 |
InstallPackageServiceException {
|
|
122 |
File pluginsDirectory = super.getPluginsDirectory();
|
|
123 |
File installerFile = super.getTemporalFile();
|
|
125 | 124 |
|
126 |
MakePluginPackageService makePluginPackageService =
|
|
127 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(
|
|
128 |
pluginsDirectory);
|
|
125 |
MakePluginPackageService makePluginPackageService = InstallerLocator
|
|
126 |
.getInstallerManager().getMakePluginPackageService(
|
|
127 |
pluginsDirectory);
|
|
129 | 128 |
|
130 |
PackageInfo packageInfo = |
|
131 |
makePluginPackageService.getPluginPackageInfo("org.gvsig.wfs"); |
|
132 |
packageInfo.setAntScript(makePluginPackageService.getDefaultAntScript()); |
|
129 |
PackageInfo packageInfo = makePluginPackageService |
|
130 |
.getPluginPackageInfo("org.gvsig.wfs"); |
|
131 |
packageInfo |
|
132 |
.setAntScript(makePluginPackageService.getDefaultAntScript()); |
|
133 | 133 |
|
134 |
// Compress the plugin and create the installer compressed file
|
|
135 |
FileOutputStream os = new FileOutputStream(installerFile);
|
|
136 |
makePluginPackageService.createPackageSet(packageInfo, os);
|
|
134 |
// Compress the plugin and create the installer compressed file
|
|
135 |
FileOutputStream os = new FileOutputStream(installerFile);
|
|
136 |
makePluginPackageService.createPackageSet(packageInfo, os);
|
|
137 | 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 |
}
|
|
138 |
// decompress the plugin and read the plugin information
|
|
139 |
InstallPackageService installPackageService = InstallerLocator
|
|
140 |
.getInstallerManager().getInstallPackageService();
|
|
141 |
installPackageService.addBundle(installerFile);
|
|
142 |
assertEquals(1, installPackageService.getPackageCount());
|
|
143 |
PackageInfo newInstallerInfo = makePluginPackageService
|
|
144 |
.getPluginPackageInfo(0);
|
|
145 |
assertTrue(newInstallerInfo.getAntScript().startsWith("<project"));
|
|
146 |
}
|
|
147 | 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"); |
|
148 |
public void testCreateInstallerWithFiles() throws IOException, |
|
149 |
LocatorException, MakePluginPackageServiceException, |
|
150 |
InstallPackageServiceException { |
|
151 |
File pluginsDirectory = super.getPluginsDirectory(); |
|
152 |
File installerFile = super.getTemporalFile(); |
|
153 |
File resource = new File(pluginsDirectory + File.separator |
|
154 |
+ "org.gvsig.wms" + File.separator + "resources2.txt"); |
|
156 | 155 |
|
157 |
MakePluginPackageService makePluginPackageService =
|
|
158 |
InstallerLocator.getInstallerManager().getMakePluginPackageService(
|
|
159 |
pluginsDirectory);
|
|
156 |
MakePluginPackageService makePluginPackageService = InstallerLocator
|
|
157 |
.getInstallerManager().getMakePluginPackageService(
|
|
158 |
pluginsDirectory);
|
|
160 | 159 |
|
161 |
PackageInfo packageInfo =
|
|
162 |
makePluginPackageService.getPluginPackageInfo("org.gvsig.wcs");
|
|
163 |
packageInfo.getFilesToCopy().add(resource);
|
|
160 |
PackageInfo packageInfo = makePluginPackageService
|
|
161 |
.getPluginPackageInfo("org.gvsig.wcs");
|
|
162 |
packageInfo.getFilesToCopy().add(resource);
|
|
164 | 163 |
|
165 |
// Compress the plugin and create the installer compressed file
|
|
166 |
FileOutputStream os = new FileOutputStream(installerFile);
|
|
167 |
makePluginPackageService.createPackageSet(packageInfo, os);
|
|
164 |
// Compress the plugin and create the installer compressed file
|
|
165 |
FileOutputStream os = new FileOutputStream(installerFile);
|
|
166 |
makePluginPackageService.createPackageSet(packageInfo, os);
|
|
168 | 167 |
|
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.getFilesToCopy().size());
|
|
177 |
}
|
|
168 |
// decompress the plugin and read the plugin information
|
|
169 |
InstallPackageService installPackageService = InstallerLocator
|
|
170 |
.getInstallerManager().getInstallPackageService();
|
|
171 |
installPackageService.addBundle(installerFile);
|
|
172 |
assertEquals(1, installPackageService.getPackageCount());
|
|
173 |
PackageInfo newInstallerInfo = makePluginPackageService
|
|
174 |
.getPluginPackageInfo(0);
|
|
175 |
assertEquals(1, newInstallerInfo.getFilesToCopy().size());
|
|
176 |
}
|
|
178 | 177 |
} |
Also available in: Unified diff