Eclipse Yoxos Services Downloads Blogs About
Home > Blogs >

Archive for the ‘syndicate’ Category

on Sep 20th, 2011Eclipse Juno Milestone 2, available for download

With summer behind us and autumn almost here (in the northern hemisphere), you can feel the change in the air.

fall Eclipse Juno Milestone 2, available for download

The Eclipse and Equinox teams have made Juno Milestone 2 available, however, these milestones are no longer based on the Eclipse 3.x stream. Starting with this milestone, we will be encouraging users to actively test the 4.2 stream. The Eclipse Juno release (coming June 2012) will be based on the 4.x stream.

There are a few goodies in this release including Quick-Fixes for loop refactoring:
convert to for loop Eclipse Juno Milestone 2, available for download

An enhanced Ant editor:

ant extension assist Eclipse Juno Milestone 2, available for download

And some fancy new transitions:

Checkout the entire New and Noteworthy. Or better yet, download the milestone and take it for a spin.

on Sep 19th, 2011Effective Mockito Part 1

Last week I talked to a fellow developer, Frank Appel, about Mockito. We’ve been using this mocking library for over a year. We both agreed that of all the innovations we’ve tried in the last year or so, Mockito has boosted our coding productivity the most. With this blog series we want to share our experiences with Mockito. You see that I used the word “effective” in the title, and, in this context I want to define “effective” as arriving at clean test and production code as fast as possible.

To understand these posts you need to have a basic understanding of what mocking is. I recommend reading Martin Fowlers article,”Mocks aren’t Stubs“. You’ll also need some practice with Mockito. But, since you found this blog, you probably searched for the term Mockito icon wink Effective Mockito Part 1 , so this should be a given. Anyway, there is a third thing, that only affects this first post. You need to use Eclipse as your IDE. This post shows you how to setup Mockito in your IDE for the daily work. If you are using another IDE and you know how to achieve what I have described here, please share your tips in a comment. The follow up posts will not require Eclipse because they will be more Mockito specific. Enough prerequisites, let’s start with with the first thing that will boost your Mockito experience.

I always write tests first. My goal is to come up with a first test method really quickly to be able to create all the classes that I need by resolving the compiler errors using Eclipse’s quick fix functionality (CTRL/CMD+1 is your friend). What would be ideal, is to create a test class and just write the test without importing all the other stuff.  The Mockito and Junit stuff should automatically appear in my content assist. When using Mockito, I want to create a test method, write “mo”, open the content assist and it should show me all the “mock” methods.

I’ll give you an example to make this clearer and to show how to achieve this. If I write a test method and open the content assist (which I use all the time), the standard selection options are very basic.

Screen Shot 2011 09 12 at 8.37.40 AM Effective Mockito Part 1As you can see there are no “mock” methods but at least the Mockito classes. The reason is that the content assist only shows methods that are imported in the current class. So, by static importing Mockito this can be fixed.

Screen Shot 2011 09 12 at 8.38.31 AM Effective Mockito Part 1But this is not what I want. This assumes that I have to import all Mockito stuff manually, or that I need to write “Mockito” and organize my imports automatically. I really want to be able to just write “mo” and get a pre-filled content assist. Luckily there is an option that lets us achieve this. In Eclpse it’s called “content assist favorites”. It can be configured within your preferences. Let’s take a look at our favorites.

Screen Shot 2011 09 12 at 8.41.16 AM Effective Mockito Part 1As you can see, I added Mockito.*, Matchers.* and Assert.* to my favorites. This enables my content assist to show the available methods and import them when I’m using one. You may think, “hey, this will fill my content assist with unnecessary stuff when I’m writing production code.” But this is not the case. These imports are only available when Mockito and JUnit is on your build class path. So, by separating test and production code you only have these imports available in your test projects. Let’s take a look at the result.

Screen Shot 2011 09 12 at 8.41.29 AM Effective Mockito Part 1As you can see I haven’t imported any Mockito stuff yet but I can select all the mock methods from my content assist. This enables me to write tests really quickly because I don’t have to think about setting up a test, I can just write it.

