Package fr.imag.adele.apam.pax.test.implS1

Examples of fr.imag.adele.apam.pax.test.implS1.ServiceDependencySource_tct018


    "fr.imag.adele.apam.pax.test.impl.S1Impl");

  Instance s1Instance = s1Impl.createInstance(null,
    new HashMap<String, String>());

  S1Impl s1 = (S1Impl) s1Instance.getServiceObject();

  Assert.assertTrue(
    "The init method declared in <callback> tag should have been called during the bundle start",
    s1.getIsOnInitCallbackCalled());

    }
View Full Code Here


    "fr.imag.adele.apam.pax.test.impl.S1Impl");

  Instance s1Instance = s1Impl.createInstance(null,
    new HashMap<String, String>());

  S1Impl s1 = (S1Impl) s1Instance.getServiceObject();

  Assert.assertFalse(
    "The remove method declared in <callback> tag should NOT have been called during the bundle start",
    s1.getIsOnRemoveCallbackCalled());

  Bundle bc = s1.getContext().getBundle();
  bc.stop();

  Assert.assertTrue(
    "The remove method declared in <callback> tag should have been called during the bundle stop",
    s1.getIsOnRemoveCallbackCalled());

  bc.start();

    }
View Full Code Here

  Instance s1Inst = s1Impl.createInstance(null, null);

  apam.waitForIt(Constants.CONST_WAIT_TIME);

  S1Impl s1 = (S1Impl) s1Inst.getServiceObject();

  Eletronic samsungSwitch = (Eletronic) samsungInst.getServiceObject();
  Eletronic lgSwitch = (Eletronic) lgInst.getServiceObject();
  Eletronic siemensSwitch = (Eletronic) siemensInst.getServiceObject();

  System.out.println("Instances after injection request");
  auxListInstances("\t");

  Instance injectedInstance = CST.componentBroker.getInstService(s1
    .getDeviceConstraint110v());

  Assert.assertTrue(
    String.format(
      "The instance injected should obey the contraints (currentVoltage=500) given in the xml, this does not happens when there is a <preference> tag with nothing declared inside. The instance %s (currentVoltage:%s) was injected instead of %s (currentVoltage:%s)",
      injectedInstance.getName(), injectedInstance
        .getAllProperties().get("currentVoltage"),
      samsungInst.getName(), samsungInst.getAllProperties()
        .get("currentVoltage")), s1
      .getDeviceConstraint110v() == samsungSwitch);

    }
View Full Code Here

  Instance s1Inst = s1Impl.createInstance(null, null);

  apam.waitForIt(Constants.CONST_WAIT_TIME);

  S1Impl s1 = (S1Impl) s1Inst.getServiceObject();

  Eletronic[] eletronicInstancesInArray = s1
    .getEletronicInstancesInArray();
  int initialSize = 0;

  if (eletronicInstancesInArray != null) {
      initialSize = eletronicInstancesInArray.length;
  }

  for (Link wire : s1Inst.getRawLinks()) {
      wire.remove();
  }

  Implementation sansungImpl = waitForImplByName(null, "SamsungSwitch");

  Instance sansungInst = sansungImpl.createInstance(null, null);

  apam.waitForIt(Constants.CONST_WAIT_TIME);

  GenericSwitch samsungSwitch = (GenericSwitch) sansungInst
    .getServiceObject();

  int finalSize = s1.getEletronicInstancesInArray().length;

  String messageTemplate = "We use as dependency a multiple field(Set type) to receive all instances available of the type %s, after create a new instance this Set should receive the new instance";

  String message = String.format(messageTemplate,
    Eletronic.class.getCanonicalName());
View Full Code Here

  Instance s1Inst = s1Impl.createInstance(null, null);

  apam.waitForIt(Constants.CONST_WAIT_TIME);

  S1Impl s1 = (S1Impl) s1Inst.getServiceObject();

  int initialSize = s1.getEletronicInstancesInSet().size();

  auxDisconectWires(s1Inst);

  Instance sansungInst = sansungImpl.createInstance(null, null);

  apam.waitForIt(Constants.CONST_WAIT_TIME);

  GenericSwitch samsungSwitch = (GenericSwitch) sansungInst
    .getServiceObject();

  int finalSize = s1.getEletronicInstancesInSet().size();

  auxListInstances("instances---");

  // Make sure that one instance was added
  String messageTemplate = "We use as dependency a multiple field(Set type) to receive all instances available of the type %s, after create a new instance this Set should receive the new instance";
View Full Code Here

  Instance s1Inst = s1Impl.createInstance(null, null);

  // apam.waitForIt(Constants.CONST_WAIT_TIME);

  S1Impl s1 = (S1Impl) s1Inst.getServiceObject();

  Eletronic samsungSwitch = (Eletronic) samsungInst.getServiceObject();
  Eletronic philipsSwitch = (Eletronic) philipsInst.getServiceObject();
  Eletronic lgSwitch = (Eletronic) lgInst.getServiceObject();
  Eletronic siemensSwitch = (Eletronic) siemensInst.getServiceObject();

  System.out.println("Instances after injection request");
  auxListInstances("\t");

  Instance injectedInstance = CST.componentBroker.getInstService(s1
    .getDevicePreference110v());

  System.out.println("Injected:" + injectedInstance);

  Assert.assertTrue(
    String.format(
      "The instance injected should be the prefered one (currentVoltage=500), since there exist an instance in which the preference is valid. The instance %s (currentVoltage:%s) was injected instead of %s (currentVoltage:%s)",
      injectedInstance.getName(), injectedInstance
        .getAllProperties().get("currentVoltage"),
      samsungInst.getName(), samsungInst.getAllProperties()
        .get("currentVoltage")),
    s1.getDevicePreference110v() == samsungSwitch
      || s1.getDevicePreference110v() == philipsSwitch);

    }
