Hello.
I wrote a simple application using the vaadin framework.
It only has a textbox for input and a button to fire an action (get values to the input and display it). It’s a vaadin 7 project in eclipse and it runs on a tomcat 7.
The application works fine, if I call it directly by the url.
Next thing i wanted to realize: a unit test. So I wrote a simple unit-test from a recorded selenium file. But when I start this test, i get the “Failed to load the bootstrap javascript: ./VAADIN/vaadinBootstrap.js” error.
I read there’s maby an error with the web.xml, but i didn’t know which or how to fix it.
Could you help with that without pointing to the vaadin benchtest?
here my sources:
vaadin-ui-class:
package com.example.vaadin_ui_test;
import com.vaadin.annotations.Title;
import com.vaadin.event.ShortcutAction.KeyCode;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@SuppressWarnings(“serial”)
@Title(“Performance Test”)
public class Vaadin_ui_testUI extends UI {
private TextField searchField = new TextField();
private Button searchButton = new Button("Starte Suche");
@Override
protected void init(VaadinRequest request) {
initLayout();
}
private void initLayout(){
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
searchField.focus();
layout.addComponent(searchField);
searchButton.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
String id = searchField.getValue();
String valueToId = "";
if (id != null && !id.isEmpty()){
valueToId = getValueToId(id);
layout.addComponent(new Label("value for your id "+id+" is: "+valueToId));
}
searchField.setValue("");
searchField.focus();
}
private String getValueToId(String id) {
String returnValue = "";
RDBMS rdbms = new RDBMS();
if (rdbms.connect()){
returnValue = rdbms.getTextToPower(id);
rdbms.disconnect();
}
return returnValue;
}
});
searchButton.setClickShortcut(KeyCode.ENTER, null);
layout.addComponent(searchButton);
}
}
web.xml:
<?xml version="1.0" encoding="UTF-8"?> Vaadin Web Application Vaadin production mode productionMode true Vaadin com.vaadin.server.VaadinServlet Vaadin UI to display UI com.example.vaadin_ui_test.Vaadin_ui_testUI Vaadin /*unit-test:
package mme;
import static org.junit.Assert.fail;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SinglePerformanceTest {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = “http://localhost:8080/”;
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testMe() throws Exception {
driver.get(baseUrl + “/vaadin-ui-test/”);
driver.findElement(By.xpath("//input[@type=‘text’]
“)).clear();
driver.findElement(By.xpath(”//input[@type=‘text’]
“)).sendKeys(“123”);
driver.findElement(By.xpath(”//input[@type=‘text’]
“)).clear();
driver.findElement(By.xpath(”//input[@type=‘text’]
“)).sendKeys(“666”);
driver.findElement(By.cssSelector(“span.v-button-caption”)).click();
driver.findElement(By.xpath(”//input[@type=‘text’]
“)).clear();
driver.findElement(By.xpath(”//input[@type=‘text’]
")).sendKeys(“769”);
driver.findElement(By.cssSelector(“span.v-button-caption”)).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!“”.equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
}