Package de.danet.an.util.persistentmaps

Examples of de.danet.an.util.persistentmaps.JDBCPersistentMap$MapValue


    /**
     * Testing null and "" distinction.
     * @exception Exception if an error occurs
     */
    public void nullString() throws Exception {
  JDBCPersistentMap map
      = new JDBCPersistentMap(null, "Danet","DefaultPersistenceMap");
  map.setConnection(con);
  map.put("nullString", null);
  map.put("emptyString", "");
  map.store();
  map.load();
  assertTrue (map.get ("nullString") == null);
  assertTrue (map.get("emptyString").equals (""));
    }
View Full Code Here


    /**
     * Test setting of IDs
     * @exception Exception if an error occurs
     */
    public void setID() throws Exception {
  JDBCPersistentMap testMap = new JDBCPersistentMap(null, "Danet");
  assertTrue(!testMap.isModified());
  testMap.setConnection(con);
  assertTrue(!testMap.isModified());
  testMap.put("HSc", "Holger Schl�ter");
  assertTrue(testMap.isModified());
  testMap.put("MSc", "Matthias Schirm");
  testMap.setConnection(con);
  assertTrue(testMap.isModified());
  testMap.store();
  assertTrue(!testMap.isModified());
  testMap.setMapId("Dnaet");
  assertTrue(!testMap.isModified());
  testMap.load();
  assertTrue(!testMap.isModified());
  assertTrue(testMap.size() == 0);
  testMap.setMapId("Danet");
  testMap.load();
  assertTrue(testMap.size() == 2);
  testMap.clear();
  testMap.store();
    }
