Google
 

Thursday, May 31, 2007

Words 4 ever ...

"Gravitation cannot be held responsible for people falling in love. How on earth can you explain in terms of chemistry and physics so important a biological phenomenon as first love? Put your hand on a stove for a minute and it seems like an hour. Sit with that special girl for an hour and it seems like a minute. That's relativity." Albert Einstein

Tuesday, May 29, 2007

Au fil de mes lectures

"Si nous serrions bien de près notre persuasion la plus chère, nous verrions que ce que nous appelons plus ou moins folie dans les autres, c'est tout ce qui n'est pas purement et simplement notre pensée propre et elle seule, tout ce qui n'est pas moi : fou, c'est le synonyme intime de toi."

(
Charles Augustin Sainte-Beuve - Pensées et maximes, p.16, Grasset 1954)

Polyphasic sleep

Polyphasic sleep is a term used to describe several alternative sleep patterns intended to reduce sleep time to 2–6 hours daily. This is achieved by spreading out sleep into short naps of around 15–30 minutes throughout the day, and in some variants, a core sleep period of a few hours at night.

The process of adapting to a polyphasic schedule can involve a mentally and physically very difficult one- to two-week transition period, especially for the variant known as Uberman sleep. Thereafter, independent testers claim to experience no apparent drop of cognition or alertness, despite the few hours of sleep attained each day. On the other hand, polyphasic sleep typically requires adhering to a rigid schedule, which makes it unfeasible for many people.

Relatively little scientific research has been performed on polyphasic sleep. Much, if not most, of the information about it comes from the claims of independent testers, many of whom are bloggers.

Types
The term "polyphasic sleep" itself refers only to the practice of sleeping multiple times in a 24-hour period (usually, more than two, in contrast to "biphasic sleep") and does not imply any particular schedule.

In application, "Uberman's sleep schedule" is likely to be the most widely known type of polyphasic sleep, and also the most strict. It consists of six naps of 20–25 minutes each, occurring four hours apart throughout the day. This is also the closest schedule to the type that has been studied by Claudio Stampi in connection with long-distance solo boat races.

"Core sleep" is a variant of Uberman that adds a block of sleep, usually several hours, to the Uberman schedule, replacing one or two naps. (This term is also sometimes used to describe accidental oversleep by someone following Uberman, though one will more likely see the term "crash", and occasionally "reboot".)

Buckminster Fuller advocated "Dymaxion Sleep," a regimen consisting of 30 minute naps every six hours. A short article was published about this schedule in the October 11, 1943 issue of Time Magazine. According to this article, he followed this schedule for two years, but after that had to quit because "his schedule conflicted with that of his business associates, who insisted on sleeping like other men."

Criticism
Some consider the theory behind polyphasic sleep unsound, claiming that there is no brain control mechanism that would make it possible to switch from a typical biphasic (or monophasic) sleep pattern to a "multiple naps" system. They claim, the body will always tend to consolidate sleep into at least one solid block of sleep (usually during the night or early in the morning), and, as a result, adepts of polyphasic sleep suffer through a never-ending period of "adaptation". Critics often point to the fact that there is no scientific evidence, specifically no articles have been published in any peer-reviewed scientific journals supporting the possibility of entrainment of the polyphasic pattern.

and Advocates of polyphasic sleep often claim that the procedure boosts their alertness, but skeptics question whether this alertness is related to the sleep pattern or whether increased adrenaline and cortisol is gained from eagerness to succeed in their polyphasic experiment and their other productive pursuits. A study published in the Journal of Sleep Research in September of 2002 concerning the effects of napping on productivity found that 10-minute naps tended to improve productivity more than longer naps, which may suggest that the onset of sleep is the cause of the increased alertness.

Proponents claim that several famous people applied catnapping to a large extent.
  • Leonardo da Vinci - unverified. It seems all that is known about Leonardo's sleep was written after his death. Polyphasic sleep logs claim he slept only 15 minutes at a time, every two hours. The term "Da Vinci sleep" is often used as a synonym for polyphasic sleep.
  • Lord Byron, poet and hedonist.
  • Paul Erdős, the itinerant mathematician, slept two hours a day for several decades through a combination of napping and amphetamine use.
  • P. Diddy - unverified. He spoke about sleeping habits similar to polyphasic sleep patterns on the show MTV Diary claiming that he sleeps between two to four hours a day.
