Package org.jboss.classloading.spi.version

Examples of org.jboss.classloading.spi.version.VersionComparatorRegistry


  
   protected void testVersionCompareViaRegistry(String version1, String version2, int result)
   {
      if (version1 == null)
         return;
      VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
      if (result < 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0);
      }
      else if (result > 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0);
      }
      else
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0);
      }
   }
View Full Code Here


  
   protected void testVersionCompareViaRegistry(String version1, Version version2, int result)
   {
      if (version1 == null)
         return;
      VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
      if (result < 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0);
      }
      else if (result > 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0);
      }
      else
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0);
      }
   }
View Full Code Here

  
   protected void testVersionCompareViaRegistry(Version version1, Version version2, int result)
   {
      if (version1 == null)
         return;
      VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
      if (result < 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0);
      }
      else if (result > 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0);
      }
      else
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0);
      }
   }
View Full Code Here

      super(name);
   }
  
   public void testComparatorSameClass()
   {
      VersionComparatorRegistry registry = new VersionComparatorRegistry();
      MyVersion version1 = MyVersion.parseMyVersion("1.0");
      MyVersion version2 = MyVersion.parseMyVersion("2.0");
     
      try
      {
         registry.compare(version1, version2);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
     
      MyVersionToMyVersionComparator comparator = new MyVersionToMyVersionComparator();
      registry.registerVersionComparator(MyVersion.class, comparator);
      assertTrue(registry.compare(version1, version2) < 0);
      assertTrue(registry.compare(version2, version1) > 0);
     
      registry.removeVersionComparator(MyVersion.class);
     
      try
      {
         registry.compare(version1, version2);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      registry.registerVersionComparator(MyVersion.class, MyVersion.class, comparator);
      assertTrue(registry.compare(version1, version2) < 0);
      assertTrue(registry.compare(version2, version1) > 0);
     
      registry.removeVersionComparator(MyVersion.class, MyVersion.class);
     
      try
      {
         registry.compare(version1, version2);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
View Full Code Here

      }
   }
  
   public void testComparatorDifferentClass()
   {
      VersionComparatorRegistry registry = new VersionComparatorRegistry();
      String version1 = "1.0";
      MyVersion version2 = MyVersion.parseMyVersion("2.0");
     
      try
      {
         registry.compare(version1, version2);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
     
      TestStringToMyVersionComparator comparator = new TestStringToMyVersionComparator();
      registry.registerVersionComparator(String.class, MyVersion.class, comparator);
      assertTrue(registry.compare(version1, version2) < 0);
      assertTrue(registry.compare(version2, version1) > 0);
     
      registry.removeVersionComparator(MyVersion.class, String.class);
     
      try
      {
         registry.compare(version1, version2);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      registry.registerVersionComparator(String.class, MyVersion.class, comparator);
      assertTrue(registry.compare(version1, version2) < 0);
      assertTrue(registry.compare(version2, version1) > 0);
     
      registry.removeVersionComparator(MyVersion.class, String.class);
     
      try
      {
         registry.compare(version1, version2);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
View Full Code Here

      testStringStringCompare("1.0.0.Beta10", "1.0.0.Beta2", -1);
   }
  
   protected <T> void testReplaceBuiltInComparator(Class<T> classT, VersionComparator<T, T> comparator)
   {
      VersionComparatorRegistry registry = new VersionComparatorRegistry();
      try
      {
         registry.registerVersionComparator(classT, comparator);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      try
      {
         registry.registerVersionComparator(classT, classT, comparator);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      try
      {
         registry.removeVersionComparator(classT);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      try
      {
         registry.removeVersionComparator(classT, classT);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      try
      {
         registry.registerVersionComparator(classT, classT, null);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
View Full Code Here

      }
   }
  
   protected <T, U> void testReplaceBuiltInComparator(Class<T> classT, Class<U> classU, VersionComparator<T, U> comparator)
   {
      VersionComparatorRegistry registry = new VersionComparatorRegistry();
      try
      {
         registry.registerVersionComparator(classT, classU, comparator);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      try
      {
         registry.removeVersionComparator(classT, classU);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
      }
      try
      {
         registry.registerVersionComparator(classT, classU, null);
         fail("Should not be here");
      }
      catch (Throwable t)
      {
         checkThrowable(IllegalArgumentException.class, t);
View Full Code Here

      testVersionVersionCompareViaRegistry(version1, version2, result);
   }
  
   protected void testVersionVersionCompareViaRegistry(Object version1, Object version2, int result)
   {
      VersionComparatorRegistry registry = VersionComparatorRegistry.getInstance();
      if (result < 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be negative " + registry.compare(version1, version2), registry.compare(version1, version2) < 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be positive " + registry.compare(version2, version1), registry.compare(version2, version1) > 0);
      }
      else if (result > 0)
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be positive " + registry.compare(version1, version2), registry.compare(version1, version2) > 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be negative" + registry.compare(version2, version1), registry.compare(version2, version1) < 0);
      }
      else
      {
         assertTrue("Expected " + version1 + ".compareTo(" + version2 + ") to be zero " + registry.compare(version1, version2), registry.compare(version1, version2) == 0);
         assertTrue("Expected " + version2 + ".compareTo(" + version1 + ") to be zero" + registry.compare(version2, version1), registry.compare(version2, version1) == 0);
      }

      if (result == 0)
      {
         assertTrue("Expected " + version1 + ".equals(" + version2 + ") to be true", registry.same(version1, version2));
         assertTrue("Expected " + version2 + ".equals(" + version1 + ") to be true", registry.same(version2, version1));
      }
      else
      {
         assertFalse("Expected " + version1 + ".equals(" + version2 + ") to be false", registry.same(version1, version2));
         assertFalse("Expected " + version2 + ".equals(" + version1 + ") to be false", registry.same(version2, version1));
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.classloading.spi.version.VersionComparatorRegistry

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.