Package org.apache.aries.application

Examples of org.apache.aries.application.VersionRange


 
  @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

    String version9="a.b.c";
    String version10=null;
    String version11="";
    String version12="\"[1.2.3, 4.5.6]\"";
   
    VersionRange vr = new VersionRangeImpl(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 = new VersionRangeImpl(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 = new VersionRangeImpl(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 = new VersionRangeImpl(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 = new VersionRangeImpl(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 = new VersionRangeImpl(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 = new VersionRangeImpl(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 = new VersionRangeImpl(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 = new VersionRangeImpl(version9);
    } catch (Exception e){
      exception = true;
    }
   
    assertTrue("The value is wrong", exception);
    boolean exceptionNull = false;
    try {
      vr = new VersionRangeImpl(version10);
    } catch (Exception e){
      exceptionNull = true;
    }
    assertTrue("The value is wrong", exceptionNull);
    // empty version should be defaulted to >=0.0.0
    vr = new VersionRangeImpl(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 = new VersionRangeImpl(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

      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

  }
 
  @Test
  public void testExactVersion() throws Exception
  {
    VersionRange vr;
    try {
      vr = new VersionRangeImpl("[1.0.0, 2.0.0]", true);
      fail("from 1 to 2 not excludsive is not an exact range");
    } catch (IllegalArgumentException e) {
      // expected
    }
   
    vr = new VersionRangeImpl("[1.0.0, 1.0.0]", true);
    assertTrue(vr.isExactVersion());
   
    try {
      vr = new VersionRangeImpl("(1.0.0, 1.0.0]", true);
      fail("from 1 (not including 1) to 1, is not valid");
    } catch (IllegalArgumentException e) {
      // expected
    }
   
    try {
      vr = new VersionRangeImpl("[1.0.0, 1.0.0)", true);
      fail("sfrom 1 to 1 (not including 1), is not valid");
    } catch (IllegalArgumentException e) {
      // expected
    }

    vr = new VersionRangeImpl("1.0.0", true);
    assertTrue(vr.isExactVersion());

    vr = new VersionRangeImpl("1.0.0", false);
    assertFalse(vr.isExactVersion());

    vr = new VersionRangeImpl("[1.0.0, 2.0.0]");
    assertFalse(vr.isExactVersion());
   
    vr = new VersionRangeImpl("[1.0.0, 1.0.0]");
    assertTrue(vr.isExactVersion());

    vr = new VersionRangeImpl("1.0.0", true);
    assertEquals(new Version("1.0.0"), vr.getMinimumVersion());
    assertTrue(vr.isExactVersion());
   
    vr = new VersionRangeImpl("1.0.0", false);
    assertEquals(new Version("1.0.0"), vr.getMinimumVersion());
    assertNull(vr.getMaximumVersion());
    assertFalse(vr.isExactVersion());
   
    // don't throw any silly exceptions
    vr = new VersionRangeImpl("[1.0.0,2.0.0)", false);
    assertFalse(vr.isExactVersion());
   
    vr = new VersionRangeImpl("[1.0.0, 2.0.0]");
    assertFalse(vr.isExactVersion());

    vr = new VersionRangeImpl("[1.0.0, 1.0.0]");
    assertTrue(vr.isExactVersion());

  }
View Full Code Here

  }
 
  @Test
  public void testMatches()
  {
    VersionRange vr = new VersionRangeImpl("[1.0.0, 2.0.0]");
   
    assertFalse(vr.matches(new Version(0,9,0)));
    assertFalse(vr.matches(new Version(2,1,0)));
    assertTrue(vr.matches(new Version(2,0,0)));
    assertTrue(vr.matches(new Version(1,0,0)));
    assertTrue(vr.matches(new Version(1,5,0)));
   
    vr = new VersionRangeImpl("[1.0.0, 2.0.0)");
   
    assertFalse(vr.matches(new Version(0,9,0)));
    assertFalse(vr.matches(new Version(2,1,0)));
    assertFalse(vr.matches(new Version(2,0,0)));
    assertTrue(vr.matches(new Version(1,0,0)));
    assertTrue(vr.matches(new Version(1,5,0)));

    vr = new VersionRangeImpl("(1.0.0, 2.0.0)");
   
    assertFalse(vr.matches(new Version(0,9,0)));
    assertFalse(vr.matches(new Version(2,1,0)));
    assertFalse(vr.matches(new Version(2,0,0)));
    assertFalse(vr.matches(new Version(1,0,0)));
    assertTrue(vr.matches(new Version(1,5,0)));

    vr = new VersionRangeImpl("[1.0.0, 1.0.0]");
    assertFalse(vr.matches(new Version(0,9,0)));
    assertFalse(vr.matches(new Version(2,0,0)));
    assertTrue(vr.matches(new Version(1,0,0)));
    assertFalse(vr.matches(new Version(1,5,0)));
    assertFalse(vr.matches(new Version(1,9,9)));
  }
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

  }
 
  @Test
  public void testIntersectVersionRange_Valid1()
  {
    VersionRange v1 = new VersionRangeImpl("[1.0.0,3.0.0]");
    VersionRange v2 = new VersionRangeImpl("[2.0.0,3.0.0)");
    VersionRange result = v1.intersect(v2);
    assertNotNull(result);
    assertEquals("[2.0.0,3.0.0)", result.toString());
  }
View Full Code Here

  }
 
  @Test
  public void testIntersectVersionRange_Valid2()
  {
    VersionRange v1 = new VersionRangeImpl("[1.0.0,3.0.0)");
    VersionRange v2 = new VersionRangeImpl("(2.0.0,3.0.0]");
    VersionRange result = v1.intersect(v2);
    assertNotNull(result);
    assertEquals("(2.0.0,3.0.0)", result.toString());
  }
View Full Code Here

TOP

Related Classes of org.apache.aries.application.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.