Timing / intermittent problems - Java 8 maybe?

74 views
Skip to first unread message

Paul Williams

unread,
Dec 22, 2014, 10:08:48 AM12/22/14
to growing-object-o...@googlegroups.com
I've managed to progress through Chapter 16, but have two intermittent issues that I think maybe threading / timing related, and wondered these could be due to Java 8. 

The first problem appears to be with WindowLicker. When I attempt to run MainWindowTest under Arch Linux or OS X, it fails to enter the correct text into the JTextField. The book suggests "an item-id" as a test case. On my linux box, although the code attempts this, Window Licker only puts in "n item-id" - notice the missing first 'a'. The same text on my mac enters the first 'a' but always misses the last 'd'. Either way, the tests fail. I assume it's a race condition between Swing, WindowLicker and my code. 

The second problem occurs when running the whole suite from Maven. Regardless of success or failure of the MainWindowTest suite, the End to End tests fail as more and more Swing panes open, and WindowLicker struggles to address the correct one. Strangely, if I only run the End to End tests, these pass, at least on OSX. The multiple auction end to end test does however fail on Linux as it fails to clear the JTextField which I believe to be another instance of the first issue above. 


Thank you. 

Steve Freeman

unread,
Dec 22, 2014, 3:23:23 PM12/22/14
to growing-object-o...@googlegroups.com
I don't have an answer to this, expect to wonder if Maven is running the tests in parallel. We never tried that.

Have you tried an older version of Java?

S
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Paul Williams

unread,
Dec 22, 2014, 4:08:40 PM12/22/14
to growing-object-o...@googlegroups.com
Cheers for quick reply Steve,

I am currently suspecting Maven. I've subsequently downgraded to Java 7, and can still replicate the issue. 

I don't think it's parallelisation; running the end to end test suite works fine, at least on OS X and I can see the suites tests execute in series. However, the single test in MainWindowTest fails with the previously described unreliable but repeatable 'typing' problem as possibly seen below.  


My next step is to extract the source, and execute it without maven and will advise whether this works.

Cheers

> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

Paul Williams

unread,
Dec 22, 2014, 4:37:08 PM12/22/14
to growing-object-o...@googlegroups.com
Hi, 

I've now eliminated Maven from the equation. Running:

java -cp "target/dependency/*:target/test-classes/:target/classes/" org.junit.runner.JUnitCore uk.me.paulswilliams.auction.tests.AuctionSniperEndToEndTest

results in successful 

JUnit version 4.11
....
Time: 18.042

OK (4 tests)

However, executing just MainWindowTests 

java -cp "target/dependency/*:target/test-classes/:target/classes/" org.junit.runner.JUnitCore uk.me.paulswilliams.auction.MainWindowTest

results in 

makesUserRequestWhenJoinButtonClicked(uk.me.paulswilliams.auction.MainWindowTest)
java.lang.AssertionError: 
Tried to find:
    join request "an item-id"
but:
    join request "an item-id". . Received: "n item-i"
at com.objogate.wl.PollingProber.check(PollingProber.java:38)

This later failure is due to WindowLicker failing to type the whole 'an item-id' value into the text box :-/

I will continue in my investigation into the root cause.

Paul.

Steve Freeman

unread,
Dec 22, 2014, 4:39:13 PM12/22/14
to growing-object-o...@googlegroups.com
Might be worth going all the way back to java 6. That's what we used at the time.

Sorry I can't be more helpful.

S

Paul Williams

unread,
Dec 22, 2014, 5:22:34 PM12/22/14
to growing-object-o...@googlegroups.com
Cheers Steve,

I think I've found the problem. I've been comparing my code to http://github.com/edzhelyov/goos and I've successfully ran the MainWindowTest test from edzhelyov's project. 

Before doing a line by line source comparison to ensure Swing threading etc was okay in my code, I tried copying my r286 window licker jar files into it's lib directory and replicated the problem. Maybe edzhelyov's dev snapshots are newer than my Maven dependency, so I think I'll try using these dependencies on mine. Hopefully this might work. 

Cheers,

Paul.

Nat Pryce

unread,
Dec 22, 2014, 5:55:31 PM12/22/14
to growing-object-o...@googlegroups.com
Unfortunately AWT and Swing are very testing-unfriendly.  Windowlicker was written for Windows XP, and made to work on whatever Java did on MacOS X five or six years ago.   But it requires an inordinate amount of effort to keep the test framework compatible with all the different implementations of Swing.  I would strongly recommend not using WindowLicker any more.  Try Google's WindowTester (https://developers.google.com/java-dev-tools/wintester/html/index) -- it has the same programming model as WindowLicker and a big company maintaining it.

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Paul Williams

