indexing description: "Tests the peer id" license: "MIT license (see ../../license.txt)" author: "Beat Strasser " date: "$Date$" revision: "$Revision$" deferred class TEST_PEER_ID inherit TS_TEST_CASE feature -- Tests test_make is -- Test make local pid: P2P_PEER_ID do create pid.make (tpuuid, tguuid) validate (pid) end test_make_from_urn is -- Test make_from_urn local pid: P2P_PEER_ID do create pid.make_from_urn ("urn:jxta:uuid-" + tid) validate (pid) end validate (pid: P2P_PEER_ID) is -- Validate pid require Pid_valid: pid /= Void do assert_true ("is_valid", pid.is_valid) assert_equal ("format", "uuid", pid.format) assert_equal ("unique id", tid, pid.unique_id) assert_true ("unique id valid", pid.is_unique_id_valid (pid.unique_id)) assert_equal ("out", "urn:jxta:uuid-" + tid, pid.out) assert_equal ("out_short", "uuid-" + tid, pid.out_short) assert_equal ("flag id type", {NATURAL_8} 3, pid.flag_id_type) assert_equal ("peer uuid", tpuuid, pid.uuid) assert_equal ("group id", tguuid, pid.peer_group_id.uuid) end test_make_new_with_group is -- Test make_new_with_group local pid: P2P_PEER_ID do create pid.make_new_with_group (tguuid) assert_true ("is_valid", pid.is_valid) assert_equal ("format", "uuid", pid.format) assert_equal ("unique id", tid.substring (1, 32), pid.unique_id.substring (1, 32)) assert_true ("unique id valid", pid.is_unique_id_valid (pid.unique_id)) assert_equal ("out", "urn:jxta:uuid-" + tid.substring (1, 32), pid.out.substring (1, 46)) assert_equal ("out_short", "uuid-" + tid.substring (1, 32), pid.out_short.substring (1, 37)) assert_equal ("flag id type", {NATURAL_8} 3, pid.flag_id_type) assert_equal ("peer uuid", 16, pid.uuid.count) assert_equal ("group id", tguuid, pid.peer_group_id.uuid) end feature {NONE} -- Test data tid: STRING is "B6228B74806B456281AF9854A151F11DF592E37849884567B82EA12C0850E15B03" tpuuid: ARRAY [NATURAL_8] is -- Peer UUID once Result := << 0x92, 0xE3, 0x78, 0x49, 0x88, 0x45, 0x67, 0xB8, 0x2E, 0xA1, 0x2C, 0x08, 0x50, 0xE1, 0x5B >> Result.force (0xF5, 0) end tguuid: ARRAY [NATURAL_8] is -- Group UUID once Result := << 0x22, 0x8B, 0x74, 0x80, 0x6B, 0x45, 0x62, 0x81, 0xAF, 0x98, 0x54, 0xA1, 0x51, 0xF1, 0x1D >> Result.force (0xB6, 0) end end