Search in sources :

Example 11 with FileNotFoundException

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());
    }
}
Also used : FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) RouteBuilder(org.apache.camel.builder.RouteBuilder) FileNotFoundException(java.io.FileNotFoundException) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) FileNotFoundException(java.io.FileNotFoundException) ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException)

Example 12 with FileNotFoundException

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);
}
Also used : SocketException(java.net.SocketException) OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) FileNotFoundException(java.io.FileNotFoundException) ConnectException(java.net.ConnectException)

Example 13 with FileNotFoundException

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);
}
Also used : FileNotFoundException(java.io.FileNotFoundException) OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) RuntimeCamelException(org.apache.camel.RuntimeCamelException) IOException(java.io.IOException)

Example 14 with FileNotFoundException

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();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) FileNotFoundException(java.io.FileNotFoundException) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 15 with FileNotFoundException

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;
}
Also used : Context(javax.naming.Context) TransientRepository(org.apache.jackrabbit.core.TransientRepository) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)3218 IOException (java.io.IOException)1836 File (java.io.File)1277 FileInputStream (java.io.FileInputStream)814 FileOutputStream (java.io.FileOutputStream)492 InputStream (java.io.InputStream)466 BufferedReader (java.io.BufferedReader)262 FileReader (java.io.FileReader)230 ArrayList (java.util.ArrayList)205 Path (org.apache.hadoop.fs.Path)202 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)189 InputStreamReader (java.io.InputStreamReader)171 Test (org.junit.Test)171 XmlPullParser (org.xmlpull.v1.XmlPullParser)166 BufferedInputStream (java.io.BufferedInputStream)138 ParcelFileDescriptor (android.os.ParcelFileDescriptor)131 Properties (java.util.Properties)120 URL (java.net.URL)119 FileStatus (org.apache.hadoop.fs.FileStatus)119 RandomAccessFile (java.io.RandomAccessFile)101