View Full Code Here

  Instance s1Inst = s1Impl.createInstance(null, null);

  apam.waitForIt(Constants.CONST_WAIT_TIME);

  S1Impl s1 = (S1Impl) s1Inst.getServiceObject();

  Eletronic samsungSwitch = (Eletronic) samsungInst.getServiceObject();
  Eletronic samsungSwitch2 = (Eletronic) samsungInst2.getServiceObject();
  Eletronic lgSwitch = (Eletronic) lgInst.getServiceObject();
  Eletronic siemensSwitch = (Eletronic) siemensInst.getServiceObject();

  System.out.println("Instances after injection request");
  auxListInstances("\t");

  Instance injectedInstance = CST.componentBroker.getInstService(s1
    .getDevicePreference110v());
  Assert.assertTrue(
    String.format(
      "The instance injected should be the prefered one (currentVoltage=500), \nsince there exist an instance in which the preference is valid. \nThe instance %s (currentVoltage:%s) was injected \ninstead of %s (currentVoltage:%s)",
      injectedInstance.getName(), injectedInstance
        .getAllProperties().get("currentVoltage"),
      samsungInst.getName(), samsungInst.getAllProperties()
        .get("currentVoltage")),
    s1.getDevicePreference110v() == samsungSwitch
      || s1.getDevicePreference110v() == samsungSwitch2);

    }
View Full Code Here

  Instance s1Inst = s1Impl.createInstance(null, null);

  // apam.waitForIt(Constants.CONST_WAIT_TIME);

  S1Impl s1 = (S1Impl) s1Inst.getServiceObject();

  Eletronic lgSwitch = (Eletronic) lgInst.getServiceObject();

  System.out
    .println("Instances after FIRST injection request (preference cannot be resolved)");
  auxListInstances("\t");

  Instance injectedInstance = CST.componentBroker.getInstService(s1
    .getDevicePreference110v());

  System.out.println("Injected:" + injectedInstance);

  Assert.assertTrue(
    String.format(
      "The instance injected cannot be the prefered one (currentVoltage=500), since there exist no instance in which the preference is valid."
        + " The instance %s (currentVoltage:%s) was injected instead of %s (currentVoltage:%s)",
      injectedInstance.getName(), injectedInstance
        .getAllProperties().get("currentVoltage"),
      lgInst.getName(),
      lgInst.getAllProperties().get("currentVoltage")), s1
      .getDevicePreference110v() == lgSwitch);

  Implementation samsungImpl = waitForImplByName(null, "SamsungSwitch");
  final Instance samsungInst = samsungImpl.createInstance(null,
    new HashMap<String, String>() {
        {
      put("currentVoltage", "500");
        }
    });
  Eletronic samsungSwitch = (Eletronic) samsungInst.getServiceObject();
  Instance injectedInstance2 = CST.componentBroker.getInstService(s1
    .getDevicePreference110v());

  System.out.println("Injected (new resolution) :" + injectedInstance);
  Assert.assertTrue(
    String.format(
      "The instance injected should be the prefered one (currentVoltage=500), since there exist an instance in which the preference is valid. The instance %s (currentVoltage:%s) was injected instead of %s (currentVoltage:%s)",
      injectedInstance.getName(), injectedInstance
        .getAllProperties().get("currentVoltage"),
      samsungInst.getName(), samsungInst.getAllProperties()
        .get("currentVoltage")), s1
      .getDevicePreference110v() == samsungSwitch);

    }
View Full Code Here

    "S1Impl-removed-callback-with-constraint");

  Instance instance = impl.createInstance(null,
    new HashMap<String, String>());

  S1Impl s1 = (S1Impl) instance.getServiceObject();

  S2 first = s1.getS2();

  // The line s1.getS2() creates the link and sets the
  // UnbindReceivedInstanceParameter to true, so we roll it back to false

  s1.setIsBindUnbindReceivedInstanceParameter(false);

  // after change the variable we expect apam to call the remove method

  instance.getLinkDest("s2").setProperty("defined-property", "invalid");

  S2 second = s1.getS2();

  Assert.assertTrue(messageTemplate,
    s1.getIsBindUnbindReceivedInstanceParameter() == true);

  Assert.assertNotSame("Must be a new instance", first, second);

    }
View Full Code Here

    "S1Impl-removed-callback-with-no-constraint");

  Instance instance = impl.createInstance(null,
    new HashMap<String, String>());

  S1Impl s1 = (S1Impl) instance.getServiceObject();

  s1.getS2();

  // The line s1.getS2() creates the link and sets the
  // UnbindReceivedInstanceParameter to true, so we roll it back to false

  s1.setIsBindUnbindReceivedInstanceParameter(false);

  // after change the variable we expect apam NOT to call the remove
  // method

  instance.getLinkDest("s2").setProperty("defined-property", "ups");

  Assert.assertTrue(messageTemplate,
    s1.getIsBindUnbindReceivedInstanceParameter() == false);

    }
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.pax.test.implS1.ServiceDependencySource_tct018

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.