@Test
public void testGetEncodings() {

  final URI stringDatatype = URI.create("xs:string");
  final BigInteger expectedUtf8 = new BigInteger("68C3A96C6CC3B807", 16);
  final BigInteger expectedSha = new BigInteger(HASH_OF_TEST_STRING, 16);
  
  MyAttributeValue v1 = MyAttributeEncodingFactory.parseValueFromEncoding(ENCODING_STRING_UTF_8, TEST_STRING, null);
  MyAttributeValue v2 = MyAttributeEncodingFactory.parseValueFromEncoding(ENCODING_STRING_SHA, TEST_STRING, null);
  MyAttributeValue v3 = MyAttributeValueFactory.parseValue(stringDatatype, TEST_STRING, null);
  
  Set<MyAttributeValue> set1 = new HashSet<MyAttributeValue>();
  set1.add(v1);
  set1.add(v3);
  assertEquals(expectedUtf8, v3.getCompatibleIntegerValue(set1));
  
  Set<MyAttributeValue> set2 = new HashSet<MyAttributeValue>();
  set2.add(v2);
  set2.add(v3);
  assertEquals(expectedSha, v3.getCompatibleIntegerValue(set2));
  
  Set<MyAttributeValue> set3 = new HashSet<MyAttributeValue>();
  set3.add(v3);
  try {
    v3.getCompatibleIntegerValue(set3);
    fail();
  } catch(RuntimeException e) {
    // expected
    assertTrue(e.getMessage().contains("No encoding"));
  }
  
  Set<MyAttributeValue> set4 = new HashSet<MyAttributeValue>();
  set4.add(v1);
  set4.add(v2);
  set4.add(v3);
  try {
    v3.getCompatibleIntegerValue(set4);
    fail();
  } catch(RuntimeException e) {
    // expected
    assertTrue(e.getMessage().contains("Too many encodings"));
  }
  
  assertEquals(v1.getEncodingOrNull(), ENCODING_STRING_UTF_8);
  assertEquals(v2.getEncodingOrNull(), ENCODING_STRING_SHA);
  assertEquals(v3.getEncodingOrNull(), null);
  
}