@Test
public void testInstanceArchitecture() {
// Version 1.0
ServiceReference refv1 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-v1");
Assert.assertNotNull(refv1);
Architecture archv1 = (Architecture) osgi.getServiceObject(refv1);
String version = archv1.getInstanceDescription().getComponentDescription().getVersion();
Assert.assertEquals("1.0", version);
// Version 1.1
ServiceReference refv11 = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-v1.1");
Assert.assertNotNull(refv11);
Architecture archv11 = (Architecture) osgi.getServiceObject(refv11);
String version11 = archv11.getInstanceDescription().getComponentDescription().getVersion();
Assert.assertEquals("1.1", version11);
// No Version
ServiceReference refany = ipojo.getServiceReferenceByName(Architecture.class.getName(), "instance-any");
Assert.assertNotNull(refany);
Architecture archany = (Architecture) osgi.getServiceObject(refany);
String any = archany.getInstanceDescription().getComponentDescription().getVersion();
Assert.assertNotNull(any);
// No version set in the factory, so no version.
ServiceReference refmci = ipojo.getServiceReferenceByName(Architecture.class.getName(), "MyComponentInstance");
Assert.assertNotNull(refmci);
Architecture archmcy = (Architecture) osgi.getServiceObject(refmci);
String mci = archmcy.getInstanceDescription().getComponentDescription().getVersion();
Assert.assertNull(mci);
}