Search in sources :

Example 1 with JVMParameterProvider

use of org.pentaho.platform.util.JVMParameterProvider in project pentaho-platform by pentaho.

the class MultipleComponentIT method testJVMParameterProvider.

public void testJVMParameterProvider() {
    startTest();
    // $NON-NLS-1$//$NON-NLS-2$
    System.setProperty("teststring", "test string");
    // $NON-NLS-1$//$NON-NLS-2$
    System.setProperty("testlong", "32");
    // $NON-NLS-1$//$NON-NLS-2$
    System.setProperty("testdecimal", "66.6");
    Date someDate = new Date();
    // $NON-NLS-1$
    System.setProperty("testdate", DateFormat.getInstance().format(someDate));
    JVMParameterProvider provider = new JVMParameterProvider();
    // assertEquals(someDate, provider.getDateParameter("testdate", null) ); //$NON-NLS-1$
    // $NON-NLS-1$
    assertEquals(someDate, provider.getDateParameter("bogus", someDate));
    // $NON-NLS-1$
    assertEquals(32, provider.getLongParameter("testlong", 0));
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("test string", provider.getStringParameter("teststring", null));
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals(new BigDecimal("66.6"), provider.getDecimalParameter("testdecimal", null));
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("test string", provider.getParameter("teststring"));
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("string", provider.getParameterType("teststring"));
    Iterator it = provider.getParameterNames();
    while (it.hasNext()) {
        String pName = (String) it.next();
        // $NON-NLS-1$
        System.out.println(pName + "=" + provider.getStringParameter(pName, null));
    }
    finishTest();
}
Also used : JVMParameterProvider(org.pentaho.platform.util.JVMParameterProvider) Iterator(java.util.Iterator) Date(java.util.Date) BigDecimal(java.math.BigDecimal)

Example 2 with JVMParameterProvider

use of org.pentaho.platform.util.JVMParameterProvider in project pentaho-platform by pentaho.

the class MultipleComponentIT method testJVMParameterProviderDifferentPath.

public void testJVMParameterProviderDifferentPath() {
    startTest();
    JVMParameterProvider provider = new JVMParameterProvider();
    // $NON-NLS-1$
    assertEquals(99, provider.getLongParameter("bogus", 99));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    assertEquals(new BigDecimal("99"), provider.getDecimalParameter("bogus", new BigDecimal("99")));
    finishTest();
}
Also used : JVMParameterProvider(org.pentaho.platform.util.JVMParameterProvider) BigDecimal(java.math.BigDecimal)

Example 3 with JVMParameterProvider

use of org.pentaho.platform.util.JVMParameterProvider in project pentaho-platform by pentaho.

the class MessageFormatterTest method makeParameterProviders.

private Map<String, IParameterProvider> makeParameterProviders(final IPentahoSession session) {
    final Map<String, IParameterProvider> res = new HashMap<>();
    res.put("jvm", new JVMParameterProvider());
    res.put(SecurityParameterProvider.SCOPE_SECURITY, new SecurityParameterProvider(session));
    return res;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) JVMParameterProvider(org.pentaho.platform.util.JVMParameterProvider) SecurityParameterProvider(org.pentaho.platform.engine.security.SecurityParameterProvider)

Example 4 with JVMParameterProvider

use of org.pentaho.platform.util.JVMParameterProvider in project pentaho-platform by pentaho.

the class RuntimeContextTest method makeParameterProviders.

private Map<String, IParameterProvider> makeParameterProviders(final IPentahoSession session) {
    final Map<String, IParameterProvider> res = new HashMap<>();
    res.put("jvm", new JVMParameterProvider());
    res.put(SecurityParameterProvider.SCOPE_SECURITY, new SecurityParameterProvider(session));
    return res;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) HashMap(java.util.HashMap) JVMParameterProvider(org.pentaho.platform.util.JVMParameterProvider) Matchers.anyString(org.mockito.Matchers.anyString) SecurityParameterProvider(org.pentaho.platform.engine.security.SecurityParameterProvider)

Example 5 with JVMParameterProvider

use of org.pentaho.platform.util.JVMParameterProvider in project pentaho-platform by pentaho.

the class SolutionEngine method init.

public void init(final IPentahoSession pSession) {
    parameterProviders = new HashMap<String, IParameterProvider>();
    this.session = pSession;
    this.setParameterProvider(SolutionEngine.JVM_PARAMETER_PROVIDER, new JVMParameterProvider());
    setForcePrompt(false);
    // Provide the security parameter provider to the parameter provider map in the super class
    SecurityParameterProvider provider = new SecurityParameterProvider(pSession);
    this.setParameterProvider(SecurityParameterProvider.SCOPE_SECURITY, provider);
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) JVMParameterProvider(org.pentaho.platform.util.JVMParameterProvider) SecurityParameterProvider(org.pentaho.platform.engine.security.SecurityParameterProvider)

Aggregations

JVMParameterProvider (org.pentaho.platform.util.JVMParameterProvider)6 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)3 SecurityParameterProvider (org.pentaho.platform.engine.security.SecurityParameterProvider)3 BigDecimal (java.math.BigDecimal)2 HashMap (java.util.HashMap)2 Date (java.util.Date)1 Iterator (java.util.Iterator)1 Matchers.anyString (org.mockito.Matchers.anyString)1 AuditException (org.pentaho.platform.api.engine.AuditException)1 InvalidParameterException (org.pentaho.platform.api.engine.InvalidParameterException)1 ContentException (org.pentaho.platform.api.repository.ContentException)1 RepositoryException (org.pentaho.platform.api.repository.RepositoryException)1 PentahoChainedException (org.pentaho.platform.api.util.PentahoChainedException)1 SQLResultSetException (org.pentaho.platform.plugin.services.connections.sql.SQLResultSetException)1