public void testUnresolved() throws ResolutionException { Repository repo = ws.getPlugin(Repository.class); BndEditModel model = new BndEditModel(); model.setRunFw("org.apache.felix.framework"); List<Requirement> requires = new ArrayList<Requirement>(); CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.webconsole", "[4,5)"); requires.add(capReq.buildSyntheticRequirement()); Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires); assertNotNull(shell); assertEquals(1, shell.size()); model.setRunRequires(requires); BndrunResolveContext context = new BndrunResolveContext(model, ws, log); Resolver resolver = new BndResolver(new org.apache.felix.resolver.Logger(4)); try { Map<Resource, List<Wire>> resolved = resolver.resolve(context); fail("Resolve did not fail"); } catch (ResolutionException e) { assertEquals(1, e.getUnresolvedRequirements().size()); ResolutionException augmented = ResolveProcess.augment(context, e); assertEquals(2, augmented.getUnresolvedRequirements().size()); } }
public void testSimpleResolve() { Repository repo = ws.getPlugin(Repository.class); BndEditModel model = new BndEditModel(); model.setRunFw("org.apache.felix.framework"); List<Requirement> requires = new ArrayList<Requirement>(); CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.gogo.shell", "[0,1)"); requires.add(capReq.buildSyntheticRequirement()); Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires); assertNotNull(shell); assertEquals(1, shell.size()); model.setRunRequires(requires); BndrunResolveContext context = new BndrunResolveContext(model, ws, log); Resolver resolver = new BndResolver(new org.apache.felix.resolver.Logger(4)); try { Map<Resource, List<Wire>> resolved = resolver.resolve(context); Set<Resource> resources = resolved.keySet(); Resource resource = getResource(resources, "org.apache.felix.gogo.runtime", "0.12"); assertNotNull(resource); } catch (ResolutionException e) { fail("Resolve failed"); } }
@Override public void commit(boolean onSave) { try { // Stop listening to property changes during the commit only model.removePropertyChangeListener(this); if (dirtySet.contains(Constants.BUNDLE_NAME)) { String name = bundleName.getText(); if (name != null && name.length() == 0) name = null; model.setBundleName(name); } if (dirtySet.contains(Constants.BUNDLE_DESCRIPTION)) { String name = bundleDescription.getText(); if (name != null && name.length() == 0) name = null; model.setBundleDescription(name); } if (dirtySet.contains(Constants.BUNDLE_CATEGORY)) { String name = bundleCategory.getText(); if (name != null && name.length() == 0) name = null; model.setBundleCategory(name); } } finally { // Restore property change listening model.addPropertyChangeListener(this); dirtySet.clear(); getManagedForm().dirtyStateChanged(); } }
public void testScr() { Repository repo = ws.getPlugin(Repository.class); BndEditModel model = new BndEditModel(); model.setRunFw("org.apache.felix.framework"); List<Requirement> requires = new ArrayList<Requirement>(); CapReqBuilder capReq = CapReqBuilder.createSimpleRequirement("osgi.extender", "osgi.component", "[1.1,2)"); requires.add(capReq.buildSyntheticRequirement()); Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires); assertNotNull(shell); assertEquals(1, shell.size()); }
@Override public void init(IEditorSite site, IEditorInput input) throws PartInitException { super.init(site, input); sourcePage.init(site, input); setPartNameForInput(input); IResource resource = ResourceUtil.getResource(input); if (resource != null) { resource.getWorkspace().addResourceChangeListener(this); } final IDocumentProvider docProvider = sourcePage.getDocumentProvider(); IDocument document = docProvider.getDocument(input); try { model.loadFrom(new IDocumentWrapper(document)); model.setProjectFile(Project.BNDFILE.equals(input.getName())); if (resource != null) { model.setBndResource(resource.getLocation().toFile()); } // model.addPropertyChangeListener(modelListener); } catch (IOException e) { throw new PartInitException("Error reading editor input.", e); } // Ensure the field values are updated if the file content is replaced docProvider.addElementStateListener( new IElementStateListener() { public void elementMoved(Object originalElement, Object movedElement) {} public void elementDirtyStateChanged(Object element, boolean isDirty) {} public void elementDeleted(Object element) {} public void elementContentReplaced(Object element) { try { model.loadFrom(new IDocumentWrapper(docProvider.getDocument(element))); } catch (IOException e) { logger.logError("Error loading model from document.", e); } } public void elementContentAboutToBeReplaced(Object element) {} }); }
private ResolveMode getResolveMode() { ResolveMode resolveMode = ResolveMode.manual; try { String str = (String) model.genericGet(BndConstants.RESOLVE_MODE); if (str != null) resolveMode = Enum.valueOf(ResolveMode.class, str); } catch (Exception e) { logger.logError("Error parsing '-resolve' header.", e); } return resolveMode; }
private List<String> getPagesBnd(String fileName) { List<String> pages = new ArrayList<String>(5); boolean isProjectFile = Project.BNDFILE.equals(fileName); List<String> subBndFiles = model.getSubBndFiles(); boolean isSubBundles = subBndFiles != null && !subBndFiles.isEmpty(); for (Entry<String, IFormPageFactory> pageEntry : pageFactories.entrySet()) { String pageId = pageEntry.getKey(); IFormPageFactory page = pageEntry.getValue(); if (!isSubBundles && page.supportsMode(IFormPageFactory.Mode.bundle)) pages.add(pageId); else if (isProjectFile && page.supportsMode(IFormPageFactory.Mode.build)) pages.add(pageId); else if (isProjectFile && page.supportsMode(IFormPageFactory.Mode.run)) pages.add(pageId); } return pages; }