Package ch.agent.crnickl.api

Examples of ch.agent.crnickl.api.UpdatableChronicle


  }
 
  public void test_delete_series_in_actual_use_fails() {
    try {
      Schema schema = db.getSchemas("schema1a").iterator().next();
      UpdatableChronicle chro = db.getTopChronicle().edit().createChronicle("schema1achro", false, "test chronicle", null, schema);
      chro.applyUpdates();
      UpdatableSeries<Double> ser = db.getUpdatableSeries("bt.schema1achro.fou", true);
      ser.setValue(Workday.DOMAIN.time("2011-06-30"), 42.);
      ser.applyUpdates();
      // erase the series from the schema (should fail, of course)
      UpdatableSchema sch1 = schema.edit();
View Full Code Here


  }

  public void test_delete_series_in_use_via_base_schema() {
    try {
      Schema schema = db.getSchemas("schema4").iterator().next();
      UpdatableChronicle chro = db.getTopChronicle().edit().createChronicle("schema4chro", false, "test chronicle", null, schema);
      chro.applyUpdates();
      UpdatableSeries<Double> ser = db.getUpdatableSeries("bt.schema4chro.fooo", true);
      ser.applyUpdates();
      // note that the series is deleted in the base schema
      UpdatableSchema sch1 = db.getUpdatableSchemas("schema1a").iterator().next();
      sch1.deleteSeries(1);
View Full Code Here

  public void test_delete_chronicle_attribute_with_actual_values() {
    try {
      UpdatableSchema schema = db.getUpdatableSchemas("schema1a").iterator().next();

      // use the attribute
      UpdatableChronicle chro = db.getChronicle("bt.schema1achro", true).edit();
      assertEquals("t1v1", chro.getAttribute("prop1", true).get().toString());
      Attribute<?> a = chro.getAttribute("prop1", true);
      a.scan("t1v2");
      assertEquals("t1v2", a.get().toString());
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v2", chro.getAttribute("prop1", true).get().toString());
      schema.deleteAttribute(1);
      schema.applyUpdates();
      expectException();
    } catch (Exception e) {
      assertException(e, null, D.D30146);
View Full Code Here

  }
 
  public void test_delete_chronicle_attribute_via_base_with_actual_values() {
    try {
      Schema schema3 = db.getSchemas("schema3").iterator().next();
      UpdatableChronicle chro = db.getTopChronicle().edit().createChronicle("schema3chro", false, "test chronicle", null, schema3);
      chro.applyUpdates();
      // use the attribute
      Attribute<?> a = chro.getAttribute("prop1", true);
      a.scan("t1v3");
      assertEquals("t1v3", a.get().toString());
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v3", chro.getAttribute("prop1", true).get().toString());
      // remove the attribute from the base schema of schema3 (should fail)
      UpdatableSchema schema1 = db.getUpdatableSchemas("schema1a").iterator().next();
      schema1.deleteAttribute(1);
      schema1.applyUpdates();
      expectException();
View Full Code Here

  }

  public void test_erase_attribute_still_in_use() {
    try {
      // erase attribute
      UpdatableChronicle chro = db.getChronicle("bt.schema3chro", true).edit();
      assertEquals("t1v3", chro.getAttribute("prop1", true).get().toString());
      // use the attribute
      Attribute<?> a = chro.getAttribute("prop1", true);
      a.reset();
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v2", chro.getAttribute("prop1", true).get().toString());
     
      UpdatableSchema schema3 = db.getUpdatableSchemas("schema3").iterator().next();
      schema3.addAttribute(1);
      schema3.eraseAttribute(1);
      schema3.applyUpdates();
      assertEquals(null, schema3.getAttributeDefinition("prop1", false));
      // value still here because it's the default value, which is not in the chronicle
      assertEquals("t1v2", chro.getAttribute("prop1", true).get().toString());
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

  }

  public void test_set_chronicle_attribute_with_value_same_as_default() {
    try {
      Schema schema1 = db.getSchemas("schema1a").iterator().next();
      UpdatableChronicle chro = db.getTopChronicle().edit().createChronicle("schema1achro2", false, "test chronicle", null, schema1);
      chro.applyUpdates();
      // use the attribute
      Attribute<?> a = chro.getAttribute("prop1", true);
      assertEquals("t1v1", schema1.getAttributeDefinition("prop1", false).getValue().toString());
      a.scan("t1v1");
      chro.setAttribute(a);
      chro.applyUpdates();
      assertEquals("t1v1", chro.getAttribute("prop1", true).get().toString());
      // now change the default
      UpdatableSchema uschema1 = schema1.edit();
      uschema1.setAttributeDefault(1, "t1v2");
      uschema1.applyUpdates();
      // expect that the attribute value has changed because t1v1 above was not set, being the default
View Full Code Here

   * but was good for event logging, which relied on objects existing, except
   * when deleted. So test1 exercised two distinct but mutually exclusive bugs.
   */
  public void test1() {
    try {
      UpdatableChronicle uc = db.getTopChronicle().edit().createChronicle("test", false, "testing...", null, null);
      uc.applyUpdates();
      String su1 = uc.getSurrogate().toString();
      // access with "test" okay, because of non-strict mode
      String su2 = db.getChronicle("test", true).getSurrogate().toString();
      assertEquals(su1, su2);
      uc.destroy();
      uc.applyUpdates();
      uc = db.getTopChronicle().edit().createChronicle("test", false, "testing...", null, null);
      uc.applyUpdates();
      // DON'T commit... old version of system removed things from cache on commit
      String su3 = uc.getSurrogate().toString();
      String su4 = db.getChronicle("test", true).getSurrogate().toString();
      assertEquals(su3, su4);
      db.commit();
    } catch (Exception e) {
//      e.printStackTrace();
View Full Code Here

  protected void firstSetUp() throws Exception {
    db = getContext().getDatabase();
    Chronicle testData = db.getChronicle(FULLNAME, false);
    if (testData != null) {
      Util.deleteChronicleCollection(testData);
      UpdatableChronicle upd = testData.edit();
      upd.destroy();
      upd.applyUpdates();
      db.commit();
    }
  }
View Full Code Here

    Util.deleteChronicles(db, FULLNAME, FULLNAME_UPDATED);
  }

  public void test1() {
    try {
      UpdatableChronicle testEntity = ((UpdatableChronicle)db.getTopChronicle()).createChronicle(SIMPLENAME, false, "test", null, null);
      testEntity.applyUpdates();
      assertEquals(FULLNAME, testEntity.getName(true));
    } catch (Exception e) {
      fail(e.getMessage());
    }
  }
View Full Code Here

    }
  }
 
  public void test2() {
    try {
      UpdatableChronicle testEntity = ((UpdatableChronicle)db.getTopChronicle()).createChronicle(SIMPLENAME, false, "test", null, null);
      testEntity.applyUpdates();
      expectException();
    } catch (Exception e) {
      assertException(e, D.D40126);
    }
  }
View Full Code Here

TOP

Related Classes of ch.agent.crnickl.api.UpdatableChronicle

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.