Example usage for com.google.gwt.validation.rebind GwtSpecificValidatorGenerator GwtSpecificValidatorGenerator

List of usage examples for com.google.gwt.validation.rebind GwtSpecificValidatorGenerator GwtSpecificValidatorGenerator

Introduction

In this page you can find the example usage for com.google.gwt.validation.rebind GwtSpecificValidatorGenerator GwtSpecificValidatorGenerator.

Prototype

GwtSpecificValidatorGenerator

Source Link

Usage

From source file:org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.java

License:Apache License

/**
 * Asserts that calling/*from w ww. j  a va 2  s .  c  o  m*/
 * {@link ValidatorGenerator#generate(TreeLogger, com.google.gwt.core.ext.GeneratorContext, String)}
 * causes a {@link UnableToCompleteException} with exactly the log messages
 * specified in {@code testLogger}.
 * 
 * @param testLogger test logger with expected log messages set.
 * @param fullyQaulifiedModuleName the gwt Module to load.
 * @param validatorClass the Validator to generate.
 * @param beanType the type of bean to create a validator for.
 * @throws UnableToCompleteException if The module or derived CompilationState
 *           can not be loaded.
 */
public static void assertModuleFails(UnitTestTreeLogger testLogger, String fullyQaulifiedModuleName,
        Class<? extends Validator> validatorClass, Class<?> beanType) throws UnableToCompleteException {
    TreeLogger logger = createFailLogger();
    StandardGeneratorContext context = createGeneratorContext(fullyQaulifiedModuleName, logger);

    ValidatorGenerator generator = new ValidatorGenerator();
    GwtSpecificValidatorGenerator specificGenerator = new GwtSpecificValidatorGenerator();
    generator.generate(testLogger, context, validatorClass.getCanonicalName());
    context.finish(logger);
    try {
        specificGenerator.generate(testLogger, context,
                BeanHelper.createBeanHelper(beanType, testLogger, context).getFullyQualifiedValidatorName());
        Assert.fail("Expected a " + UnableToCompleteException.class);
    } catch (UnableToCompleteException expected) {
        // expected
    }
    testLogger.assertCorrectLogEntries();
}