Package org.hibernate.ogm.util.configurationreader.spi

Examples of org.hibernate.ogm.util.configurationreader.spi.ConfigurationPropertyReader


  public void shouldRetrieveIntProperty() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "foo", "123" );
    properties.put( "bar", 456 );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    int value = reader.property( "foo", int.class ).getValue();
    assertThat( value ).isEqualTo( 123 );

    value = reader.property( "bar", int.class ).getValue();
    assertThat( value ).isEqualTo( 456 );
  }
View Full Code Here


  public void shouldRetrieveBooleanProperty() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "foo", "true" );
    properties.put( "bar", true );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    boolean value = reader.property( "foo", boolean.class ).getValue();
    assertThat( value ).isEqualTo( true );

    value = reader.property( "bar", boolean.class ).getValue();
    assertThat( value ).isEqualTo( true );
  }
View Full Code Here

  public void shouldRetrieveEnumProperty() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "foo", "ANNOTATION_TYPE" );
    properties.put( "bar", ElementType.FIELD );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    ElementType value = reader.property( "foo", ElementType.class ).getValue();
    assertThat( value ).isEqualTo( ElementType.ANNOTATION_TYPE );

    value = reader.property( "bar", ElementType.class ).getValue();
    assertThat( value ).isEqualTo( ElementType.FIELD );
  }
View Full Code Here

  @Test
  public void shouldRetrieveEnumPropertyWithDefaultValue() {
    Map<String, Object> properties = new HashMap<String, Object>();

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    ElementType value = reader.property( "foo", ElementType.class )
        .withDefault( ElementType.ANNOTATION_TYPE )
        .getValue();
    assertThat( value ).isEqualTo( ElementType.ANNOTATION_TYPE );
  }
View Full Code Here

  @Test
  public void shouldRetrieveUrlPropertyGivenAsClassPathResource() throws Exception {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "configuration_resource", "configuration-test.properties" );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    URL value = reader.property( "configuration_resource", URL.class ).getValue();
    assertThat( value ).isNotNull();

    Properties loadedProperties = loadPropertiesFromUrl( value );
    assertThat( loadedProperties.get( "hibernate.ogm.configuration.testproperty" ) ).isEqualTo( "foobar" );
  }
View Full Code Here

  public void shouldRetrieveUrlPropertyGivenAsStringUrl() throws Exception {
    URL root = ConfigurationPropertyReaderTest.class.getClassLoader().getResource( "." );
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "configuration_resource", root.toExternalForm() + "/configuration-test.properties" );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    URL value = reader.property( "configuration_resource", URL.class ).getValue();
    assertThat( value ).isNotNull();

    Properties loadedProperties = loadPropertiesFromUrl( value );
    assertThat( loadedProperties.get( "hibernate.ogm.configuration.testproperty" ) ).isEqualTo( "foobar" );
  }
View Full Code Here

  public void shouldRetrieveUrlPropertyGivenAsFileSystemPath() throws Exception {
    File root = new File( ConfigurationPropertyReaderTest.class.getClassLoader().getResource( "." ).toURI() );
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "configuration_resource", root + File.separator + "configuration-test.properties" );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    URL value = reader.property( "configuration_resource", URL.class ).getValue();
    assertThat( value ).isNotNull();

    Properties loadedProperties = loadPropertiesFromUrl( value );
    assertThat( loadedProperties.get( "hibernate.ogm.configuration.testproperty" ) ).isEqualTo( "foobar" );
  }
View Full Code Here

  @Test
  public void shouldRetrieveUrlPropertyGivenAsUrl() throws Exception {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "configuration_resource", new URL( "file://foobar/" ) );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    URL value = reader.property( "configuration_resource", URL.class ).getValue();
    assertThat( value ).isEqualTo( new URL( "file://foobar/" ) );
  }
View Full Code Here

    Map<String, Object> properties = new HashMap<String, Object>();

    thrown.expect( HibernateException.class );
    thrown.expectMessage( "OGM000052" );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    reader.property( "foo", ElementType.class )
        .required()
        .getValue();
  }
View Full Code Here

    properties.put( "myPort", 98765 );

    thrown.expect( HibernateException.class );
    thrown.expectMessage( "OGM000049" );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    reader.property( "myPort", int.class )
        .withValidator( Validators.PORT )
        .getValue();
  }
View Full Code Here

TOP

Related Classes of org.hibernate.ogm.util.configurationreader.spi.ConfigurationPropertyReader

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.