@GET @Produces("text/plain") public String getVersion() { TikaResource.checkIsOperating(); return tika.toString(); } }
private void version() { System.out.println(new Tika().toString()); }
@GET @Produces("text/plain") public String getWelcomePlain() { TikaResource.checkIsOperating(); StringBuffer text = new StringBuffer(); text.append(tika.toString()); text.append("\n"); text.append("For endpoints, please see "); text.append(DOCS_URL); text.append("\n\n"); for (Endpoint e : identifyEndpoints()) { text.append(e.httpMethod); text.append(" "); text.append(e.path); text.append("\n"); for (String produces : e.produces) { text.append(" => "); text.append(produces); text.append("\n"); } } return text.toString(); }
String tikaVersion = tika.toString();
@Test public void testToString() { String version = new Tika().toString(); assertNotNull(version); assertTrue(version.matches( "Apache Tika \\d+\\.\\d+(\\.\\d+)?(-SNAPSHOT)?")); }
@Test public void testGetVersion() throws Exception { Response response = WebClient .create(endPoint + VERSION_PATH) .type("text/plain") .accept("text/plain") .get(); assertEquals(new Tika().toString(), getStringFromInputStream((InputStream) response.getEntity())); } }
@Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("TikaProvider [tika=").append(tika.toString()).append("]"); return builder.toString(); }
@Test public void testGetTextWelcome() throws Exception { Response response = WebClient .create(endPoint + WELCOME_PATH) .type("text/plain") .accept("text/plain") .get(); String text = getStringFromInputStream((InputStream) response.getEntity()); assertContains(new Tika().toString(), text); // Check our details were found assertContains("GET " + WELCOME_PATH, text); assertContains("=> text/plain", text); // Check that the Tika Version details come through too assertContains("GET " + VERSION_PATH, text); }
@Test public void testGetHTMLWelcome() throws Exception { String html = WebClient .create(endPoint + WELCOME_PATH) .type("text/html") .accept("text/html") .get(String.class); assertContains(new Tika().toString(), html); assertContains("href=\"http", html); // Check our details were found assertContains("GET", html); assertContains(WELCOME_PATH, html); assertContains("text/plain", html); // Check that the Tika Version details come through too assertContains(VERSION_PATH, html); }