Urban legends
  • Benjamin Franklin — It is Franklin who said "There will be sleeping enough in the grave" as well as "The sleeping fox catches no poultry". However, he is also attributed with "Early to bed and early to rise makes a man healthy, wealthy, and wise", which is a definite monophasic mantra.
  • Thomas Jefferson — This claim is likely to be an urban legend as Jefferson, in his own words, indicated that he slept irregularly in a single block of 5–8 hours in the night, always after 30–60 minutes of inspirational reading (Letters to Vine Utley, 1819).
  • Albert Einstein - False. Albert enjoyed occasional super-bouts of 9 hour sleep and was generally a long sleeper.
References
Claudio Stampi. Why We Nap: Evolution, Chronobiology, and Functions of Polyphasic and Ultrashort Sleep. (1992)

The 13 Principles of Success

  1. Desire
  2. Faith
  3. Auto-suggestion
  4. Specialized Knowledge
  5. Imagination
  6. Organized Planning
  7. Decision
  8. Persistence
  9. The Master Mind
  10. The Mystery of Sex Transmutation
  11. The Subconscious Mind
  12. The Brain
  13. The Sixth Sense

... and outwit your Fears

( Napoleon Hill )

Outils Gratuits/Free Java Tools

Si vous cherchez les meilleurs Editeurs/EDI/RAD pour développer en Java, vizitez Les Outils Gratuits

Vous y trouverez des informations et des comptes-rendus sur les éditeurs avancés et simples.

My recommendations

If you love French and if you're passionate about programming, you should visit this site: http://developpez.com/
Here you can find lots of tutorials, articles, reviews for FREE.

Enjoy ;)

Reports made easy with JasperReports

The open source JasperReports uses XML templates for your reporting needs


Generating reports is a common, if not always glamorous, task for programmers. In the past, report generation has largely been the domain of large commercial products such as Crystal Reports. Today, the open source JasperReports report generating library gives Java developers a viable alternative to commercial software.

JasperReports provides the necessary features to generate dynamic reports, including data retrieval using JDBC (Java Database Connectivity), as well as support for parameters, expressions, variables, and groups. JasperReports also includes advanced features, such as custom data sources, scriptlets, and subreports. All in all, JasperReports combines good features, maturity, community participation, and, best of all, it's free.

Sunday, May 27, 2007

Words 4 ever ...

"Love is composed of a single soul inhabiting two bodies." ( Aristotle )

"A kiss is a lovely trick designed by nature to stop speech when words become superfluous." ( Ingrid Bergman )

"
The test of a first-rate intelligence is the ability to hold two opposed ideas in mind at the same time and still retain the ability to function. " ( F. Scott Fitzgerald )

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." ( Albert Einstein )

Oferte Nisipurile de Aur si Sfintii Constantin si Elena

Aici puteti gasi oferte de vacanta in statiunile Constantin si Elena si in Nisipurile de Aur, Bulgaria:

Easy Travel - Constantin si Elena

Vacante In Bulgaria - Constantin si Elena
Info Turism - Constantin si Elena
Info Turism - Golden Sands

Tuesday, May 22, 2007

Hoteluri - Nispurile de Aur (Golden Sands)

Mai jos este lista de hoteluri ordonate dupa numarul de stele - pentru mai multe detalii dati click pe numele hotelului.

5 stele:

Hotel ADMIRAL
KEMPINKSI GRAND HOTEL HERMITAGE

4 stele:

ASTERA
BERLIN GREEN PARK
BERLING GOLDEN BEACH
GRIFID ARABELLA
GRIFID BOLERO
HELIOS SPA & RESORT
IBEROSTAR OBZOR BEACH
MIMOZA
MORSKO OKO GARDEN
SOFIA
VIVA CLUB

3 stele:

EXCELSIOR
MADARA
METROPOL
MORSKO OKO BEACH
SHIPKA
SIRENA
SUNRISE
ZLATNA KOTVA

