/*
 * (C) Copyright 2015 Boni Garcia (http://bonigarcia.github.io/)
 *
 * 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 io.github.bonigarcia.wdm.test;

import static io.github.bonigarcia.wdm.WebDriverManager.edgedriver;
import static java.lang.invoke.MethodHandles.lookup;
import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.File;

import org.junit.Test;
import org.slf4j.Logger;

import io.github.bonigarcia.wdm.WebDriverManagerException;

/**
 * Test with Microsoft Edge forcing to extract MSI file.
 *
 * @author Boni Garcia (boni.gg@gmail.com)
 * @since 2.1.0
 */
public class EdgeMsiTest {

    final Logger log = getLogger(lookup().lookupClass());

    @Test(expected = WebDriverManagerException.class)
    public void testMsiOutWindows() {
        assumeFalse(IS_OS_WINDOWS);
        edgedriver().version("2.10586").setup();
    }

    @Test
    public void testMsiInWindows() {
        assumeTrue(IS_OS_WINDOWS);
        edgedriver().version("2.10586").setup();
        File binary = new File(edgedriver().getBinaryPath());
        log.debug("Edge driver {}", binary);
        assertTrue(binary.getName().endsWith(".exe"));
    }

}

@@ -664,16 +664,79 @@
 .test;%0A%0A
+import static io.github.bonigarcia.wdm.DriverManagerType.EDGE;%0A
 import s
@@ -848,16 +848,78 @@
 lookup;%0A
+import static org.apache.commons.io.FileUtils.cleanDirectory;%0A
 import s
@@ -1177,16 +1177,93 @@
 o.File;%0A
+import java.io.IOException;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;
 %0Aimport 
@@ -1300,24 +1300,68 @@
 4j.Logger;%0A%0A
+import io.github.bonigarcia.wdm.Downloader;%0A
 import io.gi
@@ -1622,16 +1622,168 @@
 ss());%0A%0A
+    @Before%0A    @After%0A    public void cleanCache() throws IOException %7B%0A        cleanDirectory(new File(new Downloader(EDGE).getTargetPath()));%0A    %7D%0A%0A
     @Tes

Clean driver cache before and after test for Edge MSI