Пример #1
0
  public void testForcePrompt() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    OutputStream outputStream =
        getOutputStream("RuntimeTest.testForcePrompt", ".html"); // $NON-NLS-1$ //$NON-NLS-2$
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_PARAMETERS);
    StandaloneSession session =
        new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); // $NON-NLS-1$

    ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session);
    solutionEngine.setLoggingLevel(getLoggingLevel());
    solutionEngine.init(session);
    solutionEngine.setForcePrompt(true);
    IRuntimeContext context =
        run(
            solutionEngine,
            "test",
            "reporting",
            "jfreereport-reports-test-param.xaction",
            null,
            false,
            parameterProvider,
            outputHandler); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals(
        Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"),
        IRuntimeContext.RUNTIME_STATUS_SUCCESS,
        context.getStatus()); // $NON-NLS-1$

    finishTest();
  }
Пример #2
0
  public void testHelloWorld() {
    startTest();
    SimpleParameterProvider parameterProvider = new SimpleParameterProvider();
    parameterProvider.setParameter("type", "html"); // $NON-NLS-1$ //$NON-NLS-2$
    OutputStream outputStream =
        getOutputStream("RuntimeTest.testHelloWorld", ".html"); // $NON-NLS-1$ //$NON-NLS-2$
    SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true);
    StandaloneSession session =
        new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); // $NON-NLS-1$

    IRuntimeContext context =
        run(
            "test",
            "platform",
            "HelloWorld.xaction",
            null,
            false,
            parameterProvider,
            outputHandler,
            session); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals(
        Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"),
        IRuntimeContext.RUNTIME_STATUS_SUCCESS,
        context.getStatus()); // $NON-NLS-1$

    finishTest();
  }
Пример #3
0
 public void testLooping() {
   startTest();
   IRuntimeContext context =
       run("test", "platform", "LoopingTest.xaction"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   assertEquals(
       Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"),
       IRuntimeContext.RUNTIME_STATUS_SUCCESS,
       context.getStatus()); // $NON-NLS-1$
   finishTest();
 }
  /** Performs the process of reloading the domain information from the repository */
  private void internalReloadDomains() {
    lock.writeLock().lock();
    try {
      metadataMapping.reset();

      // Reload the metadata about the metadata (that was fun to say)
      final List<RepositoryFile> children = repository.getChildren(getMetadataDir().getId(), "*");
      if (logger.isTraceEnabled()) {
        logger.trace("\tFound " + children.size() + " files in the repository");
      }
      for (final RepositoryFile child : children) {
        if (getAclHelper().canAccess(child, READ)) {
          // Get the metadata for this file
          final Map<String, Serializable> fileMetadata = repository.getFileMetadata(child.getId());
          if (fileMetadata == null
              || StringUtils.isEmpty((String) fileMetadata.get(PROPERTY_NAME_DOMAIN_ID))) {
            if (logger.isWarnEnabled()) {
              logger.warn(
                  messages.getString(
                      "PentahoMetadataDomainRepository.WARN_0001_FILE_WITHOUT_METADATA",
                      child.getName()));
            }
            continue;
          }
          final String domainId = (String) fileMetadata.get(PROPERTY_NAME_DOMAIN_ID);
          final String type = (String) fileMetadata.get(PROPERTY_NAME_TYPE);
          final String locale = (String) fileMetadata.get(PROPERTY_NAME_LOCALE);
          if (logger.isTraceEnabled()) {
            logger.trace(
                "\tprocessing file [type="
                    + type
                    + " : domainId="
                    + domainId
                    + " : locale="
                    + locale
                    + "]");
          }

          // Save the data in the map
          if (StringUtils.equals(type, TYPE_DOMAIN)) {
            metadataMapping.addDomain(domainId, child);
          } else if (StringUtils.equals(type, TYPE_LOCALE)) {
            metadataMapping.addLocale(domainId, locale, child);
          }
        }
      }

      needToReload = false;
    } finally {
      lock.writeLock().unlock();
    }
  }
Пример #5
0
  public void testViewList() {
    startTest();

    IPentahoUrlFactory urlFactory = new SimpleUrlFactory(""); // $NON-NLS-1$

    PMDUIComponent component = new PMDUIComponent(urlFactory, new ArrayList());
    StandaloneSession session =
        new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); // $NON-NLS-1$
    component.validate(session, null);
    component.setAction(PMDUIComponent.ACTION_LIST_MODELS);

    Document doc = component.getXmlContent();
    System.out.println(doc.asXML());
    try {
      OutputStream outputStream =
          getOutputStream("MetadataTest.testViewList", ".xml"); // $NON-NLS-1$//$NON-NLS-2$
      outputStream.write(doc.asXML().getBytes());
    } catch (IOException e) {
    }
    finishTest();
  }
  protected XulMenubar getXulMenubar(String id, String documentPath, IPentahoSession session) {
    XulDomContainer container = getXulContainer(documentPath, session);
    if (container == null) {
      return null;
    }
    List<XulComponent> components =
        container.getDocumentRoot().getElementsByTagName("menubar"); // $NON-NLS-1$
    for (XulComponent component : components) {
      if (component instanceof XulMenubar && component.getId().equals(id)) {
        XulMenubar menubar = (XulMenubar) component;
        // now get customizations to it
        IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, session);
        List<?> menuCustomizations = pluginManager.getMenuCustomizations();
        for (Object custom : menuCustomizations) {
          if (custom instanceof IMenuCustomization) {
            IMenuCustomization item = (IMenuCustomization) custom;
            try {
              // apply each customization and log any failures
              MenuUtil.customizeMenu(menubar, item, getXulLoader());
            } catch (Exception e) {
              session.error(
                  Messages.getString(
                      "BaseMenuProvider.ERROR_0004_COULD_NOT_CUSTOMIZE_MENU",
                      item.getId(),
                      item.getLabel()),
                  e); //$NON-NLS-1$
            }
          }
        }

        return menubar;
      }
    }
    Logger.error(
        getClass().getName(),
        Messages.getErrorString(
            "BaseMenuProvider.ERROR_0002_COULD_NOT_GET_MENUBAR")); //$NON-NLS-1$
    return null;
  }
Пример #7
0
  public void __testLookup() {
    startTest();

    IPentahoUrlFactory urlFactory = new SimpleUrlFactory(""); // $NON-NLS-1$

    PMDUIComponent component = new PMDUIComponent(urlFactory, new ArrayList());
    StandaloneSession session =
        new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); // $NON-NLS-1$
    component.validate(session, null);
    component.setAction(PMDUIComponent.ACTION_LOOKUP);
    component.setDomainName("test"); // $NON-NLS-1$
    component.setModelId("Orders"); // $NON-NLS-1$
    component.setColumnId("BC_CUSTOMERS_CUSTOMERNAME"); // $NON-NLS-1$

    Document doc = component.getXmlContent();
    System.out.println(doc.asXML());
    try {
      OutputStream outputStream =
          getOutputStream("MetadataTest.testLoadView", ".xml"); // $NON-NLS-1$//$NON-NLS-2$
      outputStream.write(doc.asXML().getBytes());
    } catch (IOException e) {
    }
    finishTest();
  }