Package fr.imag.adele.apam

Examples of fr.imag.adele.apam.Implementation


    }

    @Test
    public void RelationSourceSpecificationTargetImplementationFailExceptionCustom_tc108() {

  Implementation implementation = waitForImplByName(null,
    "S07-implementation-12");

  Instance instance = implementation.createInstance(null,
    Collections.<String, String> emptyMap());

  S07ImplementationImporter12 dependency = (S07ImplementationImporter12) instance
    .getServiceObject();
View Full Code Here


    }

    @Test
    public void RelationSourceSpecificationTargetImplementationFailExceptionGeneric_tc107() {

  Implementation implementation = waitForImplByName(null,
    "S07-implementation-11");

  Instance instance = implementation.createInstance(null,
    Collections.<String, String> emptyMap());

  S07ImplementationImporter11 dependency = (S07ImplementationImporter11) instance
    .getServiceObject();
View Full Code Here

    }

    @Test
    public void RelationSourceSpecificationTargetImplementationFailWait_tc106() {

  Implementation implementation = waitForImplByName(null,
    "S07-implementation-10");

  Instance instance = implementation.createInstance(null,
    Collections.<String, String> emptyMap());

  S07ImplementationImporter10 dependency = (S07ImplementationImporter10) instance
    .getServiceObject();
View Full Code Here

    if (composite == null) {
      throw new InvalidConfiguration("Null parent while creating instance");
    }

    Implementation implementation = CST.componentBroker.getImpl(apformInst.getDeclaration().getImplementation().getName());

    if (implementation == null) {
      throw new InvalidConfiguration("Null implementation while creating instance");
    }
View Full Code Here

    }

    @Test
    public void RelationSourceSpecificationTargetInstance_tc103() {

  Implementation target = waitForImplByName(null, "S07-DependencyImpl");
  target.createInstance(null, null);

  Implementation implementation = waitForImplByName(null,
    "S07-implementation-07");

  Instance instance = implementation.createInstance(null, null);

  S07ImplementationImporter07 dependency = (S07ImplementationImporter07) instance
    .getServiceObject();

  // Force field injection
  dependency.getInjected();

  ComponentImpl ci = (ComponentImpl) implementation.getSpec();

  Assert.assertTrue(String.format(
    "One link should have been created, but %s links were found",
    ci.getLocalLinks().size()), ci.getLocalLinks().size() == 1);
View Full Code Here

    }

    @Test
    public void RelationSourceSpecificationTargetSpecification_tc105() {

  Implementation implementation = waitForImplByName(null,
    "S07-implementation-09");

  Instance instance = implementation.createInstance(null,
    Collections.<String, String> emptyMap());

  S07ImplementationImporter09 dependency = (S07ImplementationImporter09) instance
    .getServiceObject();

  // Force field injection
  dependency.getInjected();

  ComponentImpl ci = (ComponentImpl) implementation.getSpec();

  Assert.assertTrue(String.format(
    "One link should have been created, but %s links were found",
    ci.getLocalLinks().size()), ci.getLocalLinks().size() == 1);
View Full Code Here

      if (relToResolve.getTargetKind() == ComponentKind.SPECIFICATION) {
        return new Resolved<Specification>(spec);
      }
      impls = spec.getImpls();
    } else if (relToResolve.getTarget() instanceof ImplementationReference) {
      Implementation impl = CST.componentBroker.getImpl(name);
      if (impl == null) {
        return null;
      }
      if (relToResolve.getTargetKind() == ComponentKind.IMPLEMENTATION) {
        return new Resolved<Implementation>(impl);
      }
      impls = new HashSet<Implementation>();
      impls.add(impl);
    } else if (relToResolve.getTarget() instanceof InstanceReference) {
      Instance inst = CST.componentBroker.getInst(name);
      if (inst == null) {
        return null;
      }
      if (relToResolve.getTargetKind() == ComponentKind.INSTANCE) {
        return new Resolved<Instance>(inst);
      }
      logger.debug("if (relToResolve.getTarget() instanceof InstanceReference) ") ;
      return null;
    } else if (relToResolve.getTarget() instanceof ComponentReference<?>) {
      logger.error("Invalid target reference : " + relToResolve.getTarget());
      return null;
    }

    /*
     * We have computed all component references It is either already
     * resolved, or the implems are in impls. Now Resolve by resource.
     */
    else if (relToResolve.getTarget() instanceof ResourceReference) {
      if (relToResolve.getTargetKind() == ComponentKind.SPECIFICATION) {
        Set<Specification> specs = new HashSet<Specification>();
        for (Specification spec : CST.componentBroker.getSpecs()) {
          if (spec.getProvidedResources().contains(relToResolve.getTarget())) {
            specs.add(spec);
          }
        }
        return relToResolve.getResolved(specs, false);
      }

      /*
       * target Kind is implem or instance get all the implems that
       * implement the resource
       */
      impls = new HashSet<Implementation>();
      for (Implementation impl : CST.componentBroker.getImpls()) {
        if (impl.getProvidedResources().contains((relToResolve.getTarget()))) {
          impls.add(impl);
        }
      }
    }

    // TargetKind is implem or instance, but no implem found.
    if (impls == null || impls.isEmpty()) {
      return null;
    }

    // If TargetKind is implem, select the good one(s)
    if (relToResolve.getTargetKind() == ComponentKind.IMPLEMENTATION) {
      return relToResolve.getResolved(impls, false);
    }

    /*
     * We have in impls all the implementations satisfying the relation
     * target (type and name only). We are looking for instances. Take all
     * the instances of these implementations satisfying the relation
     * constraints and visibility.
     */

    /*
     *  Fast track : if looking for one instance and no preferences, return the first valid instance
     */
    boolean fast = (!relToResolve.isMultiple() && !relToResolve.hasPreferences());

    Set<Instance> insts = new HashSet<Instance>();
    for (Implementation impl : impls) {
      for (Instance inst : impl.getInsts()) {
        if (inst.isSharable() && source.canSee(inst) && inst.matchRelationConstraints(relToResolve)) {
          if (fast) {
            return new Resolved<Instance>(inst);
          }
          insts.add(inst);
        }
      }
    }

    if (!insts.isEmpty()) {
      /*
       * If relation is singleton, select the best instance.
       */
      if (relToResolve.isMultiple()) {
        return new Resolved<Instance>(insts);
      }
      return new Resolved<Instance>(relToResolve.getPrefered(insts));
    }

    /*
     * Keep only the implementations satisfying the constraints of the
     * relation
     */
    Set<Implementation> valid = new HashSet<Implementation>();
    for (Implementation impl : impls) {
      if (relToResolve.matchRelationConstraints(ComponentKind.IMPLEMENTATION, impl.getAllProperties())) {
        valid.add(impl);
      }
    }

    if (!!!valid.isEmpty()) {
View Full Code Here

    Composite compositeInstance = (Composite) composite.createInstance(
        null, null);

    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");

    Assert.assertTrue(triggerInstance != null);

    List<Instance> instancesOfB = auxLookForInstanceOf(((AtomicImplementationDeclaration) triggered
        .getImplDeclaration()).getClassName());

    apam.waitForIt(Constants.CONST_WAIT_TIME);

    auxListInstances("INSTANCE-t2-");
View Full Code Here

    Composite compositeInstance = (Composite) composite.createInstance(
        null, null);

    apam.waitForIt(Constants.CONST_WAIT_TIME);

    Implementation trigger = waitForImplByName(null,
        "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
        .getImplDeclaration()).getClassName());

    apam.waitForIt(Constants.CONST_WAIT_TIME);

    auxListInstances("INSTANCE-t2-");
