Running unit tests that touch AWT

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Running unit tests that touch AWT

Augusto Sellhorn
This is not really a Hudson specific question, but I'm having the problem manifest on my CI server.

I have some unit test that interact with GUI components, they don't display them but obviously down the line in AWT something is trying to connect to X11 (this is on Solaris 10). Now I passed the
-Djava.awt.headless=true property, but still I get this ...

    [junit] Testcase: testUI(some.ui.package.Test):	Caused an ERROR
[junit] Can't connect to X11 window server using 'localhost:0.0 ' as the value of the DISPLAY variable.
[junit] java.lang.InternalError: Can't connect to X11 window server using 'localhost:0.0' as the value of the DISPLAY variable.
[junit] at sun.awt.X11GraphicsEnvironment.initDisplay (Native Method)
[junit] at sun.awt.X11GraphicsEnvironment.access$000(X11GraphicsEnvironment.java:53)
[junit] at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:142)
[junit] at java.security.AccessController.doPrivileged (Native Method)
[junit] at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java :164)
[junit] at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
[junit] at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:93)
[junit] at java.lang.Class.forName0 (Native Method)
[junit] at java.lang.Class.forName(Class.java:164)
[junit] at java.awt.Toolkit$2.run(Toolkit.java:821)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:804)
[junit] at javax.swing.UIManager.initialize(UIManager.java:1262)
[junit] at javax.swing.UIManager.maybeInitialize(UIManager.java:1245)
[junit] at javax.swing.UIManager.getUI(UIManager.java:851)
[junit] at javax.swing.JButton.updateUI(JButton.java:113)
[junit] at javax.swing.AbstractButton.init(AbstractButton.java:2003)
[junit] at javax.swing.JButton .<init>(JButton.java:103)
[junit] at javax.swing.JButton.<init>(JButton.java:76)
I thought java.awt.headless=true would due it, but I'm obviously missing something here. Do I need to run a specialized X server, xvnc, frame buffer?

Thanks

--
Augusto
http://sellmic.com
Reply | Threaded
Open this post in threaded view
|

Re: Running unit tests that touch AWT

Jesse Glick
Augusto Sellhorn wrote:
> I thought java.awt.headless=true would due it, but [it doesn't]

Odd, I would have thought that would work too. Consider filing a bug for
the JRE if you can make a small, reproducible test case.

> Do I need to run a specialized X server, xvnc, frame buffer?

That is easy enough. If you have XVNC installed on your server, just
grab the XVNC plugin for Hudson and enable it for your project. It is
designed specifically to let you run tests that might manipulate
graphics objects during a Hudson build.

-J.

--
[hidden email]  netbeans.org  ant.apache.org  hudson.dev.java.net
             http://google.com/search?q=e%5E%28pi*i%29%2B1

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Running unit tests that touch AWT

Benjamin Muschko
In reply to this post by Augusto Sellhorn
Try using the PJA toolkit library (http://www.eteks.com/pja/en/) for running the tests. I once had the same problem. This is how I used it:

<junit printsummary="yes" haltonerror="no" haltonfailure="no" fork="yes">
   <jvmarg value="-Xbootclasspath/a:${repository.lib.pja.dir}/pja.jar"/>
   <jvmarg value="-Dawt.toolkit=com.eteks.awt.PJAToolkit"/>
   <jvmarg value="-Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment"/>
   <jvmarg value="-Djava.awt.fonts=${repository.lib.root.dir}/jre/1_4_2_03/lib/fonts"/
   ...

Hope that helps.

Ben

<quote author="Augusto Sellhorn">
This is not really a Hudson specific question, but I'm having the problem
manifest on my CI server.

I have some unit test that interact with GUI components, they don't display
them but obviously down the line in AWT something is trying to connect to
X11 (this is on Solaris 10). Now I passed the
-Djava.awt.headless=true property, but still I get this ...

    [junit] Testcase: testUI(some.ui.package.Test): Caused an ERROR
    [junit] Can't connect to X11 window server using 'localhost:0.0'
as the value of the DISPLAY variable.
    [junit] java.lang.InternalError: Can't connect to X11 window
server using 'localhost:0.0' as the value of the DISPLAY variable.
    [junit] at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    [junit] at
sun.awt.X11GraphicsEnvironment.access$000(X11GraphicsEnvironment.java:53)
    [junit] at
sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:142)
    [junit] at java.security.AccessController.doPrivileged(Native Method)
    [junit] at
sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:131)
    [junit] at java.lang.Class.forName0(Native Method)
    [junit] at java.lang.Class.forName(Class.java:164)
    [junit] at
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
    [junit] at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:93)
    [junit] at java.lang.Class.forName0(Native Method)
    [junit] at java.lang.Class.forName(Class.java:164)
    [junit] at java.awt.Toolkit$2.run(Toolkit.java:821)
    [junit] at java.security.AccessController.doPrivileged(Native Method)
    [junit] at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:804)
    [junit] at javax.swing.UIManager.initialize(UIManager.java:1262)
    [junit] at javax.swing.UIManager.maybeInitialize(UIManager.java:1245)
    [junit] at javax.swing.UIManager.getUI(UIManager.java:851)
    [junit] at javax.swing.JButton.updateUI(JButton.java:113)
    [junit] at javax.swing.AbstractButton.init(AbstractButton.java:2003)
    [junit] at javax.swing.JButton.<init>(JButton.java:103)
    [junit] at javax.swing.JButton.<init>(JButton.java:76)

