<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>andthennothing.net: Aspects</title>
  <subtitle type="html">&amp;ldquo;first there was a three-legged monkey...&amp;rdquo;</subtitle>
  <id>tag:andthennothing.net,2005:Typo</id>
  <generator uri="http://typo.leetsoft.com" version="4.0">Typo</generator>
  <link href="http://andthennothing.net/xml/atom10/article/213/feed.xml" rel="self" type="application/xml+atom"/>
  <link href="http://andthennothing.net/archives/2002/10/02/aspects" rel="alternate" type="text/html"/>
  <updated>2005-12-18T03:19:07+00:00</updated>
  <entry>
    <author>
      <name>Jonas Bengtsson</name>
      <email>jonas.b@home.se</email>
    </author>
    <id>urn:uuid:8a929ecb-b508-485c-808a-a58a04fd7d75</id>
    <published>2002-10-02T12:48:38+00:00</published>
    <updated>2005-12-18T03:19:07+00:00</updated>
    <title>Aspects</title>
    <link href="http://andthennothing.net/archives/2002/10/02/aspects" rel="alternate" type="text/html"/>
    <content type="html">&lt;p&gt;I have looked at &lt;a href="http://aosd.net/"&gt;Aspect-Oriented Programming&lt;/a&gt; (and &lt;a href="http://www.aspectj.org/"&gt;AspectJ&lt;/a&gt;) before, and I&amp;#8217;ve thought that it seems quite interesting, but also quite complicated. However, today I&amp;#8217;ve read about one situation it seems to be really useful.&lt;br /&gt;&lt;br /&gt;In an article at &lt;a href="http://www.xprogramming.com/"&gt;XProgramming.com&lt;/a&gt; called &lt;a href="http://www.xprogramming.com/xpmag/virtualMockObjects.htm"&gt;Virtual Mock Objects using AspectJ with &lt;span class="caps"&gt;JUNIT&lt;/span&gt;&lt;/a&gt;, Simon Monk and Stephen Hall is describing how AspectJ can be used to create virtual &lt;a href="http://www.mockobjects.com/"&gt;mock objects&lt;/a&gt;. With their &amp;#8220;framework&amp;#8221; (source code available &lt;a href="http://www.shopwriter.co.uk/simon/aspectj/"&gt;here&lt;/a&gt;) you just have your test case class subclass their &lt;a href="http://www.shopwriter.co.uk/simon/aspectj/ComponentTestCase.java"&gt;ComponentTestCase&lt;/a&gt; instead of &lt;a href="http://www.junit.org/"&gt;JUnit&lt;/a&gt;&amp;#8217;s TestCase. You can then create virtual mock objects by calling setMock(className, methodName, mockResult) (or a couple of alternatives). It&amp;#8217;s that simple! You can then use assertCalled() and assertArgumentPassed() to make sure the virtual mock objects are used in a correct manner. (There are more features in there. Check out the article for more details, it&amp;#8217;s a good read!)&lt;br /&gt;&lt;br /&gt;I guess I have to look further into Aspect-Based Programming at some point. Perhaps when the AspectJ plug-in to &lt;a href="http://www.eclipse.org/"&gt;Eclipse&lt;/a&gt;, called &lt;a href="http://www.eclipse.org/ajdt/"&gt;&lt;span class="caps"&gt;AJDT&lt;/span&gt;&lt;/a&gt;, is finished (it might be finished already, I&amp;#8217;m not sure).&lt;/p&gt;</content>
  </entry>
</feed>
