Examples of BootstrapConfiguration


Examples of javax.validation.BootstrapConfiguration

  }

  @Test
  @SpecAssertion(section = "5.5.3", id = "f")
  public void testGetBootstrapConfiguration() {
    BootstrapConfiguration bootstrapConfiguration = TestUtil.getConfigurationUnderTest()
        .getBootstrapConfiguration();

    assertNotNull( bootstrapConfiguration );

    assertNotNull( bootstrapConfiguration.getConstraintMappingResourcePaths() );
    assertEquals(
        bootstrapConfiguration.getConstraintMappingResourcePaths(),
        asSet( "mapping1", "mapping2" )
    );

    assertEquals(
        bootstrapConfiguration.getConstraintValidatorFactoryClassName(),
        "com.acme.ConstraintValidatorFactory"
    );
    assertEquals(
        bootstrapConfiguration.getDefaultProviderClassName(),
        "com.acme.ValidationProvider"
    );
    assertEquals(
        bootstrapConfiguration.getMessageInterpolatorClassName(),
        "com.acme.MessageInterpolator"
    );
    assertEquals(
        bootstrapConfiguration.getParameterNameProviderClassName(),
        "com.acme.ParameterNameProvider"
    );

    assertNotNull( bootstrapConfiguration.getProperties() );
    assertEquals( bootstrapConfiguration.getProperties().size(), 2 );
    assertEquals( bootstrapConfiguration.getProperties().get( "com.acme.Foo" ), "Bar" );
    assertEquals( bootstrapConfiguration.getProperties().get( "com.acme.Baz" ), "Qux" );

    assertEquals(
        bootstrapConfiguration.getTraversableResolverClassName(),
        "com.acme.TraversableResolver"
    );

    assertNotNull( bootstrapConfiguration.getDefaultValidatedExecutableTypes() );
    assertEquals(
        bootstrapConfiguration.getDefaultValidatedExecutableTypes(),
        EnumSet.of( ExecutableType.CONSTRUCTORS, ExecutableType.NON_GETTER_METHODS )
    );
  }
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  @SpecAssertions({
      @SpecAssertion(section = "5.5.3", id = "f"),
      @SpecAssertion(section = "5.5.6", id = "l")
  })
  public void testGetDefaultValidatedExecutableTypesReturnsSetWithAllOptionsIfALLAndNONEAreContained() {
    BootstrapConfiguration bootstrapConfiguration = TestUtil.getConfigurationUnderTest()
        .getBootstrapConfiguration();

    assertNotNull( bootstrapConfiguration );
    assertEquals(
        bootstrapConfiguration.getDefaultValidatedExecutableTypes(),
        EnumSet.of(
            ExecutableType.CONSTRUCTORS,
            ExecutableType.GETTER_METHODS,
            ExecutableType.NON_GETTER_METHODS
        )
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  }

  @Test(expectedExceptions = ValidationException.class)
  @SpecAssertion(section = "5.5.3", id = "f")
  public void testEmptyExecutableTypesCauseValidationException() {
    BootstrapConfiguration bootstrapConfiguration = TestUtil.getConfigurationUnderTest()
        .getBootstrapConfiguration();

    bootstrapConfiguration.getDefaultValidatedExecutableTypes();
  }
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  }

  @Test
  @SpecAssertion(section = "5.5.3", id = "f")
  public void testGetBootstrapConfigurationNoValidationXml() {
    BootstrapConfiguration bootstrapConfiguration = TestUtil.getConfigurationUnderTest()
        .getBootstrapConfiguration();

    assertNotNull( bootstrapConfiguration );

    assertNotNull( bootstrapConfiguration.getConstraintMappingResourcePaths() );
    assertTrue( bootstrapConfiguration.getConstraintMappingResourcePaths().isEmpty() );

    assertNull( bootstrapConfiguration.getConstraintValidatorFactoryClassName() );
    assertNull( bootstrapConfiguration.getDefaultProviderClassName() );
    assertNull( bootstrapConfiguration.getMessageInterpolatorClassName() );
    assertNull( bootstrapConfiguration.getParameterNameProviderClassName() );

    assertNotNull( bootstrapConfiguration.getDefaultValidatedExecutableTypes() );
    assertEquals(
        bootstrapConfiguration.getDefaultValidatedExecutableTypes(),
        EnumSet.of( ExecutableType.CONSTRUCTORS, ExecutableType.NON_GETTER_METHODS )
    );

    assertNotNull( bootstrapConfiguration.getProperties() );
    assertTrue( bootstrapConfiguration.getProperties().isEmpty() );

    assertNull( bootstrapConfiguration.getTraversableResolverClassName() );
  }
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  @SpecAssertions({
      @SpecAssertion(section = "5.5.3", id = "f"),
      @SpecAssertion(section = "5.5.6", id = "l")
  })
  public void testGetDefaultValidatedExecutableTypesReturnsSetWithAllOptionsIfALLIsContained() {
    BootstrapConfiguration bootstrapConfiguration = TestUtil.getConfigurationUnderTest()
        .getBootstrapConfiguration();

    assertNotNull( bootstrapConfiguration );
    assertEquals(
        bootstrapConfiguration.getDefaultValidatedExecutableTypes(),
        EnumSet.of(
            ExecutableType.CONSTRUCTORS,
            ExecutableType.GETTER_METHODS,
            ExecutableType.NON_GETTER_METHODS
        )
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  @SpecAssertions({
      @SpecAssertion(section = "5.5.3", id = "f"),
      @SpecAssertion(section = "5.5.6", id = "l")
  })
  public void testGetDefaultValidatedExecutableTypesReturnsEmptySetIfNONEIsContained() {
    BootstrapConfiguration bootstrapConfiguration = TestUtil.getConfigurationUnderTest()
        .getBootstrapConfiguration();

    assertNotNull( bootstrapConfiguration );

    assertEquals( bootstrapConfiguration.getDefaultValidatedExecutableTypes(), EnumSet.noneOf( ExecutableType.class ) );
  }
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  @SpecAssertions({
      @SpecAssertion(section = "5.5.3", id = "f"),
      @SpecAssertion(section = "5.5.6", id = "l")
  })
  public void testGetDefaultValidatedExecutableTypesReturnsSetWithConfiguredValues() {
    BootstrapConfiguration bootstrapConfiguration = TestUtil.getConfigurationUnderTest()
        .getBootstrapConfiguration();

    assertNotNull( bootstrapConfiguration );
    assertEquals(
        bootstrapConfiguration.getDefaultValidatedExecutableTypes(),
        EnumSet.of( ExecutableType.CONSTRUCTORS, ExecutableType.NON_GETTER_METHODS )
    );
  }
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  public ValidationExtension() {
    validatorRegisteredUnderDefaultQualifier = false;
    validatorRegisteredUnderHibernateQualifier = false;

    Configuration<?> config = Validation.byDefaultProvider().configure();
    BootstrapConfiguration bootstrap = config.getBootstrapConfiguration();
    globalExecutableTypes = bootstrap.getDefaultValidatedExecutableTypes();
    isExecutableValidationEnabled = bootstrap.isExecutableValidationEnabled();
    validator = config.buildValidatorFactory().getValidator();
  }
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

    private boolean isExecutableValidationEnabled;

    public BValExtension() { // read the config, could be done in a quicker way but this let us get defaults without duplicating code
        config = Validation.byDefaultProvider().configure();
        try {
            final BootstrapConfiguration bootstrap = config.getBootstrapConfiguration();
            globalExecutableTypes = convertToRuntimeTypes(bootstrap.getDefaultValidatedExecutableTypes());
            isExecutableValidationEnabled = bootstrap.isExecutableValidationEnabled();

            validBean = globalExecutableTypes.contains(ExecutableType.IMPLICIT) || globalExecutableTypes.contains(ExecutableType.ALL);
            validConstructors =validBean || globalExecutableTypes.contains(ExecutableType.CONSTRUCTORS);
            validBusinessMethods = validBean || globalExecutableTypes.contains(ExecutableType.NON_GETTER_METHODS);
            validGetterMethods = globalExecutableTypes.contains(ExecutableType.ALL) || globalExecutableTypes.contains(ExecutableType.GETTER_METHODS);
View Full Code Here

Examples of javax.validation.BootstrapConfiguration

  private Bean<?> defaultValidatorBean;
  private Bean<?> hibernateValidatorBean;

  public ValidationExtension() {
    Configuration<?> config = Validation.byDefaultProvider().configure();
    BootstrapConfiguration bootstrap = config.getBootstrapConfiguration();
    globalExecutableTypes = bootstrap.getDefaultValidatedExecutableTypes();
    isExecutableValidationEnabled = bootstrap.isExecutableValidationEnabled();
    validatorFactory = config.buildValidatorFactory();
    validator = validatorFactory.getValidator();

    executableHelper = new ExecutableHelper( new TypeResolutionHelper() );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.