Package org.apache.aries.util

Examples of org.apache.aries.util.VersionRange


      String version9="a.b.c";
      String version10=null;
      String version11="";
      String version12="\"[1.2.3, 4.5.6]\"";
     
      VersionRange vr = ManifestHeaderProcessor.parseVersionRange(version1);
      assertEquals("The value is wrong", "1.2.3", vr.getMinimumVersion().toString());
      assertFalse("The value is wrong", vr.isMinimumExclusive());
      assertEquals("The value is wrong", "4.5.6", vr.getMaximumVersion().toString());
      assertFalse("The value is wrong", vr.isMaximumExclusive());
     
      vr = ManifestHeaderProcessor.parseVersionRange(version2);
      assertEquals("The value is wrong", "1.0.0", vr.getMinimumVersion().toString());
      assertTrue("The value is wrong", vr.isMinimumExclusive());
      assertEquals("The value is wrong", "2.0.0", vr.getMaximumVersion().toString());
      assertFalse("The value is wrong", vr.isMaximumExclusive());
     
      vr = ManifestHeaderProcessor.parseVersionRange(version3);
     
      assertEquals("The value is wrong", "2.0.0", vr.getMinimumVersion().toString());
      assertFalse("The value is wrong", vr.isMinimumExclusive());
      assertEquals("The value is wrong", "4.0.0", vr.getMaximumVersion().toString());
      assertTrue("The value is wrong", vr.isMaximumExclusive());
     
      vr = ManifestHeaderProcessor.parseVersionRange(version4);
     
      assertEquals("The value is wrong", "1.0.0", vr.getMinimumVersion().toString());
      assertTrue("The value is wrong", vr.isMinimumExclusive());
      assertEquals("The value is wrong", "2.0.0", vr.getMaximumVersion().toString());
      assertTrue("The value is wrong", vr.isMaximumExclusive());
     
      vr = ManifestHeaderProcessor.parseVersionRange(version5);
      assertEquals("The value is wrong", "2.0.0", vr.getMinimumVersion().toString());
      assertFalse("The value is wrong", vr.isMinimumExclusive());
      assertNull("The value is wrong", vr.getMaximumVersion());
      assertFalse("The value is wrong", vr.isMaximumExclusive());
     
      vr = ManifestHeaderProcessor.parseVersionRange(version6);
      assertEquals("The value is wrong", "2.3.0", vr.getMinimumVersion().toString());
      assertFalse("The value is wrong", vr.isMinimumExclusive());
      assertNull("The value is wrong", vr.getMaximumVersion());
      assertFalse("The value is wrong", vr.isMaximumExclusive());
     
      vr = ManifestHeaderProcessor.parseVersionRange(version7);
      assertEquals("The value is wrong", "1.2.3.q", vr.getMinimumVersion().toString());
      assertFalse("The value is wrong", vr.isMinimumExclusive());
      assertEquals("The value is wrong", "2.3.4.p", vr.getMaximumVersion().toString());
      assertTrue("The value is wrong", vr.isMaximumExclusive());
     
      vr = ManifestHeaderProcessor.parseVersionRange(version8);
      assertEquals("The value is wrong", "1.2.2.5", vr.getMinimumVersion().toString());
      assertFalse("The value is wrong", vr.isMinimumExclusive());
      assertNull("The value is wrong", vr.getMaximumVersion());
      assertFalse("The value is wrong", vr.isMaximumExclusive());
      boolean exception = false;
      try {
      vr = ManifestHeaderProcessor.parseVersionRange(version9);
      } catch (Exception e){
        exception = true;
      }
     
      assertTrue("The value is wrong", exception);
      boolean exceptionNull = false;
      try {
        vr = ManifestHeaderProcessor.parseVersionRange(version10);
        } catch (Exception e){
          exceptionNull = true;
        }
        assertTrue("The value is wrong", exceptionNull);
        // empty version should be defaulted to >=0.0.0
        vr = ManifestHeaderProcessor.parseVersionRange(version11);
        assertEquals("The value is wrong", "0.0.0", vr.getMinimumVersion().toString());
        assertFalse("The value is wrong", vr.isMinimumExclusive());
        assertNull("The value is wrong", vr.getMaximumVersion());
        assertFalse("The value is wrong", vr.isMaximumExclusive());
         
         
          vr = ManifestHeaderProcessor.parseVersionRange(version12);
          assertEquals("The value is wrong", "1.2.3", vr.getMinimumVersion().toString());
          assertFalse("The value is wrong", vr.isMinimumExclusive());
          assertEquals("The value is wrong", "4.5.6", vr.getMaximumVersion().toString());
          assertFalse("The value is wrong", vr.isMaximumExclusive())
    }
View Full Code Here


    //"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
    List<Content> contents = am.getApplicationContents();
    for (Content content : contents){
      if ("com.travel.reservation.web".equals(content.getContentName())){
        VersionRange vr = content.getVersion();
        assertEquals(vr.getMinimumVersion(),new Version("1.1.0"));
        assertEquals(vr.getMaximumVersion(),new Version("1.2.0"));
      } else if("com.travel.reservation.business".equals(content.getContentName())){
        VersionRange vr = content.getVersion();
        assertEquals(new Version(0,0,0), vr.getMinimumVersion());
      } else
        fail("Unexepcted content name " + content.getContentName());
    }
  }
