EMMA Coverage Report (generated Sun Mar 01 22:06:14 CET 2015)
[all classes][org.h2.engine]

COVERAGE SUMMARY FOR SOURCE FILE [SessionWithState.java]

nameclass, %method, %block, %line, %
SessionWithState.java100% (1/1)100% (3/3)90%  (80/89)95%  (20.9/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SessionWithState100% (1/1)100% (3/3)90%  (80/89)95%  (20.9/22)
recreateSessionState (): void 100% (1/1)81%  (38/47)89%  (8.9/10)
SessionWithState (): void 100% (1/1)100% (3/3)100% (1/1)
readSessionState (): void 100% (1/1)100% (39/39)100% (11/11)

1/*
2 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (http://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6package org.h2.engine;
7 
8import java.util.ArrayList;
9import org.h2.command.CommandInterface;
10import org.h2.result.ResultInterface;
11import org.h2.util.New;
12import org.h2.value.Value;
13 
14/**
15 * The base class for both remote and embedded sessions.
16 */
17abstract class SessionWithState implements SessionInterface {
18 
19    protected ArrayList<String> sessionState;
20    protected boolean sessionStateChanged;
21    private boolean sessionStateUpdating;
22 
23    /**
24     * Re-create the session state using the stored sessionState list.
25     */
26    protected void recreateSessionState() {
27        if (sessionState != null && sessionState.size() > 0) {
28            sessionStateUpdating = true;
29            try {
30                for (String sql : sessionState) {
31                    CommandInterface ci = prepareCommand(sql, Integer.MAX_VALUE);
32                    ci.executeUpdate();
33                }
34            } finally {
35                sessionStateUpdating = false;
36                sessionStateChanged = false;
37            }
38        }
39    }
40 
41    /**
42     * Read the session state if necessary.
43     */
44    public void readSessionState() {
45        if (!sessionStateChanged || sessionStateUpdating) {
46            return;
47        }
48        sessionStateChanged = false;
49        sessionState = New.arrayList();
50        CommandInterface ci = prepareCommand(
51                "SELECT * FROM INFORMATION_SCHEMA.SESSION_STATE",
52                Integer.MAX_VALUE);
53        ResultInterface result = ci.executeQuery(0, false);
54        while (result.next()) {
55            Value[] row = result.currentRow();
56            sessionState.add(row[1].getString());
57        }
58    }
59 
60}

[all classes][org.h2.engine]
EMMA 2.0.5312 (C) Vladimir Roubtsov