Package fr.imag.adele.apam

Examples of fr.imag.adele.apam.Instance


  Composite subjectEComposite = (Composite) subjectECompositeType
    .createInstance(null, Collections.<String, String> emptyMap());

  Implementation implementationAlpha = waitForImplByName(null,
    "impl-case-17");
  Instance instanceEcho = implementationAlpha.createInstance(
    subjectEComposite, null);

  Implementation subjectCimpl = waitForImplByName(null, "subject-e");

  // Instance of the subject-a (parent)
  Instance subjectE = subjectCimpl.createInstance(null, null);
  S6Impl s6 = (S6Impl) subjectE.getServiceObject();

  // Force injection
  s6.getS6();

  auxListProperties("\t", subjectE);

  String parentProperty = subjectE
    .getProperty("property-case-17-parent-composite");
  String dependencyProperty = subjectE
    .getProperty("property-case-17-dep-composite");
  System.out.println("parentProperty -->" + parentProperty
    + " | subjectEComposite.getName() -->"
    + subjectE.getComposite().getName());

  String template = "Using metasubstitution, with components in different composites , %s";

  Assert.assertTrue(
    String.format(template,
      "although the dependency do not correspond to the correct one"),
    dependencyProperty.equals(subjectEComposite.getName()));

  Assert.assertTrue(String.format(template,
    "although the parent do not correspond the correct one"),
    parentProperty.equals(subjectE.getComposite().getName()));

  Assert.assertTrue(
    String.format(
      template,
      "although checking a dependency property we vefiried that the value do not match with the right one"),
    subjectE.getProperty("property-case-17-dep-property").equals(
      instanceEcho.getProperty("property-case-17")));

    }
View Full Code Here


    null, "subject-b-composite");
  Composite subjectBComposite = (Composite) subjectBCompositeType
    .createInstance(null, Collections.<String, String> emptyMap());

  // Instance of the subject-a (parent)
  Instance subjectB = subjectBimpl
    .createInstance(subjectBComposite, null);

  auxListProperties("\t", subjectB);

  System.err.println(subjectB.getProperty("property-case-14"));

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

    }
View Full Code Here

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

  // Instance of the subject-a (parent)
  Instance subjectD = subjectDimpl
    .createInstance(subjectDComposite, null);

  auxListProperties("\t", subjectD);

  Assert.assertTrue(
    "Trying to recover the name of the group, but the name found do not correspond to the real group of the implem",
    subjectD.getProperty("property-case-16").equals("spec-case-16"));

    }
View Full Code Here

        "composite-a-hide");

    Composite composite_a = (Composite) cta.createInstance(composite_root,
        null);// inner composite with hide='true'

    Instance instanceApp1 = composite_a.getMainInst();

    S3GroupAImpl ga1 = (S3GroupAImpl) instanceApp1.getServiceObject();
    // force injection
    ga1.getElement();

    auxListInstances("\t");
View Full Code Here

    apam.waitForIt(Constants.CONST_WAIT_TIME);

    Implementation trigger = waitForImplByName(null,
        "group-a-start-trigger");

    Instance triggerInstance = trigger.createInstance(compositeInstance,
        null);

    Implementation triggered = waitForImplByName(null,
        "group-b-started-by-trigger");
View Full Code Here

        "group-a-start-trigger");

    Implementation triggered = waitForImplByName(null,
        "group-b-started-by-trigger");

    Instance triggerInstance = trigger.createInstance(compositeInstance,
        null);

    Assert.assertTrue(triggerInstance != null);

    List<Instance> instancesOfB = auxLookForInstanceOf(((AtomicImplementationDeclaration) triggered
View Full Code Here

    Component destination = resolutionResult.iterator().next().getDestination();
    Assert.assertTrue( String.format(message,
        "Although, the resolution of dependence required(specification 'electronic-device') doesn't satisfy the target kind"),
        destination instanceof Instance);

    Instance target = (Instance) destination;
   
    Assert.assertTrue( String.format(message,
        "Although, the resolution of dependence required(specification 'electronic-device') doesn't satisfy the constraints"),
        target.getImpl().getName().equals("deadMansSwitch"));
   
  }
View Full Code Here

    Assert.assertEquals("Property testVersionDef type is a version ", "version", client.getPropertyDefinition("testVersionDef").getType());
    Assert.assertEquals("Property testVersionDef value is 4.5.6 ", Version.parseVersion("4.5.6"), client.getPropertyObject("testVersionDef"));
   
    System.err.println("Creating an instance, defined properties should be inherited");

    Instance instClient = client.createInstance(null, null);
    System.err.println("Client instance properties, "+instClient.getAllProperties().entrySet());

    Assert.assertNotNull("Property testVersionProp must exist ",instClient.getPropertyObject("testVersionProp"));
    Assert.assertEquals("Property testVersionProp type is a version ", "version", instClient.getPropertyDefinition("testVersionProp").getType());
    Assert.assertEquals("Property testVersionProp value is 1.2.3 ", Version.parseVersion("1.2.3"), instClient.getPropertyObject("testVersionProp"));
   
    Assert.assertNotNull("Property testVersionDef must exist ",instClient.getPropertyObject("testVersionDef"));
    Assert.assertEquals("Property testVersionDef type is a version ", "version", instClient.getPropertyDefinition("testVersionDef").getType());
    Assert.assertEquals("Property testVersionDef value is 4.5.6 ", Version.parseVersion("4.5.6"), instClient.getPropertyObject("testVersionDef"));
   
    System.err.println("Test injection");
    ClientObject myObject = (ClientObject) instClient.getServiceObject();
    myObject.setMyVersionInjected(Version.parseVersion("7.8.9"));
   
    Assert.assertNotNull("Property testVersionInjected must exist ",instClient.getPropertyObject("testVersionInjected"));
    Assert.assertEquals("Property testVersionInjected type is a version ", "version", instClient.getPropertyDefinition("testVersionInjected").getType());
    Assert.assertEquals("Property testVersionInjected value is 7.8.9 ", Version.parseVersion("7.8.9"), instClient.getPropertyObject("testVersionInjected"))
   
    instClient.setProperty("testVersionInjected", Version.parseVersion("1.0.1"));
    Assert.assertEquals("Property testVersionInjected value (from javaclass) ", Version.parseVersion("1.0.1"), myObject.getMyVersionInjected());

  }
