/**
 *
 * Copyright (c) 2006-2016, Speedment, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); You may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.speedment.tool.internal.component;

import com.speedment.generator.GeneratorBundle;
import com.speedment.runtime.Speedment;
import com.speedment.runtime.internal.DefaultApplicationBuilder;
import com.speedment.runtime.internal.EmptyApplicationMetadata;
import com.speedment.tool.ToolBundle;
import com.speedment.tool.component.VersionComponent;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.junit.Test;

/**
 *
 * @author  Emil Forslund
 * @since   3.0.0
 */
public class VersionComponentImplTest {

    /**
     * Test of latestVersion method, of class VersionComponentImpl.
     */
    @Test
    public void testLatestVersion() {
        System.out.println("Determining the latest version of Speedment.");
        final Speedment speedment = new DefaultApplicationBuilder(EmptyApplicationMetadata.class)
            .withBundle(GeneratorBundle.class)
            .withBundle(ToolBundle.class)
            .withSkipCheckDatabaseConnectivity()
            .withSkipValidateRuntimeConfig()
            .build();
        
        final VersionComponent version = speedment.getOrThrow(VersionComponent.class);
        
        try {
            final String latest = version.latestVersion().get(2, TimeUnit.SECONDS);
            System.out.println("The latest released version of Speedment is " + latest + ".");
        } catch (final ExecutionException | InterruptedException ex) {
            throw new RuntimeException(ex);
        } catch (final TimeoutException ex ) {
            System.out.println("Connection timed out before a version could be established");
        }
    }
    
}

@@ -976,24 +976,63 @@
 onComponent;
+%0A%0Aimport java.net.UnknownHostException;
 %0Aimport java
@@ -2148,24 +2148,202 @@
 ption ex) %7B%0A
+            if (hasCause(ex, UnknownHostException.class)) %7B%0A                System.out.println(%22UnknownHostException - not connected to the Internet?%22);%0A            %7D else %7B%0A    
             
@@ -2374,16 +2374,30 @@
 on(ex);%0A
+            %7D%0A
         
@@ -2545,15 +2545,332 @@
 %7D%0A    %7D%0A
+%0A
     
+private static boolean hasCause(Exception ex, Class%3C? extends Throwable%3E c) %7B%0A        Throwable cause = ex.getCause();%0A        while (cause != null) %7B%0A            if (c.equals(cause.getClass())) %7B%0A                return true;%0A            %7D%0A            cause = cause.getCause();%0A        %7D%0A        return false;%0A    %7D%0A
 %0A%7D%0A

Make test work on airplane