This is just a simple trick to come up to speed as quickly as possible when writing tests using Mockito. In the next posts I will focus more on the Mockito specifics. I hope you liked it and will stay tuned icon wink Effective Mockito Part 1

followme Effective Mockito Part 1

Read the other Effective Mockito posts:

on Sep 9th, 2011My Eclipse Testing Day

At September 7th I attended the Eclipse Testing Day 2011.

In the morning we heard several talks about various testing strategies in different commercial products. Alexander Klein from BeOne held an inspiring talk about testing the users experience for a product. Among other ideas he recommended to watch users while they are confronted with the product to get ideas for the next iteration.

In the afternoon things became more hands-on. Michaela Greiler presented her Eclipse Plug-in Test Suite. This is a test runner that allows static and dynamic analysis to report on executed extension points and OSGi services. By itself it is merely interesting, but imho not interesting enough to be a standalone project. I think this technology should go as additional metrics in something like EclEmma. Maybe JaCoCo will provide a home? Hear me, Marc?

Jubula was a major point of talk. Felix Ziesel from BREDEX showed how he uses the Eclipse for Testers download to define an automated smoke test suite to test the completeness of the Eclipse for RCP and RAP developers. I hope he will repeat this talk at an EclipseCon where other packagers are present. This just looked as it ought to be, but obviously it wasn’t feasible before Jubula.

The last talk was mine. I presented an example of a full-featured PDE build from a git repository with test automation. Even though it was the last one of a full day of talks the discussion afterwards was interesting and showed I had hit a sore spot in many projects.

At the side where a few booths from various companies. I was excited to see Xored advertising Q7 there. This is a UI testing tool that only supports Eclipse. Because of this exclusiveness the scripting language gets right to the point. Capture and Replay functionality is also available. Why was I excited about that? – Coming as complete outsiders, they did a talk at last years Eclipse Testing Day about this side product they developed to make testing their application easier. It was extremely well perceived and for a while they where the focus of attention with this thing that’s now Q7. I’d really like to see them more involved with the Eclipse community. Specifically I think their tool might be in a good position to allow UI testing for a RAP workbench.

As a conclusion I have mixed feelings about the Eclipse Testing Day. It shows that things are moving and keeps a handful of people talking. I think it could be a real benefit for the community, if it would show up. But while last year all talks where held in english, now only 3 out of 10 did so, making the Testing Day too much of a german and too less an international event. Many key players where missing. Nobody mentioned SWTBot or JaCoCo. WindowTester didn’t even seem to exist. Is FrogLogic still in business (Their website says, yes)?
It seemed to me that compared to last year there was almost an entirely new audience. I recognized only a handful people and 2 of them where speakers.
It think that the talks and the audience are a bit too diverse. The name “Testing Day” brings together developers people who drive test processes in larger companies, but did’t lead them to talk to one another. Instead of accepting just mixing them in a single branch of talks, the Testing Day could improve by cutting down the program for the whole audience to maybe half a day. Fill the other half day with special interest topics, i.e. bring together the developers to talk about TDD, JUnit, issues about test automation with their test runners and hard times with AspectJ. Bring the people together who want to discuss test processes in big projects, but separate these two groups for a while at least.

The organizers are aware of this, too, so I’m looking forward for a strong and interesting Eclipse Testing Day 2012.

on Sep 8th, 2011Announcing a full featured PDE Build example from a Git repository

I set up a githup repository that gives a working example for a PDE product build from a git repository. It is meant to ease the pain of setting up new builds by having a working template that just needs to be adjusted to the new project.

I’m planning a series of blog entries with and around that example. Some features are:

  • Works system independent
  • Executes tests
  • Builds from map files
  • Separates compile step and assemble step (Improves build time)
  • Mostly self-contained (Required: An Eclipse SDK and Git)

How to get it running in short:

  • Fetch from git://github.com/mkempka/hyperbola-pde-build-demo.git
  • Adjust values in org.eclipsercp.hyperbola.releng/custom.properties
  • Execute org.eclipsercp.hyperbola.releng/build.xml with ant

