Skip to content

Article on JUnit 4

I’ve published an article about JUnit 4 on DevX : Get Acquainted with the New Advanced Features of JUnit 4. JUnit 4 has changed a lot and it looks like there is much more to come. This article shows you how to migrate from JUnit 3.8 to JUnit 4 and gives you an overview of JUnit 4 new features. An article is never written alone. So first of all I would like to thank my wife Denise who read and corrected a boring technical article that she didn’t understand a word. Second, Lori Piquet from JupiterMedia for his help and expertise in writing articles. And a special thanks to both my friends Alexis Midon and Zouheir Cadi who took a bit of time to review this article. Do not hesitate to post comments.

Read More →

Annotations are great ! Really ?

Do you remember 6/7 years ago. EJBs were the big thing and with them came deployment descriptor written in XML. Then Webapp with their web.xml, and then Enterprise applications with their application.xml. XML was everywhere, XML was cool. Imagine, you can write your Java code, deploy it and after just twist bits and pieces in your XML files. XML, XML… Then we had SAX, DOM, JAXB, Castor, XSL, XSLT, Schemas, DTD… God, life became so flexible. Too flexible ? Of course ! XML has taken over our lives, we all hate XML now. We hate it so much that we started using xDoclet to get rid of it. But now, thanks to Java 5, we are really getting rid of XML and giving up all this XML flexible into more rigid annotations. But it‘s so much better : code and annotations are at the same place, on the same class, on the same method. Much better, easier to read. You see, annotations are so cool that we use them for persistence (Hibernate, JPA…), components (EJB 3), unit testing (JUnit 4), XML (with JAXB 2)… and so on. Yes, I tell you, annotations are great ! And there is no way that in 6/7 years we will end up coding this : @Entity @Name('componentName') @Inheritance @Scope(ScopeType.CONVERSATION) @Logger('loggerName') @TransactionAttribute(NEVER) @Remote({examples.Animal.class}) @ExcludeDefaultInterceptors @NamedQuery(name='findAllAnimals') class Animal extends Creature ( @Id @SequenceGenerator(name='ANIMAL_SEQ', allocationSize=25) @GeneratedValue(strategy=SEQUENCE, generator='ANIM_SEQ') @Column(name='ANIM_ID') private String id @AssociationOverride @Enumerated private Owner owner @Deprecated […]

Read More →

JAXB 2.0 Hello World

For people who have played with JAXB 1.x, JAXB 2.0 has the same beahavior: it can marshall/unmarshall object from/to XML. But the syntax is completly different. It uses all kind of annotations. This blog is just about writing and executing a good old Hello World with JAXB 2.0. First you need to download and install the binary. For the following example you will just need to put jaxb-api.jar and jaxb-impl.jar in your classpath. The following code represents a HelloWorld class with two attributes. The main method creates a HelloWorld object, sets some values, marshalles it to the hello.xml file, displays the xml representation, unmarshalles the xml file into a HelloWord and displays the toString method : import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import javax.xml.bind.annotation.XmlRootElement; import java.io.File; import java.io.FileOutputStream; @XmlRootElement public class HelloWorld { private String hello; private Integer world; public String getHello() { return hello; } public void setHello(String hello) { this.hello = hello; } public Integer getWorld() { return world; } public void setWorld(Integer world) { this.world = world; } public String toString() { return hello "-" world; } public static void main(String[] args) throws Exception { // Set up file and JAXB context final File file = new File("hello.xml"); JAXBContext context = JAXBContext.newInstance(HelloWorld.class); // Creates a HelloWorld object HelloWorld hw = new HelloWorld(); hw.setHello("Hello !!!"); hw.setWorld(1234); // From a HelloWorld object creates a hello.xml file Marshaller m = context.createMarshaller(); m.marshal(hw, new FileOutputStream(file)); m.marshal(hw, System.out); // From the hello.xml […]

Read More →

Java Day 2006 in Paris

Well, in fact Java Day 2006 wasn’t held in Paris itself but in Versailles, just in front of the castle So, yes, things also happen outside the US. I know, it was just a one day java conferences with only 5 sessions, nothing compare to the four days of Java One and its 188 sessions. But still, we had James Goslings on stage. If you look at the agenda, this is what happened. Welcome Eric Mahé ? Technology Advisor ? Sun Microsystems France Eric, who has been working for 17 years at Sun, introduced the java day and the agenda. After few marketing slides (you always have to thank the sponsors) he joked about Extreme Pixel Programming. The idea is that Eric is not a java programmer, the tool he uses the most is Photoshop and he would like to use it to code some java classes. So he opened Photoshop, dragged & dropped some images, saved it as a raw file, opened the raw file, copied the content and pasted it into a java file in Netbeans. He then executed it, and the image was displayed with animation. He said that the one who finds the trick will win one of its own art work… bets opened. The Next Wave of Java Tools James Gosling ? Chief Technology Officer of Sun’s Developer Products group James arrived on stage and threw some left over t-shirt of Java One at the […]

Read More →

What would be your ideal job?

I‘ve been working in the IT industry for quite a long time now. Mainly in big companies, on big projects where you spend half your time in meetings and the other half writing meeting reports. Through this experience I‘ve met a lot of people who have had different experiences, different projects but I‘ve never met anyone who has had their ideal job during his/her career. There are always management, political, personnel or budget problems which cause the project to turn into a nightmare. When you talk to people, everybody seems to converge towards an ideal situation where innovation, dynamism, professionalism, intelligent management and beauty flow 10 hours a day… but that never happens. As a Java developer, architect or project leader, what would be your ideal job? Working in a big company, an editor, a start-up, self-employed, working in open-source, in a training company? At the office or at home? Part-time or full-time? What kind of industry would fulfil your dreams? Bank, insurance, telecommunications, industry, leisure? What would be the perfect allocation between development, management, training, publishing articles, working for open source, technology watch, learning new things? Or would you quit Java to move to .Net or a deserted island under the sun? While waiting for the magical wand to create the job of our dreams, let’s blog about it.

Read More →

Weblogic cluster life cycle

When you run a weblogic cluster you have to deal with several messages BEA-0001xx . It is then difficult to figure out what is the normal behavior of a cluster and the normal messages to get. Imagine two managed servers ClusterServer1 (listening on port 4001) and ClusterServer2 (port 4002) running on a cluster and sharing heartbeats through the multicast address […]

Read More →