Search in sources :

Example 36 with MicroPlatform

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

the class PentahoBlockoutManagerIT method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    MicroPlatform mp = new MicroPlatform();
    mp.define(IPluginManager.class, TstPluginManager.class);
    // $NON-NLS-1$
    mp.define("IScheduler2", TestQuartzScheduler.class);
    mp.define(IUserRoleListService.class, StubUserRoleListService.class);
    mp.define(UserDetailsService.class, StubUserDetailsService.class);
    mp.define(IBlockoutManager.class, PentahoBlockoutManager.class);
    mp.start();
    blockOutManager = new PentahoBlockoutManager();
    // $NON-NLS-1$;
    scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
    jobIdsToClear.clear();
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) Before(org.junit.Before)

Example 37 with MicroPlatform

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

the class QuartzSchedulerIT method init.

@Before
public void init() throws SchedulerException, PlatformInitializationException {
    scheduler = new QuartzScheduler();
    scheduler.start();
    TestAction.reset();
    TestAction2.reset();
    TestAction3.reset();
    TestActionCustomParam.reset();
    MicroPlatform mp = new MicroPlatform();
    // $NON-NLS-1$
    mp.define("IScheduler2", TestQuartzScheduler.class);
    mp.define(IUserRoleListService.class, StubUserRoleListService.class);
    mp.define(UserDetailsService.class, StubUserDetailsService.class);
    mp.define(IAuditEntry.class, TestAuditEntry.class);
    mp.start();
    SecurityHelper.getInstance().becomeUser(TEST_USER);
    jobParams = new HashMap<String, Serializable>();
}
Also used : Serializable(java.io.Serializable) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) TestQuartzScheduler(org.pentaho.platform.scheduler2.ws.test.TestQuartzScheduler) QuartzScheduler(org.pentaho.platform.scheduler2.quartz.QuartzScheduler) Before(org.junit.Before)

Example 38 with MicroPlatform

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

the class DefaultUnifiedRepositoryBase method initialize.

public void initialize(boolean multiByteEncoding) throws Exception {
    loginAsRepositoryAdmin();
    SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
    mp = new MicroPlatform(getSolutionPath());
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance("ILockHelper", new DefaultLockHelper(userNameUtils));
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(this.jcrTemplate, this.repositoryFileDao));
    mp.defineInstance("ITenantedPrincipleNameResolver", new DefaultTenantedPrincipleNameResolver());
    mp.defineInstance("useMultiByteEncoding", multiByteEncoding);
    mp.defineInstance(IUnifiedRepository.class, repo);
    mp.defineInstance(IRepositoryFileAclDao.class, repositoryFileAclDao);
    IUserRoleListService userRoleListService = mock(IUserRoleListService.class);
    when(userRoleListService.getRolesForUser(any(ITenant.class), anyString())).thenReturn(Arrays.asList(tenantAdminRoleName, AUTHENTICATED_ROLE_NAME));
    mp.defineInstance(IUserRoleListService.class, userRoleListService);
    mp.defineInstance("singleTenantAdminUserName", singleTenantAdminUserName);
    mp.defineInstance("singleTenantAdminAuthorityName", tenantAdminRoleName);
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
    userRoleDao.createUser(systemTenant, sysAdminUserName, PASSWORD, "", new String[] { tenantAdminRoleName });
    logout();
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) DefaultLockHelper(org.pentaho.platform.repository2.unified.jcr.DefaultLockHelper) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) DefaultTenantedPrincipleNameResolver(org.pentaho.platform.security.userroledao.DefaultTenantedPrincipleNameResolver) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory)

Example 39 with MicroPlatform

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

the class DefaultDeleteHelperTest method setUp.

@Before
public void setUp() throws Exception {
    mp = new MicroPlatform(getSolutionPath());
    IPentahoSession pentahoSession = mock(IPentahoSession.class);
    when(pentahoSession.getName()).thenReturn("test");
    PentahoSessionHolder.setSession(pentahoSession);
    session = mock(Session.class);
    final Node rootNode = mock(Node.class);
    when(session.getRootNode()).thenReturn(rootNode);
    when(session.getNamespacePrefix(anyString())).thenReturn("prefix:");
    pentahoJcrConstants = new PentahoJcrConstants(session);
    pathConversionHelper = mock(IPathConversionHelper.class);
    lockHelper = mock(ILockHelper.class);
    defaultDeleteHelper = new DefaultDeleteHelper(lockHelper, pathConversionHelper);
    final RepositoryFileProxy repositoryFileProxy = mock(RepositoryFileProxy.class);
    final RepositoryFileProxyFactory repositoryFileProxyFactory = mock(RepositoryFileProxyFactory.class);
    when(repositoryFileProxyFactory.getProxy(Matchers.<Node>anyObject(), Matchers.<IPentahoLocale>anyObject())).thenReturn(repositoryFileProxy);
    // set file ID to random value to make different files not equal
    when(repositoryFileProxy.getId()).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return String.valueOf(new Random().nextDouble());
        }
    });
    when(repositoryFileProxy.getTitle()).thenReturn("title");
    mp.defineInstance(RepositoryFileProxyFactory.class, repositoryFileProxyFactory);
    mp.start();
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Node(javax.jcr.Node) Random(java.util.Random) InvocationOnMock(org.mockito.invocation.InvocationOnMock) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Session(javax.jcr.Session) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) Before(org.junit.Before)

Example 40 with MicroPlatform

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

the class JcrStringHelperTest method testFilePath_1EncodeUsingMultiByteEncoding.

@Test
public void testFilePath_1EncodeUsingMultiByteEncoding() throws PlatformInitializationException {
    MicroPlatform mp = new MicroPlatform(getSolutionPath());
    mp.defineInstance("useMultiByteEncoding", new Boolean(true));
    // Start the micro-platform
    mp.start();
    JcrStringHelper.setMultiByteEncodingEnabled(true);
    String path = "/asdf/3err";
    String encodedPath = JcrStringHelper.pathEncode(path);
    assertFalse(path.equals(encodedPath));
    assertEquals("/asdf/_x0033_err", encodedPath);
}
Also used : MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) Test(org.junit.Test)

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