Thursday, June 18, 2009

Integration Problem between Selenium-Maven_Plugin and GWT

Problem

When trying to run gwt in hosted mode, showed the following error message:

Exception in thread "main" java.lang.IncompatibleClassChangeError: Class org.mortbay.jetty.servlet.HashSessionManager does not implement the requested interface org.mortbay.jetty.SessionManager
at org.mortbay.jetty.servlet.SessionHandler.setSessionManager(SessionHandler.java:88) at org.mortbay.jetty.servlet.SessionHandler.(SessionHandler.java:62) at org.mortbay.jetty.servlet.SessionHandler.(SessionHandler.java:53) at org.mortbay.jetty.webapp.WebAppContext.(WebAppContext.java:297) at com.google.gwt.dev.ServletValidator.create(ServletValidator.java:67) at com.google.gwt.dev.ServletValidator.create(ServletValidator.java:51) at com.google.gwt.dev.HostedMode.doStartup(HostedMode.java:344) at com.google.gwt.dev.HostedModeBase.startUp(HostedModeBase.java:585) at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:397) at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)

Reason

The following excerpt from pom.xml:
...
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<scope>test</scope>
</dependency>
...
The above depency is causing problems to execution of hosted mode. One solution proposed by someone here to exclude the jetty does not work.

Solution

As I was just wanting the libraries of selenium to run the tests, I used the dependence of Testng as below:
...

<dependency>
<groupId>org.apache.geronimo.testsupport</groupId>
<artifactId>testsupport-selenium</artifactId>
<version>2.1.3</version>
</dependency>
...

In this solution it also brings testng.jar. I will verify latter how to exclude it.

Wednesday, June 17, 2009

Incompatilibidade entre o Selenium-Maven-Plugin e o GWT

Problema

Ao tentar executar o GWT em hosted mode, apresentou a seguinte mensagem de erro:

Exception in thread "main" java.lang.IncompatibleClassChangeError: Class org.mortbay.jetty.servlet.HashSessionManager does not implement the requested interface org.mortbay.jetty.SessionManager
at org.mortbay.jetty.servlet.SessionHandler.setSessionManager(SessionHandler.java:88) at org.mortbay.jetty.servlet.SessionHandler.(SessionHandler.java:62) at org.mortbay.jetty.servlet.SessionHandler.(SessionHandler.java:53) at org.mortbay.jetty.webapp.WebAppContext.(WebAppContext.java:297) at com.google.gwt.dev.ServletValidator.create(ServletValidator.java:67) at com.google.gwt.dev.ServletValidator.create(ServletValidator.java:51) at com.google.gwt.dev.HostedMode.doStartup(HostedMode.java:344) at com.google.gwt.dev.HostedModeBase.startUp(HostedModeBase.java:585) at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:397) at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)

Motivo

O seguinte trecho do pom.xml:

...


<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<scope>test</scope>
</dependency>

...
A dependência acima está trazendo alguma versão do jetty que está fazendo com que o hosted mode não seja executado. Uma solução proposta por alguém aqui para excluir o jetty, não funcionou.

Solução

Como só estava querendo as bliotecas do selenium para rodar os testes, utilizei a dependência do Testng, como abaixo:

...

<dependency>
<groupId>org.apache.geronimo.testsupport</groupId>
<artifactId>testsupport-selenium</artifactId>
<version>2.1.3</version>
</dependency>

...

Pendência

Na solução encontra o jar: testng-5.1-jdk15.jar é desnecesário. Verificar como excluí-lo

Sunday, June 14, 2009

Testing in Hosted Mode (GWT JUnit Test) does not work

Problem

When running the test: GWT JUnit Test, the test does not work as expected. For example:

...
public void testCallTheOnBlurHandler () throws Exception (
final StringBuffer value = new StringBuffer ( "one");
TextBox textbox = new TextBox ();
RootPanel.get (). Add (TextBox);
textBox.addBlurHandler (new BlurHandler () (

@ Override
public void onBlur (BlurEvent event) (
valor.append ( "two");

)
));
textBox.setFocus (false);
assertEquals ( "Not called BlurHandler,"
"two", valor.toString ());
)