I thought java.awt.headless=true would due it, but I'm obviously missing
something here. Do I need to run a specialized X server, xvnc, frame buffer?

Thanks

--
Augusto
http://sellmic.com


Reply | Threaded
Open this post in threaded view
|

Re: Running unit tests that touch AWT

Augusto Sellhorn
Thanks everybody.

Well the headless parameter didn't work, also x11vnc seems to want to connect to a real X11 server. So I ended up using the Xvbf command for the frame buffer and that seems to work. I'm going to try this PJAToolkit later, this looks like I can setup from my build in the first place and doesn't require the "setup" of having the Xvbf program setup on a machine.

On 10/30/07, Benjamin Muschko <[hidden email]> wrote:

Try using the PJA toolkit library (http://www.eteks.com/pja/en/) for running
the tests. I once had the same problem. This is how I used it:

<junit printsummary="yes" haltonerror="no" haltonfailure="no" fork="yes">
   <jvmarg value="-Xbootclasspath/a:${repository.lib.pja.dir}/pja.jar"/>
   <jvmarg value="-Dawt.toolkit=com.eteks.awt.PJAToolkit"/>
   <jvmarg
value="-Djava.awt.graphicsenv=com.eteks.java2d.PJAGraphicsEnvironment "/>
   <jvmarg
value="-Djava.awt.fonts=${repository.lib.root.dir}/jre/1_4_2_03/lib/fonts"/
   ...

Hope that helps.

Ben


Augusto Sellhorn wrote:
>
> This is not really a Hudson specific question, but I'm having the problem
> manifest on my CI server.
>
> I have some unit test that interact with GUI components, they don't
> display
> them but obviously down the line in AWT something is trying to connect to
> X11 (this is on Solaris 10). Now I passed the

> -Djava.awt.headless=true property, but still I get this ...
>
>     [junit] Testcase: testUI(some.ui.package.Test):   Caused an ERROR
>     [junit] Can't connect to X11 window server using 'localhost: 0.0'
> as the value of the DISPLAY variable.
>     [junit] java.lang.InternalError: Can't connect to X11 window
> server using 'localhost:0.0' as the value of the DISPLAY variable.
>     [junit]   at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
>     [junit]   at
> sun.awt.X11GraphicsEnvironment.access$000(X11GraphicsEnvironment.java:53)
>     [junit]   at
> sun.awt.X11GraphicsEnvironment$1.run (X11GraphicsEnvironment.java:142)
>     [junit]   at java.security.AccessController.doPrivileged(Native Method)
>     [junit]   at
> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java :131)
>     [junit]   at java.lang.Class.forName0(Native Method)
>     [junit]   at java.lang.Class.forName(Class.java:164)
>     [junit]   at
> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment (GraphicsEnvironment.java:68)
>     [junit]   at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:93)
>     [junit]   at java.lang.Class.forName0(Native Method)
>     [junit]   at java.lang.Class.forName (Class.java:164)
>     [junit]   at java.awt.Toolkit$2.run(Toolkit.java:821)
>     [junit]   at java.security.AccessController.doPrivileged(Native Method)
>     [junit]   at java.awt.Toolkit.getDefaultToolkit (Toolkit.java:804)
>     [junit]   at javax.swing.UIManager.initialize(UIManager.java:1262)
>     [junit]   at javax.swing.UIManager.maybeInitialize(UIManager.java:1245)
>     [junit]   at javax.swing.UIManager.getUI (UIManager.java:851)
>     [junit]   at javax.swing.JButton.updateUI(JButton.java:113)
>     [junit]   at javax.swing.AbstractButton.init(AbstractButton.java:2003)
>     [junit]   at javax.swing.JButton.<init>( JButton.java:103)
>     [junit]   at javax.swing.JButton.<init>(JButton.java:76)
>
> I thought java.awt.headless=true would due it, but I'm obviously missing
> something here. Do I need to run a specialized X server, xvnc, frame
> buffer?
>
> Thanks
>
> --
> Augusto
> http://sellmic.com
>
>

--
View this message in context: http://www.nabble.com/Running-unit-tests-that-touch-AWT-tf4719901.html#a13494662
Sent from the Hudson users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




--
Augusto
http://sellmic.com
Reply | Threaded
Open this post in threaded view
|

Re: Running unit tests that touch AWT

Jesse Glick
Augusto Sellhorn wrote:
> x11vnc seems to want to connect to a real X11 server

Shouldn't. But I have only ever tested this on Linux.

--
[hidden email]  netbeans.org  ant.apache.org  hudson.dev.java.net
             http://google.com/search?q=e%5E%28pi*i%29%2B1

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]