TimingFieldParser implements SdpParser<TimingField> { @Override public TimingField parse(String sdp) throws SdpException { try { String[] values = sdp.trim().substring(2).split(" "); int startTime = Integer.parseInt(values[0]); int stopTime = Integer.parseInt(values[1]); return new TimingField(startTime, stopTime); } catch (Exception e) { throw new SdpException(PARSE_ERROR + sdp, e); } }  @Override boolean canParse(String sdp); @Override TimingField parse(String sdp); @Override void parse(TimingField field, String sdp);  }
@Test(expected = SdpException.class) public void testInvalidParseNumberFormat() throws SdpException { String line = "t=123 xyz\n\r"; parser.parse(line); }
@Test public void testValidParse() throws SdpException { String line = "t=123 456\n\r"; TimingField field = parser.parse(line); Assert.assertEquals(123, field.getStartTime()); Assert.assertEquals(456, field.getStopTime()); }
@Test(expected = SdpException.class) public void testInvalidParseMissingElement() throws SdpException { String line = "t=123\n\r"; parser.parse(line); }