Search in sources :

Example 1 with SchedulerRMProxyFactory

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory in project scheduling by ow2-proactive.

the class SessionTest method testRenewSession.

/**
 * Check that session id does not change if {@link Session#renewSession} is called on an existing session instance.
 * The test also checks that {@link SchedulerProxyUserInterface#renewSession} is invoked on embedded scheduler
 * instance if available.
 *
 * @throws NotConnectedException
 */
@Test
public void testRenewSession() throws NotConnectedException {
    SchedulerRMProxyFactory schedulerProxyFactory = mock(SchedulerRMProxyFactory.class);
    SchedulerProxyUserInterface scheduler = mock(SchedulerProxyUserInterface.class);
    Session session = new Session("sessionId", schedulerProxyFactory, new Clock());
    session.setScheduler(scheduler);
    session.renewSession();
    Assert.assertEquals("sessionId", session.getSessionId());
    verify(scheduler).renewSession();
}
Also used : SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) Test(org.junit.Test)

Example 2 with SchedulerRMProxyFactory

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory in project scheduling by ow2-proactive.

the class SharedSessionStoreTestUtils method createValidSession.

public static String createValidSession(RMProxyUserInterface rm) throws ActiveObjectCreationException, NodeException, RMException, KeyException, LoginException {
    SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
    when(schedulerFactory.connectToRM(Matchers.<CredData>any())).thenReturn(rm);
    SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
    // login
    Session session = SharedSessionStore.getInstance().createUnnamedSession();
    session.connectToRM(new CredData());
    return session.getSessionId();
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData)

Example 3 with SchedulerRMProxyFactory

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory in project scheduling by ow2-proactive.

the class RestClientExceptionHandlerTest method client_handles_jetty_errors_500.

@Test
public void client_handles_jetty_errors_500() throws Exception {
    try {
        SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
        when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenThrow(new LoginException());
        SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
        SchedulerRestClient client = new SchedulerRestClient("http://localhost:" + port + "/");
        client.getScheduler().login("demo", "demo");
        fail("Should have throw an exception");
    } catch (WebApplicationException e) {
        assertTrue(e instanceof InternalServerErrorException);
        assertEquals(500, e.getResponse().getStatus());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) LoginException(javax.security.auth.login.LoginException) InternalServerErrorException(javax.ws.rs.InternalServerErrorException) SchedulerRMProxyFactory(org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory) Test(org.junit.Test)

Example 4 with SchedulerRMProxyFactory

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory in project scheduling by ow2-proactive.

the class SharedSessionStoreTestUtils method createValidSession.

public static String createValidSession(SchedulerProxyUserInterface scheduler) throws LoginException, ActiveObjectCreationException, SchedulerException, NodeException {
    SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
    when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenReturn(scheduler);
    SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
    // login
    Session session = SharedSessionStore.getInstance().createUnnamedSession();
    session.connectToScheduler(new CredData());
    return session.getSessionId();
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData)

Example 5 with SchedulerRMProxyFactory

use of org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory in project scheduling by ow2-proactive.

the class SessionSharingTest method setUp.

@Before
public void setUp() throws Exception {
    schedulerRest = new SchedulerStateRest();
    rmRest = new RMRest();
    studioRest = new StudioRest();
    SchedulerRMProxyFactory schedulerFactory = mock(SchedulerRMProxyFactory.class);
    rmMock = mock(RMProxyUserInterface.class);
    when(schedulerFactory.connectToRM(Matchers.<CredData>any())).thenReturn(rmMock);
    schedulerMock = mock(SchedulerProxyUserInterface.class);
    when(schedulerFactory.connectToScheduler(Matchers.<CredData>any())).thenReturn(schedulerMock);
    SharedSessionStore.getInstance().setSchedulerRMProxyFactory(schedulerFactory);
}
Also used : StudioRest(org.ow2.proactive_grid_cloud_portal.studio.StudioRest) SchedulerProxyUserInterface(org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface) SchedulerStateRest(org.ow2.proactive_grid_cloud_portal.scheduler.SchedulerStateRest) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) RMRest(org.ow2.proactive_grid_cloud_portal.rm.RMRest) SchedulerRMProxyFactory(org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory) Before(org.junit.Before)

Aggregations

Test (org.junit.Test)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 SchedulerProxyUserInterface (org.ow2.proactive.scheduler.common.util.SchedulerProxyUserInterface)2 SchedulerRMProxyFactory (org.ow2.proactive_grid_cloud_portal.common.SchedulerRMProxyFactory)2 LoginException (javax.security.auth.login.LoginException)1 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Before (org.junit.Before)1 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)1 RMRest (org.ow2.proactive_grid_cloud_portal.rm.RMRest)1 SchedulerStateRest (org.ow2.proactive_grid_cloud_portal.scheduler.SchedulerStateRest)1 StudioRest (org.ow2.proactive_grid_cloud_portal.studio.StudioRest)1