package de.fred4jupiter.fredbet.web;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import org.fluentlenium.adapter.FluentTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import de.fred4jupiter.fredbet.Application;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebIntegrationTest("server.port:0")
@ActiveProfiles("dev")
public class LoginAT extends FluentTest {

	private static final Logger LOG = LoggerFactory.getLogger(LoginAT.class);

	@Value("${local.server.port}")
	private int serverPort;

	@Autowired
	private MessageUtil messageUtil;

	private String getURL() {
		return "http://localhost:" + serverPort;
	}

	@Override
	public WebDriver getDefaultDriver() {
		return new HtmlUnitDriver();
	}

	@Test
	public void login() {
		LOG.debug("try to call URL={}", getURL());

		goTo(getURL());

		fill("#username").with("admin");
		fill("#password").with("admin");

		submit("#loginSubmitBtn");
		assertThat(title(), equalTo(messageUtil.getMessageFor("all.matches")));
	}
}

@@ -462,37 +462,44 @@
 rk.b
-eans.factory.annotation.Value
+oot.context.embedded.LocalServerPort
 ;%0Aim
@@ -537,38 +537,30 @@
 est.
-SpringApplicationConfiguration
+context.SpringBootTest
 ;%0Aim
@@ -594,33 +594,52 @@
 ot.test.
-WebIntegrationTes
+context.SpringBootTest.WebEnvironmen
 t;%0Aimpor
@@ -858,32 +858,16 @@
 ring
-ApplicationConfiguration
+BootTest
 (cla
@@ -894,45 +894,53 @@
 lass
-)%0A@WebIntegrationTest(%22server.port:0%22
+, webEnvironment = WebEnvironment.RANDOM_PORT
 )%0A@A
@@ -1085,37 +1085,23 @@
 %0A%0A%09@
-Value(%22$%7Bl
+L
 ocal
-.s
+S
 erver
-.p
+P
 ort
-%7D%22)
 %0A%09pr

update test