Reason

Unidentified, but I think it is a problem of compilation because of the solution found.

Solution

Run the test in web mode: GWT JUnit Test (web mode). The test work. Go back and run the test in hosted mode.It should work.

Teste no Hosted Mode (GWT JUnit Test) Não Funciona

Problema

Ao executar os testes: GWT JUnit Test o teste não funciona conforme o esperado. Por exemplo:

...
public void testChamarOhEventoBlurHandler() throws Exception {
final StringBuffer valor = new StringBuffer("um");
TextBox textBox = new TextBox();
RootPanel.get().add(textBox);
textBox.addBlurHandler(new BlurHandler() {

@Override
public void onBlur(BlurEvent event) {
valor.append("dois");

}
});
textBox.setFocus(false);
assertEquals("Não chamou o BlurHandler",
"um", valor.toString());
}

Motivo

Não identificado, mas acho que é algum problema de compilação, pela solução encontrada.

Solução

Execute is testes no modo web: GWT JUnit Test (web mode). O teste funcionará. Volte e execute o teste no modo hosted. Deve voltar a funcionar.

Thursday, June 11, 2009

Use of lost focus with components of gwt

The gwt depreciated the use of listeners in their widgets in favor of interfaces handlers. One possible difficulty is knowing which handler is associated with the lost focus event. The interface to be used is the BlurHandler. Ex:

final TextBox box = new TextBox ();
box.addBlurHandler (new BlurHandler () (

@ Override
public void onBlur (BlurEvent event) (
box.setText ( "The event was triggered");
)));

Utilização de lost focus com componentes do GWT

O GWT depreciou a utilização de listeners nos seus widgets em favor de interfaces handlers. Um possível dificuldade é saber qual handler utilizar para o evento lost focus. A interface a ser utiliza é o BlurHandler. Ex:

final TextBox box = new TextBox();
box.addBlurHandler(new BlurHandler(){

@Override
public void onBlur(BlurEvent event) {
box.setText("O vento foi disparado");
}});

Tuesday, June 2, 2009

CNTRL ALT SETA gira a tela ao invés de mover linha no eclipse

Problema

Ao utilizar as teclas de atalho CNTRL + ALT + SETA (para cima ou para baixo), ao invés de mover a linha dentro do IDE Eclispe, coloca a tela de cabeça para baixo (ou retorna a posição normal)

Motivo

Em alguns computadores, esta combinação de teclas já está associada a um panel de controle de vídeo da intel.

Solução

Digite CNTRL+ALT+F12 para abrir o panel da intel.
Clique na aba teclas de atalho
Desmarque a seleção ativar teclas de atalho

Monday, June 1, 2009

Button.click() not working


Problem


When calling the method Button.click () (class of GWT) nothing happens. Ex:

...
Button button = new Button ( "Button");

button.addClickHandler (new ClickHandler () (
@ Override
public void onClick (ClickEvent event) (
throw new RuntimeException ( "RuntimeException");
)));

button.click ();
...

This code, in principle, should launch an exception.

Reason

The button, or an object that contains it, was not added to RootPanel.

Solution

Add the widget to RootPanel. Ex:

...
Button button = new Button ( "Button");

RootPanel.get (). Add (button);

button.addClickHandler (new ClickHandler () (
@ Override
public void onClick (ClickEvent event) (
throw new RuntimeException ( "RuntimeException");
)));

button.click ();
...

More:


Button.click() não funciona


Problema

Ao chamar o método Button.click() (classe do GWT) nada acontece. Ex:

...
Button button = new Button("Button");

button.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
throw new RuntimeException("RuntimeException");
}});

button.click();
...

Este código, a princípio, deveria lançar uma exceção.

Motivo

O botão, ou um objeto que o contém, não foi adicionado ao RootPanel.

Solução

Adicionar o widget ao RootPanel. Ex:

...
Button button = new Button("Button");

RootPanel.get().add(button);

button.addClickHandler(new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
throw new RuntimeException("RuntimeException");
}});

button.click();
...

Mais: