ModelStorateThinClientProcessor implements CustomQueryProcessor { private ClientResponse error(long requestId, String msg) { return new ClientResponse(requestId, msg); } ModelStorateThinClientProcessor(ModelStorage modelStorage); @Override ClientResponse call(long requestId, byte methodId, BinaryRawReader reader); @Override String id(); static final String PROCESSOR_ID; }
@Test public void testReadDirectory() { long reqId = 2; BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.READ_FILE); message.writeString("/a/b"); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); assertEquals(ClientStatus.FAILED, resp.status()); assertFalse(resp.error().isEmpty()); }
@Test public void testReadUnexistedFile() { long reqId = 3; BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.READ_FILE); message.writeString("/a/b/unexisted_file"); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); assertEquals(ClientStatus.FAILED, resp.status()); assertFalse(resp.error().isEmpty()); }
@Test public void testMoveWithExistedName() { long reqId = 7; String from = "/a/b/testMoveWithExistedName"; ms.putFile(from, file1); String to = pathToFile1; BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.MOVE); message.writeString(from); message.writeString(to); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); assertEquals(ClientStatus.FAILED, resp.status()); assertFalse(resp.error().isEmpty()); }
@Test public void testListFiles2() { long reqId = 17; BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.LIST_FILES); message.writeString(pathToFile1); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); assertEquals(ClientStatus.FAILED, resp.status()); assertFalse(resp.error().isEmpty()); }
@Test public void testListFiles3() { long reqId = 17; BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.LIST_FILES); message.writeString("/test/list/files/3/unexisted_file"); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); assertEquals(ClientStatus.FAILED, resp.status()); assertFalse(resp.error().isEmpty()); }
@Test public void testPutFile2() { long reqId = 20; String path = "/a/b/testPutFile2"; boolean create = false; boolean append = false; byte[] data = new byte[] {6, 5, 4, 3, 2, 1, 0}; BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.WRITE_FILE); message.writeString(path); message.writeBoolean(create); message.writeBoolean(append); message.writeByteArray(data); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); assertEquals(ClientStatus.FAILED, resp.status()); assertFalse(resp.error().isEmpty()); }
@Test public void testPutFile3() { long reqId = 21; String path = "/a/b/testPutFile3"; boolean create = false; boolean append = true; byte[] data = new byte[] {6, 5, 4, 3, 2, 1, 0}; BinaryRawWriterEx message = createMessage(reqId, ModelStorateThinClientProcessor.PROCESSOR_ID, ModelStorateThinClientProcessor.Method.WRITE_FILE); message.writeString(path); message.writeBoolean(create); message.writeBoolean(append); message.writeByteArray(data); ClientCustomQueryRequest req = new ClientCustomQueryRequest(toReader(message)); ClientResponse resp = req.process(connCtx); assertEquals(ClientStatus.FAILED, resp.status()); assertFalse(resp.error().isEmpty()); }