Remove vaadin tests (#2257)
* Refactor Vaadin samples * Refactor Vaadin samples
This commit is contained in:
parent
3718dfd0d1
commit
4233d90902
|
@ -463,10 +463,6 @@
|
||||||
<groupId>com.vaadin</groupId>
|
<groupId>com.vaadin</groupId>
|
||||||
<artifactId>vaadin-server</artifactId>
|
<artifactId>vaadin-server</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.vaadin</groupId>
|
|
||||||
<artifactId>vaadin-push</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.vaadin</groupId>
|
<groupId>com.vaadin</groupId>
|
||||||
<artifactId>vaadin-client-compiled</artifactId>
|
<artifactId>vaadin-client-compiled</artifactId>
|
||||||
|
|
|
@ -6,11 +6,11 @@ import org.eclipse.jetty.server.ServerConnector;
|
||||||
import org.eclipse.jetty.servlet.ServletHandler;
|
import org.eclipse.jetty.servlet.ServletHandler;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
|
|
||||||
public class JettyServer {
|
class JettyServer {
|
||||||
|
|
||||||
private Server server;
|
private Server server;
|
||||||
|
|
||||||
public void start() throws Exception {
|
void start() throws Exception {
|
||||||
|
|
||||||
int maxThreads = 100;
|
int maxThreads = 100;
|
||||||
int minThreads = 10;
|
int minThreads = 10;
|
||||||
|
@ -33,7 +33,7 @@ public class JettyServer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() throws Exception {
|
void stop() throws Exception {
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package com.baeldung.junitparams;
|
package com.baeldung.junitparams;
|
||||||
|
|
||||||
public class SafeAdditionUtil {
|
class SafeAdditionUtil {
|
||||||
|
|
||||||
public int safeAdd(int a, int b) {
|
int safeAdd(int a, int b) {
|
||||||
long result = ((long) a) + b;
|
long result = ((long) a) + b;
|
||||||
if (result > Integer.MAX_VALUE) {
|
if (result > Integer.MAX_VALUE) {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class NettyServer {
|
||||||
|
|
||||||
private int port;
|
private int port;
|
||||||
|
|
||||||
public NettyServer(int port) {
|
private NettyServer(int port) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class NettyServer {
|
||||||
new NettyServer(port).run();
|
new NettyServer(port).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() throws Exception {
|
private void run() throws Exception {
|
||||||
EventLoopGroup bossGroup = new NioEventLoopGroup();
|
EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,27 +4,27 @@ public class RequestData {
|
||||||
private int intValue;
|
private int intValue;
|
||||||
private String stringValue;
|
private String stringValue;
|
||||||
|
|
||||||
public int getIntValue() {
|
int getIntValue() {
|
||||||
return intValue;
|
return intValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIntValue(int intValue) {
|
void setIntValue(int intValue) {
|
||||||
this.intValue = intValue;
|
this.intValue = intValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStringValue() {
|
String getStringValue() {
|
||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStringValue(String stringValue) {
|
void setStringValue(String stringValue) {
|
||||||
this.stringValue = stringValue;
|
this.stringValue = stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RequestData{" +
|
return "RequestData{" +
|
||||||
"intValue=" + intValue +
|
"intValue=" + intValue +
|
||||||
", stringValue='" + stringValue + '\'' +
|
", stringValue='" + stringValue + '\'' +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ package com.baeldung.netty;
|
||||||
public class ResponseData {
|
public class ResponseData {
|
||||||
private int intValue;
|
private int intValue;
|
||||||
|
|
||||||
public int getIntValue() {
|
int getIntValue() {
|
||||||
return intValue;
|
return intValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIntValue(int intValue) {
|
void setIntValue(int intValue) {
|
||||||
this.intValue = intValue;
|
this.intValue = intValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package com.baeldung.netty;
|
package com.baeldung.netty;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.handler.codec.ReplayingDecoder;
|
import io.netty.handler.codec.ReplayingDecoder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ResponseDataDecoder extends ReplayingDecoder<ResponseData> {
|
public class ResponseDataDecoder extends ReplayingDecoder<ResponseData> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,44 +20,44 @@ public class QuartzExample {
|
||||||
Scheduler sched = schedFact.getScheduler();
|
Scheduler sched = schedFact.getScheduler();
|
||||||
|
|
||||||
JobDetail job = JobBuilder.newJob(SimpleJob.class)
|
JobDetail job = JobBuilder.newJob(SimpleJob.class)
|
||||||
.withIdentity("myJob", "group1")
|
.withIdentity("myJob", "group1")
|
||||||
.usingJobData("jobSays", "Hello World!")
|
.usingJobData("jobSays", "Hello World!")
|
||||||
.usingJobData("myFloatValue", 3.141f)
|
.usingJobData("myFloatValue", 3.141f)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Trigger trigger = TriggerBuilder.newTrigger()
|
Trigger trigger = TriggerBuilder.newTrigger()
|
||||||
.withIdentity("myTrigger", "group1")
|
.withIdentity("myTrigger", "group1")
|
||||||
.startNow()
|
.startNow()
|
||||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
|
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
|
||||||
.withIntervalInSeconds(40)
|
.withIntervalInSeconds(40)
|
||||||
.repeatForever())
|
.repeatForever())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
JobDetail jobA = JobBuilder.newJob(JobA.class)
|
JobDetail jobA = JobBuilder.newJob(JobA.class)
|
||||||
.withIdentity("jobA", "group2")
|
.withIdentity("jobA", "group2")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
JobDetail jobB = JobBuilder.newJob(JobB.class)
|
JobDetail jobB = JobBuilder.newJob(JobB.class)
|
||||||
.withIdentity("jobB", "group2")
|
.withIdentity("jobB", "group2")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Trigger triggerA = TriggerBuilder.newTrigger()
|
Trigger triggerA = TriggerBuilder.newTrigger()
|
||||||
.withIdentity("triggerA", "group2")
|
.withIdentity("triggerA", "group2")
|
||||||
.startNow()
|
.startNow()
|
||||||
.withPriority(15)
|
.withPriority(15)
|
||||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
|
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
|
||||||
.withIntervalInSeconds(40)
|
.withIntervalInSeconds(40)
|
||||||
.repeatForever())
|
.repeatForever())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Trigger triggerB = TriggerBuilder.newTrigger()
|
Trigger triggerB = TriggerBuilder.newTrigger()
|
||||||
.withIdentity("triggerB", "group2")
|
.withIdentity("triggerB", "group2")
|
||||||
.startNow()
|
.startNow()
|
||||||
.withPriority(10)
|
.withPriority(10)
|
||||||
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
|
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
|
||||||
.withIntervalInSeconds(20)
|
.withIntervalInSeconds(20)
|
||||||
.repeatForever())
|
.repeatForever())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
sched.scheduleJob(job, trigger);
|
sched.scheduleJob(job, trigger);
|
||||||
sched.scheduleJob(jobA, triggerA);
|
sched.scheduleJob(jobA, triggerA);
|
||||||
|
|
|
@ -9,13 +9,11 @@ public class SimpleJob implements Job {
|
||||||
|
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
JobDataMap dataMap = context.getJobDetail()
|
JobDataMap dataMap = context.getJobDetail()
|
||||||
.getJobDataMap();
|
.getJobDataMap();
|
||||||
|
|
||||||
String jobSays = dataMap.getString("jobSays");
|
String jobSays = dataMap.getString("jobSays");
|
||||||
float myFloatValue = dataMap.getFloat("myFloatValue");
|
float myFloatValue = dataMap.getFloat("myFloatValue");
|
||||||
|
|
||||||
System.out.println("Job says: " + jobSays + ", and val is: " + myFloatValue);
|
System.out.println("Job says: " + jobSays + ", and val is: " + myFloatValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,20 +10,20 @@ public class Account {
|
||||||
private final TxnLong lastUpdate;
|
private final TxnLong lastUpdate;
|
||||||
private final TxnInteger balance;
|
private final TxnInteger balance;
|
||||||
|
|
||||||
public Account(final int balance) {
|
Account(final int balance) {
|
||||||
this.lastUpdate = StmUtils.newTxnLong(System.currentTimeMillis());
|
this.lastUpdate = StmUtils.newTxnLong(System.currentTimeMillis());
|
||||||
this.balance = StmUtils.newTxnInteger(balance);
|
this.balance = StmUtils.newTxnInteger(balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getBalance() {
|
Integer getBalance() {
|
||||||
return balance.atomicGet();
|
return balance.atomicGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adjustBy(final int amount) {
|
void adjustBy(final int amount) {
|
||||||
adjustBy(amount, System.currentTimeMillis());
|
adjustBy(amount, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adjustBy(final int amount, final long date) {
|
private void adjustBy(final int amount, final long date) {
|
||||||
StmUtils.atomic(() -> {
|
StmUtils.atomic(() -> {
|
||||||
balance.increment(amount);
|
balance.increment(amount);
|
||||||
lastUpdate.set(date);
|
lastUpdate.set(date);
|
||||||
|
@ -34,7 +34,7 @@ public class Account {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferTo(final Account other, final int amount) {
|
void transferTo(final Account other, final int amount) {
|
||||||
StmUtils.atomic(() -> {
|
StmUtils.atomic(() -> {
|
||||||
final long date = System.currentTimeMillis();
|
final long date = System.currentTimeMillis();
|
||||||
adjustBy(-amount, date);
|
adjustBy(-amount, date);
|
||||||
|
@ -45,6 +45,6 @@ public class Account {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return StmUtils.atomic((TxnCallable<String>)
|
return StmUtils.atomic((TxnCallable<String>)
|
||||||
txn -> "Balance: " + balance.get(txn) + " lastUpdateDate: " + lastUpdate.get(txn));
|
txn -> "Balance: " + balance.get(txn) + " lastUpdateDate: " + lastUpdate.get(txn));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,9 +1,4 @@
|
||||||
package com.baeldung.vaadin;
|
package com.baeldung.vaadin;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
|
||||||
|
|
||||||
import com.vaadin.annotations.Theme;
|
import com.vaadin.annotations.Theme;
|
||||||
import com.vaadin.annotations.VaadinServletConfiguration;
|
import com.vaadin.annotations.VaadinServletConfiguration;
|
||||||
|
@ -34,7 +29,11 @@ import com.vaadin.ui.TwinColSelect;
|
||||||
import com.vaadin.ui.UI;
|
import com.vaadin.ui.UI;
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Theme("mytheme")
|
@Theme("mytheme")
|
||||||
public class VaadinUI extends UI {
|
public class VaadinUI extends UI {
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public class VaadinUI extends UI {
|
||||||
final VerticalLayout verticalLayout = new VerticalLayout();
|
final VerticalLayout verticalLayout = new VerticalLayout();
|
||||||
verticalLayout.setSpacing(true);
|
verticalLayout.setSpacing(true);
|
||||||
verticalLayout.setMargin(true);
|
verticalLayout.setMargin(true);
|
||||||
final GridLayout gridLayout = new GridLayout(3,2);
|
final GridLayout gridLayout = new GridLayout(3, 2);
|
||||||
gridLayout.setSpacing(true);
|
gridLayout.setSpacing(true);
|
||||||
gridLayout.setMargin(true);
|
gridLayout.setMargin(true);
|
||||||
final HorizontalLayout horizontalLayout = new HorizontalLayout();
|
final HorizontalLayout horizontalLayout = new HorizontalLayout();
|
||||||
|
@ -61,9 +60,9 @@ public class VaadinUI extends UI {
|
||||||
label.setValue("Label Value");
|
label.setValue("Label Value");
|
||||||
label.setCaption("Label");
|
label.setCaption("Label");
|
||||||
gridLayout.addComponent(label);
|
gridLayout.addComponent(label);
|
||||||
|
|
||||||
final Link link = new Link("Baeldung",
|
final Link link = new Link("Baeldung",
|
||||||
new ExternalResource("http://www.baeldung.com/"));
|
new ExternalResource("http://www.baeldung.com/"));
|
||||||
link.setId("Link");
|
link.setId("Link");
|
||||||
link.setTargetName("_blank");
|
link.setTargetName("_blank");
|
||||||
gridLayout.addComponent(link);
|
gridLayout.addComponent(link);
|
||||||
|
@ -80,41 +79,41 @@ public class VaadinUI extends UI {
|
||||||
textArea.setId("TextArea");
|
textArea.setId("TextArea");
|
||||||
textArea.setValue("TextArea Value");
|
textArea.setValue("TextArea Value");
|
||||||
gridLayout.addComponent(textArea);
|
gridLayout.addComponent(textArea);
|
||||||
|
|
||||||
final DateField dateField = new DateField("DateField", new Date(0));
|
final DateField dateField = new DateField("DateField", new Date(0));
|
||||||
dateField.setId("DateField");
|
dateField.setId("DateField");
|
||||||
gridLayout.addComponent(dateField);
|
gridLayout.addComponent(dateField);
|
||||||
|
|
||||||
final PasswordField passwordField = new PasswordField();
|
final PasswordField passwordField = new PasswordField();
|
||||||
passwordField.setId("PasswordField");
|
passwordField.setId("PasswordField");
|
||||||
passwordField.setCaption("PasswordField:");
|
passwordField.setCaption("PasswordField:");
|
||||||
passwordField.setValue("password");
|
passwordField.setValue("password");
|
||||||
gridLayout.addComponent(passwordField);
|
gridLayout.addComponent(passwordField);
|
||||||
|
|
||||||
final RichTextArea richTextArea = new RichTextArea();
|
final RichTextArea richTextArea = new RichTextArea();
|
||||||
richTextArea.setCaption("Rich Text Area");
|
richTextArea.setCaption("Rich Text Area");
|
||||||
richTextArea.setValue("<h1>RichTextArea</h1>");
|
richTextArea.setValue("<h1>RichTextArea</h1>");
|
||||||
richTextArea.setSizeFull();
|
richTextArea.setSizeFull();
|
||||||
|
|
||||||
Panel richTextPanel = new Panel();
|
Panel richTextPanel = new Panel();
|
||||||
richTextPanel.setContent(richTextArea);
|
richTextPanel.setContent(richTextArea);
|
||||||
|
|
||||||
final InlineDateField inlineDateField = new InlineDateField();
|
final InlineDateField inlineDateField = new InlineDateField();
|
||||||
inlineDateField.setValue(new Date(0));
|
inlineDateField.setValue(new Date(0));
|
||||||
inlineDateField.setCaption("Inline Date Field");
|
inlineDateField.setCaption("Inline Date Field");
|
||||||
horizontalLayout.addComponent(inlineDateField);
|
horizontalLayout.addComponent(inlineDateField);
|
||||||
|
|
||||||
Button normalButton = new Button("Normal Button");
|
Button normalButton = new Button("Normal Button");
|
||||||
normalButton.setId("NormalButton");
|
normalButton.setId("NormalButton");
|
||||||
normalButton.addClickListener(e -> {
|
normalButton.addClickListener(e -> {
|
||||||
label.setValue("CLICK");
|
label.setValue("CLICK");
|
||||||
});
|
});
|
||||||
buttonLayout.addComponent(normalButton);
|
buttonLayout.addComponent(normalButton);
|
||||||
|
|
||||||
Button tinyButton = new Button("Tiny Button");
|
Button tinyButton = new Button("Tiny Button");
|
||||||
tinyButton.addStyleName("tiny");
|
tinyButton.addStyleName("tiny");
|
||||||
buttonLayout.addComponent(tinyButton);
|
buttonLayout.addComponent(tinyButton);
|
||||||
|
|
||||||
Button smallButton = new Button("Small Button");
|
Button smallButton = new Button("Small Button");
|
||||||
smallButton.addStyleName("small");
|
smallButton.addStyleName("small");
|
||||||
buttonLayout.addComponent(smallButton);
|
buttonLayout.addComponent(smallButton);
|
||||||
|
@ -148,14 +147,14 @@ public class VaadinUI extends UI {
|
||||||
Button primaryButton = new Button("Primary Button");
|
Button primaryButton = new Button("Primary Button");
|
||||||
primaryButton.addStyleName("primary");
|
primaryButton.addStyleName("primary");
|
||||||
buttonLayout.addComponent(primaryButton);
|
buttonLayout.addComponent(primaryButton);
|
||||||
|
|
||||||
NativeButton nativeButton = new NativeButton("Native Button");
|
NativeButton nativeButton = new NativeButton("Native Button");
|
||||||
buttonLayout.addComponent(nativeButton);
|
buttonLayout.addComponent(nativeButton);
|
||||||
|
|
||||||
Button iconButton = new Button("Icon Button");
|
Button iconButton = new Button("Icon Button");
|
||||||
iconButton.setIcon(FontAwesome.ALIGN_LEFT);
|
iconButton.setIcon(FontAwesome.ALIGN_LEFT);
|
||||||
buttonLayout.addComponent(iconButton);
|
buttonLayout.addComponent(iconButton);
|
||||||
|
|
||||||
Button borderlessButton = new Button("BorderLess Button");
|
Button borderlessButton = new Button("BorderLess Button");
|
||||||
borderlessButton.addStyleName("borderless");
|
borderlessButton.addStyleName("borderless");
|
||||||
buttonLayout.addComponent(borderlessButton);
|
buttonLayout.addComponent(borderlessButton);
|
||||||
|
@ -170,12 +169,12 @@ public class VaadinUI extends UI {
|
||||||
|
|
||||||
horizontalLayout.addComponent(buttonLayout);
|
horizontalLayout.addComponent(buttonLayout);
|
||||||
|
|
||||||
final CheckBox checkbox = new CheckBox("CheckBox");
|
final CheckBox checkbox = new CheckBox("CheckBox");
|
||||||
checkbox.setValue(true);
|
checkbox.setValue(true);
|
||||||
checkbox.addValueChangeListener(e ->
|
checkbox.addValueChangeListener(e ->
|
||||||
checkbox.setValue(!checkbox.getValue()));
|
checkbox.setValue(!checkbox.getValue()));
|
||||||
formLayout.addComponent(checkbox);
|
formLayout.addComponent(checkbox);
|
||||||
|
|
||||||
List<String> numbers = new ArrayList<String>();
|
List<String> numbers = new ArrayList<String>();
|
||||||
numbers.add("One");
|
numbers.add("One");
|
||||||
numbers.add("Ten");
|
numbers.add("Ten");
|
||||||
|
@ -183,28 +182,28 @@ public class VaadinUI extends UI {
|
||||||
ComboBox comboBox = new ComboBox("ComboBox");
|
ComboBox comboBox = new ComboBox("ComboBox");
|
||||||
comboBox.addItems(numbers);
|
comboBox.addItems(numbers);
|
||||||
formLayout.addComponent(comboBox);
|
formLayout.addComponent(comboBox);
|
||||||
|
|
||||||
ListSelect listSelect = new ListSelect("ListSelect");
|
ListSelect listSelect = new ListSelect("ListSelect");
|
||||||
listSelect.addItems(numbers);
|
listSelect.addItems(numbers);
|
||||||
listSelect.setRows(2);
|
listSelect.setRows(2);
|
||||||
formLayout.addComponent(listSelect);
|
formLayout.addComponent(listSelect);
|
||||||
|
|
||||||
NativeSelect nativeSelect = new NativeSelect("NativeSelect");
|
NativeSelect nativeSelect = new NativeSelect("NativeSelect");
|
||||||
nativeSelect.addItems(numbers);
|
nativeSelect.addItems(numbers);
|
||||||
formLayout.addComponent(nativeSelect);
|
formLayout.addComponent(nativeSelect);
|
||||||
|
|
||||||
TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect");
|
TwinColSelect twinColSelect = new TwinColSelect("TwinColSelect");
|
||||||
twinColSelect.addItems(numbers);
|
twinColSelect.addItems(numbers);
|
||||||
|
|
||||||
Grid grid = new Grid("Grid");
|
Grid grid = new Grid("Grid");
|
||||||
grid.setColumns(new Object[] {"Column1", "Column2", "Column3"});
|
grid.setColumns("Column1", "Column2", "Column3");
|
||||||
grid.addRow(new Object[] {"Item1", "Item2", "Item3"});
|
grid.addRow("Item1", "Item2", "Item3");
|
||||||
grid.addRow(new Object[] {"Item4", "Item5", "Item6"});
|
grid.addRow("Item4", "Item5", "Item6");
|
||||||
|
|
||||||
Panel panel = new Panel("Panel");
|
Panel panel = new Panel("Panel");
|
||||||
panel.setContent(grid);
|
panel.setContent(grid);
|
||||||
panel.setSizeUndefined();
|
panel.setSizeUndefined();
|
||||||
|
|
||||||
verticalLayout.addComponent(gridLayout);
|
verticalLayout.addComponent(gridLayout);
|
||||||
verticalLayout.addComponent(richTextPanel);
|
verticalLayout.addComponent(richTextPanel);
|
||||||
verticalLayout.addComponent(horizontalLayout);
|
verticalLayout.addComponent(horizontalLayout);
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
package com.baeldung.vaadin;
|
|
||||||
|
|
||||||
import com.gargoylesoftware.htmlunit.BrowserVersion;
|
|
||||||
import com.vaadin.server.DefaultUIProvider;
|
|
||||||
import com.vaadin.server.VaadinServlet;
|
|
||||||
import org.eclipse.jetty.server.Connector;
|
|
||||||
import org.eclipse.jetty.server.Server;
|
|
||||||
import org.eclipse.jetty.server.ServerConnector;
|
|
||||||
import org.eclipse.jetty.servlet.ServletContextHandler;
|
|
||||||
import org.eclipse.jetty.servlet.ServletHolder;
|
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
|
||||||
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.WebElement;
|
|
||||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
|
|
||||||
public class VaadinUITests {
|
|
||||||
|
|
||||||
private WebDriver driver;
|
|
||||||
private Server server;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
startJettyServer();
|
|
||||||
driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_45, true);
|
|
||||||
driver.get("http://localhost:8080");
|
|
||||||
Thread.sleep(10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void whenPageLoadedThenShouldSeeURL() {
|
|
||||||
String url = driver.getCurrentUrl();
|
|
||||||
assertEquals("http://localhost:8080/", url);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenLabel_WhenGetValue_ThenValueMatch() {
|
|
||||||
WebElement label = driver.findElement(By.id("Label"));
|
|
||||||
assertEquals("Label Value", label.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenTextField_WhenGetValue_ThenValueMatch() {
|
|
||||||
WebElement textField = driver.findElement(By.id("TextField"));
|
|
||||||
assertEquals("TextField Value", textField.getAttribute("Value"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenTextArea_WhenGetValue_ThenValueMatch() {
|
|
||||||
WebElement textArea = driver.findElement(By.id("TextArea"));
|
|
||||||
assertEquals("TextArea Value", textArea.getAttribute("Value"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenDateField_WhenGetValue_ThenValueMatch() {
|
|
||||||
WebElement dateField = driver.findElement(By.id("DateField"));
|
|
||||||
assertEquals("12/31/69", dateField.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenPasswordField_WhenGetValue_ThenValueMatch() {
|
|
||||||
WebElement passwordField = driver.findElement(By.id("PasswordField"));
|
|
||||||
assertEquals("password", passwordField.getAttribute("Value"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void cleanUp() throws Exception {
|
|
||||||
driver.close();
|
|
||||||
server.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startJettyServer() throws Exception {
|
|
||||||
|
|
||||||
int maxThreads = 100;
|
|
||||||
int minThreads = 10;
|
|
||||||
int idleTimeout = 120;
|
|
||||||
|
|
||||||
QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads, minThreads, idleTimeout);
|
|
||||||
server = new Server(threadPool);
|
|
||||||
ServerConnector connector = new ServerConnector(server);
|
|
||||||
connector.setPort(8080);
|
|
||||||
server.setConnectors(new Connector[]{connector});
|
|
||||||
ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
|
||||||
contextHandler.setContextPath("/");
|
|
||||||
ServletHolder sh = new ServletHolder(new VaadinServlet());
|
|
||||||
contextHandler.addServlet(sh, "/*");
|
|
||||||
contextHandler.setInitParameter("ui", VaadinUI.class.getName());
|
|
||||||
contextHandler.setInitParameter(VaadinServlet.SERVLET_PARAMETER_UI_PROVIDER, DefaultUIProvider.class.getName());
|
|
||||||
server.setHandler(contextHandler);
|
|
||||||
|
|
||||||
server.start();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue