Search in sources :

Example 16 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class GridLogCommandHandlerTest method testHandleAsync.

/**
     * @throws Exception If failed.
     */
public void testHandleAsync() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setIgniteHome(igniteHome);
    GridTestKernalContext ctx = newContext(cfg);
    GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
    GridRestLogRequest req = new GridRestLogRequest();
    req.to(5);
    req.from(2);
    req.path(igniteHome + "/work/log/" + "test.log");
    IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
    assertNull(resp.result().getError());
    assertEquals(GridRestResponse.STATUS_SUCCESS, resp.result().getSuccessStatus());
    assertNotNull(resp.result().getResponse());
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridRestResponse(org.apache.ignite.internal.processors.rest.GridRestResponse) GridRestLogRequest(org.apache.ignite.internal.processors.rest.request.GridRestLogRequest)

Example 17 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class GridLogCommandHandlerTest method testHandleAsyncPathIsOutsideIgniteHome.

/**
     * @throws Exception If failed.
     */
public void testHandleAsyncPathIsOutsideIgniteHome() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setIgniteHome(igniteHome);
    GridTestKernalContext ctx = newContext(cfg);
    GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
    GridRestLogRequest req = new GridRestLogRequest();
    req.to(5);
    req.from(2);
    req.path("/home/users/mytest.log");
    IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
    assertEquals("Request parameter 'path' must contain a path to valid log file.", resp.result().getError());
    assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus());
    assertNull(resp.result().getResponse());
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridRestResponse(org.apache.ignite.internal.processors.rest.GridRestResponse) GridRestLogRequest(org.apache.ignite.internal.processors.rest.request.GridRestLogRequest)

Example 18 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class GridLogCommandHandlerTest method testHandleAsyncFromEqualTo.

/**
     * @throws Exception If failed.
     */
public void testHandleAsyncFromEqualTo() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setIgniteHome(igniteHome);
    GridTestKernalContext ctx = newContext(cfg);
    GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
    GridRestLogRequest req = new GridRestLogRequest();
    req.to(5);
    req.from(5);
    req.path(igniteHome + "/work/log/" + "test.log");
    IgniteInternalFuture<GridRestResponse> resp = cmdHandler.handleAsync(req);
    assertEquals("Request parameter 'from' must be less than 'to'.", resp.result().getError());
    assertEquals(GridRestResponse.STATUS_FAILED, resp.result().getSuccessStatus());
    assertNull(resp.result().getResponse());
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridRestResponse(org.apache.ignite.internal.processors.rest.GridRestResponse) GridRestLogRequest(org.apache.ignite.internal.processors.rest.request.GridRestLogRequest)

Example 19 with GridTestKernalContext

use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.

the class GridDeploymentManagerStopSelfTest method testOnKernalStop.

/**
     * @throws Exception If failed.
     */
public void testOnKernalStop() throws Exception {
    DeploymentSpi spi = new GridTestDeploymentSpi();
    GridTestKernalContext ctx = newContext();
    ctx.config().setMarshaller(new JdkMarshaller());
    ctx.config().setDeploymentSpi(spi);
    GridResourceProcessor resProc = new GridResourceProcessor(ctx);
    resProc.setSpringContext(null);
    ctx.add(resProc);
    GridComponent mgr = new GridDeploymentManager(ctx);
    try {
        mgr.onKernalStop(true);
    } catch (Exception e) {
        error("Error during onKernalStop() callback.", e);
        assert false : "Unexpected exception " + e;
    }
}
Also used : GridComponent(org.apache.ignite.internal.GridComponent) GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) GridResourceProcessor(org.apache.ignite.internal.processors.resource.GridResourceProcessor) DeploymentSpi(org.apache.ignite.spi.deployment.DeploymentSpi) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException)

Aggregations

GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)19 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)10 GridRestResponse (org.apache.ignite.internal.processors.rest.GridRestResponse)7 GridRestLogRequest (org.apache.ignite.internal.processors.rest.request.GridRestLogRequest)7 GridTimeoutProcessor (org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor)3 HashMap (java.util.HashMap)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 IgniteException (org.apache.ignite.IgniteException)2 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)2 GridClosureProcessor (org.apache.ignite.internal.processors.closure.GridClosureProcessor)2 PoolProcessor (org.apache.ignite.internal.processors.pool.PoolProcessor)2 GridResourceProcessor (org.apache.ignite.internal.processors.resource.GridResourceProcessor)2 GridRestCommand (org.apache.ignite.internal.processors.rest.GridRestCommand)2 NullLogger (org.apache.ignite.logger.NullLogger)2 MarshallerContextTestImpl (org.apache.ignite.marshaller.MarshallerContextTestImpl)2 DiscoverySpiCustomMessage (org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1