UrlChecker { public LinkStatus getUrlStatus(String url) { try { if (url.startsWith("ftp")) { return getFTPStatus(url); } LinkStatus status = getUrlStatus(url, 5); Log.info(Geonet.GEONETWORK,"getUrlStatus for: "+url); Log.info(Geonet.GEONETWORK,"result: "+status); return status; } catch (Exception e) { return buildExceptionStatus(e); } }  String getUserAgent(); void setUserAgent(String ua); LinkStatus getUrlStatus(String url); public String urlCheckerUserAgent; }
@Test public void status451() throws IOException { UrlChecker toTest = new UrlChecker(); GeonetHttpRequestFactory mockResquetFactory = mock(GeonetHttpRequestFactory.class); ClientHttpResponse response = createUnknowStatus(); when(mockResquetFactory.execute(any(HttpUriRequest.class), anyObject())).thenReturn(response); toTest.requestFactory = mockResquetFactory; LinkStatus linkStatus = toTest.getUrlStatus("dummy"); assertEquals((451) + "", linkStatus.getStatusValue()); assertEquals(true, linkStatus.isFailing().booleanValue()); assertEquals("dummy 451", linkStatus.getStatusInfo()); }