Permalink
Browse files

ISPN-2978 Allow executing the interpreter with a throwaway session

  • Loading branch information...
1 parent 9ca3bf0 commit dc6ff488bda75b8994adda6204a4e3eee22bdd0a @tristantarrant tristantarrant committed with Mircea Markus Mar 28, 2013
@@ -189,7 +189,12 @@ void expireSessions() {
}
private Session validateSession(final String sessionId) {
- if (sessionId == null || !sessions.containsKey(sessionId)) {
+ if (sessionId == null) {
+ Session session = new SessionImpl(codecRegistry, cacheManager, null);
+ session.setCurrentCache(BasicCacheContainer.DEFAULT_CACHE_NAME);
+ return session;
+ }
+ if (!sessions.containsKey(sessionId)) {
throw log.invalidSession(sessionId);
}
return sessions.get(sessionId);
@@ -198,4 +198,11 @@ public void testParserErrors() throws Exception {
Map<String, String> response = interpreter.execute(sessionId, "got a;");
assertTrue(response.containsKey(ResultKeys.ERROR.toString()));
}
+
+ public void testTemporarySession() throws Exception {
+ Interpreter interpreter = getInterpreter();
+ Map<String, String> response = interpreter.execute(null, "put 'a' 'a';");
+ assertFalse(response.containsKey(ResultKeys.ERROR.toString()));
+ assertEquals("a", (String)cache.get("a"));
+ }
}

0 comments on commit dc6ff48

Please sign in to comment.