Google Web Toolkit

Google Web Toolkit (GWT) is an open source Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don't speak browser quirks as a second language. Writing dynamic web applications today is a tedious and error-prone process; you spend 90% of your time working around subtle incompatibilities between web browsers and platforms, and JavaScript's lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile.

GWT lets you avoid many of these headaches while offering your users the same dynamic, standards-compliant experience. You write your front end in the Java programming language, and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML.


Featured Example Projects
Desktop App Clone
A replica of the UI of a desktop email application.
Kitchen Sink
An application that includes every UI widget GWT supports.

For more information about GWT, you can read the Getting Started Guide, which you can find here: GWT Tutorial

Sunday, May 20, 2007

Oferte Bulgaria 2007

Oferta agentiei AliBabaTour
Oferta agentiei Patriot
Oferta agentiei Klever Travel pentru statiunea Nisipurile de Aur din Bulgaria - vara 2007
Descarca oferta in format doc de aici: Oferta Vara Nisipurile de Aur - Klever Travel
Oferta agentiei Fun Travel pentru statiunea Nisipurile de Aur din Bulgaria - vara 2007
Descarca oferta in format doc de aici: Nisipurile de Aur 2007

Friday, May 18, 2007

Java Beans

JavaBeans™ is a portable, platform-independent component model written in the Java programming language. The JavaBeans architecture was built through a collaborative industry effort and enables developers to write reusable components in the Java programming language.

With the JavaBeans API you can create reuseable, platform-independent components. Using JavaBeans-compliant application builder tools, you can combine these components into applets, applications, or composite components.

JavaBean components are known as beans. Beans are dynamic in that they can be changed or customized. Through the design mode of a builder tool, you use the property sheet or bean customizer to customize the bean and then save (persist) your customized beans.

For a complete training on JavaBeans, take the lessons from:

http://java.sun.com/docs/books/tutorial/javabeans/whatis/index.html
http://java.sun.com/docs/books/tutorial/javabeans/writingbean/index.html
http://java.sun.com/docs/books/tutorial/javabeans/persistence/index.html
http://java.sun.com/docs/books/tutorial/javabeans/longpersistence/index.html
http://java.sun.com/docs/books/tutorial/javabeans/introspection/index.html
http://java.sun.com/docs/books/tutorial/javabeans/customization/index.html
http://java.sun.com/docs/books/tutorial/javabeans/beancontext/index.html

Thursday, May 17, 2007

ICEfaces open source project

Product Overview

ICEfaces is an integrated Ajax application framework that enables Java EE application developers to easily create and deploy thin-client rich Internet applications (RIA) in pure Java. ICEfaces is a fully featured product that enterprise developers can use to develop new or existing Java EE applications at no cost.

ICEfaces is the only RIA framework on the market today that delivers unique Ajax Push capabilities. Discover the power of Ajax Push and create collaborative and dynamic enterprise applications like never before.

ICEfaces leverages the entire standards-based Java EE ecosystem of tools and execution environments. Rich enterprise application features are developed in pure Java, and in a pure thin-client model. There are no Applets or proprietary browser plug-ins required. ICEfaces applications are JavaServer Faces (JSF) applications, so Java EE application development skills apply directly and Java developers are isolated from doing any JavaScript related development.

You can view ICEfaces Product documentation by visiting the site below: http://www.icefaces.org/main/resources/documentation.iface

Wednesday, May 16, 2007

The Most Intelligent Java IDE

IntelliJ IDEA is an intelligent Java IDE intensely focused on developer productivity that provides a robust combination of enhanced development tools. Its functionality is continuously extended by the users and third parties


Key Features

Intelligent Coding Assistance
Smart editor that recognizes Java, HTML/XHTML, XML/XSL, CSS, Ruby and JavaScript, supports frameworks like Rails and GWT provides you the ultimate environment for creating the cutting edge code. Whatever language you are using, the advanced code completion, validation, formatting and styling are always at your hands. Plus, smart error and syntax highlighting combined with intelligent quick-fixes let effectively produce error free, clear code and focus on the logic of your project instead of routine dry work.

