Search in sources :

Example 6 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project pentaho-platform by pentaho.

the class HttpSessionPentahoSessionIntegrationFilterTest method testSessionCookieNoAuthenticationProviders.

@Test
public void testSessionCookieNoAuthenticationProviders() {
    final ISystemSettings systemSettings = PentahoSystem.getSystemSettings();
    try {
        final ISystemSettings mockSettings = Mockito.mock(ISystemSettings.class);
        Mockito.when(mockSettings.getSystemSetting("session-expired-dialog", "true")).thenReturn("true");
        PentahoSystem.setSystemSettingsService(mockSettings);
        new HttpSessionPentahoSessionIntegrationFilter().setSessionExpirationCookies(httpSession, pentahoSession, servletResponse);
        Mockito.verify(servletResponse, Mockito.never()).addCookie(Mockito.any());
    } finally {
        PentahoSystem.setSystemSettingsService(systemSettings);
    }
}
Also used : ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) Test(org.junit.Test)

Example 7 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project pentaho-platform by pentaho.

the class PluginResourceLoaderTest method testGetPluginSettings.

@Test
public void testGetPluginSettings() {
    final ISystemSettings mockSettings = mockery.mock(ISystemSettings.class);
    final String fullPathToSettingsFile = resLoader.getSystemRelativePluginPath(pluginClass.getClassLoader()) + "/settings.xml";
    mockery.checking(new Expectations() {

        {
            oneOf(mockSettings).getSystemSetting(fullPathToSettingsFile, "testsetting", null);
            will(returnValue("false"));
            oneOf(mockSettings).getSystemSetting(fullPathToSettingsFile, "bogussetting", null);
            will(returnValue(null));
            oneOf(mockSettings).getSystemSetting(fullPathToSettingsFile, "bogussetting", "true");
            will(returnValue("true"));
        }
    });
    PentahoSystem.setSystemSettingsService(mockSettings);
    assertEquals("Cache value incorrect", "false", resLoader.getPluginSetting(pluginClass, "testsetting"));
    assertNull("Bogus value should not have been found", resLoader.getPluginSetting(pluginClass, "bogussetting"));
    assertEquals("Bogus value should have a default of true", "true", resLoader.getPluginSetting(pluginClass, "bogussetting", "true"));
}
Also used : Expectations(org.jmock.Expectations) ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) Test(org.junit.Test)

Example 8 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project pentaho-platform by pentaho.

the class WebApplicationContextTest method testGetPentahoServerName.

@Test
public void testGetPentahoServerName() throws Exception {
    webAppContext = new WebApplicationContext("rootPath", null, null);
    ISystemSettings settingsService = mock(ISystemSettings.class);
    when(settingsService.getSystemSetting(eq("name"), anyString())).thenReturn("PENTAHO");
    PentahoSystem.setSystemSettingsService(settingsService);
    assertEquals("PENTAHO", webAppContext.getPentahoServerName());
}
Also used : ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) Test(org.junit.Test)

Example 9 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project data-access by pentaho.

the class AgileHelperTest method testGetFolderPath.

@Test
public void testGetFolderPath() {
    PentahoSystem.setSystemSettingsService(null);
    assertNull(AgileHelper.getFolderPath(null));
    String sampleProject = AgileHelper.PLUGIN_NAME;
    String sampleFolderPath = "/etc/";
    ISystemSettings systemSettings = mock(ISystemSettings.class);
    when(systemSettings.getSystemSetting(anyString(), anyString(), anyString())).thenReturn(null).thenReturn(sampleFolderPath);
    PentahoSystem.setSystemSettingsService(systemSettings);
    assertNull(AgileHelper.getFolderPath(sampleProject));
    assertTrue((sampleFolderPath + sampleProject).equals(AgileHelper.getFolderPath(sampleProject)));
}
Also used : ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) Test(org.junit.Test)

Example 10 with ISystemSettings

use of org.pentaho.platform.api.engine.ISystemSettings in project data-access by pentaho.

the class AgileHelperTest method testGetSchemaName.

@Test
public void testGetSchemaName() {
    PentahoSystem.setSystemSettingsService(null);
    assertNull(AgileHelper.getSchemaName());
    ISystemSettings systemSettings = mock(ISystemSettings.class);
    when(systemSettings.getSystemSetting(anyString(), anyString(), anyString())).thenReturn(null);
    PentahoSystem.setSystemSettingsService(systemSettings);
    assertNull(AgileHelper.getSchemaName());
}
Also used : ISystemSettings(org.pentaho.platform.api.engine.ISystemSettings) Test(org.junit.Test)

Aggregations

ISystemSettings (org.pentaho.platform.api.engine.ISystemSettings)21 Test (org.junit.Test)13 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 Before (org.junit.Before)3 File (java.io.File)2 Matchers.anyString (org.mockito.Matchers.anyString)2 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)2 ISolutionEngine (org.pentaho.platform.api.engine.ISolutionEngine)2 ObjectFactoryException (org.pentaho.platform.api.engine.ObjectFactoryException)2 DatasourceDTO (org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceDTO)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Node (org.dom4j.Node)1 Expectations (org.jmock.Expectations)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 IActionCompleteListener (org.pentaho.platform.api.engine.IActionCompleteListener)1