Package org.apache.aries.util

Examples of org.apache.aries.util.VersionRange


        }
      }
    }
    //If we have too many provider class names or incompatible version ranges specified then blow up
   
    VersionRange range = null;
    if(!!!versionRanges.isEmpty()) {
      try {
        range = combineVersionRanges(versionRanges);
      } catch (InvalidRangeCombination e) {
        Bundle bundle = parsedPersistenceUnits.iterator().next().getDefiningBundle();
View Full Code Here


      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

   * @param s
   * @return VersionRange object.
   * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
   */
  public static VersionRange parseVersionRange(String s) throws IllegalArgumentException{
    return new VersionRange(s);
  }
View Full Code Here

   * @param exactVersion
   * @return VersionRange object.
   * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
   */
  public static VersionRange parseVersionRange(String s, boolean exactVersion) throws IllegalArgumentException{
    return new VersionRange(s, exactVersion);
  }
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 (NESTED_FILTER_ATTRIBUTE.equals(attribName)) {
View Full Code Here

    }

    @Test
    public void testExactVersion() throws Exception
    {
      VersionRange vr;
      try {
        vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 2.0.0]", true);
        fail("should not get here 1");
      } catch (IllegalArgumentException e) {
        // expected
      }

      vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 1.0.0]", true);
      assertTrue(vr.isExactVersion());

      try {
        vr = ManifestHeaderProcessor.parseVersionRange("(1.0.0, 1.0.0]", true);
        fail("should not get here 2");
      } catch (IllegalArgumentException e) {
        // expected
      }

      try {
        vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 1.0.0)", true);
        fail("should not get here 3");
      } catch (IllegalArgumentException e) {
        // expected
      }

      vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 2.0.0]");
      assertFalse(vr.isExactVersion());

      vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 1.0.0]");
      assertTrue(vr.isExactVersion());


    }
View Full Code Here

   * @param s
   * @return VersionRange object.
   * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
   */
  public static VersionRange parseVersionRange(String s) throws IllegalArgumentException{
    return new VersionRange(s);
  }
View Full Code Here

   * @param exactVersion
   * @return VersionRange object.
   * @throws IllegalArgumentException if the String could not be parsed as a VersionRange
   */
  public static VersionRange parseVersionRange(String s, boolean exactVersion) throws IllegalArgumentException{
    return new VersionRange(s, exactVersion);
  }
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 (NESTED_FILTER_ATTRIBUTE.equals(attribName)) {
View Full Code Here

    }
   
    @Test
    public void testExactVersion() throws Exception
    {
      VersionRange vr;
      try {
        vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 2.0.0]", true);
        fail("should not get here 1");
      } catch (IllegalArgumentException e) {
        // expected
      }
     
      vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 1.0.0]", true);
      assertTrue(vr.isExactVersion());
     
      try {
        vr = ManifestHeaderProcessor.parseVersionRange("(1.0.0, 1.0.0]", true);
        fail("should not get here 2");
      } catch (IllegalArgumentException e) {
        // expected
      }
     
      try {
        vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 1.0.0)", true);
        fail("should not get here 3");
      } catch (IllegalArgumentException e) {
        // expected
      }
     
      vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 2.0.0]");
      assertFalse(vr.isExactVersion());
     
      vr = ManifestHeaderProcessor.parseVersionRange("[1.0.0, 1.0.0]");
      assertTrue(vr.isExactVersion());
     
     
    }
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.