Examples of Specification


Examples of fr.imag.adele.apam.Specification

  public void testFindImplByName () {
    System.out.println("=====MODIFIED====== start testFindImplByName");
    System.out.println("testing findImplByName in OBR");

    System.out.println("Empty spec");
    Specification spec = CST.apamResolver.findSpecByName(null,"dummySpec");
    assertTrue(spec != null);

    System.out.println("Abstract composite with empty spec");
    Implementation implem = CST.apamResolver.findImplByName(null,"AbstractCompositeType");
    assertTrue(implem != null);
View Full Code Here

Examples of fr.imag.adele.apam.Specification

    assertTrue (appliSetAttr_0 != null);
    //assertEquals ((CompositeImpl)appliSetAttr_0.getMainInst () != null);

    System.out.println(" Testing attributes on main implem declared: location = {living, kitchen, bedroom}");
    Implementation impl = appliSetAttr.getMainImpl(); //S1toS2Final
    Specification spec = impl.getSpec() ;
    Instance inst = null ;
    inst = impl.getInst() ; // any instance
    System.out.println("Tested instance : " + inst + ". TestedImpl : " + impl + " Tested spec : " + spec);


    //check attributes defined in the xml
    System.out.println("=========== start testing xml attributes");
    assertEquals (spec.getProperty("S1-Attr"), "coucou") ;
    assertNotEquals (spec.getProperty("s1-attr"), "coucou") ; //case sensitive for attr
    assertNotEquals (spec.getProperty("S1-Attr"), "Coucou") ; // case sensitive for value
    assertEquals (impl.getProperty("S1-Attr"), "coucou") ;
    assertEquals (inst.getProperty("S1-Attr"), "coucou") ;

    assertEquals (spec.getProperty("S1-Enum"), "s1-2") ;
    assertEquals (impl.getProperty("S1-Enum"), "s1-2") ;
    assertEquals (inst.getProperty("S1-Enum"), "s1-2") ;

    //default values S1toS2Final-Attr
    assertNotEquals (spec.getProperty("s1b"), "true") ;
    assertEquals (impl.getProperty("s1b"), "true") ;
    assertEquals (inst.getProperty("s1b"), "true") ;
    assertEquals (impl.getProperty("location"), "bedroom") ;
    assertEquals (inst.getProperty("S1toS2Final-Bool"), "true") ;
    assertNotEquals (impl.getProperty("S1toS2Final-Bool"), "true") ;

    assertTrue (impl.getProperty("S1toS2Final-Attr") == null) ;
    assertTrue (inst.getProperty("S1toS2Final-Attr") == null) ;

    assertEquals (impl.getProperty("testEnumere"), "v2") ;
    assertEquals (inst.getProperty("testEnumere"), "v2") ;

    //    assertTrue (inst.getProperty("S1toS2Final-Bool") == null) ;
    //    assertEquals (inst.getProperty("S1toS2Final-String"), "a String Value") ;
    //    assertTrue (inst.getProperty("badAttr") == null) ;
    System.out.println("=========== passed testing xml attributes");


    System.out.println("=========== start testing setting attributes");

    //    <property   name="autoString" value="aValue" type="string"/>
    //    <property   name="autoSet" value="Z-1, Z-2" type="{Z-0, Z-1, Z-2, Z-3}"/>

    //setting auto defined attributes
    assertEquals (impl.getProperty("autoString"), "aValue") ;
    assertEquals (inst.getProperty("autoString"), "aValue") ;
    assertEquals (impl.getProperty("autoSet"), "Z-1, Z-2") ;
    assertEquals (inst.getProperty("autoSet"), "Z-1, Z-2") ;

    impl.setProperty("autoString", "New-value") ;
    assertEquals (impl.getProperty("autoString"), "New-value") ;
    assertEquals (inst.getProperty("autoString"), "New-value") ;
    impl.setProperty("autoSet", "Z-3, Z-2") ;
    assertEquals (impl.getProperty("autoSet"), "Z-3, Z-2") ;
    assertEquals (inst.getProperty("autoSet"), "Z-3, Z-2") ;

    //is it allowed to set an attribute at the level of its definition ? If YES, it should be equal.
    impl.setProperty("S1toS2Final-String1", "falseVal") ;
    assertEquals(impl.getProperty("S1toS2Final-String1"), "falseVal");

    //Setting spec attributes.
    spec.setProperty("xxx", "value") ;
    assertTrue (spec.getProperty("xxx") == null) ;

    spec.setProperty("S1-Attr", "New-value") ;
    assertEquals (spec.getProperty("S1-Attr"), "New-value") ;
    assertEquals (impl.getProperty("S1-Attr"), "New-value") ;
    assertEquals (inst.getProperty("S1-Attr"), "New-value") ;

    spec.setProperty("S1-Enum", "New-value") ;
    assertEquals (spec.getProperty("S1-Enum"), "s1-2") ;
    spec.setProperty("S1-Enum", "s1-3") ;
    assertEquals (spec.getProperty("S1-Enum"), "s1-3") ;
    assertEquals (impl.getProperty("S1-Enum"), "s1-3") ;
    assertEquals (inst.getProperty("S1-Enum"), "s1-3") ;

    impl.setProperty("S1-Enum", "s1-1") ;
    assertEquals (spec.getProperty("S1-Enum"), "s1-3") ;
    assertEquals (impl.getProperty("S1-Enum"), "s1-3") ;
    assertEquals (inst.getProperty("S1-Enum"), "s1-3") ;

    impl.setProperty("location", "living"); // good
    assertEquals(impl.getProperty("location"), "living");
    assertEquals(inst.getProperty("location"), "living");

    impl.setProperty("location", "Living"); // error: Value is case sensitive
    assertEquals(impl.getProperty("location"), "living");

    impl.setProperty("location", "anywhere"); // error: false value
    assertEquals(impl.getProperty("location"), "living");

    impl.setProperty("testMain", "valeurTestMain"); // error: not defined
    assertTrue(impl.getProperty("testMain") == null);

    impl.setProperty("impl-name", "5"); // error: final attribute
    assertEquals(impl.getProperty("impl-name"), impl.getName());

    //boolean
    impl.setProperty("s1b", "5"); // error: bool attribute
    assertNotEquals(impl.getProperty("s1b"), "5");

    impl.setProperty("s1b", "true"); // Ok
    assertEquals(impl.getProperty("s1b"), "true");
    assertEquals(inst.getProperty("s1b"), "true");

    //integer
    impl.setProperty("s1i", "entier"); // error: int attribute
    assertTrue(impl.getProperty("s1i") == null);

    impl.setProperty("s1i", "5"); // Ok
    assertEquals(impl.getProperty("s1i"), "5");
    assertEquals(inst.getProperty("s1i"), "5");
    impl.setProperty("s1i", "5, 7, 55,985"); // Ok
    assertNotEquals(impl.getProperty("s1i"), "5, 7, 55,985");

    //    assertEquals(inst.getProperty("s1i"), "5, 7, 55,985");

    //    impl.setProperty("s1i", "5, zz, 55,985"); // wrong
    //    assertNotEquals(impl.getProperty("s1i"), "5, zz, 55,985");

    boolean ok  ;

    assertTrue ( inst.match("(s1i>=4)")) ;
    assertTrue (!inst.match("(s1i<=4)")) ;
    assertTrue (!inst.match("(s1i>=6)")) ;
    assertTrue ( inst.match("(s1i<=6)")) ;
    assertTrue (!inst.match("(s1i>=10)")) ;
    assertTrue ( inst.match("(s1i<=10)")) ;
    assertTrue ( inst.match("(s1i>=01)")) ;
    assertTrue (!inst.match("(s1i<=01)")) ;
    assertTrue ( inst.match("(s1i>=-61)")) ;
    assertTrue (!inst.match("(s1i<=-61)")) ;

    impl.setProperty("S1-Attr", "5"); // error: cannot redefine
    assertEquals(spec.getProperty("S1-Attr"), "New-value");

    //field and internal. Set by program when starting
    assertEquals(inst.getProperty("fieldAttr"), "initial set by program");
    String s = "to set the field attribute" ;
    ((TestAttr)inst.getServiceObject()).callS1 (s) ; //callS1 sets the attribute to s
View Full Code Here

Examples of fr.imag.adele.apam.Specification

  }

  @Override
  public Resolved<?> resolve(RelToResolve dep) {
   
    Specification spec = CST.componentBroker.getSpecResource(dep.getTarget());
    if (spec == null) {
      return null;
    }

    waitComponent(spec.getName());
    return null;
  }
