Implementation s1Impl = waitForImplByName(null,
"fr.imag.adele.apam.pax.test.impl.S1Impl");
Instance s1Inst = s1Impl.createInstance(null, null);
S1Impl s1 = (S1Impl) s1Inst.getServiceObject();
String messageTemplace = "for a property type injected='external', the %s";
Assert.assertTrue(String.format(messageTemplace,
"initial value declared in the xml should NOT be ignored"), s1
.getStateNotInternal().equals("default"));
s1Inst.setProperty("stateNotInternal", "changedByApamAPI");
Assert.assertTrue(
String.format(
messageTemplace,
"value should be changeable by ApamInstance.setProperty, which is not true when checking the java instance property value"),
(s1.getStateNotInternal() == null ? "" : s1
.getStateNotInternal()).equals("changedByApamAPI"));
Assert.assertTrue(
String.format(
messageTemplace,
"value should be changeable by ApamInstance.setProperty, which is not true when checking ApamInstance.getProperty"),
s1Inst.getProperty("stateNotInternal").equals(
"changedByApamAPI"));
Assert.assertTrue(
String.format(
messageTemplace,
"value should be changeable by ApamInstance.setProperty, which is not true when checking ApamInstance.getAllProperties"),
s1Inst.getAllProperties().get("stateNotInternal")
.equals("changedByApamAPI"));
s1.setStateNotInternal("changedByJavaInstance");
// All the following situation should remains unchanged since the field
// is an external (check the spec:
// https://docs.google.com/document/d/1JNffl2oNeS26HFbJ2OT-KnpvZnEYm5sja2XprsYG3Mo/edit#)
Assert.assertNotNull(s1.getStateNotInternal());
Assert.assertTrue(
String.format(
messageTemplace,
"value should be changeable by java instance, although the value remains un altered when checking the java instance value"),
s1.getStateNotInternal().equals("changedByApamAPI"));
Assert.assertTrue(
String.format(
messageTemplace,
"value should be changeable by java instance, although the value remains un altered when checking ApamInstance.getProperty"),