unread,
Dec 23, 2014, 4:55:24 AM12/23/14
to growing-object-o...@googlegroups.com
Well, in the end, persistence paid off. I've resolved both problems with differing approaches.

The first issue with unreliable, but repeatable failures was due to using the http://mvnrepository.com/artifact/com.googlecode.windowlicker/windowlicker-swing/r268 maven dependency. Replacing this with the DEV snapshot from https://github.com/edzhelyov/goos resolved this.

The second problem relates to running the unit and integration tests in one session. It appears that attempting to run the end to end tests straight after MainWindowTest causes the teardown failures. I've now renamed the end to end test with IT suffix, so maven runs this in the integration test phase and all is well.

To help others in the future, the version passing my CI is at https://github.com/paulspencerwilliams/auctionsniperjava/commit/2253f08de86b9377b654dc2dfe4c95c75c1ac843

Steve, Nat, cheers for the help. Nat, I understand your advise, and way well take it, and try WindowTester as I progress further. However, there does seem to be some conceptual changes which I'm going to deliberately defer unless I find the need later.

BTW, this code now works on Java 8 :-)
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Steve Freeman

unread,
Dec 23, 2014, 5:32:40 AM12/23/14
to growing-object-o...@googlegroups.com
Thanks for the update.

Perhaps it's time we rewrote the example...

S
> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> http://www.natpryce.com
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

Paul Williams

unread,
Dec 23, 2014, 6:17:04 AM12/23/14
to growing-object-o...@googlegroups.com
Rewrote, or just a little refresh?

Smack changes, and Windowlicker issues are the only real problems I've seen. My only slight frustration has been their distraction from the TDD / feedback core concepts trying to be taught.

Paul.

You received this message because you are subscribed to a topic in the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/growing-object-oriented-software/aEFI72rjn7w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to growing-object-oriente...@googlegroups.com.

Paul Williams

unread,
Dec 23, 2014, 6:19:07 AM12/23/14
to growing-object-o...@googlegroups.com
Saying that, the other thing is possibly to address the strict mock to less strick mock fashion change in recent years.

Steve Freeman

unread,
Dec 23, 2014, 6:23:48 AM12/23/14
to growing-object-o...@googlegroups.com
Sorry, we just disagree on that one. Plus jmock already implements quite flexible allowing() syntax.

S

Nat Pryce

unread,
Dec 23, 2014, 6:25:10 AM12/23/14
to growing-object-o...@googlegroups.com
On 23 December 2014 at 11:19, Paul Williams <pa...@paulswilliams.me.uk> wrote:
Saying that, the other thing is possibly to address the strict mock to less strick mock fashion change in recent years.

In that aspect, I'm stolidly unfashionable.  I'm a tweed suit, brogues and Barbour sort of chap when it comes to strict mocks!

Paul Williams

unread,
Dec 23, 2014, 7:21:52 AM12/23/14
to growing-object-o...@googlegroups.com
Notice my careful, if maybe too subtle use of the word address, rather than buckle in to. I have however, seen strict mocks being used as the common reason for brittle tests, rather than the more likely, chatty nature of tightly coupled classes etc. I might have lost track of earlier advise in the book, on how the better fix would be to address this coupling rather than applying the loose mocks elasterplast.

Anyhow, I thought brogues were very hipster fashionable ;-)
> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> http://www.natpryce.com
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/growing-object-oriented-software/aEFI72rjn7w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Evgeni Dzhelyov

unread,
Dec 23, 2014, 10:07:09 AM12/23/14
to growing-object-o...@googlegroups.com
I was a bit frustrated in the beginning when I had to gather all correct versions of the dependencies that eventually worked together.

In that sense, I think the examples can be improved by explicit versioning of the dependencies and some form of a artifacts repository where you can download all of them.


To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

Nat Pryce

unread,
Dec 23, 2014, 10:17:31 AM12/23/14
to growing-object-o...@googlegroups.com
On 23 December 2014 at 11:17, Paul Williams <pa...@paulswilliams.me.uk> wrote:
Rewrote, or just a little refresh?

Smack changes, and Windowlicker issues are the only real problems I've seen. My only slight frustration has been their distraction from the TDD / feedback core concepts trying to be taught.

Or you could think of it as a demonstration of why creating a walking skeleton is such a useful practice :-)

Paul Williams

unread,
Dec 23, 2014, 10:44:58 AM12/23/14
to growing-object-o...@googlegroups.com
Absolutely, it does reflect the start of a real project :-)

Paul.

> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> http://www.natpryce.com
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to a topic in the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/growing-object-oriented-software/aEFI72rjn7w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages