use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class InlineIndexColumnTest method testBytes.
/**
*/
@Test
public void testBytes() throws Exception {
DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, PAGE_SIZE, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), false);
pageMem.start();
long pageId = 0L;
long page = 0L;
try {
pageId = pageMem.allocatePage(CACHE_ID, 1, PageIdAllocator.FLAG_DATA);
page = pageMem.acquirePage(CACHE_ID, pageId);
long pageAddr = pageMem.readLock(CACHE_ID, pageId, page);
int off = 0;
IndexKeyTypeSettings keyTypeSettings = new IndexKeyTypeSettings().inlineObjHash(false).stringOptimizedCompare(false);
InlineIndexKeyType keyType = InlineIndexKeyTypeRegistry.get(Value.BYTES, keyTypeSettings);
int maxSize = 3 + 3;
int savedBytesCnt = keyType.put(pageAddr, off, idxKey(ValueBytes.get(new byte[] { 1, 2, 3, 4, 5 }), keyTypeSettings), maxSize);
assertTrue(savedBytesCnt > 0);
assertTrue(savedBytesCnt <= maxSize);
maxSize = 3 + 5;
assertTrue(Arrays.equals(new byte[] { 1, 2, 3 }, (byte[]) keyType.get(pageAddr, off, maxSize).key()));
savedBytesCnt = keyType.put(pageAddr, off, idxKey(ValueBytes.get(new byte[] { 1, 2, 3, 4, 5 }), keyTypeSettings), maxSize);
assertTrue(savedBytesCnt > 0);
assertTrue(savedBytesCnt <= maxSize);
assertTrue(Arrays.equals(new byte[] { 1, 2, 3, 4, 5 }, (byte[]) keyType.get(pageAddr, off, maxSize).key()));
} finally {
if (page != 0L)
pageMem.releasePage(CACHE_ID, pageId, page);
pageMem.stop(true);
}
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridLogCommandHandlerTest method testHandleAsyncFromAndToNotSet.
/**
* @throws Exception If failed.
*/
@Test
public void testHandleAsyncFromAndToNotSet() throws Exception {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteHome(igniteHome);
GridTestKernalContext ctx = newContext(cfg);
GridLogCommandHandler cmdHandler = new GridLogCommandHandler(ctx);
GridRestLogRequest req = new GridRestLogRequest();
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());
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridQueryCommandHandlerTest method testUnsupportedCommands.
/**
* @throws Exception If failed.
*/
@Test
public void testUnsupportedCommands() throws Exception {
GridTestKernalContext ctx = newContext(grid().configuration());
ctx.add(new GridTimeoutProcessor(ctx));
QueryCommandHandler cmdHnd = new QueryCommandHandler(ctx);
Collection<GridRestCommand> commands = cmdHnd.supportedCommands();
assertFalse(commands.contains(GridRestCommand.LOG));
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridLogCommandHandlerTest method testHandleAsyncPathIsOutsideIgniteHome.
/**
* @throws Exception If failed.
*/
@Test
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());
}
use of org.apache.ignite.testframework.junits.GridTestKernalContext in project ignite by apache.
the class GridLogCommandHandlerTest method testHandleAsync.
/**
* @throws Exception If failed.
*/
@Test
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());
}
Aggregations