View Full Code Here

 
  @Test
  public void getNewPredefinedProperties_tct039()
      throws InvalidSyntaxException {

    Implementation client = waitForImplByName(null, "implem-client");
    System.err.println("properties, "+client.getImplDeclaration().getProperties());
    Assert.assertNotNull("client must exists", client);
    Assert.assertNotNull("Property maven.groupId must exist ",client.getPropertyObject("maven.groupId"));
    Assert.assertEquals("Property maven.groupId type is a string ", "string", client.getPropertyDefinition("maven.groupId").getType());
   
    Assert.assertNotNull("Property maven.artifactId must exist ",client.getPropertyObject("maven.artifactId"));
    Assert.assertEquals("Property maven.artifactId type is a string ", "string", client.getPropertyDefinition("maven.artifactId").getType());
   
    Assert.assertNotNull("Property maven.version must exist ",client.getPropertyObject("maven.version"));
    Assert.assertEquals("Property maven.version type is a string ", "string", client.getPropertyDefinition("maven.version").getType());
   
    Assert.assertNotNull("Property apam.version must exist ",client.getPropertyObject("apam.version"));
    Assert.assertEquals("Property apam.version type is a version ", "version", client.getPropertyDefinition("apam.version").getType());
   
    Assert.assertNotNull("Property version must exist ",client.getPropertyObject("version"));
    Assert.assertEquals("Property version type is a version ", "version", client.getPropertyDefinition("version").getType());
  }
View Full Code Here

TOP

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

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.