Here are my slides from my talk at the Eclipse Testing Day 2011 that include some documentation. I’ll do more documentation in separate blog entries the next weeks.

on Sep 7th, 2011Eclipse Stammtisch Europe

Sorry for the eye catcher, I meant “München” icon smile Eclipse Stammtisch Europe

To shorten the time until EclipseCon Europe, we cordially invite you to the Eclipse Stammtisch München on October 4th. The Stammtisch is always a good opportunity to meet the community in your region and talk about Eclipse and of course, non-Eclipse topics.

If you would like to attend, please register for this event, as we will make a reservation based on the number of registered people. Currently, we plan to meet at Sappralott. But, as the location might change, please provide a valid mail address so that we can notify you about the details.

Based on your feedback from the last Stammtisch, we would like to give people a forum to present interesting things. However, since this is not a democamp, there will be no stage or agenda. People who want to show something can bring their laptop. We will distribute the presenters around the tables and people can walk around to see what they are showing. That means you can present something, you can watch something, but if you are not in the mood, you can just sit there, have a conversation and drink beer icon smile Eclipse Stammtisch Europe

If you want to present, please register as a presenter and send me a short description of what you are planning: jhelming@eclipsesource.com

stammtisch Eclipse Stammtisch Europe

 

on Sep 1st, 2011Eclipse turning 10, let’s go to Europe!

Eclipse is turning 10 this fall! My first experience with Eclipse came 8 1/2 years ago when I started building visualization tools on top of GEF. I was an IBM CAS Student while doing my PhD at the University of Victoria. Over the years I’ve attended several demo camps, presented Eclipse content at the local Java User Group, delivered presentations and tutorials at numerous EclipseCons and even attended the occasional Eclipse stammtisch. However, I’ve never attended an Eclipse conference in Europe icon sad Eclipse turning 10, lets go to Europe! .

2011 09 01%25252010.22.09 Eclipse turning 10, lets go to Europe!

I’m hoping to change that this year so that I can join in the Eclipse 10th anniversary celebrations.  I’ve submitted 3 talks to the conference:

  • p2, your savior or your achilles heel? Everything an Eclipse team needs to know about p2: This is re-hash of the talk Pascal and I gave an EclipseCon 2011 (the one in North America). We highlight 10 things that all Eclipse developers need to know about p2, or at least the types of things that will make your life a lot easier.
  • It’s Raining Bytes: Scaling p2 Using the Cloud: In this talk I will discuss how we use p2 to build something as complex as the Yoxos distribution. Yoxos contains over 30,000 artifacts, split across dozens of self contained slices and all delivered using the Amazon Cloud services.   Each one of these components has been validated to ensure that it installs and that all dependencies are available. This talk is intended for those looking for practical advice on how to scale p2 (the eclipse provisioning platform).
  • Moving from CVS to Git, 10 things I’ve learned: This talk was inspired by a blog post a wrote a while ago, when I was first learning Git. I often find that once someone starts using Git heavily, they forget about the growing pains they went through.  With these pains still fresh in my mind, I hope to use this opportunity to present 10 things I learned along the way.  This talk is geared towards those just starting off with Git.

I hope to see you in Germany this fall.

on Aug 29th, 2011Lightweight OSGi Applications using RAP’s Widget Toolkit

RAP is well known as an “RCP for the web browser”, including workbench, extension points, and all that stuff. Indeed, one of the greatest features of RAP is its ability to reuse RCP code in web applications. But did you know that you can also use RAP’s widget toolkit (RWT) to create simple web UIs for your applications, without the heavy weight Eclipse UI stack?

With RAP 1.5, you can now simply include RWT in any OSGi application. You only need two bundles: org.eclipse.rap.rwt (the RAP widget toolkit itself) and org.eclipse.rap.rwt.osgi which integrates RWT with the OSGi HTTP service. There are no tie-ins with Equinox anymore, thus RAP also works with other OSGi containers.

