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();
}
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();
}
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());
}
}
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();
}
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);
}
Aggregations