use of java.io.FileNotFoundException in project camel by apache.
the class PropertiesComponentDefaultTest method testPropertiesComponentDefaultNoFileFound.
public void testPropertiesComponentDefaultNoFileFound() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").to("properties:bar.end?locations=org/apache/camel/component/properties/unknown.properties");
}
});
try {
context.start();
fail("Should throw exception");
} catch (FailedToCreateRouteException e) {
ResolveEndpointFailedException cause = assertIsInstanceOf(ResolveEndpointFailedException.class, e.getCause());
FileNotFoundException fnfe = assertIsInstanceOf(FileNotFoundException.class, cause.getCause());
assertEquals("Properties file org/apache/camel/component/properties/unknown.properties not found in classpath", fnfe.getMessage());
}
}
use of java.io.FileNotFoundException in project camel by apache.
the class DefaultExceptionPolicyStrategyTest method testClosetMatch3.
public void testClosetMatch3() {
setupPolicies();
OnExceptionDefinition result = strategy.getExceptionPolicy(policies, null, new ConnectException(""));
assertEquals(type3, result);
result = strategy.getExceptionPolicy(policies, null, new SocketException(""));
assertEquals(type3, result);
result = strategy.getExceptionPolicy(policies, null, new FileNotFoundException());
assertEquals(type3, result);
}
use of java.io.FileNotFoundException in project camel by apache.
the class DefaultExceptionPolicyStrategyTest method testCausedByWrapped.
public void testCausedByWrapped() {
setupPoliciesCausedBy();
IOException ioe = new IOException("Damm");
ioe.initCause(new FileNotFoundException("Somefile not found"));
OnExceptionDefinition result = strategy.getExceptionPolicy(policies, null, new RuntimeCamelException(ioe));
assertEquals(type1, result);
}
use of java.io.FileNotFoundException in project camel by apache.
the class ResourceHelperTest method testLoadClasspathNotFound.
public void testLoadClasspathNotFound() throws Exception {
CamelContext context = new DefaultCamelContext();
context.start();
try {
ResourceHelper.resolveMandatoryResourceAsInputStream(context, "classpath:notfound.txt");
fail("Should not find file");
} catch (FileNotFoundException e) {
assertEquals("Cannot find resource: classpath:notfound.txt in classpath for URI: classpath:notfound.txt", e.getMessage());
}
context.stop();
}
use of java.io.FileNotFoundException in project camel by apache.
the class JcrRouteTestSupport method createJndiContext.
@Override
protected Context createJndiContext() throws Exception {
File config = new File(CONFIG_FILE);
if (!config.exists()) {
throw new FileNotFoundException("Missing config file: " + config.getPath());
}
Context context = super.createJndiContext();
repository = new TransientRepository(CONFIG_FILE, REPO_PATH);
context.bind("repository", repository);
return context;
}
Aggregations