Package org.jboss.classloading.spi.dependency.policy.mock

Examples of org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData


      super(name);
   }
  
   public void testLoadClassFromThisModule() throws Exception
   {
      MockClassLoadingMetaData a = new MockClassLoadingMetaData("a");
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
      a.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA = install(a);
      try
      {
         ClassLoader clA = assertClassLoader(contextA);
         Module moduleA = assertModule(contextA);
View Full Code Here


      assertNoClassLoader(contextA);
   }
  
   public void testLoadClassFromOtherModule() throws Exception
   {
      MockClassLoadingMetaData a = new MockClassLoadingMetaData("a");
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
      a.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA = install(a);
      try
      {
         ClassLoader clA = assertClassLoader(contextA);
         Module moduleA = assertModule(contextA);

         assertEquals(moduleA, ClassLoading.getModuleForClassLoader(clA));

         MockClassLoadingMetaData b = new MockClassLoadingMetaData("b");
         b.getRequirements().addRequirement(factory.createRequireModule("ModuleA"));
         b.setPathsAndPackageNames(B.class);
         KernelControllerContext contextB = install(b);
         try
         {
            ClassLoader clB = assertClassLoader(contextB);
            Module moduleB = assertModule(contextB);
View Full Code Here

   }
  
   public void testLoadClassFromOtherModuleDuplicates() throws Exception
   {
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
      MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0");
      a1.getCapabilities().addCapability(factory.createModule("ModuleA", "1.0.0"));
      a1.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a1.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA1 = install(a1);
      try
      {
         ClassLoader clA1 = assertClassLoader(contextA1);
         Module moduleA1 = assertModule(contextA1);

         assertEquals(moduleA1, ClassLoading.getModuleForClassLoader(clA1));

         MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a", "2.0.0");
         a2.getCapabilities().addCapability(factory.createModule("ModuleA", "2.0.0"));
         a2.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
         a2.setPathsAndPackageNames(A.class);
         KernelControllerContext contextA2 = install(a2);
         try
         {
            ClassLoader clA2 = assertClassLoader(contextA2);
            Module moduleA2 = assertModule(contextA2);

            assertEquals(moduleA1, ClassLoading.getModuleForClassLoader(clA1));
            assertEquals(moduleA2, ClassLoading.getModuleForClassLoader(clA2));

            MockClassLoadingMetaData b = new MockClassLoadingMetaData("b");
            b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("2.0.0")));
            b.setPathsAndPackageNames(B.class);
            KernelControllerContext contextB = install(b);
            try
            {
               ClassLoader clB = assertClassLoader(contextB);
               Module moduleB = assertModule(contextB);
View Full Code Here

      assertNoClassLoader(contextA1);
   }
  
   public void testLoadClassNotFound() throws Exception
   {
      MockClassLoadingMetaData a = new MockClassLoadingMetaData("a");
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
      a.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA = install(a);
      try
      {
         assertClassLoader(contextA);
         Module moduleA = assertModule(contextA);

         MockClassLoadingMetaData b = new MockClassLoadingMetaData("b");
         b.getRequirements().addRequirement(factory.createRequireModule("ModuleA"));
         b.setPathsAndPackageNames(B.class);
         KernelControllerContext contextB = install(b);
         try
         {
            assertClassLoader(contextB);
            try
View Full Code Here

      assertNoClassLoader(contextA);
   }
  
   public void testLoadClassNotAModule() throws Exception
   {
      MockClassLoadingMetaData a = new MockClassLoadingMetaData("a");
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
      a.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA = install(a);
      try
      {
         assertClassLoader(contextA);
         Module moduleA = assertModule(contextA);

         MockClassLoadingMetaData b = new MockClassLoadingMetaData("b");
         b.getRequirements().addRequirement(factory.createRequireModule("ModuleA"));
         b.setPathsAndPackageNames(B.class);
         KernelControllerContext contextB = install(b);
         try
         {
            assertClassLoader(contextB);
            Module moduleB = assertModule(contextB);
View Full Code Here

      assertNoClassLoader(contextA);
   }
  
   public void testGetResourceFromThisModule() throws Exception
   {
      MockClassLoadingMetaData a = new MockClassLoadingMetaData("a");
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
      a.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA = install(a);
      try
      {
         assertClassLoader(contextA);
         String path = ClassLoaderUtils.classNameToPath(A.class);
View Full Code Here

  
   public void testSeveralModulesWithSamePackages() throws Exception
   {
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();

      MockClassLoadingMetaData x = new MockClassLoadingMetaData("x");
      x.getCapabilities().addCapability(factory.createModule("ModuleX"));
      x.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      x.setPathsAndPackageNames(A.class);
      KernelControllerContext contextX = install(x);

      MockClassLoadingMetaData a = new MockClassLoadingMetaData("a");
      a.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA = install(a);

      MockClassLoadingMetaData y = new MockClassLoadingMetaData("y");
      y.getCapabilities().addCapability(factory.createModule("ModuleY"));
      y.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      y.setPathsAndPackageNames(A.class);
      KernelControllerContext contextY = install(y);

      try
      {
         ClassLoader clX = assertClassLoader(contextX);
         ClassLoader clA = assertClassLoader(contextA);
         ClassLoader clY = assertClassLoader(contextY);

         assertLoadClass(A.class, clX);
         assertLoadClass(A.class, clA);
         assertLoadClass(A.class, clY);
        
         MockClassLoadingMetaData b = new MockClassLoadingMetaData("b");
         b.getRequirements().addRequirement(factory.createRequireModule("ModuleA"));
         b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName()));
         b.setPathsAndPackageNames(B.class);
         KernelControllerContext contextB = install(b);

         try
         {
            ClassLoader clB = assertClassLoader(contextB);
View Full Code Here

  
   public void testSeveralModulesWithSameNamesDifferentVersions() throws Exception
   {
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();

      MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1");
      a1.getCapabilities().addCapability(factory.createModule("ModuleA", "1.0.0"));
      a1.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a1.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA1 = install(a1);

      MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2");
      a2.getCapabilities().addCapability(factory.createModule("ModuleA", "2.0.0"));
      a2.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a2.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA2 = install(a2);

      MockClassLoadingMetaData a3 = new MockClassLoadingMetaData("a3");
      a3.getCapabilities().addCapability(factory.createModule("ModuleA", "3.0.0"));
      a3.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName()));
      a3.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA3 = install(a3);

      try
      {
         ClassLoader clA1 = assertClassLoader(contextA1);
         ClassLoader clA2 = assertClassLoader(contextA2);
         ClassLoader clA3 = assertClassLoader(contextA3);

         assertLoadClass(A.class, clA1);
         assertLoadClass(A.class, clA2);
         assertLoadClass(A.class, clA3);
        
         MockClassLoadingMetaData b = new MockClassLoadingMetaData("b");
         b.getRequirements().addRequirement(factory.createRequireModule("ModuleA", new VersionRange("2.0.0", true, "3.0.0", false)));
         b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName()));
         b.setPathsAndPackageNames(B.class);
         KernelControllerContext contextB = install(b);

         try
         {
            ClassLoader clB = assertClassLoader(contextB);
View Full Code Here

   public void testSeveralModulesWithSamePackagesDifferentVersions() throws Exception
   {
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();

      MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a1");
      a1.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a1.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "1.0.0"));
      a1.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA1 = install(a1);

      MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a2");
      a2.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a2.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "2.0.0"));
      a2.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA2 = install(a2);

      MockClassLoadingMetaData a3 = new MockClassLoadingMetaData("a3");
      a3.getCapabilities().addCapability(factory.createModule("ModuleA"));
      a3.getCapabilities().addCapability(factory.createPackage(A.class.getPackage().getName(), "3.0.0"));
      a3.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA3 = install(a3);

      try
      {
         ClassLoader clA1 = assertClassLoader(contextA1);
         ClassLoader clA2 = assertClassLoader(contextA2);
         ClassLoader clA3 = assertClassLoader(contextA3);

         assertLoadClass(A.class, clA1);
         assertLoadClass(A.class, clA2);
         assertLoadClass(A.class, clA3);
        
         MockClassLoadingMetaData b = new MockClassLoadingMetaData("b");
         b.getRequirements().addRequirement(factory.createRequirePackage(A.class.getPackage().getName(), new VersionRange("2.0.0", true, "3.0.0", false)));
         b.getCapabilities().addCapability(factory.createPackage(B.class.getPackage().getName()));
         b.setPathsAndPackageNames(B.class);
         KernelControllerContext contextB = install(b);

         try
         {
            ClassLoader clB = assertClassLoader(contextB);
View Full Code Here

   }
  
   public void testConflictingRequirement() throws Exception
   {
      ClassLoadingMetaDataFactory factory = ClassLoadingMetaDataFactory.getInstance();
      MockClassLoadingMetaData a1 = new MockClassLoadingMetaData("a", "1.0.0");
      a1.setPathsAndPackageNames(A.class);
      KernelControllerContext contextA1 = install(a1);
      try
      {
         ClassLoader clA1 = assertClassLoader(contextA1);
         assertLoadClass(A.class, clA1);
         assertLoadClassFail(B.class, clA1);
         assertLoadClassFail(C.class, clA1);

         MockClassLoadingMetaData a2 = new MockClassLoadingMetaData("a", "2.0.0");
         a2.setPathsAndPackageNames(A.class);
         KernelControllerContext contextA2 = install(a2);
         try
         {
            ClassLoader clA2 = assertClassLoader(contextA2);
            assertLoadClass(A.class, clA2);
            assertLoadClassFail(B.class, clA2);
            assertLoadClassFail(C.class, clA2);

            MockClassLoadingMetaData b1 = new MockClassLoadingMetaData("b", "1.0.0");
            b1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("2.0.0", "3.0.0")));
            b1.setPathsAndPackageNames(B.class);
            KernelControllerContext contextB1 = install(b1);
            try
            {
               ClassLoader clB1 = assertClassLoader(contextB1);
               assertLoadClass(B.class, clB1);
               assertLoadClass(A.class, clB1, clA2);
               assertLoadClassFail(C.class, clB1);

               MockClassLoadingMetaData c1 = new MockClassLoadingMetaData("c", "1.0.0");
               c1.getRequirements().addRequirement(factory.createRequireModule("b"));
               c1.getRequirements().addRequirement(factory.createRequireModule("a", new VersionRange("1.0.0", "2.0.0")));
               c1.setPathsAndPackageNames(C.class);
               KernelControllerContext contextC1 = install(c1);
               try
               {
                  assertNoClassLoader(contextC1);
               }
View Full Code Here

TOP

Related Classes of org.jboss.classloading.spi.dependency.policy.mock.MockClassLoadingMetaData

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.