Search in sources :

Example 16 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class EmailServiceIT method setUp.

@Override
public void setUp() throws Exception {
    mp = new MicroPlatform();
    mp.defineInstance(IAuthorizationPolicy.class, new TestAuthorizationPolicy());
    mp.start();
    // Setup the temp directory
    tempDir = File.createTempFile("EmailServiceTest", "");
    assertTrue("Error setting up testing scenario", tempDir.delete());
    assertTrue("Error setting up testing scenario", tempDir.mkdir());
    tempDir.deleteOnExit();
    final File systemDir = new File(tempDir, "system");
    assertTrue("Error setting up testing scenario", systemDir.mkdir());
    final File configDir = new File(systemDir, "smtp-email");
    assertTrue("Error setting up testing scenario", configDir.mkdir());
    defaultConfigFile = new File(configDir, "email_config.xml");
    assertTrue("Error setting up testing scenario", defaultConfigFile.createNewFile());
    PentahoSystem.setApplicationContext(new MockApplicationContext(tempDir.getAbsolutePath()));
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) File(java.io.File)

Example 17 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class MetadataImportHandlerIT method setUp.

@Before
public void setUp() throws Exception {
    // mock logger to prevent npe
    importLogger = new Log4JRepositoryImportLogger();
    context = new Mockery();
    metadataImporter = context.mock(IPentahoMetadataDomainRepositoryImporter.class);
    MicroPlatform microPlatform = new MicroPlatform();
    NameBaseMimeResolver nameResolver = new NameBaseMimeResolver();
    microPlatform.defineInstance(IPlatformMimeResolver.class, nameResolver);
    List<IMimeType> mimeList = new ArrayList<IMimeType>();
    mimeList.add(new MimeType("text/xmi+xml", "xmi"));
    metadataHandler = new MetadataImportHandler(mimeList, metadataImporter);
    handlers.add(metadataHandler);
    importer = new PentahoPlatformImporter(handlers, new DefaultRepositoryContentConverterHandler(new HashMap<String, Converter>()));
    importer.setRepositoryImportLogger(importLogger);
}
Also used : ArrayList(java.util.ArrayList) Mockery(org.jmock.Mockery) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) MimeType(org.pentaho.platform.core.mimetype.MimeType) IPentahoMetadataDomainRepositoryImporter(org.pentaho.platform.plugin.services.metadata.IPentahoMetadataDomainRepositoryImporter) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) Log4JRepositoryImportLogger(org.pentaho.platform.plugin.services.importexport.Log4JRepositoryImportLogger) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Converter(org.pentaho.platform.api.repository2.unified.Converter) Before(org.junit.Before)

Example 18 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class SolutionImportHandlerIT method init.

@Before
public void init() throws PlatformInitializationException, SchedulerException {
    MicroPlatform mp = new MicroPlatform();
    mp.define("IScheduler", TestQuartzScheduler.class);
    mp.define(IUserRoleListService.class, StubUserRoleListService.class);
    IAuthorizationPolicy policy = mock(IAuthorizationPolicy.class);
    when(policy.isAllowed(anyString())).thenReturn(true);
    mp.defineInstance(IAuthorizationPolicy.class, policy);
    mp.start();
    scheduler = PentahoSystem.get(IScheduler.class);
    scheduler.start();
}
Also used : IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) Before(org.junit.Before)

Example 19 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform 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")));
}
Also used : IMimeType(org.pentaho.platform.api.mimetype.IMimeType) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) MimeType(org.pentaho.platform.core.mimetype.MimeType) IMimeType(org.pentaho.platform.api.mimetype.IMimeType) StandaloneSpringPentahoObjectFactory(org.pentaho.platform.engine.core.system.objfac.StandaloneSpringPentahoObjectFactory) Test(org.junit.Test)

Example 20 with MicroPlatform

use of org.pentaho.test.platform.engine.core.MicroPlatform in project pentaho-platform by pentaho.

the class MondrianCatalogRepositoryHelperIT method setUpClass.

@BeforeClass
public static void setUpClass() throws Exception {
    MicroPlatform platform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
    platform.defineInstance("inlineModeling", new MondrianSchemaAnnotator() {

        @Override
        public InputStream getInputStream(final InputStream schemaInputStream, final InputStream annotationsInputStream) {
            return new java.io.SequenceInputStream(schemaInputStream, annotationsInputStream);
        }
    });
    platform.start();
}
Also used : MondrianSchemaAnnotator(org.pentaho.platform.api.repository2.unified.MondrianSchemaAnnotator) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) BeforeClass(org.junit.BeforeClass)

Aggregations

MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)64 Before (org.junit.Before)40 File (java.io.File)15 Test (org.junit.Test)12 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)10 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)10 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)10 RepositoryFileProxyFactory (org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)9 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)8 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)8 BeforeClass (org.junit.BeforeClass)7 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)6 ArrayList (java.util.ArrayList)5 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)5 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)5 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)5 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ITenant (org.pentaho.platform.api.mt.ITenant)4