use of org.apache.tika.config.Param in project tika by apache.
the class AnnotationUtilsTest method testParamValueInheritance.
@Test
public void testParamValueInheritance() {
class Bean {
@Field(required = true)
CharSequence field;
}
Bean parser = new Bean();
Map<String, Param> params = new HashMap<>();
try {
String val = "someval";
params.put("field", new Param<String>("field", String.class, val));
AnnotationUtils.assignFieldParams(parser, params);
Assert.assertEquals(val, parser.field);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Exception not expected, string is assignable to CharSequence");
}
try {
Date val = new Date();
params.put("field", new Param<Date>("field", Date.class, val));
AnnotationUtils.assignFieldParams(parser, params);
Assert.fail("Exception expected, Date is not assignable to CharSequence.");
} catch (TikaConfigException e) {
//expected
}
}
use of org.apache.tika.config.Param in project tika by apache.
the class TensorflowVideoRecParserTest method recognise.
@Test
public void recognise() throws Exception {
TensorflowRESTVideoRecogniser recogniser = new TensorflowRESTVideoRecogniser();
recogniser.initialize(new HashMap<String, Param>());
try (InputStream stream = getClass().getClassLoader().getResourceAsStream("test-documents/testVideoMp4.mp4")) {
List<RecognisedObject> objects = recogniser.recognise(stream, new DefaultHandler(), new Metadata(), new ParseContext());
Assert.assertTrue(objects.size() > 0);
Set<String> objectLabels = new HashSet<>();
for (RecognisedObject object : objects) {
objectLabels.add(object.getLabel());
}
Assert.assertTrue(objectLabels.size() > 0);
}
}
use of org.apache.tika.config.Param in project tika by apache.
the class TensorflowImageRecParserTest method recognise.
@Test
public void recognise() throws Exception {
TensorflowImageRecParser recogniser = new TensorflowImageRecParser();
recogniser.initialize(new HashMap<String, Param>());
try (InputStream stream = getClass().getClassLoader().getResourceAsStream("test-documents/testJPEG.jpg")) {
List<RecognisedObject> objects = recogniser.recognise(stream, new DefaultHandler(), new Metadata(), new ParseContext());
Assert.assertTrue(5 == objects.size());
Set<String> objectLabels = new HashSet<>();
for (RecognisedObject object : objects) {
objectLabels.add(object.getLabel());
}
System.out.println(objectLabels);
String[] expected = { "Egyptian cat", "tabby, tabby cat" };
for (String label : expected) {
Assert.assertTrue(label + " is expected", objectLabels.contains(label));
}
}
}
Aggregations