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

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


  @Test
  public void shouldRetrievePropertyWithClassValue() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "service", MyServiceImpl.class );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );
    MyService value = reader.property( "service", MyService.class )
        .instantiate()
        .getValue();

    assertThat( value.getClass() ).isEqualTo( MyServiceImpl.class );
  }
View Full Code Here


  @Test
  public void shouldRetrievePropertyWithStringValue() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "service", MyServiceImpl.class.getName() );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );
    MyService value = reader.property( "service", MyService.class )
        .instantiate()
        .getValue();

    assertThat( value.getClass() ).isEqualTo( MyServiceImpl.class );
  }
View Full Code Here

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

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );
    MyService value = reader.property( "service", MyService.class )
        .instantiate()
        .withDefaultImplementation( MyOtherServiceImpl.class )
        .getValue();

    assertThat( value.getClass() ).isEqualTo( MyOtherServiceImpl.class );
View Full Code Here

  @Test
  public void shouldRetrievePropertyWithShortName() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "service", "other" );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );
    MyService value = reader.property( "service", MyService.class )
        .instantiate()
        .withShortNameResolver( new MyShortNameResolver() )
        .getValue();

    assertThat( value.getClass() ).isEqualTo( MyOtherServiceImpl.class );
View Full Code Here

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

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );
    MyService value = reader.property( "service", MyService.class )
        .instantiate()
        .withDefaultImplementation( MyServiceImpl.class.getName() )
        .getValue();

    assertThat( value.getClass() ).isEqualTo( MyServiceImpl.class );
View Full Code Here

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

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );
    MyService value = ( (DefaultClassPropertyReaderContext<MyService>) reader.property( "service", MyService.class )
        .instantiate() )
        .withDefaultImplementation( MyYetAnotherServiceImpl.class )
        .withInstantiator( new MyInstantiator() )
        .getValue();
View Full Code Here

    thrown.expectMessage( "OGM000046" );

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "service", 42 );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );

    reader.property( "service", MyService.class )
        .instantiate()
        .getValue();
  }
View Full Code Here

    thrown.expectMessage( "OGM000045" );

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "service", Integer.class );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );

    reader.property( "service", MyService.class )
        .instantiate()
        .getValue();
  }
View Full Code Here

    thrown.expectMessage( "OGM000045" );

    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put( "service", Integer.class.getName() );

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties, new ClassLoaderServiceImpl() );

    reader.property( "service", MyService.class )
        .instantiate()
        .getValue();
  }
View Full Code Here

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

    ConfigurationPropertyReader reader = new ConfigurationPropertyReader( properties );

    String value = reader.property( "foo", String.class ).getValue();
    assertThat( value ).isEqualTo( "bar" );
  }
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.