Package srsim.persistence

Examples of srsim.persistence.DerbyEmbeddedDS


public class PersistenceTest {

  @Test
  public void testDerbyConnection() throws InstantiationException,
      IllegalAccessException, ClassNotFoundException, SQLException {
    new DerbyEmbeddedDS();
  }
View Full Code Here


  @Test
  public void testPersistingAndRetrievingRecord()
      throws InstantiationException, IllegalAccessException,
      ClassNotFoundException, SQLException {

    DerbyEmbeddedDS ds = new DerbyEmbeddedDS();

    SimulationRecord record = new SimulationRecord();
    record.setBrightness(100.0D);
    record.setTemperature(15.0D);
    record.setEnergyConsumption(1400.0D);
    record.setTimeStamp(System.currentTimeMillis());
    ds.persist(record);
    Criterion criterion = new Criterion("temperature").lessEqual("20").and(
        new Criterion("brightness").lessThan("10000"));
    List<SimulationRecord> storedRecords = ds.find(criterion);
    Assert.assertFalse(storedRecords.isEmpty());
  }
View Full Code Here

  @Test
  public void testRetrievingAllRecords() throws InstantiationException,
      IllegalAccessException, ClassNotFoundException, SQLException {

    DerbyEmbeddedDS ds = new DerbyEmbeddedDS();
    List<SimulationRecord> storedRecords = ds.findAll();
    Assert.assertTrue(storedRecords.size() > 1);
  }
View Full Code Here

  }

  @Test
  public void testDeletingRecord() throws InstantiationException,
      IllegalAccessException, ClassNotFoundException, SQLException {
    DerbyEmbeddedDS ds = new DerbyEmbeddedDS();
    SimulationRecord record = new SimulationRecord();
    record.setBrightness(42.0D);
    record.setTemperature(42.0D);
    record.setEnergyConsumption(42.0D);
    long timeStamp = System.currentTimeMillis();
    record.setTimeStamp(timeStamp);
    ds.persist(record);
    Criterion criterion = new Criterion("timestamp").equal(String.valueOf(timeStamp));
    List<SimulationRecord> storedRecords = ds.find(criterion);
    Assert.assertFalse(storedRecords.isEmpty());
    record = storedRecords.get(0);
    ds.delete(record);
    storedRecords = ds.find(criterion);
    Assert.assertTrue(storedRecords.isEmpty());
  }
View Full Code Here

   * @throws IllegalAccessException
   * @throws InstantiationException
   */
  public static void main(String[] args) throws InstantiationException,
      IllegalAccessException, ClassNotFoundException, SQLException {
    new QueryUI(new DerbyEmbeddedDS()).display();
  }
View Full Code Here

  public SRSimMain() throws InstantiationException, IllegalAccessException,
      ClassNotFoundException, IOException, SimulationContextException,
      SQLException, SimulationConfigurationException {
    ready = false;
    dataStore = new DerbyEmbeddedDS();

    // Create SmartRoomSimulator and load configuration
    URL url = getClass().getClassLoader().getResource("simulation.json");
    simulator = new SmartRoomSimulator(dataStore);
    simulator.readConfiguration(url);
View Full Code Here

TOP

Related Classes of srsim.persistence.DerbyEmbeddedDS

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.