Created
May 27, 2013 06:26
-
-
Save rmannibucau/5655463 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org; | |
import org.apache.openejb.loader.IO; | |
import org.apache.tomee.embedded.Configuration; | |
import org.apache.tomee.embedded.Container; | |
import org.junit.BeforeClass; | |
import org.junit.Test; | |
import java.io.File; | |
import java.io.FileWriter; | |
import java.io.IOException; | |
import java.net.URL; | |
import static org.junit.Assert.assertEquals; | |
public class TesterTest { | |
private static final File WAR = new File("target/ROOT"); | |
@BeforeClass | |
public static void createWebapp() throws IOException { | |
if (!WAR.mkdirs()) { | |
throw new IllegalStateException("Can't create " + WAR.getAbsolutePath()); | |
} | |
final File index = new File(WAR, "index.html"); | |
final FileWriter w = new FileWriter(index); | |
w.write("hello"); | |
w.close(); | |
} | |
@Test | |
public void run() throws Exception { // Microsoft Windows [version 6.1.7601] | |
final Container container = new Container(); | |
container.setup(new Configuration() {{ | |
setHttpPort(8080); | |
}}); | |
container.start(); | |
container.deploy("", WAR, true); | |
assertEquals("hello", IO.slurp(new URL("http://localhost:8080/index.html"))); | |
container.stop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment