Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.mapdb;
 
 import org.junit.Test;
 
 
 import static org.junit.Assert.assertTrue;
 
public class Issue164Test {
    public static class Scenario implements Serializable {
        private static final long serialVersionUID = 1L;
        protected String id = null;
        protected String brief = null;
        protected String headNodeId = null;
        protected HashSet nodeIdSet = null;
        public Scenario() {
             = Long.toHexString(System.nanoTime());
             = null;
             = null;
             = null;
        }
        public void setId(String arg_id) {
            synchronized(this) {
                 = arg_id;
            }
        }
        public String getId() {
            synchronized(this) {
                return ;
            }
        }
        public void setBrief(String arg_brief) {
            synchronized(this) {
                 = arg_brief;
            }
        }
        public String getBrief() {
            synchronized(this) {
                return ;
            }
        }
        public String getHeadNodeId() {
            synchronized(this) {
                return ;
            }
        }
        public void setHeadNodeId(String arg_header_node_id) {
            synchronized(this) {
                 = arg_header_node_id;
                if (!.contains(arg_header_node_id))
                    .add(arg_header_node_id);
            }
        }
        public void addConversationNodeId(String arg_conversation_node_idthrows Exception {
            synchronized(this) {
                if ( == null) {
                     = arg_conversation_node_id;
                    .add(arg_conversation_node_id);
                }
                else
                    throw new Exception();
            } // of synchronized(this)
        }
        public void removeConversationNodeId(String arg_conversation_node_id) {
            synchronized(this) {
                if ( != null) {
                    .remove(arg_conversation_node_id);
                    if (arg_conversation_node_id.equals())
                         = null// the set is empty now
                }
            } // of synchronized(this)
        }
    }
    @Test
    public void main() {
        int rc = 0;
        BTreeMap map=null;
        try {
            DB db = DBMaker.newMemoryDB()
                    .closeOnJvmShutdown()
                    .make();
// the following test shows that the db is opened if it always exists
            map = db.getTreeMap("test");
            if (!map.containsKey("t1")) {
                map.put("t1"new Scenario());
                db.commit();
            }
            rc = 1;
        } catch(Exception ex) {
            rc = -1;
        }
        assertTrue(map.get("t1")!=null);
        assertTrue(rc > 0);
    }
New to GrepCode? Check out our FAQ X