<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jayway Team Blog &#187; eclipse</title>
	<atom:link href="http://blog.jayway.com/tag/eclipse/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayway.com</link>
	<description>Sharing Experience</description>
	<lastBuildDate>Sat, 11 Feb 2012 10:33:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Extending the JDT</title>
		<link>http://blog.jayway.com/2010/04/20/extending-the-jdt/</link>
		<comments>http://blog.jayway.com/2010/04/20/extending-the-jdt/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 21:01:43 +0000</pubDate>
		<dc:creator>Michael Kober</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=5387</guid>
		<description><![CDATA[A couple of weeks ago I had a look at the Motodevstudio for Android developers and I think it has some quite nice features like code snippets or wizards for Android activities, services and more. Actually it's is quite easy to extend the eclipse JDT and provide such useful plugins. This blog post is about [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago I had a look at the <a href="http://developer.motorola.com/docstools/motodevstudio/">Motodevstudio</a> for Android developers and I think it has some quite nice features like code snippets or wizards for Android activities, services and more. Actually it's is quite easy to extend the eclipse JDT and provide such useful plugins. This blog post is about how to extend the NewElementWizard in JDT using eclipse Galileo.  </p>
<p>We start with creating a new eclipse plugin project and create our wizard class. The NewElementWizard we want to extend resides in the <code>org.eclipse.jdt.ui</code> bundle. So we add both <code>org.eclipse.jdt.ui</code> and <code>org.eclipse.jdt.core</code> to our plugin manifest:</p>
<p><a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/04/Screen-shot-2010-02-28-at-9.53.40-PM.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2010/04/Screen-shot-2010-02-28-at-9.53.40-PM-300x234.png" alt="Manifest" title="Manifest" width="300" height="234" class="alignnone size-medium wp-image-5388" /></a></p>
<p>Then we create a new class "NewActivityWizard":</p>
<pre class="brush:java">
package newwizard;

import org.eclipse.jdt.internal.ui.wizards.NewElementWizard;

public class NewActivityWizard extends NewElementWizard {

}
</pre>
<p>First thing we get is a warning<br />
"Discouraged access: The type NewElementWizard is not accessible due to restriction on required library /Applications/eclipse/plugins/org.eclipse.jdt.ui_3.5.1.r351_v20090821-0800.jar".</p>
<p>The NewElementWizard belongs to an internal package and is only exported (using the 'xfriends' directive) to some chosen bundles. So we have the choice to have a look at the code of NewElementWizard and implement our wizard by extending <code>org.eclipse.jface.wizard.Wizard</code> instead, or we could make our plugin a fragment. Fragments are part of the OSGi R4 release and according to the specification a fragment is “a bundle that is attached to a host bundle”, adding content to the target bundle. For now we choose the later alternative, just because it requires less work.</p>
<p>Next thing we have to do is to override some methods of the superclass and of course we want to add our own wizard page. Our wizardpage will extend the <code>org.eclipse.jdt.ui.wizards.NewTypeWizardPage</code>. The following code is pretty much the same as in the wizards used internally in JDT as for example <code>org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard</code>. </p>
<pre class="brush:java">
public class NewActivityWizard extends NewElementWizard {

	private NewActivityWizardPage newActivityPage = null;

	public NewActivityWizard() {
        setWindowTitle("My new Android Activity");
        newActivityPage = new NewActivityWizardPage();
    }

	@Override
	public void addPages() {
        addPage(newActivityPage);
    }

    @Override
	 public void init(IWorkbench workbench, IStructuredSelection selection) {
    	newActivityPage.init(selection);
    }

    @Override
	public boolean canFinish() {
       return super.canFinish() &&
                   getContainer().getCurrentPage() == newActivityPage;
    }

	@Override
	protected void finishPage(IProgressMonitor monitor)	throws InterruptedException, CoreException {
		newActivityPage.createType(monitor);
	}

	@Override
	public IJavaElement getCreatedElement() {
		return newActivityPage.getCreatedType();
	}
}
</pre>
<p>Next we have to define the extension in the fragment.xml:</p>
<pre class="brush:xml">
 <extension  point="org.eclipse.ui.newWizards">
      <wizard
            canFinishEarly="false"
            category="com.android.ide.eclipse.wizards.category"
            class="newwizard.NewActivityWizard"
            finalPerspective="org.eclipse.jdt.ui.JavaPerspective"
            id="newwizard.NewActivityWizard"
            name="My Android Activity"
            preferredPerspectives="org.eclipse.jdt.ui.JavaPerspective"
            project="false">
      </wizard>
   </extension>
</pre>
<p>The most interesting part of the wizard page is the code generation part. We want to generate a <code>onCreate</code> method that takes a <code>android.os.Bundle</code> as argument:</p>
<pre class="brush:java">
private void generateOnCreate(IType type, ImportsManager imports) throws CoreException, JavaModelException {
	StringBuilder buf = new StringBuilder();
	final String delim = "\n";
	buf.append("@Override");
	buf.append(lineDelim);
	buf.append("public void onCreate(");
	buf.append(imports.addImport("android.os.Bundle"));
	buf.append(" savedInstanceState) {");
	buf.append(lineDelim);
	buf.append("super.onCreate(savedInstanceState);");
	buf.append(lineDelim);
	final String content =
            CodeGeneration.getMethodBodyContent(type.getCompilationUnit(),
               type.getTypeQualifiedName('.'), "onCreate", false, "", delim);
	if (content != null && content.length() != 0)
		buf.append(content);
	buf.append(lineDelim);
	buf.append("}"); //$NON-NLS-1$
	type.createMethod(buf.toString(), null, false, null);
}
</pre>
<p>This is just the basic version of the new wizard, we also want to add intent actions and categories and update the Android manifest file. The complete source is available at <a href="http://github.com/kobmic/adt-extensions">http://github.com/kobmic/adt-extensions</a>. 	</p>
<p>So how do we update the android manifest? As a Java programmer <a href="http://www.dom4j.org">dom4j</a> and <a href="http://xstream.codehaus.org">XStream</a> are some of my favourite XML frameworks - but I'm quite enthusiastic about Scala and Scala provides XML support baked into the language. The XML generation code for a new Android activtiy with a given list of intent actions and categories in Scala looks like this:</p>
<pre class="brush:scala">
def createXML(activityName: String, intentActions: List[String], intentCategories: List[String]) : Node = {
  val xml =
    <activity android:name={activityName}
      <intent-filter>
         {for(action <- intentActions)
             yield {<action android:name={action} />}}
	 {for(category <- intentCategories)
             yield {<category android:name={category} />}}
      </intent-filter>
    </activity>
   xml
}
</pre>
<h2>Putting it all together</h2>
<p>I chose to do the XML manipulation (written in Scala) and the Wizard (written in Java) in different OSGi bundles. If you don't have the eclipse Scala IDE installed you even need the Scala library 2.7.7 as OSGi bundle. You can download the wizard with or without Scala dependencies from <a href="http://github.com/kobmic/adt-extensions/downloads">http://github.com/kobmic/adt-extensions/downloads</a>. </p>
<p>The complete wizard looks like this:<br />
<a href="http://blog.jayway.com/wordpress/wp-content/uploads/2010/04/new-activity-wizard.png" rel="lightbox"><img src="http://blog.jayway.com/wordpress/wp-content/uploads/2010/04/new-activity-wizard-228x300.png" alt="" title="new-activity-wizard" width="228" height="300" class="aligncenter size-medium wp-image-5389" /></a></p>
<p>At time of writing there's a new version of MOTODEV studio available, now even as a set of plugins to eclipse:<br />
<a href="http://developer.motorola.com/docstools/library/Installing_MOTODEV_Studio_for_Android">http://developer.motorola.com/docstools/library/Installing_MOTODEV_Studio_for_Android/#installingStudioPlugins</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2010/04/20/extending-the-jdt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Get nagged about keyboard shortcuts in Eclipse</title>
		<link>http://blog.jayway.com/2009/11/12/get-nagged-about-keyboard-shortcuts-in-eclipse/</link>
		<comments>http://blog.jayway.com/2009/11/12/get-nagged-about-keyboard-shortcuts-in-eclipse/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 08:29:08 +0000</pubDate>
		<dc:creator>Tobias Södergren</dc:creator>
				<category><![CDATA[User Experience]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=2226</guid>
		<description><![CDATA[I was attending the "The Productive Programmer: Mechanics" session, held by Neal Ford, at Oredev last week and I wanted to share one trick that will more or less force you to get faster when developing in Eclipse. The Eclipse plug-in MouseFeed, written by Andriy Palamarchuk, will repeatedly nag you with what keyboard shortcuts you [...]]]></description>
			<content:encoded><![CDATA[<p>I was attending the "The Productive Programmer: Mechanics" session, held by Neal Ford, at Oredev last week and I wanted to share one trick that will more or less force you to get faster when developing in Eclipse.</p>
<p>The Eclipse plug-in MouseFeed, written by Andriy Palamarchuk, will repeatedly nag you with what keyboard shortcuts you can use instead of using the mouse to perform actions. For example, if you constantly left-mouse-click the "step-over" button in the debug perspective, the MouseFeed plug-in will pop-up a notification window telling you to instead press "F6" on your keyboard. </p>
<p>You can also make the plug-in even more annoying by having MouseFeed canceling the mouse operation so that you have to use the keyboard shortcut.</p>
<p>I have installed it and forgotten about it until today, when it gently reminded me that collapsing all nodes in the Package Explorer view could be issued by "Shift-Command Numpad_Divide" on Mac OS X. Unfortunately my laptop does not come with a numeric keyboard so I have better to remap the shortcut if I find myself collapsing nodes often.</p>
<p>The MouseFeed home page can be found at: <a href="http://www.mousefeed.com">http://www.mousefeed.com</a><br />
The SourceForge project page: <a href="http://sourceforge.net/projects/mousefeed/">http://sourceforge.net/projects/mousefeed</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/11/12/get-nagged-about-keyboard-shortcuts-in-eclipse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Setting up a local Subversion repository to use with your Eclipse</title>
		<link>http://blog.jayway.com/2009/04/03/setting-up-a-local-subversion-repository-to-use-with-your-eclipse/</link>
		<comments>http://blog.jayway.com/2009/04/03/setting-up-a-local-subversion-repository-to-use-with-your-eclipse/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 08:33:48 +0000</pubDate>
		<dc:creator>Rickard Nilsson</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[repository]]></category>
		<category><![CDATA[subclipse]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=1498</guid>
		<description><![CDATA[I've been spending some time studying a tool for looking at the structure of code bases. After having tried out some of the more basic possibilities I wanted to go for the finer points and study changes between two versions of code to see what effect my changes made. This is where I realise that [...]]]></description>
			<content:encoded><![CDATA[<p>I've been spending some time studying a tool for looking at the structure of code bases. After having tried out some of the more basic possibilities I wanted to go for the finer points and study changes between two versions of code to see what effect my changes made. This is where I realise that I would like to have a local Subversion repository not only for this,  but also for how it would benefit some of my hobby projects. After some googling I found my way to <a href="http://subversion.tigris.org/project_packages.html">http://subversion.tigris.org/project_packages.html</a> where, since I'm on windows, I picked the windows path. I end up downloading the latest version of Subversion:  <a href="http://subversion.tigris.org/files/documents/15/45344/svn-win32-1.6.0.zip">http://subversion.tigris.org/files/documents/15/45344/svn-win32-1.6.0.zip</a></p>
<p>I unpack it in "C:\Program Files\Subversion". To get the commands to work you have to add the  bin to your path. In my case I add "C:\Program Files\Subversion\svn-win32-1.5.6\bin" to the path. After this I open up a  command window and do the following:</p>
<pre lang="text">
mkdir subversionRepository
cd subversionRepository
svnadmin create project1
</pre>
<p>Now, in order to make Subversion work in Eclipse I add http://subclipse.tigris.org/update_1.6.x  to my update sites. After downloading this I restart my Eclipse and go to Window -> Show View ->Other->SVN -> SVN Repositories.<br />
I right click in the opened view and create a new repository location. Instead of writing a http adress in the URL window I now type "file:///C:/subversionRepository/project1". Notice the three forward slashes after "file:".</p>
<p>I now have an empty repository that I want to put my project into so I right click on the repository and add a new remote folder that I call trunk. Right clicking on the trunk I can now import my project by importing the folder that contains the .project file. I hit F5 to refresh the view and can see that the trunk is now filled with my first version of my project.</p>
<p>But I also have to associate the repository version with Eclipse, so now I right click in the Package Explorer and choose Import -> SVN -> Checkout Projects from SVN. I pick my previously created repository, click next, mark the trunk and then click finish. I get a question if I want to overwrite my previously created project with the same name and say ok. I won't need that now that I got a versioning system! </p>
<p>I can now finally continue my studies of the tool I was looking into.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/04/03/setting-up-a-local-subversion-repository-to-use-with-your-eclipse/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Mocking Eclipse IResource.accept()</title>
		<link>http://blog.jayway.com/2009/01/15/mocking-eclipse-iresourceaccept/</link>
		<comments>http://blog.jayway.com/2009/01/15/mocking-eclipse-iresourceaccept/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 08:39:48 +0000</pubDate>
		<dc:creator>Tobias Södergren</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[mock]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=761</guid>
		<description><![CDATA[I had a junit test situation where I wanted to mock an Eclipse IResource instance but still be able to test a call-back implementation given as parameter to the mocked IResource.accept(IResourceVisitor visit) method. By default, mocking an interface gives you "call count" and expected return values but no code is executed. In order to test the implementation of IResourceVisitor, something more had to be done. Here is how I did it.]]></description>
			<content:encoded><![CDATA[<p>I am currently involved in making the ClearCase plug-in for Eclipse, the one hosted at SourceForge, a bit better. Part of the job consists of creating unit tests to make sure that my fixes will stay fixed.</p>
<p>One interesting problem was that in some of my tests, I had to mock the <code>org.eclipse.core.resources.IResource</code> interface. Nothing too hard about that, just write the following code, using EasyMock 2.4:</p>
<pre class="java">&nbsp;
@Override
<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> setUp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">setUp</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   resource1 = createMock<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;resource1&quot;</span>, IResource.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;
   resource2 = createMock<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;resource2&quot;</span>, IResource.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Now to my problem. First, I will discuss what the IResource.accept(IResourceVisitor visitor) metod does:<br />
The IResource.accept(...) method traverses the directory structure under the resource. For each resource found, starting with the IResource on which accept() was called, the visitor.visit(IResource resource) method is called. If the visit(...) method returns true, the directory structure under the resource is traversed, otherwise traversing stops for that specific resource. This way parts of the directory structure under an IResource can be visited.</p>
<p>The problem I encountered was that since I have an IResource mock, there is no code for the accept() method. The mock will just register that there has been a call for accept(), but the code in the IResourceVisitor.visit(IResource resource), which I want tested, is never called.</p>
<p>What to do? There are different solutions, one example is to use an implementation of IResource, for example <code>org.eclipse.core.internal.resources.Folder</code>, and create a partially mocked object and keep the code for accept(). Not a nice solution though, my test would depend on internal code in the Eclipse project. What I did instead was to use the <code>org.easymock.EasyMock.expectLastCall().andAnswer(IAnswer answer)</code> functionality. The andAnswer() method takes an IAnswer callback implementation, like this:</p>
<pre class="java">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> testCollectRefreshStatus<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> CoreException <span style="color: #66cc66;">&#123;</span>
   <span style="color: #808080; font-style: italic;">// Normal mock expects</span>
   expect<span style="color: #66cc66;">&#40;</span>resource1.<span style="color: #006600;">getLocation</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">andReturn</span><span style="color: #66cc66;">&#40;</span>iPath1<span style="color: #66cc66;">&#41;</span>;
   expect<span style="color: #66cc66;">&#40;</span>iPath1.<span style="color: #006600;">toOSString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">andReturn</span><span style="color: #66cc66;">&#40;</span>RESOURCE_PATH_1<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">times</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #808080; font-style: italic;">// Provide code for accept(...)</span>
   resource1.<span style="color: #006600;">accept</span><span style="color: #66cc66;">&#40;</span>isA<span style="color: #66cc66;">&#40;</span>IResourceVisitor.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
   expectLastCall<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">andAnswer</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> IAnswer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> answer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AThrowable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Throwable</span></a> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">// 1.</span>
        IResourceVisitor visitor = <span style="color: #66cc66;">&#40;</span>IResourceVisitor<span style="color: #66cc66;">&#41;</span> EasyMock.<span style="color: #006600;">getCurrentArguments</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>; <span style="color: #808080; font-style: italic;">// 2.</span>
        visitor.<span style="color: #006600;">visit</span><span style="color: #66cc66;">&#40;</span>resource2<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 3.</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;
      <span style="color: #66cc66;">&#125;</span>
   <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
   expect<span style="color: #66cc66;">&#40;</span>resource2.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">andReturn</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;file.txt&quot;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// 4.</span>
&nbsp;
   replayMocks<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #808080; font-style: italic;">// Perform test</span>
   myTestTarget.<span style="color: #006600;">someMethod</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <span style="color: #808080; font-style: italic;">// Verify test</span>
   assertEquals<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>, myTestTarget.<span style="color: #006600;">getNumberOfResources</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
   verifyMocks<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>Here are some comments to the marked lines in the code above:</p>
<p>1. The answer() method is dictated by the IAnswer interface.<br />
2. EasyMock provides a method to get access to the objects sent as parameters for the expected call. In this case, the call is resource1.accept(...) and the parameter is the IResourceVisitor implementation defined in myTestTarget, which is the code that should be tested.<br />
3. Here the test code has control of the call to the IResourceVisitor.visit() and a mock IResource is provided as parameter. To make the test even better, the boolean return value from the visit() call should be saved and asserted for the correct value to ensure that the intended traversing works as expected.<br />
4. Here the expectations on the mock IResource, for the visit(IResource ...) call, is defined. In this case myTestTarget calls getName() on IResource for some reason, so expectations for that is defined together with a resulting return value that would steer the logic in some direction.</p>
<p>This way the test has full control of the visitor implementation and it is fairly easy to test all the criterias that makes the IResourceVisitor.visit(...) implementation return true or false. Also, the visit() method often changes state of something else, and here it is also possible to test that the state is changed correctly by simulating multiple visit(...) calls, by adding more calls to visit at 3. in the code above. </p>
<p>/Tobias S&ouml;dergren</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2009/01/15/mocking-eclipse-iresourceaccept/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EclipseCon 2008  &#8211; Santa Clara, California</title>
		<link>http://blog.jayway.com/2008/05/01/eclipsecon-2008-santa-clara-california/</link>
		<comments>http://blog.jayway.com/2008/05/01/eclipsecon-2008-santa-clara-california/#comments</comments>
		<pubDate>Thu, 01 May 2008 12:38:59 +0000</pubDate>
		<dc:creator>Tobias Södergren</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[jayview]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.jayway.com/?p=3134</guid>
		<description><![CDATA[EclipseCon 2008 took place between the 17:th and the 20:th of March and was held in Santa Clara, California. It is an event for, maybe not that surprising, people working with Eclipse, OSGi and sub-projects built on the Eclipse platform. This year there were 1400 visitors spread out among the four event days. EclipseCon is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>EclipseCon 2008 took place between the 17:th and the 20:th of March and was held in Santa Clara, California. It is an event for, maybe not that surprising, people working with Eclipse, OSGi and sub-projects built on the Eclipse platform. This year there were 1400 visitors spread out among the four event days. EclipseCon is co-hosted with OSGi DevCon which focuses on the OSGi technology and surrounding projects. </strong></p>
<h2>Lots of tutorials</h2>
<p>The first day was the tutorial day with 22 simultaneous labs and tutorials. All in<br />
all there were about 80 sessions that you could attend, including “An introduction<br />
to Pax tools for OSGi” hosted by Stuart. Unfortunately we did not have time to<br />
see all of the tutorials, and it was often difficult deciding which ones to attend. </p>
<p>The sessions ranged from “introduction” to “advanced” in both core Eclipse, such as Equinox and the Debugger frameworks, and in the variety of sub-projects such as GMF, eRCP, BIRT etc. One interesting session was about the new debugger service framework, abbreviated as DSF, which supports asynchronous calls to and callbacks from the debug target. Much of the framework is dealing with the issues that stem from working asynchronously. </p>
<p>The framework is created by Windriver, a big player in C/C++ development for embedded devices, because debugging embedded devices in most cases has a different nature than debugging Java code. Embedded devices often have slow communication links and the response often come in data chunks because of optimization issues. These characteristics do not fit well with the standard debugging framework in Eclipse. </p>
<p>The OSGi tutorials were well attended, with the Spring Dynamic Modules tutorial almost standing room only. It was also good to see a lot of interest in the OSGi service registry from plugin developers, who are more used to the Eclipse extension point registry. The overall feeling was that most people knew the basics of OSGi and were now eager to learn best practices and more advanced use. </p>
<h2>Fake Steve Jobs</h2>
<p>Tuesday was the starting day of the “ordinary” conference. The keynote speaker was Dan Lyon a.k.a Fake Steve Jobs. Dan Lyon has been working as a tech writer for many years, and started his blog called Fake Steve Jobs where he was writing tech articles as he thought Steve Job would have written them. After a while, people started to try and guess who this Fake Steve guy was and ultimately his own boss was discussing it openly, to his surprise. Dan had no choice but to come clean, but the popularity of the blog still remained. Sun, Microsoft, Oracle and even Eclipse get hit by his wild bashes, where the latter was something he was nervous about, being a keynote speaker at EclipseCon. But not everything is fictional and as he put it: - People are returning because I occasionally put some seriousness in my blog entries. </p>
<h2>Services vs. Extensions </h2>
<p>Among the interesting sessions for the day, was a session by Neil Bartlett regarding how to integrate Eclipse Extensions in OSGi services and vice versa. Eclipse extensions are the base for how plug-ins extend the Eclipse platform, such as adding menu entries, dialogs, wizards etc. to the workbench. OSGi is the platform on which Eclipse plug-ins are implemented, and it provides modularity and dynamic services. By using extensions and OSGi services it is possible to write very modular applications which supports lazy loading, being robust and dynamic in nature. </p>
<h2>Services + Extensions using dependency injection</h2>
<p>Neil also gave a talk on how dependency injection could bridge the gap between extension points and services. This is a very promising approach because it would free developers from having to decide which one to use in their components, and this decision could then be made at configuration/ deployment time. The prototype work is now being continued in an official Eclipse incubator project. </p>
<h2>Automatically repairing pre-OSGi code</h2>
<p>Erik Wistrand from Makewave (Knopflerfish framework) had a short talk on using bytecode manipulation at load-time to automatically detect and repair potentially problematic legacy code. This is a popular topic at the moment, as many people are looking at how to migrate their current applications to OSGi so they can start taking advantage of OSGi for new components. </p>
<h2>OSGi on Android</h2>
<p>In another session, Neil Bartlett and BJ Hargrave, a senior manager at IBM, were<br />
presenting how they got two different open-source OSGi containers running on the Google Android mobile platform. Both Equinox, the OSGi container developed by Eclipse, and Concierge which is a small container and a research project developed at ETH Zurich, were running on the Android emulator. </p>
<p>Other OSGi frameworks able to run on Android are Apache Felix, which was the first container running on it, and mBedded Server, which is a commercial OSGi container developed by ProSyst. Being able to run is not the same as being supported by Google though, but it is interesting to see that there was not that much work involved in introducing OSGi to Android. </p>
<h2>Open Source Microsoft</h2>
<p>Wednesday started off with a keynote from Sam Ramji, director of the Open Source Software Lab at Microsoft. Knowing that the audience was probably quite skeptical about Microsoft’s relationship with open-source Sam’s first slide was about project “Supernova”, where Microsoft decides to buy Eclipse and use it for Visual Studio because they really love Java! After that ice-breaker, Sam went on to discuss some of the open-source projects his lab works on, such as dynamic languages, and how Microsoft has much more focus on interoperability these days. He already has developers working with Mozilla and Apache, but more relevant for Eclipse, they are looking at helping with SWT (Standard Widget Toolkit) support for WPF (Windows Presentation Foundation).However, during the Q&A session Sam said there’s no plan for Microsoft to join Eclipse, or even have their developers become committers, which made this sound like a token effort. </p>
<h2>Eclipse 4.0</h2>
<p>The initial work of Eclipse 4.0 was presented by Mike Wilson, Jochen Krause, Jeff McAffer and Steve Northover. The current state is “wild ideas” and the trends getting focus in this release are that Java software development is moving into Rich Web GUI backed by services, and that the IDE will move to be a mix of web and desktop targets. The presenters want to see an effort to take what currently exists and put it “in the web space”. </p>
<p>The community work in Eclipse is quite good today, but people need to be much more involved in the future platform. </p>
<p>They also want to see that work is put into making it easier to create plug-<br />
ins with a more uniform API in Eclipse. There will probably be some kind of dependency injection framework available to make it easier to use services and resources. The platform should be better documented, the API should be reasonably sized, and the API should be RESTful and accessible by JavaScript. </p>
<p>The timeline for e4 (Eclipse 4.0 platform) is that the project will be proposed and started after the Eclipse Summit later this year. Until now, everything is ideas that may or may not be included in the project. There will be regular platform builds of e4, including milestones, and it will be ready within 2 years from start. </p>
<p>It will not be an easy task to create the next version of the Eclipse platform, because of its widespread use and the many wills of the multitude of Eclipse projects. The time when Eclipse was just a Java IDE is now long gone and there are a lot of people that have invested a lot, both in time and money, in their existing projects. </p>
<h2>API Tooling</h2>
<p>Among the things that make OSGi, and also the plug-in concept of Eclipse, great is the possibility of having different versions of the same functionality available for applications without conflict. One application might need version 1.x of a jar file while another requires an API incompatible version 2.x, and with proper versions on the packages there will be no conflict. Although being a good thing, it can be quite challenging to keep the versions correctly updated. Sometimes the changes you do to a code base might break an API compatibility, sometimes not. To remedythe situation in Eclipse, there is a new toolkit called “API Tooling”. The description, which is taken directly from the developer site, states: “API tooling will assist developers in API maintenance by reporting API defects such as binary incompatibilities, incorrect plug-in version numbers, missing or incorrect @since tags, and usage of non-API code between plug-ins”. An example of functionality in the toolkit is that offending code is marked in eclipse and quick-fix will be provided for changes that can be automated. The tools are scheduled to be included in the Eclipse Ganymede release in June. </p>
<h2>Information Economy </h2>
<p>Thursday’s keynote was given by Cory Doctorow about the “information economy” where information is a commodity, and you should therefore try to keep the cost of “creating” information low. This was a very entertaining talk where he stressed the importance of collaboration over restricting access. With collaboration you can (hopefully) still maintain a competitive edge - while restricting access to information is a temporary solution that often drives up costs, like old fashioned protectionism. Cory finished by asking everyone to help preserve their existing freedoms, such as the freedom on the Internet. </p>
<h2>Some reflections</h2>
<p>It was nice to see that that OSGi as a concept has matured among both the speakers and visitors as opposed to last years EclipseCon where it was more in a state of hype and excitement. It was also interesting that OSGi is creeping into mobile phones, Spring revealed their Titan platform for Windows Mobile phones containing an OSGi container besides being MIDP compatible. Another announcement made during the conference was that EclipseLink has been chosen as the JPA 2.0 Reference implementation. </p>
<p><em>Tobias Södergren and Stuart McCulloch</em></p>
<p><em>Originally published in <a href="http://jayway.se/jayview">JayView</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayway.com/2008/05/01/eclipsecon-2008-santa-clara-california/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

