use of com.alipay.sofa.boot.annotation.PlaceHolderBinder in project sofa-boot by sofastack.
the class PlaceHolderAnnotationTest method testAnnotationPlaceHolder.
@Test
public void testAnnotationPlaceHolder() {
PlaceHolderBinder placeHolderBinder = new PlaceHolderBinder() {
@Override
public String bind(String key) {
if ("${key}".equals(key)) {
return "value";
} else if ("${subKey}".equals(key)) {
return "subValue";
} else {
return "invalid";
}
}
};
SampleAnnotation origin = SampleClass.class.getAnnotation(SampleAnnotation.class);
SampleAnnotation delegate = (SampleAnnotation) PlaceHolderAnnotationInvocationHandler.AnnotationWrapperBuilder.wrap(origin).withBinder(placeHolderBinder).build();
Assert.assertEquals("value", delegate.id());
Assert.assertEquals("subValue", delegate.bindings()[0].id());
Assert.assertEquals("invalid", delegate.bindings()[1].id());
}
Aggregations