Eclipse Yoxos Services Downloads Blogs About
Home > Blogs >

Archive for the ‘news’ Category

on Nov 17th, 2011EclipseCon Europe — Talks On-line

Eclipse has two annual conferences, EclipseCon (North America) and EclipseCon Europe. These are great venues to learn about what’s happening in the Eclipse eco-system, explore up-and-coming technologies and get to know the wonderful people behind Eclipse.

If you’re wondering how a ‘simple IDE‘ can fill two annual conferences, please read on!

EclipseCon Europe had a number of tracks, including talks related to modelling, Java 7, and Machine-to-Machine compatibility (yes, Eclipse has technology in all those spaces).  EclipseCon Europe also hosted the Eclipse 10th Birthday party!

6311272599 fbd6ca5a6a EclipseCon Europe    Talks On line

I attended the conference.  Unfortunately, there were too many interesting talks and I missed many of the ones I really wanted to see.  Luckily the talks are now on-line at http://www.fosslc.org/drupal/category/event/ece2011 (if you can’t find your talk, wait a few days… they seem to be uploading them as I type this).  By having the talks available, I was able to attend the conference, meet with all the interesting people and still find time to absorb the technical details. This is a great service, thanks!

I should also point out that the deadline for talk submissions to EclipseCon (North America) is Friday November 18th.

on Nov 16th, 2011Effective Mockito Part 5

With this effective Mockito Post I want to share a really simple pattern with you. We call this pattern “check answers” and we use it whenever we work with Mockito Answers. The code resulting from creating Mockito Answers generally looks ugly. But, as good programmers we care about test quality, right? icon smile Effective Mockito Part 5

Let’s see how we can make better looking answers using the “check answer” pattern. Mockito’s Answers are great when you need to verify that a method was called with specific parameters, or you need to execute an operation that also needs to be mocked. I’m sure you have seen situations where Answers were very useful. Let’s dive into a simple example. Our fancy program consists of three classes which are listed in the snippet below.

public class MyRuntimeState {
 
  private boolean state;
 
  public void setState( boolean state ) {
    this.state = state;
  }
 
  public boolean isTrue() {
    return state;
  }
 
}
 
 
public class MyDelegate {
 
  public void doSomething( MyRuntimeState state ) {
    // do some fancy operation
  }
 
}
 
 
public class MyObject {
 
  private final MyDelegate delegate;
 
  public MyObject( MyDelegate delegate ) {
    this.delegate = delegate;
  }
 
  public void operate() {
    MyRuntimeState state = new MyRuntimeState();
    state.setState( true ); // this is the important fact we want to test
    delegate.doSomething( state );
  }
 
}

As you can see we have the Types MyObject, MyDelegate and MyRuntimeState. MyObject needs a MyDelegate in its constructor. In the operate method, MyObject calls MyDelegate‘s doSomething method with a newly created MyRuntimeState object. Let’s assume that for some reason our fake system needs a MyRuntimeState with the state ‘true‘ to work (be creative – it’s just an example icon wink Effective Mockito Part 5 ).  So, MyObject needs to set the state of the MyRuntimeState object to true. This is exactly the case where Answers are useful to verify that the state is true within the doSomething invocation (we can probably also do this with verify in this example, but there are harder operations out there where verify can’t be used).  Let’s look at the test for this mechanism.

@RunWith( MockitoJUnitRunner.class )
public class MyObjectTest {
 
  @Mock
  private MyDelegate delegate;
  private MyObject myObject;
 
  @Before
  public void setup() {
    myObject = new MyObject( delegate );
  }
 
  @Test
  public void testSendsRightState() {
    doAnswer( new Answer<Object>() {
 
      @Override
      public Object answer( InvocationOnMock invocation ) throws Throwable {
        MyRuntimeState state = ( MyRuntimeState )invocation.getArguments()[ 0 ];
        assertTrue( state.isTrue() );
 
        return null;
      }
    } ).when( delegate ).doSomething( any( MyRuntimeState.class ) );
 
 
    myObject.operate();
  }
 
}

You see that it’s a fully working test that tests exactly what we want, but it’s also a smell. I dislike several things in the testSendsRightState method. The first thing is the method chaining over several lines. The second thing is that we have an indentation level of three which leads to unreadable code. The third thing is that we can’t see at a glance what will be tested. The fourth thing I don’t like is that the assert statement comes before the actual operate call at least in the writing of the code. The last thing is that this method is way too long.

Let’s try to get rid of most of the smells by simply doing one refactoring. You may say that this is obvious, and yes it is;). We need to extract the creation of the Answer object into a separate method. I name these methods createCheck***Answer (*** stands for a named check) because the answers that will be created are invoking the actual asserts. The result can look like this:

