Package fr.imag.adele.apam

Examples of fr.imag.adele.apam.Instance


    @Test
    public void SubstitutionReachingMultipleNodesWithInstsKeyword_tc123() {

  Implementation implementationCase12Child = waitForImplByName(null,
    "impl-case-12-child");
  Instance instanceAlpha = implementationCase12Child.createInstance(null,
    new HashMap<String, String>() {
        {
      put("property-subject-b", "alpha(child)");
        }
    });
  Instance instanceBravo = implementationCase12Child.createInstance(null,
    new HashMap<String, String>() {
        {
      put("property-subject-b", "bravo(child)");
        }
    });

  Implementation implementationCase12 = waitForImplByName(null,
    "impl-case-12");
  Instance instanceCharlie = implementationCase12.createInstance(null,
    new HashMap<String, String>() {
        {
      put("property-subject-b", "charlie(parent)");
        }
    });
  Instance instanceDelta = implementationCase12.createInstance(null,
    new HashMap<String, String>() {
        {
      put("property-subject-b", "delta(parent)");
        }
    });

  instanceCharlie.getLink("case12child");
  instanceDelta.getLink("case12child");

  // Instance of the subject-a (parent)
  Implementation subjectAimpl = waitForImplByName(null, "subject-a");
  Instance subjectA = subjectAimpl.createInstance(null, null);

  // Force the field to be injected
  S6Impl s6parent = (S6Impl) subjectA.getServiceObject();
  s6parent.getS6();

  // Force the field to be injected
  Instance middleInstance = auxListInstanceReferencedBy(s6parent.getS6());
  S6Impl s6middle = (S6Impl) middleInstance.getServiceObject();
  s6middle.getS6();

  // Force the field to be injected
  Instance childInstance = auxListInstanceReferencedBy(s6middle.getS6());
  S6Impl s6child = (S6Impl) childInstance.getServiceObject();
  s6child.getS6();

  auxListProperties("\t", subjectA);

  System.err.println(subjectA.getProperty("property-case-13"));
View Full Code Here


    null, "subject-c-composite");
  Composite subjectCComposite = (Composite) subjectCCompositeType
    .createInstance(null, Collections.<String, String> emptyMap());

  // Instance of the subject-a (parent)
  Instance subjectC = subjectCimpl
    .createInstance(subjectCComposite, null);

  auxListProperties("\t", subjectC);

  System.err.println(subjectC.getProperty("property-case-15"));

  Assert.assertTrue(
    String.format(
      "Using metasubstituion to retrieve the name of the composite in which a given component is in did not fetch the right composite (%s)",
      subjectC.getProperty("property-case-15")),
    subjectC.getProperty("property-case-15").equals(
      subjectCComposite.getProperty("name")));

    }
View Full Code Here

  Implementation impl = waitForImplByName(null,
    "S1Impl-added-removed-callback-signature-instance");
  apam.waitForIt(Constants.CONST_WAIT_TIME);

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

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

  Assert.assertTrue(
    String.format(
      message,
      "Although 'added' method should not be called before the resolution of the dependency"),
View Full Code Here

  Implementation impl = waitForImplByName(null,
    "S1Impl-added-removed-callback-signature-empty");
  apam.waitForIt(Constants.CONST_WAIT_TIME);

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

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

  Assert.assertTrue(
    String.format(
      message,
      "Although 'added' method should not be called before the resolution of the dependency"),
View Full Code Here

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

  // save the initial number of instances present in APAM
  int counterInstanceBefore = CST.componentBroker.getInsts().size();

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

  ImplementationDeclaration initialImplDecl = inst.getImpl()
    .getImplDeclaration();

  boolean found = false;

  // save the number of instances present in APAM after the creation of
View Full Code Here

    public void CallbackInit_tc021() {

  Implementation s1Impl = waitForImplByName(null,
    "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

    public void CallbackRemove_tc022() throws BundleException {

  Implementation s1Impl = waitForImplByName(null,
    "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());
View Full Code Here

    @Test
    public void ConstraintInjectionWhenEmptyPreferenceTagExistsAttribute_tc026()
      throws InvalidSyntaxException {

  Implementation lgImpl = waitForImplByName(null, "LgSwitch");
  final Instance lgInst = lgImpl.createInstance(null,
    new HashMap<String, String>() {
        {
      put("currentVoltage", "100");
        }
    });

  Implementation samsungImpl = waitForImplByName(null, "SamsungSwitch");
  final Instance samsungInst = samsungImpl.createInstance(null,
    new HashMap<String, String>() {
        {
      put("currentVoltage", "500");
        }
    });

  Implementation siemensImpl = waitForImplByName(null, "SiemensSwitch");
  final Instance siemensInst = siemensImpl.createInstance(null,
    new HashMap<String, String>() {
        {
      put("currentVoltage", "105");
        }
    });

  System.out.println("Instances before injection request");
  auxListInstances("\t");
  // Creates S1 instance (class that requires the injection)
  Implementation s1Impl = waitForImplByName(null,
    "fr.imag.adele.apam.pax.test.impl.S1Impl");

  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

    public void InjectionUpdateLinkForArrayType_tc014() {

  Implementation s1Impl = waitForImplByName(null,
    "fr.imag.adele.apam.pax.test.impl.S1Impl-tc014");

  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";
View Full Code Here

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

  // This instance is created to avoid apam to instantiate automatically
  // (done in case it doesnt find any instance available)
  Instance sansungInstInitial = sansungImpl.createInstance(null, null);

  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---");
View Full Code Here

TOP

Related Classes of fr.imag.adele.apam.Instance

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.