Search in sources :

Example 66 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class StandaloneObjectFactoryTest method testLocalObject1.

public void testLocalObject1() throws Exception {
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject(Object1.class.getSimpleName(), Object1.class.getName(), Scope.LOCAL);
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    Object1 obj1 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj1);
    Object1 obj2 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertNotNull("Object is null", obj2);
    // $NON-NLS-1$
    assertTrue("Objects are same", obj1 != obj2);
    Object1 obj3 = factory.get(Object1.class, session1);
    // $NON-NLS-1$
    assertTrue("Objects are same", obj1 != obj3);
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)

Example 67 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class StandaloneObjectFactoryTest method testNoCreator.

public void testNoCreator() {
    // $NON-NLS-1$
    IPentahoSession session1 = new StandaloneSession("test user 1");
    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    try {
        factory.get(Object1.class, session1);
        // $NON-NLS-1$
        assertFalse("exception expected", true);
    } catch (ObjectFactoryException e) {
        // $NON-NLS-1$
        assertTrue("exception expected", true);
    }
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession) ObjectFactoryException(org.pentaho.platform.api.engine.ObjectFactoryException) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) StandaloneObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)

Example 68 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class StandaloneSessionTest method testAuthenticated.

public void testAuthenticated() {
    // $NON-NLS-1$
    StandaloneSession session = new StandaloneSession("testname");
    // $NON-NLS-1$
    assertFalse("Wrong authenication", session.isAuthenticated());
    session.setAuthenticated(null);
    // $NON-NLS-1$
    assertFalse("Wrong authenication", session.isAuthenticated());
    // $NON-NLS-1$
    session.setAuthenticated("testname");
    // $NON-NLS-1$
    assertTrue("Wrong authenication", session.isAuthenticated());
    session.setNotAuthenticated();
    // $NON-NLS-1$
    assertNull("session name is wrong", session.getName());
    // $NON-NLS-1$
    assertFalse("Wrong authenication", session.isAuthenticated());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession)

Example 69 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class StandaloneSessionTest method testLogger.

public void testLogger() {
    StandaloneSession session = new StandaloneSession();
    // $NON-NLS-1$
    assertNotNull("Bad logger", session.getLogger());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession)

Example 70 with StandaloneSession

use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.

the class StandaloneSessionTest method testDefaultConstructor.

public void testDefaultConstructor() {
    StandaloneSession session = new StandaloneSession();
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("session name is wrong", "unknown", session.getName());
    // $NON-NLS-1$ //$NON-NLS-2$
    assertEquals("session id is wrong", "unknown", session.getId());
    // $NON-NLS-1$
    assertEquals("session locale is wrong", Locale.getDefault(), session.getLocale());
    // make sure this does not blow up
    session.destroy();
    // $NON-NLS-1$
    assertEquals("session object name is wrong", StandaloneSession.class.getName(), session.getObjectName());
}
Also used : StandaloneSession(org.pentaho.platform.engine.core.system.StandaloneSession)

Aggregations

StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)218 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)74 ArrayList (java.util.ArrayList)46 Authentication (org.springframework.security.core.Authentication)39 Test (org.junit.Test)38 OutputStream (java.io.OutputStream)34 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)30 GrantedAuthority (org.springframework.security.core.GrantedAuthority)30 User (org.springframework.security.core.userdetails.User)30 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)29 UserDetails (org.springframework.security.core.userdetails.UserDetails)29 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)24 File (java.io.File)21 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 StandaloneObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory)21 StandaloneSpringPentahoObjectFactory (org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory)21 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)20 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)20 HashMap (java.util.HashMap)16 Before (org.junit.Before)16