/******************************************************************************* * Copyright (c) 2004, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.osgi.tests.resolver; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.osgi.service.resolver.ExportPackageDescription; import org.eclipse.osgi.service.resolver.State; import org.eclipse.osgi.service.resolver.StateObjectFactory; import org.eclipse.osgi.tests.services.resolver.AbstractStateTest; import org.osgi.framework.BundleException; public class TestReprovide_001 extends AbstractStateTest { public TestReprovide_001(String testName) { super(testName); } BundleDescription bundle_1 = null; BundleDescription bundle_2 = null; BundleDescription bundle_3 = null; BundleDescription bundle_4 = null; public void testTest_001() { State state = buildEmptyState(); StateObjectFactory sof = platformAdmin.getFactory(); bundle_1 = create_bundle_1(sof); bundle_2 = create_bundle_2(sof); bundle_3 = create_bundle_3(sof); bundle_4 = create_bundle_4(sof); //*************************************************** // stage a // expect to pass =true //*************************************************** addBundlesToState_a(state); //*************************************************** try { state.resolve(); } catch (Throwable t) { fail("unexpected exception class=" + t.getClass().getName() + " message=" + t.getMessage()); return; } checkBundlesResolved_a(); checkWiring_a(); } // end of method public void checkWiringState_1() { ExportPackageDescription[] exports = bundle_1.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); for (int i = 0; i < exports.length; i++) { ExportPackageDescription exp = exports[i]; String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("p")) { assertNotNull("Package [p] is not wired when it should be ", exp.getExporter()); assertEquals("Package [p] is wired incorrectly ", exp.getExporter(), bundle_2); } } // end for } // end method public void checkWiringState_2() { BundleDescription[] requires = requires = bundle_2.getResolvedRequires(); assertNotNull("requires array is unexpectedly null", requires); assertTrue("requires array is unexpectedly empty", requires.length > 0); for (int i = 0; i 0); for (int i = 0; i