@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);
 }
 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);
 }
 /* (non-Javadoc)
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null) {
     return false;
   }
   if (!(obj instanceof Action)) {
     return false;
   }
   Action other = (Action) obj;
   if (parameterName == null) {
     if (other.parameterName != null) {
       return false;
     }
   } else if (!parameterName.equals(other.parameterName)) {
     return false;
   }
   if (serviceID == null) {
     if (other.serviceID != null) {
       return false;
     }
   } else if (!serviceID.getIdentifier().equals(other.serviceID.getIdentifier())) {
     return false;
   }
   if (value == null) {
     if (other.value != null) {
       return false;
     }
   } else if (!value.equals(other.value)) {
     return false;
   }
   return true;
 }
 /* (non-Javadoc)
  * @see java.lang.Object#hashCode()
  */
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((parameterName == null) ? 0 : parameterName.hashCode());
   result = prime * result + ((serviceID == null) ? 0 : serviceID.hashCode());
   result = prime * result + ((value == null) ? 0 : value.hashCode());
   return result;
 }
 private boolean equalsServiceIdentifier(ServiceResourceIdentifier other) {
   if (null == this.requestorServiceId.getIdentifier()) {
     if (other.getIdentifier() != null) {
       return false;
     }
   } else if (!this.requestorServiceId.getIdentifier().equals(other.getIdentifier())) {
     return false;
   }
   if (this.requestorServiceId.getServiceInstanceIdentifier() == null) {
     if (other.getServiceInstanceIdentifier() != null) {
       return false;
     }
   } else if (!this.requestorServiceId
       .getServiceInstanceIdentifier()
       .equals(other.getServiceInstanceIdentifier())) {
     return false;
   }
   return true;
 }
 public void deletePreference(
     IIdentity dpi,
     String serviceType,
     ServiceResourceIdentifier serviceID,
     String preferenceName) {
   PreferenceDetails details = new PreferenceDetails(serviceType, serviceID, preferenceName);
   CtxIdentifier id = this.registry.getCtxID(details);
   if (id == null) {
     // preference doesn't exist. can't delete it
     logging.debug(
         "Preference "
             + preferenceName
             + " of "
             + serviceType
             + ":"
             + serviceID.toString()
             + "doesn't exist. Aborting deletion");
   } else {
     PreferenceStorer storer = new PreferenceStorer(this.broker);
     storer.deletePreference(dpi, id);
     this.registry.deletePreference(details);
     storer.storeRegistry(dpi, registry);
   }
 }
  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);
    }
  }