View Full Code Here

    //"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
    List<Content> contents = am.getApplicationContents();
    for (Content content : contents){
      if ("com.travel.reservation.web".equals(content.getContentName())){
        VersionRange vr = content.getVersion();
        assertEquals(vr.getMinimumVersion(),new Version("1.1.0"));
        assertEquals(vr.getMaximumVersion(),new Version("1.2.0"));
      } else if("com.travel.reservation.business".equals(content.getContentName())){
        VersionRange vr = content.getVersion();
        assertEquals(new Version(0,0,0), vr.getMinimumVersion());
      } else
        fail("Unexepcted content name " + content.getContentName());
    }
  }
View Full Code Here

      useBundles.put(c.getContentName(), c.getVersion());
    }
   
    for (BundleInfo info : bundlesRequired) {
     
      VersionRange appContentRange = appContent.get(info.getSymbolicName());
      VersionRange useBundleRange = useBundles.get(info.getSymbolicName());
      DeploymentContent dp = new DeploymentContentImpl(info.getSymbolicName(), info.getVersion());
     
      if ((appContentRange == null) && (useBundleRange == null)){
        _provisionSharedContent.add(dp);
      } else if (appContentRange.matches(info.getVersion())) {
        _deploymentContent.add(dp);
      else if (useBundleRange.matches(info.getVersion())) {
        _deployedUseBundleContent.add(dp);
      }
      else {
        throw new ResolverException("Bundle " + info.getSymbolicName() + " at version " + info.getVersion() + " is not in the range " + appContentRange + " or " + useBundleRange);
      }
View Full Code Here

    return _content.getDirectives();
  }

  public VersionRange getVersion() {
    String deployedVersion = _content.getAttribute(AppConstants.DEPLOYMENT_BUNDLE_VERSION);
    VersionRange vr = null;
    if (deployedVersion != null && deployedVersion.length() > 0) {
      vr = ManifestHeaderProcessor.parseVersionRange(deployedVersion, true);
    }
    return vr;
  }
View Full Code Here

 
  @Test
  public void testDeploymentContent001() throws Exception {
    DeploymentContentImpl dc = new DeploymentContentImpl("com.travel.reservation.web;deployed-version=\"1.1.0\"");
    assertEquals("1.1.0", dc.getAttribute("deployed-version"));
    VersionRange vi = dc.getVersion();
    assertTrue(vi.isExactVersion());
    assertEquals(new Version("1.1.0"), dc.getExactVersion());
    assertEquals("com.travel.reservation.web", dc.getContentName());
    assertEquals("{deployed-version=1.1.0}", dc.getNameValueMap().toString());
  }
View Full Code Here

 
  @Test
  public void testDeploymentContent002() throws Exception {
    DeploymentContentImpl dc = new DeploymentContentImpl("com.travel.reservation.business;deployed-version=2.0");
    assertEquals("2.0", dc.getAttribute("deployed-version"));
    VersionRange vi = dc.getVersion();
    assertTrue(vi.isExactVersion());
    assertEquals(new Version("2.0"), dc.getExactVersion());
    assertEquals("com.travel.reservation.business", dc.getContentName());
    assertEquals("{deployed-version=2.0}", dc.getNameValueMap().toString());
  }
View Full Code Here

 
  @Test
  public void testDeploymentContent003() throws Exception {
    DeploymentContentImpl dc = new DeploymentContentImpl("com.travel.reservation.data;deployed-version=2.1.1");
    assertEquals("2.1.1", dc.getAttribute("deployed-version"));
    VersionRange vi = dc.getVersion();
    assertTrue(vi.isExactVersion());
    assertEquals(new Version("2.1.1"), dc.getExactVersion());
    assertEquals("com.travel.reservation.data", dc.getContentName());
    assertEquals("{deployed-version=2.1.1}", dc.getNameValueMap().toString());
  }
View Full Code Here

  public void addDirective(String key, String value) {
    this.directives.put(key, value);
  }
 
  public VersionRange getVersion() {
    VersionRange vi = null;
    if (this.attributes.get(Constants.VERSION_ATTRIBUTE) != null
        && this.attributes.get(Constants.VERSION_ATTRIBUTE).length() > 0) {
      vi = ManifestHeaderProcessor.parseVersionRange(this.attributes.get(Constants.VERSION_ATTRIBUTE));
    } else {
      // what if version is not specified?  let's interpret it as 0.0.0
View Full Code Here

                    || (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(attribName))) {
                // version and bundle-version attrib requires special
                // conversion.
                realAttrib = true;

                VersionRange vr = ManifestHeaderProcessor
                        .parseVersionRange(attrib.getValue());

                filter.append("(" + attribName + ">=" + vr.getMinimumVersion());

                if (vr.getMaximumVersion() != null) {
                    filter.append(")(" + attribName + "<=");
                    filter.append(vr.getMaximumVersion());
                }

                if (vr.getMaximumVersion() != null && vr.isMinimumExclusive()) {
                    filter.append(")(!(" + attribName + "=");
                    filter.append(vr.getMinimumVersion());
                    filter.append(")");
                }

                if (vr.getMaximumVersion() != null && vr.isMaximumExclusive()) {
                    filter.append(")(!(" + attribName + "=");
                    filter.append(vr.getMaximumVersion());
                    filter.append(")");
                }
                filter.append(")");

            } else if (Constants.OBJECTCLASS.equals(attribName)) {
View Full Code Here

TOP

Related Classes of org.apache.aries.util.VersionRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.