FingerprintAttributeParser implements SdpParser<FingerprintAttribute> { @Override public FingerprintAttribute parse(String sdp) throws SdpException { try { int separator = sdp.indexOf(AttributeField.ATTRIBUTE_SEPARATOR); if(separator == -1) { throw new IllegalArgumentException("No value found"); } String[] values = sdp.trim().substring(separator + 1).split(" "); String hashFunction = values[0]; String fingerprint = values[1]; return new FingerprintAttribute(hashFunction, fingerprint); } catch (Exception e) { throw new SdpException(PARSE_ERROR + sdp, e); } }  @Override boolean canParse(String sdp); @Override FingerprintAttribute parse(String sdp); @Override void parse(FingerprintAttribute field, String sdp);  }
@Test public void testParse() throws SdpException { String sdp1 = "a=fingerprint:sha-256 D1:2C:BE:AD:C4:F6:64:5C:25:16:11:9C:AF:E7:0F:73:79:36:4E:9C:1E:15:54:39:0C:06:8B:ED:96:86:00:39\n\r"; FingerprintAttribute obj = parser.parse(sdp1); Assert.assertEquals("sha-256", obj.getHashFunction()); Assert.assertEquals("D1:2C:BE:AD:C4:F6:64:5C:25:16:11:9C:AF:E7:0F:73:79:36:4E:9C:1E:15:54:39:0C:06:8B:ED:96:86:00:39", obj.getFingerprint()); }
@Test(expected=SdpException.class) public void testParseMissingHashFunction() throws SdpException { String sdp1 = "a=fingerprint:D1:2C:BE:AD:C4:F6:64:5C:25:16:11:9C:AF:E7:0F:73:79:36:4E:9C:1E:15:54:39:0C:06:8B:ED:96:86:00:39\n\r"; parser.parse(sdp1); }
@Test(expected=SdpException.class) public void testParseMissingFingerprint() throws SdpException { String sdp1 = "a=fingerprint:sha-256"; parser.parse(sdp1); }