package ninja.eivind.hotsreplayuploader;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

public class ClientTest {

    @Test
    public void testClientIsMainClass() throws Exception {
        Document parse = Jsoup.parse(new File("pom.xml"), "UTF-8");
        String className = parse.select("project > properties > mainClass").text();

        System.out.println("Loading class " + className);
        Class<?> mainClass = Class.forName(className);

        Method main = mainClass.getDeclaredMethod("main", String[].class);
        int modifiers = main.getModifiers();

        Class<?> returnType = main.getReturnType();

        assertEquals("Client is mainClass", Client.class, mainClass);
        assertSame("Main method returns void", returnType, Void.TYPE);
        assertTrue("Main method is static", Modifier.isStatic(modifiers));
        assertTrue("Main method is public", Modifier.isPublic(modifiers));
    }
}

@@ -92,16 +92,46 @@
 cument;%0A
+import org.junit.BeforeClass;%0A
 import o
@@ -299,134 +299,213 @@
 ert.
-assertEquals;%0Aimport static org.junit.Assert.assertSame;%0Aimport static org.junit.Assert.assertTrue;%0A%0Apublic class ClientTest %7B
+*;%0A%0Apublic class ClientTest %7B%0A%0A    private static Document parse;%0A%0A    @BeforeClass%0A    public static void setUpClass() throws IOException %7B%0A        parse = Jsoup.parse(new File(%22pom.xml%22), %22UTF-8%22);%0A    %7D
 %0A%0A  
@@ -575,76 +575,8 @@
 n %7B%0A
-        Document parse = Jsoup.parse(new File(%22pom.xml%22), %22UTF-8%22);%0A
     
@@ -1240,11 +1240,587 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testApplicationHasWindowsIcon() throws Exception %7B%0A        String appName = parse.select(%22project %3E name%22).text();%0A        File icon = new File(%22src/main/deploy/package/windows/%22 + appName + %22.ico%22);%0A%0A        assertTrue(%22Windows icon exists%22, icon.exists());%0A    %7D%0A%0A    @Test%0A    public void testApplicationHasOSXIcon() throws Exception %7B%0A        String appName = parse.select(%22project %3E name%22).text();%0A        File icon = new File(%22src/main/deploy/package/macosx/%22 + appName + %22.icns%22);%0A%0A        assertTrue(%22OSX icon exists%22, icon.exists());%0A    %7D
 %0A%7D%0A

add tests to verify that application icon is set for supported platforms