use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class AggregateObjectFactoryTest method testCombined.
@Test
public void testCombined() throws Exception {
StandaloneSession session = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
ConfigurableApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/solution/system/pentahoObjects.spring.xml");
factory.init(null, context);
StandaloneSpringPentahoObjectFactory factory2 = new StandaloneSpringPentahoObjectFactory();
factory2.init("src/test/resources/solution/system/pentahoObjects.spring.xml", null);
StandaloneObjectFactory factory3 = new StandaloneObjectFactory();
factory3.init(null, null);
factory3.defineObject("MimeTypeListener", MimeTypeListener.class.getName(), IPentahoDefinableObjectFactory.Scope.GLOBAL);
AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
aggFactory.registerObjectFactory(factory3);
List<MimeTypeListener> mimes = aggFactory.getAll(MimeTypeListener.class, session);
assertEquals(6, mimes.size());
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class AggregateObjectFactoryTest method testRegistration.
/**
* Two Spring PentahoObjectFactories with the same underlying applicationContext should not be registered twice. This
* case tests that the AggregateObjectFactory's set implementation is working properly.
*
* @throws Exception
*/
@Test
public void testRegistration() throws Exception {
StandaloneSession session = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
ConfigurableApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/solution/system/pentahoObjects.spring.xml");
factory.init(null, context);
StandaloneSpringPentahoObjectFactory factory2 = new StandaloneSpringPentahoObjectFactory();
factory2.init(null, context);
AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
aggFactory.registerObjectFactory(factory);
aggFactory.registerObjectFactory(factory2);
List<MimeTypeListener> mimes = aggFactory.getAll(MimeTypeListener.class, session);
assertEquals(5, mimes.size());
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class AggregateObjectFactoryTest method testRegisteredButNotPublishingAnythingApplicationContext.
/**
* Two Spring PentahoObjectFactories with the same underlying applicationContext should not be registered twice. This
* case tests that the AggregateObjectFactory's set implementation is working properly.
*
* @throws Exception
*/
@Test
public void testRegisteredButNotPublishingAnythingApplicationContext() throws Exception {
PublishedBeanRegistry.reset();
StandaloneSession session = new StandaloneSession();
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
ConfigurableApplicationContext context = new FileSystemXmlApplicationContext("src/test/resources/solution/system/registeredButNotPublishing.spring.xml");
// this was causing an exception.
factory.init(null, context);
AggregateObjectFactory aggFactory = (AggregateObjectFactory) PentahoSystem.getObjectFactory();
aggFactory.registerObjectFactory(factory);
assertEquals(0, PublishedBeanRegistry.getRegisteredFactories().size());
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class DefaultLdapUserRoleListServiceTest method login.
/**
* Logs in with given username.
*
* @param username
* username of user
* @param tenant
* tenant to which this user belongs
* @tenantAdmin true to add the tenant admin authority to the user's roles
*/
protected void login(final String username, final ITenant tenant) {
StandaloneSession pentahoSession = new StandaloneSession(username);
pentahoSession.setAuthenticated(username);
pentahoSession.setAttribute(IPentahoSession.TENANT_ID_KEY, tenant.getId());
final String password = "password";
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
authList.add(new SimpleGrantedAuthority("TenantAdmin"));
authList.add(new SimpleGrantedAuthority("Authenticated"));
UserDetails userDetails = new User(username, password, true, true, true, true, authList);
Authentication auth = new UsernamePasswordAuthenticationToken(userDetails, password, authList);
PentahoSessionHolder.setSession(pentahoSession);
// this line necessary for Spring Security's MethodSecurityInterceptor
SecurityContextHolder.getContext().setAuthentication(auth);
}
use of org.pentaho.platform.engine.core.system.StandaloneSession in project pentaho-platform by pentaho.
the class WsdlPageTest method setUp.
@Before
public void setUp() {
beforeTestCfg = AxisWebServiceManager.currentAxisConfiguration;
beforeTestCtx = AxisWebServiceManager.currentAxisConfigContext;
AxisConfiguration axisCfg = new AxisConfiguration();
AxisWebServiceManager.currentAxisConfiguration = axisCfg;
AxisWebServiceManager.currentAxisConfigContext = new ConfigurationContext(axisCfg);
out = new ByteArrayOutputStream();
IOutputHandler outputHandler = new SimpleOutputHandler(out, false);
outputHandler.setMimeTypeListener(new MimeTypeListener());
StandaloneSession session = new StandaloneSession("test");
StubServiceSetup serviceSetup = new StubServiceSetup();
serviceSetup.setSession(session);
contentGenerator = new AxisServiceWsdlGenerator();
contentGenerator.setOutputHandler(outputHandler);
contentGenerator.setMessagesList(new ArrayList<String>());
contentGenerator.setSession(session);
contentGenerator.setUrlFactory(new SimpleUrlFactory(BASE_URL + "?"));
}
Aggregations