Esempio n. 1
0
  @Test
  public void test_keyMetaInformation_shouldPass() {
    // setup key with meta
    Key key = Key.create(KEY_1_NAME, Key.KEY_VALUE, KEY_1_VALUE, Key.KEY_END);
    key.setMeta(KEY_1_META_1_NAME, KEY_1_META_1_VALUE);
    key.setMeta(KEY_1_META_2_NAME, KEY_1_META_2_VALUE);
    key.rewindMeta();

    // check meta
    Key meta_1 = key.currentMeta();
    assertEquals(KEY_1_META_1_NAME, meta_1.getName());
    assertEquals(KEY_1_META_1_VALUE, meta_1.getString());
    Key meta_2 = key.nextMeta();
    assertEquals(KEY_1_META_2_NAME, meta_2.getName());
    assertEquals(KEY_1_META_2_VALUE, meta_2.getString());

    // setup another key
    Key key2 = Key.create(KEY_2_NAME, Key.KEY_VALUE, KEY_2_VALUE, Key.KEY_END);
    key2.copyAllMeta(key);
    key2.rewindMeta();

    // check meta for second key
    Key meta_1_2 = key2.currentMeta();
    assertEquals(KEY_1_META_1_NAME, meta_1_2.getName());
    assertEquals(KEY_1_META_1_VALUE, meta_1_2.getString());
    Key meta_2_2 = key2.nextMeta();
    assertEquals(KEY_1_META_2_NAME, meta_2_2.getName());
    assertEquals(KEY_1_META_2_VALUE, meta_2_2.getString());
  }
Esempio n. 2
0
 @Test(expected = KeyInvalidName.class)
 public void test_keySetName_shouldFail() {
   String new_keyname = "some_random/test/stuff_or/whatever"; // initial slash missing
   Key key = Key.create(KEY_1_NAME, Key.KEY_VALUE, KEY_1_VALUE, Key.KEY_END);
   key.setName(new_keyname);
   assertEquals(new_keyname, key.getName());
 }
Esempio n. 3
0
 @Test
 public void test_keySetName_shouldPass() {
   String new_keyname = "/some_random/test/stuff_or/whatever";
   Key key = Key.create(KEY_1_NAME, Key.KEY_VALUE, KEY_1_VALUE, Key.KEY_END);
   key.setName(new_keyname);
   assertEquals(new_keyname, key.getName());
 }