Package atunit.core

Examples of atunit.core.Container


        try {
            Class<?> c = context.introspector().testClass();
            Set<Field> testFields = getFields(c);

            Container container = getContainerFor(c);
            MockFramework mockFramework = getMockFrameworkFor(c);

            // make sure we have one (and only one) @Unit field
            Field unitField = getUnitField(testFields);
            if (unitField.getAnnotation(Mock.class) != null) {
                throw new IncompatibleAnnotationException(Unit.class, Mock.class);
            }

            final Map<Field, Object> fieldValues = mockFramework.getValues(testFields.toArray(new Field[testFields.size()]));
            if (fieldValues.containsKey(unitField)) {
                throw new IncompatibleAnnotationException(Unit.class, unitField.getType());
            }

            container.createTest(c, fieldValues);

            for (Field field : fieldValues.keySet()) {
                field.setAccessible(true);
                if (field.get(context.introspector().instance()) == null) {
                    field.set(context.introspector().instance(), fieldValues.get(field));
View Full Code Here


  @Override
  protected Object createTest() throws Exception {
    Class<?> c = getTestClass().getJavaClass();
    Set<Field> testFields = getFields(c);
   
    Container container = getContainerFor(c);
    MockFramework mockFramework = getMockFrameworkFor(c);
       
    // make sure we have one (and only one) @Unit field
    Field unitField = getUnitField(testFields);
    if ( unitField.getAnnotation(Mock.class) != null ) {
      throw new IncompatibleAnnotationException(Unit.class, Mock.class);
    }
   
    final Map<Field,Object> fieldValues = mockFramework.getValues(testFields.toArray(new Field[0]));
    if ( fieldValues.containsKey(unitField)) {
      throw new IncompatibleAnnotationException(Unit.class, unitField.getType());
    }
   
    Object test = container.createTest(c, fieldValues);

    // any field values created by AtUnit but not injected by the container are injected here.
    for ( Field field : fieldValues.keySet() ) {
      field.setAccessible(true);
      if ( field.get(test) == null ) {
View Full Code Here

TOP

Related Classes of atunit.core.Container

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.