예제 #1
0
  private void standardInit() {
    ShMem.InitTest(0);
    ShMem.Start();

    ShMemObject first_obj = new ShMemObject();
    first_obj.put("Yale", "University");
    ShMem.s_state.put("name", first_obj);

    VectorTimestamp.IncrementLocal(ShMemObject.s_now);
    first_obj.put("CS", "Watson");

    ShMemObject.s_now[0] = 2;
    ShMemObject.s_now[1] = 2;

    ShMemObject second_obj = new ShMemObject();
    second_obj.put("gah", "blah");
    first_obj.put("second", second_obj);
  }
예제 #2
0
  @org.junit.Test
  public void testPutGet() {
    ShMem.InitTest(0);
    ShMem.Start();
    int[] temp = {1, 0, 0, 0};
    assertEquals(VectorTimestamp.Compare(ShMemObject.s_now, temp), Comparison.EQ);

    ShMemObject first_obj = new ShMemObject();
    first_obj.put("Yale", "University");
    ShMem.s_state.put("name", first_obj);

    ShMemObject temp_obj = (ShMemObject) ShMem.s_state.get("name");
    assertEquals(first_obj, temp_obj);
    assertEquals(temp_obj.get("Yale").getTextValue().equals("University"), true);

    VectorTimestamp.IncrementLocal(ShMemObject.s_now);
    temp[0] = 2;
    assertEquals(VectorTimestamp.Compare(ShMemObject.s_now, temp), Comparison.EQ);

    temp[0] = 1;
    temp[1] = 0;
    temp[2] = 0;
    temp[3] = 0;
    first_obj.put("CS", "Watson");
    int[] yale_timestamp = first_obj.m_key_map.get("Yale").m_timestamp;
    assertEquals(VectorTimestamp.Compare(yale_timestamp, temp), Comparison.EQ);
    int[] cs_timestamp = first_obj.m_key_map.get("CS").m_timestamp;
    temp[0] = 2;
    assertEquals(VectorTimestamp.Compare(cs_timestamp, temp), Comparison.EQ);
    int[] name_timestamp = ShMem.s_state.m_key_map.get("name").m_timestamp;
    assertEquals(VectorTimestamp.Compare(name_timestamp, temp), Comparison.EQ);

    ShMemObject.s_now[1] = 2;
    ShMemObject second_obj = new ShMemObject();
    second_obj.put("gah", "blah");
    first_obj.put("second", second_obj);

    temp[0] = 2;
    temp[1] = 2;
    temp[2] = 0;
    temp[3] = 0;
    assertEquals(VectorTimestamp.Compare(name_timestamp, temp), Comparison.EQ);
  }