use of com.google.cloud.language.v1.Token in project bayou by capergroup.
the class TokenStream method pop.
// returns and removes the next token in the stream
private Token pop(boolean performHeadNullCheck) {
if (performHeadNullCheck && _head == null)
throw new IllegalStateException();
Token toReturn = _head;
_head = _next;
if (!_tokens.hasNext()) {
_next = null;
} else {
_next = _tokens.next();
if (_next == null)
throw new IllegalStateException("_tokens may not contain null");
}
return toReturn;
}
use of com.google.cloud.language.v1.Token in project bayou by capergroup.
the class EvidenceLLexerTests method testLexAlternating.
@Test
public void testLexAlternating() {
EvidenceLLexer lexer = makeLexer();
Iterator<Token> tokens = lexer.lex("ident1:ident2:ident3").iterator();
Assert.assertTrue(tokens.hasNext());
Token token = tokens.next();
Assert.assertEquals("ident1", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
token = tokens.next();
Assert.assertEquals(":", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeColon);
token = tokens.next();
Assert.assertEquals("ident2", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
token = tokens.next();
Assert.assertEquals(":", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeColon);
token = tokens.next();
Assert.assertEquals("ident3", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
}
use of com.google.cloud.language.v1.Token in project bayou by capergroup.
the class EvidenceLLexerTests method testLexMixed1.
@Test
public void testLexMixed1() {
EvidenceLLexer lexer = makeLexer();
Iterator<Token> tokens = lexer.lex("ident1: ident2, ident3").iterator();
Assert.assertTrue(tokens.hasNext());
Token token = tokens.next();
Assert.assertEquals("ident1", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
token = tokens.next();
Assert.assertEquals(":", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeColon);
token = tokens.next();
Assert.assertEquals("ident2", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
token = tokens.next();
Assert.assertEquals(",", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeComma);
token = tokens.next();
Assert.assertEquals("ident3", token.getLexeme());
Assert.assertTrue(token.getType() instanceof TokenTypeIdentifier);
}
use of com.google.cloud.language.v1.Token in project platformlayer by platformlayer.
the class SmokeTest method buildFakeToken.
private KeystoneAuthenticationToken buildFakeToken(String tokenCode) {
Access auth = new Access();
Token tokenObject = new Token();
tokenObject.setId(tokenCode);
auth.setToken(tokenObject);
return new KeystoneAuthenticationToken(auth);
}
use of com.google.cloud.language.v1.Token in project openstack4j by ContainX.
the class OSAuthenticator method reAuthenticate.
/**
* Re-authenticates/renews the token for the current Session
*/
@SuppressWarnings("rawtypes")
public static void reAuthenticate() {
LOG.debug("Re-Authenticating session due to expired Token or invalid response");
OSClientSession session = OSClientSession.getCurrent();
switch(session.getAuthVersion()) {
case V2:
KeystoneAccess access = ((OSClientSessionV2) session).getAccess().unwrap();
SessionInfo info = new SessionInfo(access.getEndpoint(), session.getPerspective(), true, session.getProvider());
Auth auth = (Auth) ((access.isCredentialType()) ? access.getCredentials() : access.getTokenAuth());
authenticateV2((org.openstack4j.openstack.identity.v2.domain.Auth) auth, info, session.getConfig());
break;
case V3:
default:
Token token = ((OSClientSessionV3) session).getToken();
info = new SessionInfo(token.getEndpoint(), session.getPerspective(), true, session.getProvider());
authenticateV3((KeystoneAuth) token.getCredentials(), info, session.getConfig());
break;
}
}
Aggregations