### Question:
OAuthService { EndPoint parseEndPoint(String where, Element child, Uri base) throws SpecParserException { Uri url = XmlUtil.getHttpUriAttribute(child, URL_ATTR, base); if (url == null) { throw new SpecParserException("Not an HTTP url: " + child.getAttribute(URL_ATTR)); } Location location = Location.parse(child.getAttribute(PARAM_LOCATION_ATTR)); Method method = Method.parse(child.getAttribute(METHOD_ATTR)); return new EndPoint(base.resolve(url), method, location); } OAuthService();  OAuthService(Element serviceElement, Uri base); EndPoint getRequestUrl(); EndPoint getAccessUrl(); Uri getAuthorizationUrl(); String getName();  }### Answer:
@Test public void testParseEndPoint() throws Exception { String xml = "<Request url='http: OAuthService.EndPoint ep = service.parseEndPoint("Request", XmlUtil.parse(xml), SPEC_URL); assertEquals("http: assertEquals(OAuthService.Location.HEADER, ep.location); assertEquals(OAuthService.Method.GET, ep.method); }
@Test public void testParseEndPoint_badlocation() throws Exception { try { String xml = "<Request url='http: service.parseEndPoint("Request", XmlUtil.parse(xml), SPEC_URL); fail("Should have thrown"); } catch (SpecParserException e) { assertEquals("Unknown OAuth param_location: body", e.getMessage()); } }
@Test public void testParseEndPoint_nodefaults() throws Exception { String xml = "<Request url='http: OAuthService.EndPoint ep = service.parseEndPoint("Request", XmlUtil.parse(xml), SPEC_URL); assertEquals("http: assertEquals(OAuthService.Location.BODY, ep.location); assertEquals(OAuthService.Method.GET, ep.method); }
@Test(expected=SpecParserException.class) public void testParseEndPoint_nourl() throws Exception { String xml = "<Request method='GET' param_location='post-body'/>"; service.parseEndPoint("Request", XmlUtil.parse(xml), SPEC_URL); }
@Test(expected=SpecParserException.class) public void testParseEndPoint_badurl() throws Exception { String xml = "<Request url='ftp: service.parseEndPoint("Request", XmlUtil.parse(xml), SPEC_URL); }