In Chapter 6 “Where to go from here” on page 58 Dean references TotallyLazy for those not wanting to take the scala / clojure route.
Hopefully this will stop someone from wasting a day of their life…
If you pass in the following when you start your Java application:
java -Dlog4j.configuration=file:///some/path/log4j.properties
And that file contains a class that is not on the class path
log4j.appender.myAppender=biz.minaret.log4j.DatedFileAppender
log4j.rootLogger=error, myAppender
Then due to the log4j static initialisers you will not see an error for the class in question but instead:
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.FileAppender
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Unfortunately for me this was caused by a transitive dependency changing in Maven. Damn you Maven/Log4J
Firstly this is not just my effort but my team and organisation.
Secondly the usual rules apply, this is expert advise and what works for me will very probably cause your whole production stack to blow up and kill people.
Lastly this is long so skip to the bit you care about or come along and chat at QCon London 2012
Well lets answer the obvious questions:
“Can this work for real apps or just fun stuff?” Yes real apps old and new.
“Does it need to be greenfield?” No but it takes a long time (months) to get builds down on old codebases.
99 Bottles of Beer in Totallylazy
import static com.googlecode.totallylazy.Runnables.printLine;
import static com.googlecode.totallylazy.lambda.Lambdas.n;
import static com.googlecode.totallylazy.lambda.Lambdas.λ;
import static com.googlecode.totallylazy.numbers.Numbers.decrement;
import static com.googlecode.totallylazy.numbers.Numbers.range;
public class BottlesOfBeer {
// Run with -javaagent:enumerable-java-0.4.0.jar -cp:totallylazy-598.jar:enumerable-java-0.4.0.jar
public static void main(String[] args) {
range(99, 0).map(λ(n, verse(n))).each(printLine("%s of beer on the wall.\n"));
}
private static String verse(Number number) {
if (number.equals(0))
return "No more bottles of beer on the wall, no more bottles of beer.\n" +
"Go to the store and buy some more, 99 bottles";
return String.format("%s of beer on the wall, %1$s of beer.\n" +
"Take one down and pass it around, %s", bottles(number), bottles(decrement(number)));
}
private static String bottles(Number number) {
if (number.equals(0)) return "no more bottles";
if (number.equals(1)) return "1 bottle";
return number + " bottles";
}
}
If you have a Dell Precision M6500 with a Synaptic TouchPad + TrackPoint) (rather than an ALPS version) and you are running Ubuntu 10.10 you may find the TrackPoint / TrackStick / Nipple is being detected as a standard PS/2 Generic Mouse and this is causing the movement to be very slow.
You can check this by typing:
xinput list
If you see something like this:
Virtual core pointer id=2 [master pointer (3)]
↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
↳ SynPS/2 Synaptics TouchPad id=11 [slave pointer (2)]
↳ PS/2 Generic Mouse id=12 [slave pointer (2)]
As you can see the TrackPoint is not listed and as such you wont see it in any of the configuration screens.
http://www.hemispheregames.com/osmos/
Very chilled out…
Crazy Talk - Holistic Web Testing - Some forces...
So given the above, the forces I am trying to balance are
- Make it easy for people to do the right thing, hard to do the wrong thing.
- Make it valuable (Finds more bugs than false alarms)
- Make it resilient (Allows me to refactor like the true crazy person I am)
- Make it fast (Magnify it’s value rather deminishing it)
- Make it good enough (Give me enough confidence to do more crazy stuff but don’t become dogmatic)
- Allow people to do what they are good at
Next I’ll talk about how the default setup I use to do, in-memory, out of container testing.
Now for some web specific whys/values I do the in-memory acceptance testing…
- Semantic Html is my golden hammer
- Progressive enhancement is my swiss army knife
- I love JavaScript but try to never write any but if i must I make sure it’s generic. I try very hard to make sure no else writes any either and if they do I just refactor it till it deletes itself.
- I love AHAH and barely tolerate AJAX / JSON
- REST is my natural state not something I read about
All of these forces / values / beliefs drive me to solve the problem of web testing in a very different approach from most people. It is about an alternative holistic approach to web architecture, testing and productivity.
Crazy Talk - Holistic Web Testing - Some values...
(Previously on TWSDEV)
As the “crazy” guy behind the in-memory / out-of-container acceptance testing on a number of java/.net projects, I think it’s important I explain to people the “Why” and the forces / constraints I am trying to balance. But first I want to quickly lay down my beliefs and values:
- I believe in testing as much as possible (UI included)
- I believe tests must add more value than they cost (Measure it!)
- I value tests that are fast and are resilient to change more than tests that take a long time to run and are brittle.
- When refactoring a feature I value acceptances tests and integration test over unit tests.
- When designing/exploring a new interface / object interaction I value unit tests over acceptance tests to help guide me.
- I believe that QA’s are so much better at finding bugs than DEVs but worse at writing code / abstractions