You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by aledsage <gi...@git.apache.org> on 2017/08/25 17:10:50 UTC

[GitHub] brooklyn-server pull request #806: Osgis.bundleFinder: support version range

GitHub user aledsage opened a pull request:

    https://github.com/apache/brooklyn-server/pull/806

    Osgis.bundleFinder: support version range

    Useful for `brooklyn.libraries` when name:version of pre-installed bundle is specified.
    
    @m4rkmckenna as discussed - can you take a look please?

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/aledsage/brooklyn-server osgisFinder-support-versionRange

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/806.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #806
    
----
commit 5347cbf3b1148a95c700e28ee9d7da0dcdba43e2
Author: Aled Sage <al...@gmail.com>
Date:   2017-08-25T17:09:32Z

    Osgis.bundleFinder: support version range
    
    Useful for `brooklyn.libraries` when name:version of pre-installed
    bundle is specified.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #806: Osgis.bundleFinder: support version range

Posted by m4rkmckenna <gi...@git.apache.org>.
Github user m4rkmckenna commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/806#discussion_r135323521
  
    --- Diff: core/src/test/java/org/apache/brooklyn/util/core/osgi/OsgisTest.java ---
    @@ -0,0 +1,117 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.util.core.osgi;
    +
    +import static org.testng.Assert.assertEquals;
    +
    +import java.util.List;
    +
    +import org.mockito.Mockito;
    +import org.osgi.framework.Bundle;
    +import org.osgi.framework.BundleContext;
    +import org.osgi.framework.Version;
    +import org.osgi.framework.launch.Framework;
    +import org.testng.annotations.BeforeMethod;
    +import org.testng.annotations.Test;
    +
    +import com.google.common.collect.ImmutableList;
    +
    +public class OsgisTest {
    +
    +    private Framework framework;
    +    private BundleContext bundleContext;
    +    private Bundle myBundle1_0_0;
    +    private Bundle myBundle1_1_0;
    +    private Bundle otherBundle1_0_0;
    +    private Bundle snapshotBundle1_0_0_snapshot;
    +    
    +    @BeforeMethod(alwaysRun=true)
    +    public void setUp() throws Exception {
    +        myBundle1_0_0 = Mockito.mock(Bundle.class);
    +        Mockito.when(myBundle1_0_0.getSymbolicName()).thenReturn("mybundle");
    +        Mockito.when(myBundle1_0_0.getVersion()).thenReturn(Version.parseVersion("1.0.0"));
    +        
    +        myBundle1_1_0 = Mockito.mock(Bundle.class);
    +        Mockito.when(myBundle1_1_0.getSymbolicName()).thenReturn("mybundle");
    +        Mockito.when(myBundle1_1_0.getVersion()).thenReturn(Version.parseVersion("1.1.0"));
    +        
    +        otherBundle1_0_0 = Mockito.mock(Bundle.class);
    +        Mockito.when(otherBundle1_0_0.getSymbolicName()).thenReturn("otherbundle");
    +        Mockito.when(otherBundle1_0_0.getVersion()).thenReturn(Version.parseVersion("1.0.0"));
    +        
    +        snapshotBundle1_0_0_snapshot = Mockito.mock(Bundle.class);
    +        Mockito.when(snapshotBundle1_0_0_snapshot.getSymbolicName()).thenReturn("snapshotbundle");
    +        Mockito.when(snapshotBundle1_0_0_snapshot.getVersion()).thenReturn(Version.parseVersion("1.0.0.SNAPSHOT"));
    +        
    +        bundleContext = Mockito.mock(BundleContext.class);
    +        Mockito.when(bundleContext.getBundles()).thenReturn(new Bundle[] {myBundle1_0_0, myBundle1_1_0, otherBundle1_0_0, snapshotBundle1_0_0_snapshot});
    +        
    +        framework = Mockito.mock(Framework.class);
    +        Mockito.when(framework.getBundleContext()).thenReturn(bundleContext);
    +        
    +    }
    +    
    +    @Test
    +    public void testFindByNameAndVersion() throws Exception {
    +        Bundle result = Osgis.bundleFinder(framework)
    +                .symbolicName("mybundle")
    +                .version("1.0.0")
    +                .find()
    +                .get();
    +        assertEquals(result, myBundle1_0_0);
    +    }
    +
    +    @Test
    +    public void testFindAllByNameAndVersion() throws Exception {
    +        List<Bundle> result = Osgis.bundleFinder(framework)
    +                .symbolicName("mybundle")
    +                .version("1.0.0")
    +                .findAll();
    +        assertEquals(result, ImmutableList.of(myBundle1_0_0));
    +    }
    +    
    +    @Test
    +    public void testFindByNameAndVersionRange() throws Exception {
    +        List<Bundle> result = Osgis.bundleFinder(framework)
    +                .symbolicName("mybundle")
    +                .version("[1.0.0, 1.1.0)")
    +                .findAll();
    +        assertEquals(result, ImmutableList.of(myBundle1_0_0));
    +        
    +        List<Bundle> result2 = Osgis.bundleFinder(framework)
    +                .symbolicName("mybundle")
    +                .version("[1.0.0, 2.0.0)")
    +                .findAll();
    +        assertEquals(result2, ImmutableList.of(myBundle1_0_0, myBundle1_1_0));
    --- End diff --
    
    I think its worth adding the versions `2.0.0.SNAPSHOT` & `2.0.0` and making assertions around this boundary
    
    Alos add checks for the range `[1.0.0, 2.0.0]`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #806: Osgis.bundleFinder: support version range

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the issue:

    https://github.com/apache/brooklyn-server/pull/806
  
    Thanks @m4rkmckenna - I've added a couple more tests, squashed it into a single commit, and rebased against master. Once jenkins confirms this builds, I'll merge it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #806: Osgis.bundleFinder: support version range

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/806


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---