1 /*******************************************************************************
2  * Copyright (c) 2004, 2013 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.osgi.tests.resolver;
15 
16 import org.eclipse.osgi.service.resolver.BundleDescription;
17 import org.eclipse.osgi.service.resolver.ExportPackageDescription;
18 import org.eclipse.osgi.service.resolver.State;
19 import org.eclipse.osgi.service.resolver.StateObjectFactory;
20 import org.eclipse.osgi.tests.services.resolver.AbstractStateTest;
21 import org.osgi.framework.BundleException;
22 
23 
24 
25 public class TestGenerated_001 extends AbstractStateTest {
TestGenerated_001(String testName)26 	public TestGenerated_001(String testName) {
27 		super(testName);
28 	}
29 
30 	BundleDescription bundle_1 = null;
31 	BundleDescription bundle_2 = null;
32 	BundleDescription bundle_3 = null;
33 	BundleDescription bundle_4 = null;
34 	BundleDescription bundle_5 = null;
35 	BundleDescription bundle_6 = null;
36 	BundleDescription bundle_7 = null;
37 	BundleDescription bundle_8 = null;
38 	BundleDescription bundle_9 = null;
39 	BundleDescription bundle_10 = null;
40 
testTest_001()41 	public void testTest_001() {
42 		State state = buildEmptyState();
43 		StateObjectFactory sof = StateObjectFactory.defaultFactory;
44 
45 		bundle_1 = create_bundle_1(sof);
46 		bundle_2 = create_bundle_2(sof);
47 		bundle_3 = create_bundle_3(sof);
48 		bundle_4 = create_bundle_4(sof);
49 		bundle_5 = create_bundle_5(sof);
50 		bundle_6 = create_bundle_6(sof);
51 		bundle_7 = create_bundle_7(sof);
52 		bundle_8 = create_bundle_8(sof);
53 		bundle_9 = create_bundle_9(sof);
54 		bundle_10 = create_bundle_10(sof);
55 		//***************************************************
56 		// stage a
57 		// expect to pass =true
58 		//***************************************************
59 		addBundlesToState_a(state);
60 		//***************************************************
61 		try {
62 			state.resolve();
63 		} catch (Throwable t) {
64 			fail("unexpected exception class=" + t.getClass().getName()
65 					+ " message=" + t.getMessage());
66 			return;
67 		}
68 		checkBundlesResolved_a();
69 		checkWiring_a();
70 	} // end of method
71 
checkWiringState_1()72 	public void checkWiringState_1() {
73 	} // end method
74 
checkWiringState_2()75 	public void checkWiringState_2() {
76 	} // end method
77 
checkWiringState_3()78 	public void checkWiringState_3() {
79 		ExportPackageDescription[] exports = null;
80 		exports = null;
81 		exports = bundle_3.getResolvedImports();
82 		assertNotNull("export array is unexpectedly null", exports);
83 		assertTrue("export array is unexpectedly empty", exports.length > 0);
84 		for (ExportPackageDescription exp : exports) {
85 			String exportPackageName = exp.getName();
86 			assertNotNull("package name is null", exportPackageName);
87 			if (exportPackageName.equals("a2")) {
88 				assertNotNull("Package [a2] is not wired when it should  be ", exp.getExporter());
89 				assertEquals("Package [a2] is  wired incorrectly ", exp.getExporter(), bundle_8);
90 			} else if (exportPackageName.equals("a1")) {
91 				assertNotNull("Package [a1] is not wired when it should  be ", exp.getExporter());
92 				assertEquals("Package [a1] is  wired incorrectly ", exp.getExporter(), bundle_3);
93 			} else if (exportPackageName.equals("a3")) {
94 				assertNotNull("Package [a3] is not wired when it should  be ", exp.getExporter());
95 				assertEquals("Package [a3] is  wired incorrectly ", exp.getExporter(), bundle_6);
96 			}
97 		} // end for
98 	} // end method
99 
checkWiringState_4()100 	public void checkWiringState_4() {
101 	} // end method
102 
checkWiringState_5()103 	public void checkWiringState_5() {
104 	} // end method
105 
checkWiringState_6()106 	public void checkWiringState_6() {
107 		ExportPackageDescription[] exports = null;
108 		exports = null;
109 		exports = bundle_6.getResolvedImports();
110 		assertNotNull("export array is unexpectedly null", exports);
111 		assertTrue("export array is unexpectedly empty", exports.length > 0);
112 		for (ExportPackageDescription exp : exports) {
113 			String exportPackageName = exp.getName();
114 			assertNotNull("package name is null", exportPackageName);
115 			if (exportPackageName.equals("a2")) {
116 				assertNotNull("Package [a2] is not wired when it should  be ", exp.getExporter());
117 				assertEquals("Package [a2] is  wired incorrectly ", exp.getExporter(), bundle_8);
118 			} else if (exportPackageName.equals("a1")) {
119 				assertNotNull("Package [a1] is not wired when it should  be ", exp.getExporter());
120 				assertEquals("Package [a1] is  wired incorrectly ", exp.getExporter(), bundle_3);
121 			} else if (exportPackageName.equals("a3")) {
122 				assertNotNull("Package [a3] is not wired when it should  be ", exp.getExporter());
123 				assertEquals("Package [a3] is  wired incorrectly ", exp.getExporter(), bundle_6);
124 			}
125 		} // end for
126 	} // end method
127 
checkWiringState_7()128 	public void checkWiringState_7() {
129 		ExportPackageDescription[] exports = null;
130 		exports = null;
131 		exports = bundle_7.getResolvedImports();
132 		assertNotNull("export array is unexpectedly null", exports);
133 		assertTrue("export array is unexpectedly empty", exports.length > 0);
134 		for (ExportPackageDescription exp : exports) {
135 			String exportPackageName = exp.getName();
136 			assertNotNull("package name is null", exportPackageName);
137 			if (exportPackageName.equals("a2")) {
138 				assertNotNull("Package [a2] is not wired when it should  be ", exp.getExporter());
139 				assertEquals("Package [a2] is  wired incorrectly ", exp.getExporter(), bundle_8);
140 			} else if (exportPackageName.equals("a1")) {
141 				assertNotNull("Package [a1] is not wired when it should  be ", exp.getExporter());
142 				assertEquals("Package [a1] is  wired incorrectly ", exp.getExporter(), bundle_3);
143 			} else if (exportPackageName.equals("a3")) {
144 				assertNotNull("Package [a3] is not wired when it should  be ", exp.getExporter());
145 				assertEquals("Package [a3] is  wired incorrectly ", exp.getExporter(), bundle_6);
146 			}
147 		} // end for
148 	} // end method
149 
checkWiringState_8()150 	public void checkWiringState_8() {
151 		ExportPackageDescription[] exports = null;
152 		exports = null;
153 		exports = bundle_8.getResolvedImports();
154 		assertNotNull("export array is unexpectedly null", exports);
155 		assertTrue("export array is unexpectedly empty", exports.length > 0);
156 		for (ExportPackageDescription exp : exports) {
157 			String exportPackageName = exp.getName();
158 			assertNotNull("package name is null", exportPackageName);
159 			if (exportPackageName.equals("a2")) {
160 				assertNotNull("Package [a2] is not wired when it should  be ", exp.getExporter());
161 				assertEquals("Package [a2] is  wired incorrectly ", exp.getExporter(), bundle_8);
162 			} else if (exportPackageName.equals("a1")) {
163 				assertNotNull("Package [a1] is not wired when it should  be ", exp.getExporter());
164 				assertEquals("Package [a1] is  wired incorrectly ", exp.getExporter(), bundle_3);
165 			} else if (exportPackageName.equals("a3")) {
166 				assertNotNull("Package [a3] is not wired when it should  be ", exp.getExporter());
167 				assertEquals("Package [a3] is  wired incorrectly ", exp.getExporter(), bundle_6);
168 			}
169 		} // end for
170 	} // end method
171 
checkWiringState_9()172 	public void checkWiringState_9() {
173 	} // end method
174 
checkWiringState_10()175 	public void checkWiringState_10() {
176 	} // end method
177 
checkWiring_a()178 	public void checkWiring_a() {
179 		checkWiringState_1();
180 		checkWiringState_2();
181 		checkWiringState_3();
182 		checkWiringState_4();
183 		checkWiringState_5();
184 		checkWiringState_6();
185 		checkWiringState_7();
186 		checkWiringState_8();
187 		checkWiringState_9();
188 		checkWiringState_10();
189 	} // end method
190 
addBundlesToState_a(State state)191 	public void addBundlesToState_a(State state) {
192 		boolean added = false;
193 		added = state.addBundle(bundle_1);
194 		assertTrue("failed to add bundle ", added);
195 		added = state.addBundle(bundle_2);
196 		assertTrue("failed to add bundle ", added);
197 		added = state.addBundle(bundle_3);
198 		assertTrue("failed to add bundle ", added);
199 		added = state.addBundle(bundle_4);
200 		assertTrue("failed to add bundle ", added);
201 		added = state.addBundle(bundle_5);
202 		assertTrue("failed to add bundle ", added);
203 		added = state.addBundle(bundle_6);
204 		assertTrue("failed to add bundle ", added);
205 		added = state.addBundle(bundle_7);
206 		assertTrue("failed to add bundle ", added);
207 		added = state.addBundle(bundle_8);
208 		assertTrue("failed to add bundle ", added);
209 		added = state.addBundle(bundle_9);
210 		assertTrue("failed to add bundle ", added);
211 		added = state.addBundle(bundle_10);
212 		assertTrue("failed to add bundle ", added);
213 	} // end method
214 
checkBundlesResolved_a()215 	public void checkBundlesResolved_a() {
216 		assertTrue("unexpected bundle resolution state", !bundle_1.isResolved());
217 		assertTrue("unexpected bundle resolution state", !bundle_2.isResolved());
218 		assertTrue("unexpected bundle resolution state", bundle_3.isResolved());
219 		assertTrue("unexpected bundle resolution state", !bundle_4.isResolved());
220 		assertTrue("unexpected bundle resolution state", !bundle_5.isResolved());
221 		assertTrue("unexpected bundle resolution state", bundle_6.isResolved());
222 		assertTrue("unexpected bundle resolution state", bundle_7.isResolved());
223 		assertTrue("unexpected bundle resolution state", bundle_8.isResolved());
224 		assertTrue("unexpected bundle resolution state", !bundle_9.isResolved());
225 		assertTrue("unexpected bundle resolution state", !bundle_10.isResolved());
226 	} // end method
227 
create_bundle_1(StateObjectFactory sof)228 	public BundleDescription create_bundle_1(StateObjectFactory sof) {
229 		java.util.Dictionary dictionary_1 = new java.util.Properties();
230 		BundleDescription bundle = null;
231 		dictionary_1.put("Bundle-ManifestVersion", "2");
232 		dictionary_1.put("Bundle-SymbolicName", "A");
233 		dictionary_1.put("Import-Package", "a1; version=\"[2, 3]\", a2; version=8, a3; version=\"[5, 13]\"");
234 		try {
235 			bundle = sof.createBundleDescription(dictionary_1, "bundle_1", 1);
236 		} catch (BundleException be) {
237 			fail(be.getMessage());
238 		}
239 		return bundle;
240 	} // end of method
241 
create_bundle_2(StateObjectFactory sof)242 	public BundleDescription create_bundle_2(StateObjectFactory sof) {
243 		java.util.Dictionary dictionary_2 = new java.util.Properties();
244 		BundleDescription bundle = null;
245 		dictionary_2.put("Bundle-ManifestVersion", "2");
246 		dictionary_2.put("Bundle-SymbolicName", "B");
247 		dictionary_2.put("Import-Package", "a1; version=\"[3, 3.9]\", a2; version=\"[8, 8.9]\", a3; version=0");
248 		try {
249 			bundle = sof.createBundleDescription(dictionary_2, "bundle_2", 2);
250 		} catch (BundleException be) {
251 			fail(be.getMessage());
252 		}
253 		return bundle;
254 	} // end of method
255 
create_bundle_3(StateObjectFactory sof)256 	public BundleDescription create_bundle_3(StateObjectFactory sof) {
257 		java.util.Dictionary dictionary_3 = new java.util.Properties();
258 		BundleDescription bundle = null;
259 		dictionary_3.put("Bundle-ManifestVersion", "2");
260 		dictionary_3.put("Bundle-SymbolicName", "C");
261 		dictionary_3.put("Export-Package", "a1; version=7");
262 		dictionary_3.put("Import-Package", "a1; version=3, a2; version=8, a3; version=0");
263 		try {
264 			bundle = sof.createBundleDescription(dictionary_3, "bundle_3", 3);
265 		} catch (BundleException be) {
266 			fail(be.getMessage());
267 		}
268 		return bundle;
269 	} // end of method
270 
create_bundle_4(StateObjectFactory sof)271 	public BundleDescription create_bundle_4(StateObjectFactory sof) {
272 		java.util.Dictionary dictionary_4 = new java.util.Properties();
273 		BundleDescription bundle = null;
274 		dictionary_4.put("Bundle-ManifestVersion", "2");
275 		dictionary_4.put("Bundle-SymbolicName", "D");
276 		dictionary_4.put("Import-Package", "a1; version=\"[3, 3.9]\", a2; version=8, a3; version=5");
277 		try {
278 			bundle = sof.createBundleDescription(dictionary_4, "bundle_4", 4);
279 		} catch (BundleException be) {
280 			fail(be.getMessage());
281 		}
282 		return bundle;
283 	} // end of method
284 
create_bundle_5(StateObjectFactory sof)285 	public BundleDescription create_bundle_5(StateObjectFactory sof) {
286 		java.util.Dictionary dictionary_5 = new java.util.Properties();
287 		BundleDescription bundle = null;
288 		dictionary_5.put("Bundle-ManifestVersion", "2");
289 		dictionary_5.put("Bundle-SymbolicName", "E");
290 		dictionary_5.put("Import-Package", "a1; version=7, a2; version=8, a3; version=5");
291 		try {
292 			bundle = sof.createBundleDescription(dictionary_5, "bundle_5", 5);
293 		} catch (BundleException be) {
294 			fail(be.getMessage());
295 		}
296 		return bundle;
297 	} // end of method
298 
create_bundle_6(StateObjectFactory sof)299 	public BundleDescription create_bundle_6(StateObjectFactory sof) {
300 		java.util.Dictionary dictionary_6 = new java.util.Properties();
301 		BundleDescription bundle = null;
302 		dictionary_6.put("Bundle-ManifestVersion", "2");
303 		dictionary_6.put("Bundle-SymbolicName", "F");
304 		dictionary_6.put("Export-Package", "a3; version=0");
305 		dictionary_6.put("Import-Package", "a1; version=7, a2; version=\"[7, 8]\", a3; version=\"[0, 0]\"");
306 		try {
307 			bundle = sof.createBundleDescription(dictionary_6, "bundle_6", 6);
308 		} catch (BundleException be) {
309 			fail(be.getMessage());
310 		}
311 		return bundle;
312 	} // end of method
313 
create_bundle_7(StateObjectFactory sof)314 	public BundleDescription create_bundle_7(StateObjectFactory sof) {
315 		java.util.Dictionary dictionary_7 = new java.util.Properties();
316 		BundleDescription bundle = null;
317 		dictionary_7.put("Bundle-ManifestVersion", "2");
318 		dictionary_7.put("Bundle-SymbolicName", "G");
319 		dictionary_7.put("Export-Package", "a1; version=3");
320 		dictionary_7.put("Import-Package", "a1; version=\"[7, 7.9]\", a2; version=8, a3; version=0");
321 		try {
322 			bundle = sof.createBundleDescription(dictionary_7, "bundle_7", 7);
323 		} catch (BundleException be) {
324 			fail(be.getMessage());
325 		}
326 		return bundle;
327 	} // end of method
328 
create_bundle_8(StateObjectFactory sof)329 	public BundleDescription create_bundle_8(StateObjectFactory sof) {
330 		java.util.Dictionary dictionary_8 = new java.util.Properties();
331 		BundleDescription bundle = null;
332 		dictionary_8.put("Bundle-ManifestVersion", "2");
333 		dictionary_8.put("Bundle-SymbolicName", "H");
334 		dictionary_8.put("Export-Package", "a2; version=8");
335 		dictionary_8.put("Import-Package", "a1; version=3, a2; version=8, a3; version=0");
336 		try {
337 			bundle = sof.createBundleDescription(dictionary_8, "bundle_8", 8);
338 		} catch (BundleException be) {
339 			fail(be.getMessage());
340 		}
341 		return bundle;
342 	} // end of method
343 
create_bundle_9(StateObjectFactory sof)344 	public BundleDescription create_bundle_9(StateObjectFactory sof) {
345 		java.util.Dictionary dictionary_9 = new java.util.Properties();
346 		BundleDescription bundle = null;
347 		dictionary_9.put("Bundle-ManifestVersion", "2");
348 		dictionary_9.put("Bundle-SymbolicName", "I");
349 		dictionary_9.put("Export-Package", "a3; version=5");
350 		dictionary_9.put("Import-Package", "a1; version=\"[3, 3.9]\", a2; version=\"[8, 16]\", a3; version=5");
351 		try {
352 			bundle = sof.createBundleDescription(dictionary_9, "bundle_9", 9);
353 		} catch (BundleException be) {
354 			fail(be.getMessage());
355 		}
356 		return bundle;
357 	} // end of method
358 
create_bundle_10(StateObjectFactory sof)359 	public BundleDescription create_bundle_10(StateObjectFactory sof) {
360 		java.util.Dictionary dictionary_10 = new java.util.Properties();
361 		BundleDescription bundle = null;
362 		dictionary_10.put("Bundle-ManifestVersion", "2");
363 		dictionary_10.put("Bundle-SymbolicName", "J");
364 		dictionary_10.put("Import-Package", "a1; version=7, a2; version=\"[7, 8]\", a3; version=5");
365 		try {
366 			bundle = sof.createBundleDescription(dictionary_10, "bundle_10", 10);
367 		} catch (BundleException be) {
368 			fail(be.getMessage());
369 		}
370 		return bundle;
371 	} // end of method
372 } // end of testcase
373