Smart Navigation & Search
Advanced project navigation view that is aware of Java, JSP, XML/XSL, HTML, Ruby and Rails code structure lets you quickly analyze even largest files at a glance, providing convenient way to browse through them. Active gutter icons let you instanly jump between symbol declaration and usages. Smart search that recognizes language elements displays results in an interactive navigation panel so helping you analyze all the files where the search item is found. Plus, Structural Search feature is especially designed for building intelligent search templates for operating with complex files.

Numerous Refactorings
IntelliJ IDEA features totally unmatched refactoring capabilities. Rich set of refactorings (50+) covers virtually every aspect of code transformation and lets you effectively maintain and upgrade your projects. All refactorings are aware of supported languages and technologies like Java, XML, JSP, EJB, Javascript and Ruby and provide an effective way to flexibly manage your code.

Unparalleled Code Analysis
Built-in high performance dynamic code analyzer with more than 600 inspections performs on-the-fly code analysis and detects all common syntax errors, plus all other errors that would be detected during compilation. You never need to compile your code to verify that it's error-free. IntelliJ IDEA provides analysis for most of the supported technologies, including JavaScript, XML, HTML and CSS, EJB, JSP, JSF, Struts, JavaDoc, properties files, Ant scripts, and more. Static code analysis detects performance bottlenecks, dead code, malformed dependencies and other problems with your code. IntelliJ IDEA provides you with automatic solutions for all detected errors.
Web & Enterprise Development Support
Rapid development of Java EE and Web applications with the full support for EJB, JSP, JSF, XML/XSL, HTML/XHTML/CSS technologies and languages, JBoss, WebSphere, Glassfish, Geronimo, Tomcat and Weblogic servers, Rails, Struts and other frameworks. Plus enhanced Javascript, AJAX and GWT support for building industry standard Web interfaces. Automated deployment and remote debugging included for maintaining optimum productivity levels through all development process stages.
Compiling, Running, Debugging
IntelliJ IDEA includes support for multiple Java compilers (javac, jikes, eclipse). You can compile your projects using your favorite compiler without having to leave your favorite IDE. IntelliJ IDEA also includes the Dependency-based make feature available for all supported compilers. The compilation results view lets you navigate to the source of any compilation message (error, warning or anything else) with a single key stroke or mouse click. IntelliJ IDEA includes the best of the breed JPDA-based debugger with a simple, easy to use user interface and leverages all its productivity-aimed features through every debugging step. The unique HotSwap technology lets you modify and recompile parts of the code during debugging without the need to restart the whole process. Plus, the intellectual breakpoints that enhance your debugging experience.

Unit Testing & Code Coverage
IntelliJ IDEA features the smart code coverage tool that measures the code coverage for your unit tests or tests written as simple applications with the main() method, improves the efficiency of code testing and ensures that you are always aware of how effectively your code is tested. Built-in test runner is fully JUnit 4 compatible. In addition, IntelliJ IDEA provides the flexible Inspection API which lets you easily create different plugins to extend the project-wide code analysis functionality and provide the means for meeting all project needs.
Team Work Facilitation
IntelliJ IDEA natively integrates with the most popular version control systems like Perforce, StarTeam, Subversion, CVS and Visual SourceSafe. Smart commits, advanced changelist management and unified VCS interface, plus integration with TeamCity — the innovative solution for continuous application development — all this boosts the productivity of your entire team. Additionally, a unique built-in instant messaging system lets developers stay in touch with each other by excanging live code pointers and stack traces.
Open API & Plugins
There are over 300 plugins for IntelliJ IDEA which extend its functionality and add various features to code inspections and refactorings, editors and tool windows, language support and application server and profiler integrations, Version Control System integrations, and so on and so forth. You can always improve an existing feature or add a missing one by using Open API — the flexible interface for building IntelliJ IDEA extensions. With Open API, you can access IntelliJ IDEA core and utilize all its power to extend the functionality as you please.

Business Objects

Business objects are objects in an object-oriented computer program that abstract the entities in the domain that the program is written to represent. For example, an order entry program needs to work with concepts such as orders, line items, invoices and so on. Each of these may be represented by a business object.

Business objects are sometimes called domain objects (where the word domain means the business), and a domain model represents the set of domain objects and the relationships between them.

