package com.proofpoint.jetty;

import com.beust.jcommander.internal.Maps;
import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.proofpoint.configuration.ConfigurationFactory;
import com.proofpoint.configuration.ConfigurationModule;
import org.eclipse.jetty.server.Server;
import org.testng.annotations.Test;

import javax.servlet.Servlet;
import java.util.Map;

public class TestJettyModule
{
    @Test
    public void testCanConstructServer()
    {
        Map<String, String> properties = Maps.newHashMap();
        ConfigurationFactory configFactory = new ConfigurationFactory(properties);
        Injector injector = Guice.createInjector(new JettyModule(),
                                                 new ConfigurationModule(configFactory),
                                                 new Module()
        {
            @Override
            public void configure(Binder binder)
            {
                binder.bind(Servlet.class).annotatedWith(TheServlet.class).to(DummyServlet.class);
            }
        });

        injector.getInstance(Server.class);
    }



}

@@ -67,16 +67,98 @@
 l.Maps;%0A
+import com.google.common.collect.ImmutableMap;%0Aimport com.google.common.io.Files;%0A
 import c
@@ -433,24 +433,111 @@
 ver.Server;%0A
+import org.testng.annotations.AfterMethod;%0Aimport org.testng.annotations.BeforeMethod;%0A
 import org.t
@@ -591,16 +591,65 @@
 ervlet;%0A
+import java.io.File;%0Aimport java.io.IOException;%0A
 import j
@@ -694,16 +694,434 @@
 odule%0A%7B%0A
+    private File tempDir;%0A%0A    @BeforeMethod%0A    public void setup()%0A            throws IOException%0A    %7B%0A        tempDir = Files.createTempDir().getCanonicalFile(); // getCanonicalFile needed to get around Issue 365 (http://code.google.com/p/guava-libraries/issues/detail?id=365)%0A    %7D%0A%0A    @AfterMethod%0A    public void tearDown()%0A            throws IOException%0A    %7B%0A        Files.deleteRecursively(tempDir);%0A    %7D%0A%0A
     @Tes
@@ -1163,16 +1163,47 @@
 erver()%0A
+            throws IOException%0A
     %7B%0A  
@@ -1245,27 +1245,167 @@
 s = 
-Maps.newHashMap
+new ImmutableMap.Builder%3CString, String%3E()%0A                .put(%22jetty.log.path%22, new File(tempDir, %22jetty.log%22).getAbsolutePath())%0A                .build
 ();%0A
+%0A
     

delete temp files when test completes