@Test
public void testInjectMetadata() {

    final TestProvider provider = new TestProvider();
    final InputStream testConfig = GenericSpringResourceBuilderTest.class.getClassLoader().getResourceAsStream( "org/deegree/spring/test.xml" );
    assertNotNull( testConfig );
    @SuppressWarnings("unchecked")
    final ResourceLocation<SingleBean> location = mock( ResourceLocation.class );
    when( location.getAsStream() ).thenReturn( testConfig );
    when( location.getIdentifier() ).thenReturn( new DefaultResourceIdentifier<SingleBean>( TestProvider.class,
                                                                                            "test" ) );
    final ResourceMetadata<SingleBean> metadata = provider.createFromLocation( workspace, location );
    assertNotNull( metadata );
    final ResourceBuilder<SingleBean> builder = metadata.prepare();
    assertNotNull( builder );
    final SingleBean beanFromComtext = context.getBean( SingleBean.class );
    assertNull( beanFromComtext.getMetadata() );
    final SingleBean beanFromBuilder = builder.build();
    assertNotNull( beanFromBuilder );
    assertEquals( beanFromComtext, beanFromBuilder );
    assertEquals( metadata, beanFromBuilder.getMetadata() );
}