To create a UI with RWT, you have to implement the interface IEntryPoint, here’s a simple example:

  public int createUI() {
    // Create a maximized top-level shell without trimmings that represents the main "page"
    Display display = new Display();
    Shell page = new Shell( display, SWT.NO_TRIM );
    page.setMaximized( true );
    page.setLayout( new GridLayout() );
 
    // Create contents of main shell
    Label label = new Label( page, SWT.NONE );
    label.setText( "Hello" );
    Button button = new Button( page, SWT.PUSH );
    button.setText( "World" );
 
    // Open the top-level shell and run the main loop to process events
    page.layout();
    page.open();
    while( !page.isDisposed() ) {
      if( !display.readAndDispatch() ) {
        display.sleep();
      }
    }
    display.dispose();
    return 0;
  }

Now what’s new is that, instead of registering this entry point with an extension point, you can now implement the new Configurator interface like this:

  public void configure( Context context ) {
    context.addEntryPoint( "default", SimpleEntryPoint.class );
    context.addBranding( new AbstractBranding() {
      @Override
      public String getServletName() {
        return "simple";
      }
      @Override
      public String getTitle() {
        return "Simple RWT Example";
      }
    } );
  }

When this implementation is registered as an OSGi service, you can access the UI with a web browser:

RWTSimple Lightweight OSGi Applications using RAPs Widget Toolkit

You can check out the example project example.rwt.simple from my rap-helpers repository on github. Please note that for this example to run you need declarative services in your target platform, which are not included in the RAP 1.5M1 target but in the latest nightly build. Also be aware that the new API is still provisional and may change again until the final release.

Kudos to Frank Appel, who contributed the new OSGi integration. He has a more detailed introduction to the new OSGi integration and examples for configuration in his blog. BTW, Frank and me plan to demo the possibilities of this approach in our talk Dynamic web applications with OSGi and RAP at the EclipseCon Europe – vote for it if you’re interested!

on Aug 16th, 2011JGit API: Reading configuration information

Lately I’ve been adding Git support to the Yoxos Workspace Provisioning. This should be done in time for Eclipse Indigo SR1 and this will mean you can easily share your Git configurations in your Yoxos profiles.

I wanted to make it easy to share your existing repository settings, but unlike CVS or SVN, sharing your Git repository makes very little sense.  Likely you want to point someone to a remote (say one you have shared on GitHub). This means I needed to read the repository settings, find all the remote repositories and order them (such that the one called ‘origin’ is on top).

This turns out to be very easy with the JGit API.  JGit reads the configuration information and stores it in a properties style object where the values are keyed based on their subsection and name. You can get a list of all the remotes by asking for the remote subsection. From here, you can get each remote URL by asking for the URL to a particular remoteName in the remote subsection.

The following code prints out each remote and its URL.

package com.ianbull;

import java.io.File;
import java.io.IOException;
import java.util.Set;

import org.eclipse.jgit.lib.Config;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;

public class RemoteReader {

  public static void main(String[] args) throws IOException {
    Repository repository = new RepositoryBuilder().findGitDir(new File("/home/irbull/git/p2")).build();
    Config storedConfig = repository.getConfig();
    Set<String> remotes = storedConfig.getSubsections("remote");

    for (String remoteName : remotes) {
      String url = storedConfig.getString("remote", remoteName, "url");
      System.out.println(remoteName + " " + url);
    }
  }
}

on Aug 15th, 2011Accessing a huge data set with the web browser

The Enron Corporation was the American energy company that was involved in accounting fraud which led to the Enron scandal in 2001. During the investigation, large parts of the company’s email conversations were published. The result is that a huge, real-life data set including more than half a million emails from 150 Enron executives came into the public domain.

I thought that this data would be a good example to show the ability of the new Tree widget in RAP to display huge datasets.

Screenshot Accessing a huge data set with the web browser

It’s clear that you cannot create half a million UI elements in a browser without running out of memory. Neither can you load the entire dataset (> 2GB on disk) into memory on the server. You need a mechanism to load and display data on demand.

