VersionFieldParser implements SdpParser<VersionField> { @Override public VersionField parse(String sdp) throws SdpException { try { short version = Short.parseShort(sdp.trim().substring(2)); return new VersionField(version); } catch (Exception e) { throw new SdpException(PARSE_ERROR + sdp, e); } }  @Override boolean canParse(String sdp); @Override VersionField parse(String sdp); @Override void parse(VersionField field, String sdp);  }
@Test public void testParse() throws SdpException { String line = "v=111\n\r"; VersionField field = parser.parse(line); Assert.assertEquals(111, field.getVersion()); }
@Test(expected=SdpException.class) public void testInvalidParse() throws SdpException { String line = "v=1 xyz\n\r"; parser.parse(line); }