Good business objects will encapsulate all of the data and behavior associated with the entity that it represents. For example, an order object will have the sole responsibility for loading an order from a database, exposing or modifying any data associated with that order (i.e. order number, the order's customer account), and saving the order back to the database.

Business objects don't necessarily need to represent objects in an actual business, though they often do. They can represent any object related to the domain for which a developer is creating business logic. The term is used to distinguish between the objects a developer is creating or using related to the domain and all the other types of object he or she may be working with such as user interface widgets and database objects such as tables or rows.

Data Access Object

Data Access Object (DAO) is a software component which provides a common interface between the application and one or more data storage devices, such as a database or file. The term is most frequently applied to the Object design pattern.

Advantages

Data Access Objects are a Core J2EE Design Pattern and considered best practice. The advantage of using data access objects is that any business object (which contains application or operation specific details) does not require direct knowledge of the final destination for the information it manipulates. As a result, if it is necessary to change where or how that data is stored that modification can be made without needing to change the main application.

Data Access Objects can be used in Java to insulate an application from the underlying Java persistence technology, which could be JDBC, JDO, EJB CMP, TopLink, Hibernate, iBATIS, or any one of a range of technologies. Using Data Access Objects means the underlying technology can be upgraded or swapped without changing other parts of the application.

Disadvantages

Flexibility has a price. When adding DAOs to an application, the additional complexity of using another persistence layer increases the amount of code executed during runtime. Configuration of persistence layers requires in most cases more work than writing a direct persistence tier that accepts Data Transfer Objects (DTOs).

For further information about Business Objects, visit the site below:
http://javaboutique.internet.com/tutorials/businessObject/

Tuesday, May 15, 2007

SWT: The Standard Widget Toolkit

The Standard Widget Toolkit (SWT) is a graphical widget toolkit for the Java platform originally developed by IBM and maintained now by the Eclipse Foundation in tandem with the Eclipse IDE. It is an alternative to the AWT and Swing Java GUI toolkits provided by Sun Microsystems as part of the Java standard.

SWT is written in Java. To display GUI elements, the SWT implementation accesses the native GUI libraries of the operating system using JNI (Java Native Interface) in a manner that is similar to those programs written using operating system-specific APIs. Programs that call SWT are portable, but the implementation of the toolkit, despite the fact that it is written in Java, is unique for each platform.

Performance

SWT is designed to be a "high performance" GUI toolkit; faster, more responsive and lighter on system resource usage than Swing. There has been some attempted benchmarking of SWT and Swing, which concluded that SWT is more efficient than Swing, although the applications benchmarked in this case were not complex enough to draw solid conclusions for all possible SWT or Swing uses.

SWT applications:
AZUREUS http://en.wikipedia.org/wiki/Azureus
Eclipse and its plugins
GumTree Platform http://en.wikipedia.org/wiki/GumTree

Here you can find useful documentation and tutorials on SWT:
http://www.eclipse.org/swt/docs.php
http://www.tutorialized.com/tutorial/SWT-Tutorial/7724







Java Glossary

If you need to know the definitions for common terms and acronyms used in the Java Industry, you should visit the sites listed below:

http://java.about.com/od/beginningjava/a/javaglossary.htm
http://java.sun.com/docs/glossary.html

Sunday, May 13, 2007

Model-view-controller

Model-view-controller (MVC) is an architectural pattern used in software engineering. In complex computer applications that present lots of data to the user, one often wishes to separate data (model) and user interface (view) concerns, so that changes to the user interface do not affect the data handling, and then the data can be reorganized without changing the user interface. The model-view-controller solves this problem by decoupling data access and business logic from data presentation and user interaction, by introducing an intermediate component: the controller.

Java Platform, Enterprise Edition
Unlike the other frameworks, Java EE defines a pattern for model objects.

Model
The model is commonly represented by entity beans, although the model can be created by a servlet using a business object framework such as Spring.
View
The view in a Java EE application may be represented by a Java Server Page. Alternately, the code to generate the view may be part of a servlet.
Controller
The controller in a Java EE application may be represented by a servlet.
Java MVC Frameworks
  • Struts is one of the original web-application frameworks which makes extensive use of MVC logic.
  • WebWork is a MVC Java web-application development framework. It is built specifically with developer productivity and code simplicity in mind, providing robust support for building reusable UI templates, such as form controls, UI themes, internationalization, dynamic form parameter mapping to JavaBeans, robust client and server side validation, and much more.
  • The Spring Framework is a newer Java EE application framework for both native Java applications as well as Java-served web-applications. Spring utilizes a multi-tier approach to java applications. One project within Spring is a web based MVC framework named "Spring MVC".
  • Roma is based on Spring Framework as IoC container, but you can use another one if you want.
  • Java Server Faces (JSF) framework is the Java EE standard web-application framework.
  • Swing (see below)
  • JFace, a MVC framework built on the Eclipse project's SWT set of operating-system-native controls
  • Openbravo, a web based ERP for small to medium sized business
  • Stripes, a light-weight yet full featured MVC framework that utilizes Java 1.5+ enhancements like annotations to simplify configuration and validation. Strong type conversion and a powerful binding engine allow complex objects to be displayed and edited in the html view. Add-on libraries like Stripernate help bind the framework to Hibernate's EJB3 persistence layer.
Java Swing

Java Swing is different from the other frameworks, in that it supports two MVC patterns.

Model (Frame level)
Like the other frameworks, the design of the real model is usually left to the developer.
Model (Control level)
Swing also supports models on the control level. Unlike other frameworks, Swing exposes the internal storage of each control as a model.
View
The view is represented by a class that inherits from Component.
Controller
Java Swing doesn't necessarily use a single controller. Because its event model is based on interfaces, it is common to create an anonymous action class for each event. In fact, the real controller is in a separate thread. It catches and propagates the events to the view and model.
For more information about the frameworks listed above, you can visit one of these sites:
http://courses.coreservlets.com/Course-Materials/struts.html
http://www.roseindia.net/struts/strutsguide.shtml
http://www.roseindia.net/spring/index.shtml
http://www.springframework.org
http://www.opensymphony.com/webwork/wikidocs/Tutorial.html

Saturday, May 12, 2007

Easy Mock

EasyMock provides Mock Objects for interfaces in JUnit tests by generating them on the fly using Java's proxy mechanism. Due to EasyMock's unique style of recording expectations, most refactorings will not affect the Mock Objects. So EasyMock is a perfect fit for Test-Driven Development.

The Easy Mock documentation can be found here:
http://www.easymock.org/Documentation.html
Easy Mock downloads:
http://www.easymock.org/Downloads.html

Mock Objects

In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. A computer programmer typically creates a mock object to test the behavior of some other object, in much the same way that a car designer uses a crash test dummy to test the behavior of a car during an accident.

Reasons for use

In a unit test, mock objects can simulate the behavior of complex, real (non-mock) objects and are therefore useful when a real object is difficult or impossible to incorporate into a unit test. If an object has any of the following characteristics, it may be useful to use a mock object in its place:

  • supplies non-deterministic results (e.g. the current time or the current temperature);
  • has states that are difficult to create or reproduce (e.g. a network error);
  • is slow (e.g. a complete database, which would have to be initialized before the test);
  • does not yet exist or may change behavior;
  • would have to include information and methods exclusively for testing purposes (and not for its actual task).

For example, an alarm clock program which causes a bell to ring at a certain time might get the current time from the outside world. To test this, the test must wait until the alarm time to know whether it has run the bell correctly. If a mock object is used in place of the real object, it can be programmed to provide the bell-ringing time (whether it is actually that time or not) so that the alarm clock program can be tested in isolation.

Use in test-driven development

Programmers working with the test-driven development (TDD) methodology make use of mock objects when writing software. Mock objects meet the interface requirements of, and stand in for, more complex real ones; thus they allow programmers to write and unit-test functionality in one area without actually calling complex underlying or collaborating classes[4].

Apart from complexity issues and the benefits gained from this separation of concerns, there are practical speed issues involved. Developing a realistic piece of software using TDD may easily involve several hundred unit tests. If many of these induce communication with databases, web services and other out-of-process or networked systems, then the suite of unit tests will quickly become too slow to be run regularly. This in turn leads to bad habits and a reluctance by the developer to maintain the basic tenets of TDD.

Warning: The following section is opinion: (Section) When mock objects are replaced by real ones then the functionality will need testing again. These are integration tests rather than unit tests, and so, strictly speaking, fall outside of the process of test-driven development.(End Section)

In reality, there is little common agreement agreement on where TDD stops. Story-Driven Development practitioners, for example, consider themselves TDD, and popular TDD methodologies like Test::Tutorial by Michael Scwern[5] make no distinction between unit and integration tests - only between "Programmer" and "Customer" tests. To quote Mike Schwern "Integration tests are still unit tests; the units are just bigger."




Testing your java applications with JUnit

JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks.

I'll present the steps to be followed in writing and organizing your own tests using JUnit:

How do you write testing code?

Simple Test Case

The simplest way is as an expression in a debugger. You can change debug expressions without recompiling, and you can wait to decide what to write until you have seen the running objects. You can also write test expressions as statements which print to the standard output stream. Both styles of tests are limited because they require human judgment to analyze their results. Also, they don't compose nicely- you can only execute one debug expression at a time and a program with too many print statements causes the dreaded "Scroll Blindness".

JUnit tests do not require human judgment to interpret, and it is easy to run many of them at the same time. When you need to test something, here is what you do:

  1. Annotate a method with @org.junit.Test
  2. When you want to check a value, import org.junit.Assert.* statically, call assertTrue() and pass a boolean that is true if the test succeeds
For example, to test that the sum of two Moneys with the same currency contains a value which is the sum of the values of the two Moneys, write:
@Test public void simpleAdd() {
Money m12CHF= new Money(12, "CHF");
Money m14CHF= new Money(14, "CHF");
Money expected= new Money(26, "CHF");
Money result= m12CHF.add(m14CHF);
assertTrue(expected.equals(result));
}
If you want to write a test similar to one you have already written, write a Fixture instead.

Fixture

What if you have two or more tests that operate on the same or similar sets of objects?

Tests need to run against the background of a known set of objects. This set of objects is called a test fixture. When you are writing tests you will often find that you spend more time writing the code to set up the fixture than you do in actually testing values.

To some extent, you can make writing the fixture code easier by paying careful attention to the constructors you write. However, a much bigger savings comes from sharing fixture code. Often, you will be able to use the same fixture for several different tests. Each case will send slightly different messages or parameters to the fixture and will check for different results.

When you have a common fixture, here is what you do:

  1. Add a field for each part of the fixture
  2. Annotate a method with @org.junit.Before and initialize the variables in that method
  3. Annotate a method with @org.junit.After to release any permanent resources you allocated in setUp
For example, to write several test cases that want to work with different combinations of 12 Swiss Francs, 14 Swiss Francs, and 28 US Dollars, first create a fixture:
public class MoneyTest {
private Money f12CHF;
private Money f14CHF;
private Money f28USD;

@Before public void setUp() {
f12CHF= new Money(12, "CHF");
f14CHF= new Money(14, "CHF");
f28USD= new Money(28, "USD");
}
}
Once you have the Fixture in place, you can write as many Test Cases as you'd like. Add as many test methods (annotated with @Test) as you'd like.

Running Tests

How do you run your tests and collect their results?

Once you have tests, you'll want to run them. JUnit provides tools to define the suite to be run and to display its results. To run tests and see the results on the console, run:

org.junit.JUnitCore.runClasses(TestClass1.class, ...);
You make your JUnit 4 test classes accessible to a TestRunner designed to work with earlier versions of JUnit, declare a static method suite that returns a test.
public static junit.framework.Test suite() {
return new JUnit4TestAdapter(Example.class);
}

Here is a useful link to the JUnit documentation:
http://junit.sourceforge.net/#Documentation


Java Coding Standards

Here you can find code conventions and style guidelines for the Java Programming Language:

http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
http://geosoft.no/development/javastyle.html
http://www.macadamian.com/index.php?option=com_content&task=view&id=34&Itemid=37#Programming%20Conventions

The Political Map of Bulgaria