@Test
public void testSendsRightState() {
  Answer<Object> checkStateAnswer = createCheckStateAnswer();
  doAnswer( checkStateAnswer ).when( delegate ).doSomething( any( MyRuntimeState.class ) );
 
  myObject.operate();
}
 
private Answer<Object> createCheckStateAnswer() {
  return new Answer<Object>() {
 
    @Override
    public Object answer( InvocationOnMock invocation ) throws Throwable {
      MyRuntimeState state = ( MyRuntimeState )invocation.getArguments()[ 0 ];
      assertTrue( state.isTrue() );
 
      return null;
    }
  };
}

This simple refactoring has a huge impact on our test method. The test method has only a length of three lines of code now. The indentation level is one. The call chain fits into one line. Even the createCheckStateAnswer is more readable because it’s not surrounded by chained calls. One drawback still resists this solution. That is, that the assert is now called within another method. To me, this is a very low price to pay compared to the problems in the first test. And, the best thing about this solution is that when you only read the test method you see at first glance that an answer called checkStateAnswer was created that obviously does something like check a state. Other programmers should be able to understand most of the test method without reading the createCheckStateAnswer method.

I know that this solution is very simple and for you, may be obvious. But when I started with Answers I didn’t do this for reasons only the Programming Gods know now. If you have any other things related to Answers in your repertoire please share them with us in a comment.

followme Effective Mockito Part 5

Read the other Effective Mockito posts:

on Nov 14th, 2011Performance boost for RAP 1.5

Consider this:
buttons15 Performance boost for RAP 1.5

 

I measured the time needed to create 200 Buttons in RAP 1.4 and RAP 1.5M3, and it shows a considerable performance boost (at least for the browsers i tested). One reason for this is that we changed from quirksmode to standard rendering in IE9, which among other things, finally allowes us to use its new HTML5-features (in this case SVG and CSS3). I expect another little boost with IE10, which has even more CSS3 support.

However, what i did not expect was a significant improvement in any other browser, in this case Google Chrome. This is likely due to the implementation of the JSON-based RAP-protocol. It remains to be seen how this develops, as work on the protocol is still going on. Currently eval() is used to parse the JSON. In the final release we will probably use other methods, such as the native JSON-parser present in many modern browser. Older browser may gain only little or no performance.

What is really awesome though is the improvment of the GC/SWT-Canvas performance in IE9 (and only IE9). Drawing in browser (without any plug-ins) used to be a real pain. While other browser adopted the HTML5-Canvas and SVG standard very early on, Microsoft stubbornly stuck to its horribly old VML implementation, making my work needlessly hard. One of the main problems with VML is that it gets exponentially slower the more elements you draw, from about 200 elements on it’s almost painful to watch. But this is 2011, HTML5 is all the buzz, and even MS could no longer ignore it. IE9 now has a decent HTML5-Canvas implementation that we use in RAP 1.5, and it shows:

gc15 Performance boost for RAP 1.5

The fine print:
These results were achieved on my Windows 7/64bit Intel i5 2,4 GHZ laptop. No other systems or browser were tested. Measurement was done using JavaScript. The 32bit version of IE9 was used. I did only 3 iterations each, but the deviance was relatively small. The results in the final RAP 1.5 release my be very different due to ongoing development. You can check out the code i used here.

on Nov 14th, 2011Introducing restfuse – a JUnit Extension to test REST APIs

For several projects at EclipseSource we are creating REST APIs. I’m involved in most of them and there is one thing that bothers me with every project. That is, testing. I mean, of course we are writing our unit tests first and we mock our services to get fast unit tests, but at some point you also have to make sure that the whole system works with integration tests. And, when writing integration tests for REST APIs in Java, as far as I know, there are currently only two solutions.

The first one is to write plain JUnit tests and do all the requests yourself within the test methods (maybe with the help of utilities). The other option is to use a library called rest-assured. This library provides a kind of DSL for testing REST APIs. You can write your tests with JUnit and use mockito-like syntax to send a request and test the response. But this doesn’t feel like the right solution, because you always have to configure your request with real Java code within your test method. I would prefer a solution where I can simply configure the request using something like annotations and just execute the test after the request is sent.

Another thing that bugs me are asynchronous services. When it comes to handling asynchronous services you always have two options: callbacks or polling. How can I test those services? For polling it’s easier – you can loop the request code – but does this sound right to you? For callbacks you have to open a server, again within your test method or before. It seems there are no cool solutions for this right now – even rest-assured can’t handle these services very well. That’s why I took a little time and tried to solve these problems. The result is a small library called restfuse.

