VMware Cloud Foundry: A Cloud Primer

1         Introduction

It’s cloudy, today. But I’m not speaking about the weather in northern hemisphere autumn. Cloud Computing, two words that cannot be explained with just a sentence, is now a reality, born to change our (digital) lives.

Cloud Computing may mean different things to different people. For some, it would be having their personal documents, photos and music synchronized “in the cloud” and accessible through their PC or mobile device. For others, it would be being able to run their favorite games and to do their favorite stuff anywhere, anytime. It may be a cost-effective, agile hosting solution, an elastic production environment for databases and application servers, and many, many other things. Google Docs, Picasa, iCloud, Facebook, Twitter, Foursquare, Amazon EC2…

In this article, though, we will be discussing about Cloud Computing as a platform where developers can deploy their highly scalable, highly available solutions. We call this Platform-as-a-Service, or PaaS for short. PaaS also means a lot of things but for us is forgetting about dealing with the OS, the application server, the disc or the memory in the server. You just have your “application space”, where you can upload your solutions, execute them, monitor how they behave and control the amount of resources available to them.

You don’t know where your application physically is, the type of host server, operating system configuration or even how the application server is configured at all. You may certainly know about some or all of this, but it is really not needed to achieve your targets: develop your idea and make it available to your clients (no matter how much or where they are) in a hassle.

VMware Cloud Foundry is one of such platforms.

Continue reading “VMware Cloud Foundry: A Cloud Primer”

Advertisements

Code Generation using Annotation Processors in the Java language – part 3: Generating Source Code

This post is the third and final part in my series about Code Generation using Annotation Processors in the Java language. In part 1 (read it here) we introduced what Annotations are in the Java language and some of their common uses. In part 2 (read it here) we introduced Annotation Processors, how to build them and how to run them.

Now, in part 3, we are going to show how an Annotation Processor can be used to generate source code.

Continue reading “Code Generation using Annotation Processors in the Java language – part 3: Generating Source Code”

Measure Code Coverage of HtmlUnit Based Tests with Sonar and JaCoCo

This blog post is the third one in a series about Integration Tests with HtmlUnit. The first post, titled “Automating Assembly and Integration Tests with HtmlUnit”, showed how to write integration tests of web UI applications using HtmlUnit. That post can be read here. The second post, titled “Integrate HtmlUnit Based Tests with Apache Maven and Cargo”, showed how to automate the execution of HtmlUnit tests using Maven and Cargo plug-in. That post can be read here.

Finally, in this post we are going to show how to measure code coverage of HtmlUnit tests using Sonar, the popular Continuous Quality Assurance tool, and JaCoCo, a very interesting code coverage tool based on JVM agents instead of instrumenting bytecodes.

Continue reading “Measure Code Coverage of HtmlUnit Based Tests with Sonar and JaCoCo”

Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors

This post is the second part in my series about Code Generation using Annotation Processors in the Java language. In part 1 (read it here) we introduced what Annotations are in the Java language and some of their common uses.

Now in part 2 we are going to introduce Annotation Processors, how to build them and how to run them.

Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors

Annotations are great, sure. You can set any kind of metadata or configuration with them, with a well defined syntax and different types to use.

From what we have seen until now, annotations have advantages compared with Javadocs but not enough to justify their inclusion into the language. Therefore, is it possible to interact with annotations and get the most from them? Sure it is:

  • At runtime, annotations with runtime retention policy are accessible through reflection. The methods getAnnotation() and getAnnotations() in Class class will do the magic (1).
  • At compile time, Annotation Processors, a specialized type of classes, will handle the different annotations found in code being compiled.

Continue reading “Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors”

Integrate HtmlUnit Based Tests with Apache Maven and Cargo

This blog post is a continuation of the one titled “Automating Assembly and Integration Tests with HtmlUnit” that can be read here.

In the previous post we learned how to make use of HtmlUnit API to write automated integration tests. In this post we are going to show how to integrate those tests in an Apache Maven project lifecycle while keeping a clear distinction between the unit test suite and the integration test suite.

Continue reading “Integrate HtmlUnit Based Tests with Apache Maven and Cargo”

Code Generation using Annotation Processors in the Java language – part 1: Annotation Types

With this post I would like to start a series about Code Generation using Annotation Processors in the Java language, how powerful they are, and at the end show how to make use of them to generate source code on compile time.

During the series we will:

  • Introduce what are Annotations in the Java language.
  • Understand the common uses of Annotations and their scopes.
  • Understand what are Annotation Processors and their defined role.
  • Learn how to build Annotation Processors.
  • Learn how to run Annotation Processors from command line, Eclipse and Maven.
  • Learn how to use Annotation Processors to generate source code.
  • Learn how to use Annotation Processors to generate source code using an external template engine as Apache Velocity.

Code Generation using Annotation Processors in the Java language – part 1: Annotation Types

Annotations were first introduced in the Java language with the third edition of the Java Language Specification (1) and first implemented in Java 5.

Using annotations, we are able to add metadata information to our source code – build or deployment information, configuration properties, compilation behavior or quality checks.

Unlike Javadocs, annotations are strong typed, having that any annotation in use has a corresponding Annotation Type defined in the classpath. Besides that, annotations can be defined to be available at run-time – not possible with Javadocs.

Continue reading “Code Generation using Annotation Processors in the Java language – part 1: Annotation Types”

Automating Assembly and Integration Tests with HtmlUnit

With this blog entry I want to start a mini-series about automating assembly and integration tests in Java. Mini-series because there are many different tools and techniques to choose from, and depending on the software being developed you will choose and combine to get the best results.

This entry will show the basics on how to use HtmlUnit to automate assembly and integration tests of web applications.

What is HtmlUnit? HtmlUnit is a framework that runs on top of the popular JUnit testing framework that simulates a web browser, including JavaScript. Using the HtmlUnit API you can interact with the web pages and get insights of the layout and contents to write assertions. An interesting fact about HtmlUnit is that you can use to automate tests of web applications written in other languages than Java.

HtmlUnit can be downloaded from the tool web site at http://htmlunit.sourceforge.net/.

With HtmlUnit there is no practical distinction when you intend to write an assembly or an integration test case. If you choose to run with an embedded (or in memory) database and web application server or with a dedicated one will mark the (sometimes controversial) distinction between an assembly or an integration test.

In this entry we are focusing on HtmlUnit setup and common use cases and for a later entry we will focus in assembly vs. integration setup, best practices and how to run them within a continuous build/integration process.

Continue reading “Automating Assembly and Integration Tests with HtmlUnit”