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

Examples of org.hibernate.ogm.util.configurationreader.spi.ConfigurationPropertyReader.property()


  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

  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

    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();
  }

  @Test
View Full Code Here

    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();
  }

  @Test
View Full Code Here

    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();
  }

  @Test
View Full Code Here

    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" );
  }

  @Test
  public void shouldRetrieveIntProperty() {
View Full Code Here

    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

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.