Package com.google.code.gaeom

Examples of com.google.code.gaeom.ObjectStore


  {
    Set<EnumObject> objs = Sets.newHashSet();
    for (int ct = 0; ct < 10; ct++)
      objs.add(new EnumObject());

    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();
    oss.store(objs).now();

    // will get new objects b/c we are using a new session
    Set<EnumObject> result = Sets.newHashSet(os.beginSession().find(EnumObject.class).now());

    assertEquals(objs, result);
  }
View Full Code Here


  }

  @Test
  public void testCount()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    List<Foo> foos = Lists.newArrayList();
    for (int ct = 0; ct < 100; ct++)
      foos.add(new Foo(ct));
    oss.store(foos).now();
View Full Code Here

  }

  @Test(expected = KeysNotFoundException.class)
  public void testDeleteCommand()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Tester t1 = new Tester();
    t1.name = "Fred Flintstone";
    Key key = oss.store(t1).now();

    oss.delete(t1).now();

    os.beginSession().load(key).now(); // may not fail because changes not rolled forward see superclass

    assertNull(os.beginSession().load(key).retries(0).now());
  }
View Full Code Here

  }

  @Test(expected = KeysNotFoundException.class)
  public void testDeleteCommandLocal()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Tester t1 = new Tester();
    t1.name = "Fred Flintstone";
    Key key = oss.store(t1).now();

    oss.delete(t1).now();

    os.beginSession().load(key).now(); // may not fail because changes not rolled forward see superclass

    assertNull(oss.load(key).retries(0).now());
  }
View Full Code Here

  }

  @Test
  public void demoTest()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Gaeom gaeom = new Gaeom();
    gaeom.description = "Supah object-datastore mapping";
    gaeom.rocks = true;

    oss.store(gaeom).id(1).now();

    os.beginSession().load(Gaeom.class).id(1).now();

    os.beginSession().find(Gaeom.class).single().now();

    os.beginSession().find(Gaeom.class).filter("rocks", true).single().now();
  }
View Full Code Here

  }

  @Test
  public void testByFilteringForNull() throws Exception
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    A a1 = new A();
    A a2 = new A();
    a2.b = new B();
View Full Code Here

  }

  @Test
  public void testByFilteringForNullEmbedded() throws Exception
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    A2 a1 = new A2();
    A2 a2 = new A2();
    a2.b = new B();
View Full Code Here

  }

  @Test
  public void testEvenutalConsistency() throws Exception
  {
    ObjectStore os = ObjectStore.Factory.create();
    Key key = os.beginSession().store(new Foo()).now();
   
    try
    {
      os.beginSession().load(key).retries(0).now();
      assertTrue(false); // should have thrown
    }
    catch (KeysNotFoundException e)
    {
    }
   
    assertTrue(os.beginSession().load(key).retries(0).now() != null);
  }
View Full Code Here

  }
 
  @Test
  public void testNameRegistration()
  {
    ObjectStore os = ObjectStore.Factory.create();
    os.register("Foo", Foo.class);

    ObjectStoreSession oss = os.beginSession();
    oss.store(new Foo("Fred Flintstone")).now();
    oss.store(new Foo("Barney Rubble")).now();

    List<Foo> foos = Lists.newArrayList(oss.find(Foo.class).now());
    assertEquals(2, foos.size());
View Full Code Here

   
    a.bs.add(new B("Fred"));
    a.bs.add(null);
    a.bs.add(new B("Sally"));
   
    ObjectStore os = ObjectStore.Factory.create();
    Key key = os.beginSession().store(a).now();
   
    A a2 = os.beginSession().load(key).now();
   
    assertEquals(a.bs, a2.bs);
  }
View Full Code Here

TOP

Related Classes of com.google.code.gaeom.ObjectStore

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.