Package org.testng

Examples of org.testng.IClass


   */
  protected IClass findOrCreateIClass(Class cls, Object instance,
      XmlTest xmlTest,
      IAnnotationFinder annotationFinder)
  {
    IClass result = m_classes.get(cls);
    if (null == result) {
      result = new ClassImpl(cls, instance, m_classes, xmlTest, annotationFinder);
      m_classes.put(cls, result);
    }

View Full Code Here


//    }
   
    Collection<Class> allClasses = invokeSuite(classes);
   
    for (Class cls : allClasses) {
      IClass ic = findOrCreateIClass(cls, null, xmlTest, finder);
      Utils.log("JUnitClassFinder", 3, "Looking up ClassFinder for " + cls + " " + cls.hashCode() + " " + finder.hashCode());
      if (null != ic) {
        putIClass(cls, ic);
      }
    }
View Full Code Here

  }

  private void process(IResultMap map) {
    for (ITestResult res : map.getAllResults()) {
      IClass clazz = res.getTestClass();
      long duration = res.getEndMillis() - res.getStartMillis();
      add(clazz, duration);
    }
  }
View Full Code Here

        if ((null == thisInstance) && Modifier.isAbstract(cls.getModifiers())) {
          Utils.log("", 5, "[WARN] Found an abstract class with no valid instance attached: " + cls);
          continue;
        }

        IClass ic= findOrCreateIClass(cls, thisInstance, xmlTest, annotationFinder,
                                      objectFactory);
        if(null != ic) {
          Object[] theseInstances = ic.getInstances(false);
          if (theseInstances.length == 0) {
            theseInstances = ic.getInstances(true);
          }
          Object instance= theseInstances[0];
          putIClass(cls, ic);

          Method factoryMethod= ClassHelper.findFactoryMethod(cls, annotationFinder);
          if(null != factoryMethod) {
            FactoryMethod fm= new FactoryMethod( /* cls, */
              factoryMethod,
              instance,
              xmlTest,
              annotationFinder,
              m_testContext);
            List<Class> moreClasses= new ArrayList<Class>();

            {
//            ppp("INVOKING FACTORY " + fm + " " + this.hashCode());
              Object[] instances= fm.invoke();

              //
              // If the factory returned IInstanceInfo, get the class from it,
              // otherwise, just call getClass() on the returned instances
              //
              if (instances.length > 0) {
                Class elementClass = instances[0].getClass();
                if(IInstanceInfo.class.isAssignableFrom(elementClass)) {
                  for(Object o : instances) {
                    IInstanceInfo ii = (IInstanceInfo) o;
                    addInstance(ii.getInstanceClass(), ii.getInstance());
                    moreClasses.add(ii.getInstanceClass());
                  }
                }
                else {
                  for(Object o : instances) {
                    addInstance(o.getClass(), o);
                    if(!classExists(o.getClass())) {
                      moreClasses.add(o.getClass());
                    }
                  }
                }
              }
            }

            if(moreClasses.size() > 0) {
              TestNGClassFinder finder=
                new TestNGClassFinder(moreClasses.toArray(
                    new Class[moreClasses.size()]),
                    m_instanceMap,
                    xmlTest,
                    annotationFinder,
                    m_testContext);

              IClass[] moreIClasses= finder.findTestClasses();
              for(IClass ic2 : moreIClasses) {
                putIClass(ic2.getRealClass(), ic2);
              }
            } // if moreClasses.size() > 0
          }
        } // null != ic
      } // if not TestNG class
      else {
        Utils.log("TestNGClassFinder", 3, "SKIPPING CLASS " + cls + " no TestNG annotations found");
      }
    } // for

    //
    // Add all the instances we found to their respective IClasses
    //
    for(Class c : m_instanceMap.keySet()) {
      List<Object> instances= m_instanceMap.get(c);
      for(Object instance : instances) {
        IClass ic= getIClass(c);
        if(null != ic) {
          ic.addInstance(instance);
        }
      }
    }
  }
