List of usage examples for com.google.gwt.validation.rebind ValidatorGenerator ValidatorGenerator
ValidatorGenerator
From source file:org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.java
License:Apache License
/** * Asserts that calling/*from w w w . j a v a 2 s .com*/ * {@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. * @throws UnableToCompleteException if The module or derived CompilationState * can not be loaded. */ public static void assertModuleFails(UnitTestTreeLogger testLogger, String fullyQaulifiedModuleName, Class<? extends Validator> validatorClass) throws UnableToCompleteException { TreeLogger logger = createFailLogger(); StandardGeneratorContext context = createGeneratorContext(fullyQaulifiedModuleName, logger); ValidatorGenerator generator = new ValidatorGenerator(); try { generator.generate(testLogger, context, validatorClass.getCanonicalName()); context.finish(logger); Assert.fail("Expected a " + UnableToCompleteException.class); } catch (UnableToCompleteException expected) { // expected } testLogger.assertCorrectLogEntries(); }
From source file:org.hibernate.jsr303.tck.util.TckGeneratorTestUtils.java
License:Apache License
/** * Asserts that calling//from w w w . 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(); }