use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method cannotSetInheritedProperties.
@Test
public void cannotSetInheritedProperties() {
Bean bean = new Bean();
bean.defineProperty("additional", "value");
DynamicObject inherited = bean.getInheritable();
try {
inherited.setProperty("additional", "new value");
fail();
} catch (MissingPropertyException e) {
assertThat(e.getMessage(), equalTo("Could not find property 'additional' inherited from <bean>."));
}
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method otherPropertiesAreNotInherited.
@Test
public void otherPropertiesAreNotInherited() {
Bean bean = new Bean();
assertTrue(bean.hasProperty("readWriteProperty"));
DynamicObject inherited = bean.getInheritable();
assertFalse(inherited.hasProperty("readWriteProperty"));
assertFalse(inherited.getProperties().containsKey("readWriteProperty"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method otherMethodsAreNotInherited.
@Test
public void otherMethodsAreNotInherited() {
Bean bean = new Bean();
assertTrue(bean.hasMethod("javaMethod", "a", "b"));
DynamicObject inherited = bean.getInheritable();
assertFalse(inherited.hasMethod("javaMethod", "a", "b"));
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method doesNotIncludeToStringInGetPropertyErrorMessageWhenItIsNotImplemented.
@Test
public void doesNotIncludeToStringInGetPropertyErrorMessageWhenItIsNotImplemented() {
DynamicObject bean = new ExtensibleDynamicObject(new Object(), Object.class, ThreadGlobalInstantiator.getOrCreate());
try {
bean.getProperty("unknown");
fail();
} catch (MissingPropertyException e) {
assertThat(e.getMessage(), equalTo("Could not get unknown property 'unknown' for object of type java.lang.Object."));
}
}
use of org.gradle.internal.metaobject.DynamicObject in project gradle by gradle.
the class ExtensibleDynamicObjectTest method inheritedAdditionalPropertiesTrackChanges.
@Test
public void inheritedAdditionalPropertiesTrackChanges() {
Bean bean = new Bean();
DynamicObject inherited = bean.getInheritable();
assertFalse(inherited.hasProperty("additional"));
bean.defineProperty("additional", "value");
assertTrue(inherited.hasProperty("additional"));
assertThat(inherited.getProperty("additional"), equalTo((Object) "value"));
}
Aggregations