MediaDescriptionFieldParser implements SdpParser<MediaDescriptionField> { @Override public boolean canParse(String sdp) { if(sdp == null || sdp.isEmpty()) { return false; } return PATTERN.matcher(sdp.trim()).matches(); }  @Override boolean canParse(String sdp); @Override MediaDescriptionField parse(String sdp); @Override void parse(MediaDescriptionField field, String sdp);  }
@Test public void testCanParse() { String sdp1 = "m=video 64534 RTP/AVPF 0 101 120\n\r"; String sdp2 = "x=video 64534 RTP/AVPF 0 101 120\n\r"; String sdp3 = "m=video xyz RTP/AVPF 0 101 120\n\r"; String sdp4 = "m=video 64534 0 101 120\n\r"; String sdp5 = "m=video 64534 RTP/AVPF 0 xyz 120\n\r"; String sdp6 = "m=image 52550 udptl t38\n\r"; boolean canParseSdp1 = parser.canParse(sdp1); boolean canParseSdp2 = parser.canParse(sdp2); boolean canParseSdp3 = parser.canParse(sdp3); boolean canParseSdp4 = parser.canParse(sdp4); boolean canParseSdp5 = parser.canParse(sdp5); boolean canParseSdp6 = parser.canParse(sdp6); Assert.assertTrue(canParseSdp1); Assert.assertFalse(canParseSdp2); Assert.assertFalse(canParseSdp3); Assert.assertFalse(canParseSdp4); Assert.assertTrue(canParseSdp5); Assert.assertTrue(canParseSdp6); }