View Full Code Here

Examples of fr.imag.adele.apam.Specification

    }
    return (Implementation) impl;
  }

  public static Specification intallSpecFromURL(URL url, String compoName) {
    Specification spec = (Specification) installFromURL(url, compoName);
    if (spec == null) {
      return null;
    }
    if (!(spec instanceof Specification)) {
      logger.error("component " + compoName + " is found but is not a Specification.");
View Full Code Here

Examples of fr.imag.adele.apam.Specification

   
    mainImpl = CST.apamResolver.findImplByName(this, mainComponent);
    if (mainImpl != null) {
      logger.debug("The main component of " + this.getName() + " is an Implementation : " + mainImpl.getName());
    } else {
      Specification spec = CST.apamResolver.findSpecByName(this, mainComponent);
      if (spec != null) {
        logger.debug("The main component of " + this.getName() + " is a Specification : " + spec.getName());
        /*
         * It is a specification to resolve as the main implem. Do not
         * select another composite
         */
        Set<String> constraints = new HashSet<String>();
View Full Code Here

Examples of fr.imag.adele.apam.Specification

    // (missing, eager)

    // Look if the client requires one of the resources provided by the
    // specification
    if (compoDep.getTarget() instanceof SpecificationReference) {
      Specification spec = CST.apamResolver.findSpecByName(compoInst, ((SpecificationReference) compoDep.getTarget()).getName());
      if ((spec != null) && spec.getDeclaration().getProvidedResources().contains(getTarget()) && (!multiple || compoDep.isMultiple())) {
        return true;
      }
    }

    // If the composite has a relation toward an implementation
View Full Code Here

Examples of fr.imag.adele.apam.Specification

  @Test
  public void testPropertyDefinitionSpec_tct026() {

    logger.debug("Testing Specification properties defined");
    Specification specsS1 = waitForSpecByName(null, "specs-s1-tct026");

    for (int i = 0; i <= 6; i++) {
      Assert.assertEquals(
          " Property def" + i + "-specs-s1 is not defined",
          "def" + i + "-specs-s1",
          specsS1.getDeclaration()
              .getPropertyDefinition("def" + i + "-specs-s1")
              .getName());
    }

    logger.debug("Testing Specification properties setted");
    Assert.assertEquals(" Property def0-specs-s1 is not setted",
        "final-value", specsS1.getProperty("def0-specs-s1"));
    Assert.assertEquals(" Property def1-specs-s1 is not setted",
        "final-value", specsS1.getProperty("def1-specs-s1"));

  }
View Full Code Here

Examples of fr.imag.adele.apam.Specification

  @Test
  public void testPropertyDefinitionFloat_tct029() {

    logger.debug("Testing definition of Float in apam descriptors ");
    Specification specsS1 = waitForSpecByName(null, "specs-s1-tct026");
    Implementation implemS1 = waitForImplByName(null, "implem-s1-tct026");
    Instance instanceS1 = waitForInstByName(null, "instance-s1-tct026");

    for (int i = 0; i < 3; i++) {
      testPropertyDefinition(specsS1, "prop-def" + i, "float",
View Full Code Here

Examples of fr.imag.adele.apam.Specification

  @Test
  public void testPropertySettingFloat_tct030() {
    logger.debug("Testing get and set of Float from apam descriptors (values and default values)");

    Specification specsS1 = waitForSpecByName(null, "specs-s1-tct026");
    Implementation implemS1 = waitForImplByName(null, "implem-s1-tct026");
    Instance instanceS1 = waitForInstByName(null, "instance-s1-tct026");

    logger.debug("Testing properties already setted in descriptor");
    testPropertyGetFloat(specsS1, "prop-def0", (float) 12.34);
    testPropertyGetFloat(implemS1, "prop-def0", (float) 12.34);
    testPropertyGetFloat(instanceS1, "prop-def0", (float) 12.34);

    testPropertyGetFloat(implemS1, "prop-impl0", (float) 23.45);
    testPropertyGetFloat(instanceS1, "prop-impl0", (float) 23.45);

    testPropertyGetFloat(instanceS1, "prop-inst0", (float) 34.56);
   
    testPropertyGetFloat(implemS1, "prop-def4", (float) 12.34);

    logger.debug("Testing properties default values setted in descriptor (not working - specification of apam behavior ambiguous)");

    logger.debug("Testing setting and getting properties using apam API");
    specsS1.setProperty("prop-def1", new Float(98.76));
    testPropertyGetFloat(specsS1, "prop-def1", (float) 98.76);

    instanceS1.setProperty("prop-inst2", new Float(98.76));
    testPropertyGetFloat(instanceS1, "prop-inst2", (float) 98.76);
  }
View Full Code Here

Examples of fr.imag.adele.apam.Specification

  }

  protected Specification waitForSpecByName(Component client,
      String componentName, long timeout) {
    waitForApam();
    Specification spec = CST.apamResolver.findSpecByName(client,
        componentName);
    long sleep = 0;

    while (sleep < timeout && spec == null) {
      try {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.