use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory 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.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class MimeTypeListFactoryIT method testGetMimeTypeList.
@Test
public void testGetMimeTypeList() throws Exception {
MicroPlatform microPlatform = new MicroPlatform();
StandaloneSpringPentahoObjectFactory objectFactory = new StandaloneSpringPentahoObjectFactory();
objectFactory.init(TestResourceLocation.TEST_RESOURCES + "/MimeTypeFactoryTest/MimeTypeFactoryTest.spring.xml", null);
PentahoSystem.registerObjectFactory(objectFactory);
MimeTypeListFactory factory = new MimeTypeListFactory(TestResourceLocation.TEST_RESOURCES + "/MimeTypeFactoryTest/ImportHandlerMimeTypeDefinitions.xml");
List<IMimeType> list1 = factory.createMimeTypeList("org.pentaho.platform.plugin.services.importer.RepositoryFileImportFileHandler");
assertNotNull(list1);
list1 = factory.createMimeTypeList("this.one.is.not.present");
assertNotNull(list1);
assertEquals(0, list1.size());
list1 = factory.createMimeTypeList("org.pentaho.platform.plugin.services.importer.SolutionImportHandler");
assertNotNull(list1);
assertTrue(list1.size() > 0);
list1 = factory.createMimeTypeList("com.pentaho.repository.importexport.PDIImportFileHandler");
assertNotNull(list1);
assert (list1.contains(new MimeType("application/vnd.pentaho.job", "ktr")));
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class BaseTest method setUp.
@Override
public void setUp() {
// used by test repository impl such as FileSystemRepositoryFileDao
System.setProperty("solution.root.dir", getSolutionPath());
messages = TestManager.getMessagesList();
if (messages == null) {
messages = new ArrayList<String>();
}
if (initOk) {
return;
}
PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
if (PentahoSystem.getApplicationContext() == null) {
// $NON-NLS-1$
StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
// set the base url assuming there is a running server on port 8080
applicationContext.setFullyQualifiedServerURL(getFullyQualifiedServerURL());
// $NON-NLS-1$ //$NON-NLS-2$
String inContainer = System.getProperty("incontainer", "false");
if (inContainer.equalsIgnoreCase("false")) {
// $NON-NLS-1$
// Setup simple-jndi for datasources
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.root", getSolutionPath() + "/system/simple-jndi");
// $NON-NLS-1$ //$NON-NLS-2$
System.setProperty("org.osjava.sj.delimiter", "/");
}
ApplicationContext springApplicationContext = getSpringApplicationContext();
IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
pentahoObjectFactory.init(null, springApplicationContext);
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
// force Spring to inject PentahoSystem, there has got to be a better way than this, perhaps an alternate way
// of
// initting spring's app context
// $NON-NLS-1$
springApplicationContext.getBean("pentahoSystemProxy");
// Initialize SecurityHelper with a mock for testing
SecurityHelper.setMockInstance(new MockSecurityHelper());
initOk = PentahoSystem.init(applicationContext);
} else {
initOk = true;
}
// $NON-NLS-1$
assertTrue(Messages.getInstance().getString("BaseTest.ERROR_0001_FAILED_INITIALIZATION"), initOk);
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project data-access by pentaho.
the class DataSourcePublishIT method setUpClass.
@BeforeClass
public static void setUpClass() throws Exception {
// folder cannot be deleted at teardown shutdown hooks have not yet necessarily completed
// parent folder must match jcrRepository.homeDir bean property in repository-test-override.spring.xml
FileUtils.deleteDirectory(new File("/tmp/repository-future/jackrabbit-test-TRUNK"));
PentahoSessionHolder.setStrategyName(PentahoSessionHolder.MODE_GLOBAL);
// register repository spring context for correct work of <pen:list>
final StandaloneSpringPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
GenericApplicationContext appCtx = new GenericApplicationContext();
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
xmlReader.loadBeanDefinitions("classpath:/repository.spring.xml");
xmlReader.loadBeanDefinitions("classpath:/solutionACL/system/repository-test-override.spring.xml");
xmlReader.loadBeanDefinitions("classpath:/solutionACL/system/importExport.xml");
xmlReader.loadBeanDefinitions("classpath:/solutionACL/system/pentahoObjects.spring.xml");
xmlReader.loadBeanDefinitions("classpath:/jackrabbit-test-repo.xml");
pentahoObjectFactory.init(null, appCtx);
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
FileUtils.deleteDirectory(new File("/tmp/data-access/jackrabbit-test-TRUNK"));
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory in project pentaho-platform by pentaho.
the class SystemResourceIT method setUp.
@Before
public void setUp() throws Exception {
mp = new MicroPlatform();
mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
mp.start();
ISystemConfig systemConfig = new SystemConfig();
IConfiguration securityConfig = mock(IConfiguration.class);
Properties props = new Properties();
props.setProperty("provider", "jackrabbit");
when(securityConfig.getProperties()).thenReturn(props);
when(securityConfig.getId()).thenReturn("security");
systemConfig.registerConfiguration(securityConfig);
systemResource = new SystemResource(systemConfig);
// $NON-NLS-1$
StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(getSolutionPath(), "");
ApplicationContext springApplicationContext = getSpringApplicationContext();
IPentahoObjectFactory pentahoObjectFactory = new StandaloneSpringPentahoObjectFactory();
pentahoObjectFactory.init(null, springApplicationContext);
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
// force Spring to populate PentahoSystem
boolean initOk = PentahoSystem.init(applicationContext);
/*
* StandaloneSession session = new StandaloneSession();
*
* StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory( );
*
* File f = new File(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml"); FileSystemResource fsr = new
* FileSystemResource(f); GenericApplicationContext appCtx = new GenericApplicationContext();
* XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx); xmlReader.loadBeanDefinitions(fsr);
*
* factory.init(TestResourceLocation.TEST_RESOURCES + "/solution/system/pentahoObjects.spring.xml", appCtx );
*/
}
Aggregations