View Full Code Here

    public void ConstraintsCheckingImplementation_tc009() {

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

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

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

  Instance philipsSwitch = CST.componentBroker.getInstService(s1
    .getSimpleDevice110v());

  philipsSwitch.setProperty("currentVoltage", "110");

  String manufacturer = philipsSwitch.getProperty("manufacturer");
  String currentVoltage = philipsSwitch.getProperty("currentVoltage");
  String voltage = philipsSwitch.getProperty("voltage");

  String messageTemplate = "The filter %s should result in a %s statement since manufacturer:%s, currentVoltage:%s and voltage:%s";

  String expression = "(manufacturer=philips)";
  Boolean result = true;

  Assert.assertTrue(String.format(messageTemplate, expression, result,
    manufacturer, currentVoltage, voltage), philipsSwitch
    .match(expression));

  expression = "(voltage=110)";
  result = true;

  Assert.assertTrue(String.format(messageTemplate, expression, result,
    manufacturer, currentVoltage, voltage), philipsSwitch
    .match(expression));

  expression = "(currentVoltage <= 110)";
  result = true;

  Assert.assertTrue(String.format(messageTemplate, expression, result,
    manufacturer, currentVoltage, voltage), philipsSwitch
    .match(expression));

  expression = "(currentVoltage >= 111)";
  result = false;

  Assert.assertFalse(String.format(messageTemplate, expression, result,
    manufacturer, currentVoltage, voltage), philipsSwitch
    .match(expression));

  expression = "(futfut)";
  result = false;

  Assert.assertFalse(String.format(messageTemplate, expression, result,
    manufacturer, currentVoltage, voltage), philipsSwitch
    .match(expression));

  expression = "(&(manufacturer!=philips)(manufacturer=philips))";
  result = false;

  Assert.assertFalse(String.format(messageTemplate, expression, result,
    manufacturer, currentVoltage, voltage), philipsSwitch
    .match(expression));

  expression = "(&(manufacturer=philips)(manufacturer=philips))";
  result = true;

  Assert.assertTrue(String.format(messageTemplate, expression, result,
    manufacturer, currentVoltage, voltage), philipsSwitch
    .match(expression));

    }
View Full Code Here

    @Test
    public void ConstraintsCheckingInstanceFilteringByInitialProperty_tc010()
      throws InvalidSyntaxException {

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

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

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

  Implementation boschImpl = waitForImplByName(null, "BoschSwitch");
  final Instance boschInst = boschImpl.createInstance(null,
    new HashMap<String, String>() {
        {
      put("currentVoltage", "110");
        }
    });

  Implementation philipsImpl = waitForImplByName(null, "philipsSwitch");
  final Instance philipsInst = philipsImpl.createInstance(null,
    new HashMap<String, String>() {
        {
      put("currentVoltage", "117");
        }
    });

  Set<Instance> validInstances = new HashSet<Instance>() {
      {
    add(siemensInst);
    add(lgInst);
    add(boschInst);
    add(samsungInst);
      }
  };

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

  // apam.waitForIt(Constants.CONST_WAIT_TIME);

  Instance s1Inst = s1Impl.createInstance(null, null);
  S1Impl s1 = (S1Impl) s1Inst.getServiceObject();

  // apam.waitForIt(Constants.CONST_WAIT_TIME);

  for (Eletronic e : s1.getEletronicInstancesConstraintsInstance()) {
      Instance p = CST.componentBroker.getInstService(e);
      System.out.println("---- Voltage:"
        + p.getProperty("currentVoltage") + " / Name:"
        + p.getName());

      boolean found = false;

      for (Instance l : validInstances) {
    if (l.getName().equals(p.getName())) {
        found = true;
        break;
    }
      }

      // Check if all valid instances were injected
      Assert.assertTrue(
        String.format(
          "Instance %s (currentVoltage:%s) was injected even if its does not obey the constraint (currentVoltage<=110)",
          p.getName(), p.getProperty("currentVoltage")), p
          .match("(currentVoltage<=110)"));
      Assert.assertTrue(
        String.format(
          "Instance %s (currentVoltage:%s) was not found in the list of valid instances for the constraint (currentVoltage<=110)",
          p.getName(), p.getProperty("currentVoltage")),
        found);

  }

  auxListInstances("--------------");
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.