As of this week, the RWT Tree widget has full SWT.VIRTUAL support, i.e. it is capable of creating Tree items only at the moment they become visible. This feature is used by the JFace TreeViewer to request data from a lazy content provider on demand.

So, in order to make a complex data set accessible with a web UI, you just need to write an ILazyTreeContentProvider implementation. That’s about one screen of Java code, mostly copied from a JFace snippet. That’s all.

Check out the example on our online demo (navigate to the tab called Complex Data). The source code of this demo page is available on github.

Full SWT.VIRTUAL support for the Tree widget is available in CVS and will be part of RAP 1.5M1.

on Aug 12th, 2011How to build a cluster with Jetty / OSGi

In this blog post I describe how to set up a cluster node with an embedded Jetty Server inside Equinox.

Basically I followed the instructions available at the Jetty Wiki page Session Clustering Using a Database [1].

There are two Jetty configuration files involved:

  • /etc/jetty.xml defining a JDBCSessionIdManager
  • /WEB-INF/jetty-web.xml defining a JDBCSessionManager

The main jetty.xml resides in the folder etc of the jetty.home.bundle which itself is a fragment of org.eclipse.jetty.osgi.boot. The jetty.osgi.boot bundle is provided by the Jetty team and is responsible for bootstrapping Jetty in an OSGi environment.

The main configuration file contains the JDBCSessionIdManager definition using a H2 database:

 <Set name="sessionIdManager">
  <New id="jdbcidmgr" class="org.eclipse.jetty.server.session.JDBCSessionIdManager">
    <Arg>
      <Ref id="Server" />
    </Arg>
    <Set name="workerName">
      <SystemProperty name="worker.name" default="primary" />
    </Set>
    <Call name="setDriverInfo">
      <Arg>org.h2.Driver</Arg>
      <Arg>jdbc:h2:tcp://localhost:9101/sessions</Arg>
    </Call>
    <Set name="scavengeInterval">60</Set>
  </New>
</Set>
<Call name="setAttribute">
  <Arg>jdbcIdMgr</Arg>
  <Arg>
    <Ref id="jdbcidmgr" />
  </Arg>
</Call>

Note: To reuse the configuration in multiple cluster nodes I use a SystemProperty tag to give every node a unique “worker.name”. The database configuration is hardwired to a local H2 database.

With additional system properties I can tell the Jetty bootstrapper where to look for the global Jetty configuration and which port the Jetty instance should bind to:

-Dworker.name=primary
-Djetty.port=18081
-Djetty.home.bundle=com.eclipsesource.cluster.jetty.home.bundle

To enable the Jetty server to load the H2 database drivers I added a dynamic import directive via the fragment org.eclipse.jetty.serverdynamic.import:

Fragment-Host: org.eclipse.jetty.server;bundle-version="7.4.2"
DynamicImport-Package: *

The web application specific configuration /WEB-INF/jetty-web.xml is located in the web bundle, com.eclipsesource.cluster.jetty.demo.webbundle. This configuration file contains the JDBCSessionManager definition.

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Get name="server">
    <Get id="jdbcIdMgr" name="sessionIdManager" />
  </Get>
  <Set name="sessionHandler">
    <New class="org.eclipse.jetty.server.session.SessionHandler">
      <Arg>
        <New class="org.eclipse.jetty.server.session.JDBCSessionManager">
          <Set name="idManager">
            <Ref id="jdbcIdMgr" />
          </Set>
        </New>
      </Arg>
    </New>
  </Set>
</Configure>

Note: “jdbcIdMgr” is a Reference to the jetty.xml from jetty.home.bundle.

If you want to try it out yourself, the code is available at GitHUB [2].

Note: The bundle com.eclipsesource.cluster.h2 contains an Eclipse launch configuration to start a local H2 database which is needed to run the example.

[1] http://wiki.eclipse.org/Jetty/Feature/Session_Clustering_Using_a_Database
[2] https://github.com/eclipsesource/com.eclipsesource.cluster

© EclipseSource 2008 - 2011