### Question:
UrlBuilder implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!request.equals(URL.class)) { return new NoSpecimen(); } try { return new URL("http: } catch (MalformedURLException e) { return new NoSpecimen(); } }  @Override Object create(Object request, SpecimenContext context);  }### Answer:
@Test public void non_url_type_request_returns_no_specimen() { Object result = this.urlBuilder.create(Integer.class, null); assertEquals(new NoSpecimen(), result); }
@Test public void url_type_request_returns_instance_of_url() { Object result = this.urlBuilder.create(URL.class, null); assertTrue(result instanceof URL); }
@Test public void url_uses_http_protocol() { URL url = (URL) this.urlBuilder.create(URL.class, null); assertEquals("http", url.getProtocol()); }
@Test public void url_point_to_localhost() { URL url = (URL) this.urlBuilder.create(URL.class, null); assertEquals("localhost", url.getHost()); }