Restfuse is a JUnit extension. It introduces an annotation called @HttpTest which can be used to configure a request. The request is sent before the annotated method is executed as a test method. The response is then injected into the test object and can be used within the test method. It also provides some new asserts like assertNotFound or assertOk to test response codes. A simple @HttpTest looks like this:

@RunWith( HttpJUnitRunner.class )
public class RestfuseTest {
 
  @Rule
  public Destination destination = new Destination( "http://restfuse.com" ); 
 
  @Context
  private Response response; // will be injected after every request
 
  @HttpTest( method = Method.GET, path = "/" )
  public void checkRestfuseOnlineStatus() {
    assertOk( response );
  }  
}

And of course, it also solves the problem with asynchronous services by introducing two annotations called @Callback and @Poll which can be used together with the @HttpTest annotation. For more information on these tests for asynchronous services take a look at the restfuse site.

Restfuse is open source, licensed under the EPL v – 1.0 and is hosted at github. The 1.0 version is also in the Maven Central and online as a p2 repository (yes, it’s an OSGi bundle).  I hope this small library will help you as much as it helped me. I would appreciate feedback on how to make restfuse even better.

followme Introducing restfuse   a JUnit Extension to test REST APIs

on Oct 29th, 2011Eclipse Juno Milestone 3, available for download

Trick or Treat!

Just in time for Halloween the Eclipse and Equinox teams have a treat for all you IDE enthusiasts… Eclipse Juno Milestone 3.  The transition to Git initially slowed some of us down, but the development teams have picked up speed now. There are lots of new things in M3 to test out.

OSGi now has a new console. It uses the Apache Felix Gogo project and supports tab completion, command history, piping, grep, and a whole host of other things.

Screen Shot 2011 10 29 at 2.33.41 PM Eclipse Juno Milestone 3, available for download

Other new features include a global debug toolbar:
debug toolbar 1 Eclipse Juno Milestone 3, available for download

And Java resource leak detection

resource leak warnings Eclipse Juno Milestone 3, available for download

resource leak example Eclipse Juno Milestone 3, available for download

 

Checkout the entire New and Noteworthy, or better yet, download Juno Milestone 3 and try it yourself.

 

 

on Oct 26th, 2011Meet the RAP team at EclipseCon Europe 2011

If you’re interested in the latest news on RAP, consider joining us at EclipseCon Europe next week in Ludwigsburg. There are quite a number of RAP talks this year:

On Thursday morning, Paul Petershagen of Vitaphone, a global provider of solutions in the telemedicine sector, will share their experience with a large RAP/RCP single-sourcing project. This is an good example of the power of single-sourcing. Paul also has some insights and figures from the project manager’s perspective.

Later that day, Frank Appel, one of our project pioneers, and me will show how RAP now supports the development of lightweight, modular, and dynamic web applications based on OSGi. This talk is 30 minutes so will not go into too much technical detail – instead, we’ll  show some cool examples and explain the new possibilities.

For those who want to understand the technical side better and try out the new features right away, we offer a 1.5 hours hands-on tutorial on Friday. In this tutorial, we’ll show how to create and structure your RAP project, and also how to build and deploy it using tycho. Frank, Rüdiger, Holger, and me will be around so you will have first-class support. By the way, did you know that RAP finally supports clustering? If you have specific questions about this feature, Friday is your chance to meet Rüdiger, who has been working on this stuff over the last months.

And, last but not least, we are happy that another Eclipse project has decided to build on RAP: the Scout project provides a framework for rapid development of complete enterprise applications. With the upcoming Juno release, Scout will provide a RAP integration. Project leads Matthias Zimmermann and Andreas Hoegger will present “the best of both worlds” on Thursday afternoon.

You will always find one of us at the EclipseSource booth. I hope to meet you in Ludwigsburg!

on Oct 24th, 2011EclipseSource Training: The p2 API

EclipseSource now has a 2 day course that focuses entirely on the p2 API.  Like our other courses, our p2 course reinforces the theoretical concepts with hands-on exercises.  The course covers a wide variety of concepts, including:

  1. The Agent
  2. The Metadata
  3. The Artifacts
  4. The Profile
  5. The Planner
  6. The Engine
  7. Building / Publishing p2 repositories
  8. Touchpoints
  9. Dynamic Provisioning

Throughout the course, the students build a working installer for Eclipse RCP / OSGi applications. The exercises demonstrate proper use of many parts of the p2 API.  In the final section we add dynamic provisioning, enabling the installer to manage and update itself.

The coures is ideal for anybody building a custom provisioning solution, or those looking to extend their knowledge of Eclipse RCP or OSGi.  Please contact us for more information on this course, or any of our other Eclipse based training.

 

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 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.

© EclipseSource 2008 - 2011