@MediumTest public void testParcelable() throws Exception { ServiceResourceIdentifier sri = new ServiceResourceIdentifier(); sri.setIdentifier(new URI("http://alec.societies.org")); sri.setServiceInstanceIdentifier("alecBundle123"); ServiceImplementation serviceImp = new ServiceImplementation(); serviceImp.setServiceClient("TestClient"); serviceImp.setServiceNameSpace("http://soceities.org/test/namespace"); serviceImp.setServiceProvider("TestProvider"); serviceImp.setServiceVersion("V0.1.1b"); ServiceInstance serInstance = new ServiceInstance(); serInstance.setCssJid("john.societies.local"); serInstance.setFullJid("[email protected]/android"); serInstance.setParentJid("parent.societies.local"); serInstance.setXMPPNode("john.societies.local"); serInstance.setParentIdentifier(sri); serInstance.setServiceImpl(serviceImp); assertEquals(0, serviceImp.describeContents()); Parcel parcel = Parcel.obtain(); serInstance.writeToParcel(parcel, 0); // done writing, now reset parcel for reading parcel.setDataPosition(0); // finish round trip ServiceInstance createFromParcel = ServiceInstance.CREATOR.createFromParcel(parcel); assertEquals(serInstance.getCssJid(), createFromParcel.getCssJid()); assertEquals(serInstance.getFullJid(), createFromParcel.getFullJid()); assertEquals(serInstance.getParentJid(), createFromParcel.getParentJid()); assertEquals(serInstance.getXMPPNode(), createFromParcel.getXMPPNode()); // CAN'T COMPARE SRI'S DIRECTLY, MUST COMPARE EACH PROPERTY assertEquals( serInstance.getParentIdentifier().getServiceInstanceIdentifier(), createFromParcel.getParentIdentifier().getServiceInstanceIdentifier()); assertEquals( serInstance.getParentIdentifier().getIdentifier(), createFromParcel.getParentIdentifier().getIdentifier()); // CAN'T COMPARE ServiceImpl'S DIRECTLY, MUST COMPARE EACH PROPERTY assertEquals( serInstance.getServiceImpl().getServiceClient(), createFromParcel.getServiceImpl().getServiceClient()); assertEquals( serInstance.getServiceImpl().getServiceNameSpace(), createFromParcel.getServiceImpl().getServiceNameSpace()); assertEquals( serInstance.getServiceImpl().getServiceProvider(), createFromParcel.getServiceImpl().getServiceProvider()); assertEquals( serInstance.getServiceImpl().getServiceVersion(), createFromParcel.getServiceImpl().getServiceVersion()); }
private RequestorService getRequestorService() throws InvalidFormatException { IIdentity requestorId = TestCase1244.commManager.getIdManager().fromJid("*****@*****.**"); ServiceResourceIdentifier serviceId = new ServiceResourceIdentifier(); serviceId.setServiceInstanceIdentifier("css://[email protected]/HelloEarth"); try { serviceId.setIdentifier(new URI("css://[email protected]/HelloEarth")); } catch (URISyntaxException e) { LOG.error("Can't create the service ID", e); } return new RequestorService(requestorId, serviceId); }
public void createContextHistoryAttributesSet() { // create actions // IIdentity identity = new MockIdentity(IdentityType.CSS, "user", "societies.org"); ServiceResourceIdentifier serviceId1 = new ServiceResourceIdentifier(); ServiceResourceIdentifier serviceId2 = new ServiceResourceIdentifier(); try { serviceId1.setIdentifier(new URI("http://testService1")); serviceId2.setIdentifier(new URI("http://testService2")); serviceId1.setServiceInstanceIdentifier("http://testService1"); serviceId2.setServiceInstanceIdentifier("http://testService2"); } catch (URISyntaxException e) { e.printStackTrace(); } // create actions IAction action1 = new Action(serviceId1, "testService", "volume", "high"); IAction action2 = new Action(serviceId2, "testService", "volume", "low"); IAction action3 = new Action(serviceId1, "testService", "volume", "mute"); IAction actionX = new Action(serviceId1, "testService", "XXXX", "XXXX"); IAction action4 = new Action(serviceId2, "testService", "colour", "blue"); IAction action5 = new Action(serviceId2, "testService", "colour", "green"); IAction actionY = new Action(serviceId1, "testService", "YYYY", "YYYY"); // System.out.println ("action service ID // "+actionY.getServiceID().getServiceInstanceIdentifier()); for (int i = 0; i < 4; i++) { monitorAction(action1, "country", "free", 10); monitorAction(action2, "office", "busy", 15); monitorAction(action3, "park", "away", 25); monitorAction(actionX, "park", "away", 25); monitorAction(actionY, "park", "away", 25); monitorAction(action4, "park", "away", 25); monitorAction(action5, "park", "away", 25); monitorAction(actionY, "park", "away", 25); monitorAction(actionX, "park", "away", 25); } }
private RequestorService getRequestorService() { IIdentity requestorId = new MyIdentity(IdentityType.CSS, "eliza", "societies.org"); ServiceResourceIdentifier serviceId = new ServiceResourceIdentifier(); serviceId.setServiceInstanceIdentifier("css://[email protected]/HelloEarth"); try { serviceId.setIdentifier(new URI("css://[email protected]/HelloEarth")); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new RequestorService(requestorId, serviceId); }