View Full Code Here

  protected IClass findOrCreateIClass(Class cls, Object instance,
      XmlTest xmlTest,
      IAnnotationFinder annotationFinder,
      IObjectFactory objectFactory)
  {
    IClass result = m_classes.get(cls);
    if (null == result) {
      result = new ClassImpl(cls, instance, m_classes, xmlTest, annotationFinder, objectFactory);
      m_classes.put(cls, result);
    }
View Full Code Here

        if ((null != ec) && !isStatic) {
          parameterTypes = new Class[] { ec };
 
          // Create an instance of the enclosing class so we can instantiate
          // the nested class (actually, we reuse the existing instance).
          IClass enclosingIClass = classes.get(ec);
          Object[] enclosingInstances;
          if (null != enclosingIClass) {
            enclosingInstances = enclosingIClass.getInstances(false);
            if ((null == enclosingInstances) || (enclosingInstances.length == 0)) {
              Object o = objectFactory.newInstance(ec.getConstructor(parameterTypes));
              enclosingIClass.addInstance(o);
              enclosingInstances = new Object[] { o };
            }
          }
          else {
            enclosingInstances = new Object[] { ec.newInstance() };
View Full Code Here

    }

    PerPackageCoverageListener listener = new PerPackageCoverageListener();

    void simulateTest(Class<?> fauxTestClass) {
        IClass mockClass = EasyMock.createMock(IClass.class);
        ITestResult mockResult = EasyMock.createMock(ITestResult.class);
        EasyMock.expect(mockResult.getTestClass()).andReturn(mockClass);
        EasyMock.expect(mockClass.getRealClass()).andReturn(fauxTestClass);
        EasyMock.replay(mockResult, mockClass);
        listener.onTestStart(mockResult);
    }
View Full Code Here

        if ((null != ec) && !isStatic) {
          parameterTypes = new Class[] { ec };

          // Create an instance of the enclosing class so we can instantiate
          // the nested class (actually, we reuse the existing instance).
          IClass enclosingIClass = classes.get(ec);
          Object[] enclosingInstances = null;
          if (null != enclosingIClass) {
            enclosingInstances = enclosingIClass.getInstances(false);
            if ((null == enclosingInstances) || (enclosingInstances.length == 0)) {
              Object o = ec.newInstance();
              enclosingIClass.addInstance(o);
              enclosingInstances = new Object[] { o };
            }
          }
          else {
            enclosingInstances = new Object[] { ec.newInstance() };
View Full Code Here

        if ((null == thisInstance) && Modifier.isAbstract(cls.getModifiers())) {
          Utils.log("", 2, "[WARN] Found an abstract class with no valid instance attached: " + cls);
          continue;
        }
       
        IClass ic= findOrCreateIClass(cls, thisInstance, xmlTest, annotationFinder);
        if(null != ic) {
          Object[] theseInstances = ic.getInstances(false);
          if (theseInstances.length == 0) {
            theseInstances = ic.getInstances(true);
          }
          Object instance= theseInstances[0];
          putIClass(cls, ic);

          Method factoryMethod= ClassHelper.findFactoryMethod(cls, annotationFinder);
          if(null != factoryMethod) {
            FactoryMethod fm= new FactoryMethod( /* cls, */
              factoryMethod,
              instance,
              xmlTest,
              annotationFinder);
            List<Class> moreClasses= new ArrayList<Class>();

            {
//            ppp("INVOKING FACTORY " + fm + " " + this.hashCode());
              Object[] instances= fm.invoke();

              //
              // If the factory returned IInstanceInfo, get the class from it,
              // otherwise, just call getClass() on the returned instances
              //
              Class elementClass= instances.getClass().getComponentType();
              if(IInstanceInfo.class.isAssignableFrom(elementClass)) {
                IInstanceInfo[] infos= (IInstanceInfo[]) instances;
                for(IInstanceInfo o : infos) {
                  addInstance(o.getInstanceClass(), o.getInstance());
                  moreClasses.add(o.getInstanceClass());
                }
              }
              else {
                for(Object o : instances) {
                  addInstance(o.getClass(), o);
                  if(!classExists(o.getClass())) {
                    moreClasses.add(o.getClass());
                  }
                }
              }
            }

            if(moreClasses.size() > 0) {
              TestNGClassFinder finder= new TestNGClassFinder(moreClasses.toArray(new Class[moreClasses
                                                                                  .size()]),
                                                              m_instanceMap,
                                                              xmlTest,
                                                              annotationFinder);

              IClass[] moreIClasses= finder.findTestClasses();
              for(IClass ic2 : moreIClasses) {
                putIClass(ic2.getRealClass(), ic2);
              }
            } // if moreClasses.size() > 0
          }
        } // null != ic
      } // if not TestNG class
      else {
        Utils.log("TestNGClassFinder", 3, "SKIPPING CLASS " + cls + " no TestNG annotations found");
      }
    } // for

    //
    // Add all the instances we found to their respective IClasses
    //
    for(Class c : m_instanceMap.keySet()) {
      List<Object> instances= m_instanceMap.get(c);
      for(Object instance : instances) {
        IClass ic= getIClass(c);
        if(null != ic) {
          ic.addInstance(instance);
        }
      }
    }
  }
View Full Code Here

        if ((null == thisInstance) && Modifier.isAbstract(cls.getModifiers())) {
          Utils.log("", 5, "[WARN] Found an abstract class with no valid instance attached: " + cls);
          continue;
        }

        IClass ic= findOrCreateIClass(cls, thisInstance, xmlTest, annotationFinder,
                                      objectFactory);
        if(null != ic) {
          Object[] theseInstances = ic.getInstances(false);
          if (theseInstances.length == 0) {
            theseInstances = ic.getInstances(true);
          }
          Object instance= theseInstances[0];
          putIClass(cls, ic);

          Method factoryMethod= ClassHelper.findFactoryMethod(cls, annotationFinder);
          if(null != factoryMethod) {
            FactoryMethod fm= new FactoryMethod( /* cls, */
              factoryMethod,
              instance,
              xmlTest,
              annotationFinder,
              m_testContext);
            List<Class> moreClasses= Lists.newArrayList();

            {
//            ppp("INVOKING FACTORY " + fm + " " + this.hashCode());
              Object[] instances= fm.invoke();

              //
              // If the factory returned IInstanceInfo, get the class from it,
              // otherwise, just call getClass() on the returned instances
              //
              if (instances.length > 0) {
                Class elementClass = instances[0].getClass();
                if(IInstanceInfo.class.isAssignableFrom(elementClass)) {
                  for(Object o : instances) {
                    IInstanceInfo ii = (IInstanceInfo) o;
                    addInstance(ii.getInstanceClass(), ii.getInstance());
                    moreClasses.add(ii.getInstanceClass());
                  }
                }
                else {
                  for(Object o : instances) {
                    addInstance(o.getClass(), o);
                    if(!classExists(o.getClass())) {
                      moreClasses.add(o.getClass());
                    }
                  }
                }
              }
            }

            if(moreClasses.size() > 0) {
              TestNGClassFinder finder=
                new TestNGClassFinder(moreClasses.toArray(
                    new Class[moreClasses.size()]),
                    m_instanceMap,
                    xmlTest,
                    annotationFinder,
                    m_testContext);

              IClass[] moreIClasses= finder.findTestClasses();
              for(IClass ic2 : moreIClasses) {
                putIClass(ic2.getRealClass(), ic2);
              }
            } // if moreClasses.size() > 0
          }
        } // null != ic
      } // if not TestNG class
      else {
        Utils.log("TestNGClassFinder", 3, "SKIPPING CLASS " + cls + " no TestNG annotations found");
      }
    } // for

    //
    // Add all the instances we found to their respective IClasses
    //
    for(Class c : m_instanceMap.keySet()) {
      List<Object> instances= m_instanceMap.get(c);
      for(Object instance : instances) {
        IClass ic= getIClass(c);
        if(null != ic) {
          ic.addInstance(instance);
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.testng.IClass

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.