View Full Code Here

     * Test storing an reloading of a map for a given connection
     * @exception Exception if an error occurs
     * @param usecon connection to be used
     */
    private void storeAndLoadCon(Connection useCon) throws Exception {
  JDBCPersistentMap storeMap = new JDBCPersistentMap(null, "Danet");
  storeMap.setConnection(useCon);
  assertTrue(storeMap.maxKeyLength() == 50);
  assertTrue(!storeMap.isModified());
  storeMap.put("HSc", "Holger Schl�ter");
  assertTrue(storeMap.isModified());
  storeMap.put("MSc", "Matthias Schirm");
  storeMap.put("ML", "Dr. Michael Lipp");
  storeMap.put("GB", "Gunnar von de Beck");
  StringBuffer sb = new StringBuffer ();
  for (int i = 0; i < 1600; i++) {
      sb.append ("0123456789");
  }
  String longString = sb.toString ();
  storeMap.put("LONG", longString);
  storeMap.put("INT", new Integer(1307));
  storeMap.put("NULL", null);
  boolean exceptionCaught = false;
  try {
      storeMap.put(null, null);
  } catch (IllegalArgumentException exc) {
      exceptionCaught = true;
  }
  assertTrue(exceptionCaught);
  storeMap.store();
  storeMap.store();
  JDBCPersistentMap loadMap = new JDBCPersistentMap(null, "Danet");
  loadMap.setConnection(useCon);
  loadMap.load();
  // Verfiy that maps do match
  assertTrue(loadMap.size() == 7);
//   for (Iterator i = loadMap.entrySet().iterator(); i.hasNext ();) {
//       Map.Entry e = (Map.Entry)i.next ();
//       assertTrue ("Got: " + e.getValue() + " != Put: "
//       + storeMap.get (e.getKey()),
//       e.getValue ().equals (storeMap.get (e.getKey())));
View Full Code Here

     * Test modifying and removing map values.
     * @param usecon connection to be used
     * @exception Exception if an error occurs
     */
    private void modifyAndRemoveCon(Connection useCon) throws Exception {
  JDBCPersistentMap storeMap = new JDBCPersistentMap(null, "Danet");
  storeMap.setConnection(useCon);
  storeMap.load();
  assertTrue(!storeMap.isModified());
  storeMap.remove("HSc");
  assertTrue(storeMap.isModified());
  storeMap.remove("MSc");
  storeMap.remove("RSc");
  storeMap.put("ML", "Dr. Michael Lipp");
  storeMap.put("ROt", "Ralf Ott");
  storeMap.put("HDO", null);
  storeMap.put("ALM", "Alex M�ller");
  storeMap.put("MSc", "Matthias Schirm");
  storeMap.put("ALM", "Alexander M�ller");
  StringBuffer sb = new StringBuffer ();
  for (int i = 0; i < 1600; i++) {
      sb.append ("0123456789");
  }
  String longString = sb.toString ();
  storeMap.put("GB", longString);
  storeMap.put("HSc", "Holger Schlueter");
  storeMap.put("NULL", "NULL");
  storeMap.remove("HDO");
  storeMap.remove("HDO");
  storeMap.put("LONG", "Gunnar von der Beck");
  storeMap.remove("INT");
  storeMap.remove("INT");
  storeMap.remove("ROt");
  storeMap.store();
  storeMap.store();
  JDBCPersistentMap loadMap = new JDBCPersistentMap(null, "Danet");
  loadMap.setConnection(useCon);
  loadMap.load();
  // Verfiy that maps do match
  assertTrue(loadMap.size() == 7);
  assertTrue(storeMap.equals(loadMap));
    }
View Full Code Here

    /**
     * Test setting the loadStatement
     * @exception Exception if an error occurs
     */
    public void loadStatement() throws Exception {
  JDBCPersistentMap map = new JDBCPersistentMap(null, "Danet");
  map.setConnection(con);
  String oldStatement = map.getLoadStatement();
  map.setLoadStatement("ILLEGAL STATEMENT");
  String newStatement = map.getLoadStatement();
  // Verfiy that new statement ist used
  assertTrue(newStatement.equals("ILLEGAL STATEMENT"));
  boolean exceptionCaught = false;
  try {
      map.load();
  } catch( IOException exc ) {
      exceptionCaught = true;
  }
  assertTrue(exceptionCaught);
    }
View Full Code Here

    /**
     * Test setting the insertStatement
     * @exception Exception if an error occurs
     */
    public void insertStatement() throws Exception {
  JDBCPersistentMap map = new JDBCPersistentMap(null, "Danet");
  map.setConnection(con);
  map.load();
  String oldStatement = map.getInsertStatement();
  map.setInsertStatement("ILLEGAL STATEMENT");
  String newStatement = map.getInsertStatement();
  assertTrue(newStatement.equals("ILLEGAL STATEMENT"));
  // Verify that nothing is done (optimizing)
  map.put("HSc", "Holger Schlueter"); // Already existing -> modify
  map.store();
  // Verfiy that new statement ist used
  map.put("HDO", "Dr. O.");
  boolean exceptionCaught = false;
  try {
      map.store();
  } catch( IOException exc ) {
      exceptionCaught = true;
  }
  assertTrue(exceptionCaught);
  map.setInsertStatement(oldStatement);
  map.store();
    }
View Full Code Here

    /**
     * Test setting the updateStatement
     * @exception Exception if an error occurs
     */
    public void updateStatement() throws Exception {
  JDBCPersistentMap map = new JDBCPersistentMap(null, "Danet");
  map.setConnection(con);
  map.load();
  String oldStatement = map.getUpdateStatement();
  map.setUpdateStatement
      ("ILLEGAL STATEMENT WHERE MAPID = ? AND ITEM = ?");
  String newStatement = map.getUpdateStatement();
  assertTrue(newStatement.equals
       ("ILLEGAL STATEMENT WHERE MAPID = ? AND ITEM = ?"));
  // Verify that nothing is done (optimizing)
  map.put("HsC", "Holger Schlueter"); // New key -> insert
  map.store();
  // Verfiy that new statement ist used
  map.put("HSc", "Holger Schl�ter");
  boolean exceptionCaught = false;
  try {
      map.store();
  } catch( IOException exc ) {
      exceptionCaught = true;
  }
  assertTrue(exceptionCaught);
  map.setUpdateStatement(oldStatement);
  map.store();
    }
View Full Code Here

    /**
     * Test setting the deleteStatement
     * @exception Exception if an error occurs
     */
    public void deleteStatement() throws Exception {
  JDBCPersistentMap map = new JDBCPersistentMap(null, "Danet");
  map.setConnection(con);
  map.load();
  String oldStatement = map.getDeleteStatement();
  map.setDeleteStatement("ILLEGAL STATEMENT");
  String newStatement = map.getDeleteStatement();
  assertTrue(newStatement.equals("ILLEGAL STATEMENT"));
  // Verify that nothing is done (optimizing)
  map.remove("HSC"); // Not existing
  map.store();
  // Verfiy that new statement ist used
  map.remove("ALM");
  boolean exceptionCaught = false;
  try {
      map.store();
  } catch( IOException exc ) {
      exceptionCaught = true;
  }
  assertTrue(exceptionCaught);
  map.setDeleteStatement(oldStatement);
  map.store();
    }
View Full Code Here

    /**
     * Copying a map
     * @exception Exception if an error occurs
     */
    public void copyMap() throws Exception {
  JDBCPersistentMap map1 = new JDBCPersistentMap(null, "Danet");
  map1.setConnection(con);
  assertTrue(map1.size() == 0);
  map1.load();
  assertTrue(map1.size() == 8);
  JDBCPersistentMap map2 = new JDBCPersistentMap(null, "Danet2");
  map2.setConnection(con);
  assertTrue(map2.size() == 0);
  map2.putAll(map1);
  assertTrue(map2.size() == 8);
  map2.store();
  JDBCPersistentMap map3= new JDBCPersistentMap(null, "Danet2");
  map3.setConnection(con);
  assertTrue(map3.size() == 0);
  map3.load();
  assertTrue(map3.size() == 8);
  map2.clear();
  map2.store();
  map3.load();
  assertTrue(map3.size() == 0);
    }
View Full Code Here

    /**
     * Cleaning the table
     * @exception Exception if an error occurs
     */
    public void cleanTable() throws Exception {
  JDBCPersistentMap map
      = new JDBCPersistentMap(null, "Danet","DefaultPersistenceMap");
  map.setConnection(con);
  map.store(); // Clear DB table
  map.put("HSc", "Holger Schl�ter");
  map.put("MSc", "Matthias Schirm");
  map.put("ML", "Dr. Michael Lipp");
  map.put("GB", "Gunnar von de Beck");
  map.put("INT", new Integer(1307));
  map.put("NULL", null);
  assertTrue(map.size() == 6);
  map.load(); // Load empty map
  assertTrue(map.size() == 0)
  map.put("HSc", "Holger Schl�ter");
  map.put("MSc", "Matthias Schirm");
  map.put("ML", "Dr. Michael Lipp");
  map.put("GB", "Gunnar von de Beck");
  map.put("INT", new Integer(1307));
  map.put("NULL", null);
  map.store();
  map.load();
  assertTrue(map.size() == 6);
  map.clear(); // Clear the map
  assertTrue(map.size() == 0)
  map.store();
  map.load();
  assertTrue(map.size() == 0)
    }
View Full Code Here

TOP

Related Classes of de.danet.an.util.persistentmaps.JDBCPersistentMap$MapValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.