예제 #1
0
  public void testImportIPManifestFromString() {
    String m = getManifest().toString();
    try {

      eu.optimis.manifest.api.ip.Manifest.Factory.newInstance(m);
    } catch (RuntimeException ex) {
      fail("Invalid IP manifest imported.");
    }
  }
예제 #2
0
 public void testShouldNotImportInvalidIPManifestFromString() {
   String wrongManifest = "something wrong";
   try {
     eu.optimis.manifest.api.ip.Manifest.Factory.newInstance(wrongManifest);
     fail("Invalid IP manifest imported. This shouldn't occur.");
   } catch (RuntimeException ex) {
     System.out.println(
         "expected exception catched. invalid IP manifest detected." + ex.getCause());
   }
 }
예제 #3
0
 public void testShouldNotImportInvalidString() {
   String string = getManifest().toString();
   string = string.replaceFirst("jboss", "test");
   try {
     Manifest.Factory.newInstance(string);
     fail("An exception should have been thrown");
   } catch (InvalidDocumentException e) {
     System.out.println("This exception was expected: " + e.getMessage());
     assertTrue("this exception was expected", true);
   }
 }
예제 #4
0
 public void testShouldNotImportInvalidXmlBeansManifest() {
   XmlBeanServiceManifestDocument manifestDocument = getManifest().toXmlBeanObject();
   manifestDocument.getServiceManifest().setManifestId("test");
   try {
     Manifest.Factory.newInstance(manifestDocument);
     fail("An exception should have been thrown");
   } catch (InvalidDocumentException e) {
     assertTrue("this exception was expected", true);
     System.out.println(e.getMessage());
   }
 }
예제 #5
0
 public void testShouldNotImportInvalidJaxBManifest() {
   JaxBServiceManifest jaxb = getManifest().toJaxB();
   jaxb.setManifestId("test");
   try {
     Manifest.Factory.newInstance(jaxb);
     fail("An exception should have been thrown");
   } catch (InvalidDocumentException e) {
     assertTrue("this exception was expected", true);
     System.out.println(e.getMessage());
   }
 }
예제 #6
0
  public void testShouldExportIPManifestAsString() throws XmlException {
    // given a new IP Manifest exists

    Manifest im = Manifest.Factory.newInstance(getManifest().toXmlBeanObject());

    // when we export the manifest as string
    String exportedManifest = im.toString();

    // then both manifests are equal
    assertTrue(
        "exported string does not match orginal",
        exportedManifest.equals(getManifest().toString()));
  }
  public SetAdmissionControlDecision(String serviceManifest, String ACdecision, Logger log) {
    log.info("Ready to attach AdmissionControlDecision to SM");

    // log.info("serviceManifest : "+serviceManifest);
    // Manifest ipManifest = Manifest.Factory.newInstance(serviceManifest);

    Manifest ipManifest = null;
    try {
      // ipManifest = Manifest.Factory.newInstance(serviceManifest);

      ipManifest = eu.optimis.manifest.api.ip.Manifest.Factory.newInstance(serviceManifest);

      // XmlBeanServiceManifestDocument xmlBeanManifest =
      // XmlBeanServiceManifestDocument.Factory.parse(serviceManifest);

      // ipManifest = Manifest.Factory.newInstance(xmlBeanManifest);

      if (ipManifest.isSetInfrastructureProviderExtensions())
        if (ipManifest.getInfrastructureProviderExtensions().isSetAllocationOffer())
          ipManifest.getInfrastructureProviderExtensions().unsetAllocationOffer();
      /*
      } catch (XmlException x) {
      	String Message="XmlException "+x.getMessage();
      	System.out.println(Message);
      	log.error(x.getMessage());
      	x.printStackTrace();
      */
    } catch (RuntimeException re) {
      String Message = "RuntimeException " + re.getMessage();
      System.out.println(Message);
      log.error(re.getMessage());
      // e.printStackTrace();

    } catch (Exception e) {
      String Message = "RuntimeException " + e.getMessage();
      System.out.println(Message);
      log.error(e.getMessage());
      // e.printStackTrace();

    }

    ipManifest.initializeInfrastructureProviderExtensions();

    log.info("initializeInfrastructureProviderExtensions");

    String AdmissionControlDecision = null;

    if (ACdecision.contains("Accepted"))
      AdmissionControlDecision = AllocationOfferDecision.accepted.toString();
    else if (ACdecision.contains("Rejected"))
      AdmissionControlDecision = AllocationOfferDecision.rejected.toString();
    else if (ACdecision.contains("Partial accepted"))
      AdmissionControlDecision = AllocationOfferDecision.partial.toString();

    ipManifest.getInfrastructureProviderExtensions().addNewAllocationOffer();
    ipManifest
        .getInfrastructureProviderExtensions()
        .getAllocationOffer()
        .setDecision(AdmissionControlDecision);

    String smg = " ACdecision " + AdmissionControlDecision + " Attached to SM";
    System.out.println(smg);
    log.info(smg);

    // serviceManifestWithACdecision = ipManifest.toString();

    try {
      serviceManifestWithACdecision = ipManifest.toString();

    } catch (Exception e) {
      String Message = "RuntimeException " + e.getMessage() + " Ignored";
      System.out.println(Message);
      log.error(e.getMessage());
      e.printStackTrace();
    }

    log.info("Finish of attach AdmissionControlDecision to SM");
  } // constructor
예제 #8
0
 public void testShouldLoadManifestFromFile() throws XmlException, IOException {
   InputStream in = this.getClass().getResourceAsStream("/SP-ManifestExample.xml");
   XmlBeanServiceManifestDocument doc = XmlBeanServiceManifestDocument.Factory.parse(in);
   Manifest manifest = Manifest.Factory.newInstance(doc);
   assertFalse(manifest.hasErrors());
 }
예제 #9
0
 public void testShouldImportFromJaxBObject() {
   JaxBServiceManifest jaxb = getManifest().toJaxB();
   Manifest ipManifest = Manifest.Factory.newInstance(jaxb);
   assertNotNull(ipManifest);
 }