@Test public void testGetTokens() { final String input = "string with; tokens ; delimited by ; ; semicolons; there;; are 7 tokens."; //$NON-NLS-1$ final List<String> tokens = StringUtil.getTokens(input,";"); //$NON-NLS-1$ assertEquals(7, tokens.size()); assertEquals("string with", tokens.get(0)); //$NON-NLS-1$ assertEquals(" tokens ", tokens.get(1)); //$NON-NLS-1$ assertEquals(" delimited by ", tokens.get(2)); //$NON-NLS-1$ assertEquals(" ", tokens.get(3)); //$NON-NLS-1$ assertEquals(" semicolons", tokens.get(4)); //$NON-NLS-1$ assertEquals(" there", tokens.get(5)); //$NON-NLS-1$ assertEquals(" are 7 tokens.", tokens.get(6)); //$NON-NLS-1$ }
public AccumuloConnectionImpl(AccumuloManagedConnectionFactory mcf, ZooKeeperInstance inst) throws ResourceException { try { if (mcf.getRoles() != null) { List<String> auths = StringUtil.getTokens(mcf.getRoles(), ","); //$NON-NLS-1$ this.roles = auths.toArray(new String[auths.size()]); } String userName = mcf.getUsername(); String password = mcf.getPassword(); // if security-domain is specified and caller identity is used; then use // credentials from subject Subject subject = ConnectionContext.getSubject(); if (subject != null) { userName = ConnectionContext.getUserName(subject, mcf, userName); password = ConnectionContext.getPassword(subject, mcf, userName, password); this.roles = ConnectionContext.getRoles(subject, this.roles); } checkTabletServerExists(inst, userName, password); this.conn = (ConnectorImpl) inst.getConnector(userName, new PasswordToken(password)); } catch (AccumuloException e) { throw new ResourceException(e); } catch (AccumuloSecurityException e) { throw new ResourceException(e); } }
public AccumuloConnectionImpl(AccumuloManagedConnectionFactory mcf, ZooKeeperInstance inst) throws ResourceException { try { if (mcf.getRoles() != null) { List<String> auths = StringUtil.getTokens(mcf.getRoles(), ","); //$NON-NLS-1$ this.roles = auths.toArray(new String[auths.size()]); } String userName = mcf.getUsername(); String password = mcf.getPassword(); // if security-domain is specified and caller identity is used; then use // credentials from subject Subject subject = ConnectionContext.getSubject(); if (subject != null) { userName = ConnectionContext.getUserName(subject, mcf, userName); password = ConnectionContext.getPassword(subject, mcf, userName, password); this.roles = ConnectionContext.getRoles(subject, this.roles); } checkTabletServerExists(inst, userName, password); this.conn = (ConnectorImpl) inst.getConnector(userName, new PasswordToken(password)); } catch (AccumuloException e) { throw new ResourceException(e); } catch (AccumuloSecurityException e) { throw new ResourceException(e); } }