use of net.imagej.omero.OMEROSession in project imagej-omero by imagej.
the class OmeroIT method testUploadTable.
@Test
public void testUploadTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
final byte[][] d = new byte[][] { { 127, 0, -128 }, { -1, -6, -23 }, { 100, 87, 4 } };
final ByteTable table = new DefaultByteTable(3, 3);
for (int c = 0; c < table.getColumnCount(); c++) {
table.setColumnHeader(c, "Heading " + (c + 1));
for (int r = 0; r < table.getRowCount(); r++) table.set(c, r, d[c][r]);
}
final long tableId = omero.uploadTable(cred, "test-table-upload", table, 1);
// When upload table was called it created a session, which cleared out
// the username and password from the credentials. The credentials must
// have a username and password to create security contexts.
final OMEROCredentials tc = new OMEROCredentials();
tc.setServer(OMERO_SERVER);
tc.setPort(OMERO_PORT);
tc.setUser(OMERO_USER);
tc.setPassword(OMERO_PASSWORD);
try (final OMEROSession session = new DefaultOMEROSession(tc)) {
final TablesFacility tablesFacility = session.getGateway().getFacility(TablesFacility.class);
final TableData td = tablesFacility.getTableInfo(session.getSecurityContext(), tableId);
assertEquals(td.getColumns().length, 3);
assertEquals(td.getColumns()[0].getName(), "Heading 1");
assertEquals(td.getColumns()[1].getName(), "Heading 2");
assertEquals(td.getColumns()[2].getName(), "Heading 3");
assertEquals(td.getNumberOfRows(), 3);
}
}
Aggregations