示例#1
0
  @Before
  public void init() throws IncubateException {

    {
      // Loading configuration
      String configurationFile = "configuration/configuration.xml";

      InputStream inputStream = getClass().getClassLoader().getResourceAsStream(configurationFile);

      try {
        String outputString = StringUtils.streamToString(inputStream);

        godiet.getXmlHelpService().registerConfigurationFile(outputString);
      } catch (IOException e) {
        log.error("", e);
        Assert.fail(e.getMessage());
      } catch (XMLParseException e) {
        log.error("", e);
        Assert.fail(e.getMessage());
      } catch (GoDietConfigurationException e) {
        log.error("", e);
        Assert.fail(e.getMessage());
      }
    }
  }
示例#2
0
  @DirtiesContext
  @Test
  public void testCommand() {
    List<String> testCaseFiles =
        Arrays.asList(
            new String[] {
              "diet/2MA-1LA-6SED.xml",
              // "diet/1MA-3LA-10SED.xml",
              // "diet/1MA-3SED.xml"
            });
    String infraCaseFiles = "infrastructure/3D-5N-3G-3L.xml";

    InputStream inputStreamPlatform =
        getClass().getClassLoader().getResourceAsStream(infraCaseFiles);
    try {
      String outputString = StringUtils.streamToString(inputStreamPlatform);

      godiet.getXmlHelpService().registerInfrastructureElements(outputString);
    } catch (IOException e) {
      log.error("", e);
      Assert.fail(e.getMessage());
    } catch (XMLParseException e) {
      log.error("", e);
      Assert.fail(e.getMessage());
    } catch (ResourceAddException e) {
      log.error("", e);
      Assert.fail(e.getMessage());
    } catch (GraphDataException e) {
      log.error("", e);
      Assert.fail(e.getMessage());
    }

    for (String testCaseFile : testCaseFiles) {
      // Retry with the same config

      try {

        InputStream inputStream = getClass().getClassLoader().getResourceAsStream(testCaseFile);
        String outputString = StringUtils.streamToString(inputStream);

        godiet.getXmlHelpService().registerDietElements(outputString);
      } catch (Exception e) {
        log.error("Test fail for file: " + testCaseFile, e);
        Assert.fail();
      }
    }
  }