<?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/"
	>

<channel>
	<title>Vidar's Musings</title>
	<atom:link href="http://www.kongsli.net/nblog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kongsli.net/nblog</link>
	<description>Deep thoughts on shallow topics</description>
	<pubDate>Thu, 18 Dec 2008 11:16:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The future of portal frameworks</title>
		<link>http://www.kongsli.net/nblog/2008/12/18/the-future-of-portal-frameworks/</link>
		<comments>http://www.kongsli.net/nblog/2008/12/18/the-future-of-portal-frameworks/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 11:16:21 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[System integration]]></category>

		<category><![CDATA[ajax]]></category>

		<category><![CDATA[gartner]]></category>

		<category><![CDATA[hype]]></category>

		<category><![CDATA[jsr-168]]></category>

		<category><![CDATA[mashup]]></category>

		<category><![CDATA[portal]]></category>

		<category><![CDATA[rss]]></category>

		<category><![CDATA[widget]]></category>

		<category><![CDATA[wsrp]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=74</guid>
		<description><![CDATA[Five years ago there was a lot of hype around portal technologies. (You know of which I speak; portlets, JSR-168, WSRP, etc.).  In 2004, Gartner listed technologies such as JSR-168(Portlet Specification), JSR-170 (Content Repository for Java™ Technology API) and WSRP (Web Services for Remote Portlets) at the peak of their hype cycle in their &#8220;Hype [...]]]></description>
			<content:encoded><![CDATA[<p>Five years ago there was a lot of hype around portal technologies. (You know of which I speak; portlets, JSR-168, WSRP, etc.).  In 2004, Gartner listed technologies such as JSR-168(Portlet Specification), JSR-170 (Content Repository for Java™ Technology API) and WSRP (Web Services for Remote Portlets) at the peak of their hype cycle in their &#8220;<a href="http://www.gartner.com/DisplayDocument?doc_cd=120898">Hype Cycle for the Portal Ecosystem</a>&#8220;. My impression is that since then those technologies have kind of faded away.</p>
<p>In my personal experience, I have not  seen any really successful portal technology deployments. (Of course, I am not implying that there are none such in existence, only I haven&#8217;t seen them). I have participated in my share of portal technology implementation projects, but none of them, I my opinion, did live up to their promise. Now seeing that there is less and less talk about portals (except from some software vendors that still are eager to sell their products that they have invested a lot in), I am questioning the future of portal frameworks as we know them.</p>
<h3>What value do portals add?</h3>
<p>In a discussion around web 2.0 technologies, a corporate communications person in a large international telecommunications company stated something like (I don&#8217;t remember his exact words) <em>&#8220;portals have not really caught on - after all people prefer to read their email in Outlook instead of settling with the inferior experience in a portal&#8221;</em>. This is a good point - many of the corporate portals focus on bringing a subset of functionality of other applications into a portal or workspace. But what is really the value added? After all, Firefox gave us tabbed browsing that has been adopted by all major browser vendors. Switching between your webmail and your (web-based) CRM system is only a Ctrl-tab away&#8230; In most scenarios, integration of applications using portal products did not deliver more than that.</p>
<p>A portal will add value when it is a common entry point where you can start when wanting to access information or a certain functionality. A typical example of this would be your corporate intranet. But it does not mean that the functionality necessarily needs to be delivered through that portal. Rather, it should guide or direct you to that application which delivers that functionality - only a click away.</p>
<p>Another area where portals could add value, is if data/functionality from several applications can be combined to add value. This has been a promise from portal frameworks that in my opinion has only to a very limited degree has been delivered. Inter-portlet communication did not happen to any large extent.</p>
<h3>What is the cost of portals?</h3>
<p>Compared to a plain web server technologies like Java Servlets, ASP.Net and the like, portal frameworks not only typically represent an extra licensing expense, they add quite a bit of complexity. In addition to configuration complexity, there is added complexity associated with customization and development. For instance, development models for portals are heavier and so are the development environments. Furthermore, portal frameworks constrain you in several ways, for instance when changing the look-and-feel or user interface experience. What is relatively easy to change in a standard web platform is much harder to change in a portal.</p>
<p>With the emergence of agile methodologies, disciplines like test-driven development and automated testing has become something that we have learned to appreciate. This has shown to be another area where portal frameworks get in your way as a developer- they are inherently hard to test.</p>
<h3>The challengers</h3>
<p>With the emergence of web 2.0-technologies, backed up by large Internet companies like Google and Yahoo! that do not sell software but services, the focus seems to be on lightweight technologies like Ajax, mashups, RSS, and REST-based services. Widgets/gadgets like the ones offered by services like Netvibes, iGoogle, Yahoo! and live.com are the <em>soupe du jour</em>. They offer a light-weight development model with a very low startup cost; no specific server-side technology knowledge is required, no specialized IDE or dev tools  required. The big question in my mind is whether these will challenge &#8220;traditional&#8221; portal technologies as the leading enabling technologies for intranet content aggregation? Quite recently Netvibes chose to open source their JavaScript widget engine. Furthermore, open source projects like <a href="http://incubator.apache.org/shindig/">Shindig</a> are popping up that aims to offer developers frameworks for widget development.</p>
<p>Portal frameworks also continue to evolve. JSR-168 has been succeeded by JSR-286 and there is a version 2 of WSRP. The question is if this is enough to to make portlets prosper. Personally, I don&#8217;t think so as the problems are at a more fundamental, conceptual level than API specifications. But time will show&#8230;</p>
<h3>In conclusion</h3>
<p>&#8220;Traditional&#8221; portal frameworks have not lived up to their expectations. The use cases for portal technology represent niche functionality, at most. Furthermore, portal technology represent a heavy development model that in many cases will slow you down, compared to other technologies. If you are considering implementing portal technology in your company, you should very carefully investigate cost/benefit. Do not exclusively listen to portal vendors; talk to peer companies that have implemented portals, inquire them about their experiences. Talk to devs. Keep a close eye on emerging technologies. Keywords include widgets, Ajax, RSS, mashups.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/12/18/the-future-of-portal-frameworks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Forvaltning av SOA-laget</title>
		<link>http://www.kongsli.net/nblog/2008/12/16/forvaltning-av-soa-laget/</link>
		<comments>http://www.kongsli.net/nblog/2008/12/16/forvaltning-av-soa-laget/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 12:13:00 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[System integration]]></category>

		<category><![CDATA[soa]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=72</guid>
		<description><![CDATA[
Hva gjør en teknolog som forvalter SOA-laget? Hvor kommer dette SOA-laget fra? Er de i førstedivisjon?
Programvareselgere har klart å få kunder til å tro at SOA handler om lagdeling. Har du noe som kalles &#8216;SOA-laget&#8217; i arkitekturen din, er det noe fundamentalt galt.
 
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kongsli.net/nblog/wp-content/uploads/2008/12/soa-laget.jpg"><img class="alignnone size-medium wp-image-73" title="soa-laget" src="http://www.kongsli.net/nblog/wp-content/uploads/2008/12/soa-laget-300x188.jpg" alt="Faksimile fra Computerworld Norge" width="600" height="376" /></a></p>
<p>Hva gjør en teknolog som forvalter SOA-laget? Hvor kommer dette SOA-laget fra? Er de i førstedivisjon?</p>
<p>Programvareselgere har klart å få kunder til å tro at SOA handler om lagdeling. Har du noe som kalles &#8216;SOA-laget&#8217; i arkitekturen din, er det noe fundamentalt galt.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/12/16/forvaltning-av-soa-laget/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Solution for unit testing SharePoint does not fix root cause</title>
		<link>http://www.kongsli.net/nblog/2008/11/27/solution-for-unit-testing-sharepoint-does-not-fix-root-cause/</link>
		<comments>http://www.kongsli.net/nblog/2008/11/27/solution-for-unit-testing-sharepoint-does-not-fix-root-cause/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 07:27:29 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Microsoft technologies]]></category>

		<category><![CDATA[Software development]]></category>

		<category><![CDATA[mocking]]></category>

		<category><![CDATA[sharepoint]]></category>

		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=71</guid>
		<description><![CDATA[21apps.com has written an article about how to use Typemock Isolator in order to unit test SharePoint applications. According to the article, &#8220;Typemock  has become the tool of choice for unit testing SharePoint as it supports faking everything including the sealed classes found throughout the object model&#8221;. Problem is that the root cause that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.21apps.com/">21apps.com</a> has written an <a href="http://www.21apps.com/wp-content/uploads/2008/11/unit-testing-sharepoint-solutions-getting-into-the-object-model.pdf">article</a> about how to use <a href="http://www.typemock.com/">Typemock</a> Isolator in order to unit test SharePoint applications. According to the article, <em>&#8220;<img src="file:///d:/tmp/moz-screenshot.jpg" alt="" /><img src="file:///d:/tmp/moz-screenshot-1.jpg" alt="" /><a href="http://www.typemock.com/">Typemock</a> </em><em> has become the tool of choice for unit testing SharePoint as it supports faking everything including the sealed classes found throughout the object model&#8221;</em>. Problem is that the <a href="http://en.wikipedia.org/wiki/Root_cause">root cause</a> that prevents unit testing in SharePoint is an invasive API that creates dependencies between your code and the API. Using <a href="http://www.typemock.com/">Typemock</a> Isolator is treating the concequences without attacking the cause of the problem. But of course, having unit test is an advantage compared to having none.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/11/27/solution-for-unit-testing-sharepoint-does-not-fix-root-cause/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Portals versus mashups analogy</title>
		<link>http://www.kongsli.net/nblog/2008/11/18/portals-versus-mashups-analogy/</link>
		<comments>http://www.kongsli.net/nblog/2008/11/18/portals-versus-mashups-analogy/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 08:08:49 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[mashup portal portlet]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=70</guid>
		<description><![CDATA[Reading up on theory about mashups I found an article on Wikipedia that states the following about &#8220;oldfashioned&#8221; portals&#8217; aggregation style: &#8220;Salad bar&#8221; style - Aggregated content is presented &#8217;side-by-side&#8217; without overlaps&#8221;. I think this is a nice analogy, and I would like to take it a step further, saying that:

Oldfashioned portals (&#8221;portlet&#8221; technology) are [...]]]></description>
			<content:encoded><![CDATA[<p>Reading up on theory about mashups I found an article on Wikipedia that states the following about &#8220;oldfashioned&#8221; portals&#8217; aggregation style: <em>&#8220;Salad bar&#8221; style - Aggregated content is presented &#8217;side-by-side&#8217; without overlaps&#8221;</em>. I think this is a nice analogy, and I would like to take it a step further, saying that:</p>
<ul>
<li>Oldfashioned portals (&#8221;portlet&#8221; technology) are salad bars, while</li>
<li>mashups are salads</li>
</ul>
<h2>Portlets:</h2>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Salad_bar.JPG/800px-Salad_bar.JPG" alt="" width="600" height="450" /></p>
<p>(Image: Wikipedia commons)</p>
<h2></h2>
<h2>Mashups:</h2>
<p><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Salad_platter02.jpg/800px-Salad_platter02.jpg" alt="" width="600" height="400" /></p>
<p>(Image: Wikipedia Commons)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/11/18/portals-versus-mashups-analogy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Measurement of code quality</title>
		<link>http://www.kongsli.net/nblog/2008/09/25/measurement-of-code-quality/</link>
		<comments>http://www.kongsli.net/nblog/2008/09/25/measurement-of-code-quality/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 10:48:09 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[code quality]]></category>

		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=69</guid>
		<description><![CDATA[No measurement beats WTFs/min!
]]></description>
			<content:encoded><![CDATA[<p>No measurement beats <a href="http://www.osnews.com/story/19266/WTFs_m">WTFs/min</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/09/25/measurement-of-code-quality/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pure functions and testability</title>
		<link>http://www.kongsli.net/nblog/2008/09/19/pure-functions-and-testability/</link>
		<comments>http://www.kongsli.net/nblog/2008/09/19/pure-functions-and-testability/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 13:36:28 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Microsoft technologies]]></category>

		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Software testing]]></category>

		<category><![CDATA[automated testing]]></category>

		<category><![CDATA[code quality]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=68</guid>
		<description><![CDATA[When trying to introduce unit tests into an existing project, code dependencies is often a problem. During a teeth-grinding session grappling with this problem I came to think about pure functions.
Pure functions are functions that (according to Wikipedia&#8217;s definition):

always evaluates the same result value given the same argument value(s). The function result value cannot depend [...]]]></description>
			<content:encoded><![CDATA[<p>When trying to introduce unit tests into an existing project, code dependencies is often a problem. During a teeth-grinding session grappling with this problem I came to think about pure functions.</p>
<p><a href="http://en.wikipedia.org/wiki/Pure_function">Pure functions</a> are functions that (according to <a href="http://en.wikipedia.org/wiki/Main_Page">Wikipedia</a>&#8217;s definition):</p>
<ul>
<li>always evaluates the same result value given the same argument value(s). The function result value cannot depend on any hidden information or state that may change as program execution proceeds, nor can it depend on any external input from I/O devices, and</li>
<li>evaluation of the result does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices.</li>
</ul>
<p>Seems to me that pure functions would be a wet dream for unit testing. Imagine, you could pass in whatever the function needed to execute, and then check its return value. No mocking about with mock objects with side effect expectations needed!</p>
<p>But alas, we live in a world with non-pure functions. Even in functional programming, which does explicitly keep any state, you find them. In an object oriented language a primary idea is that objects should carry state. An object has a state. Period. However, if we can be inspired by the notion of pure functions, and make methods that have less dependencies, we will be much better off when it comes to unit testing.</p>
<p>I my experience, the ASP.NET programming model with ASPX code behind files is a model that promotes writing methods that are problematic to create unit tests for.</p>
<p>Take, for example, the following (theoretical, I admit) code behind snippet example:</p>
<pre style="padding-left: 30px;">protected void Page_Load(object sender, EventArgs e)</pre>
<pre>    {</pre>
<pre>        ShowOrHideEditButton(Page.User.Identity.Name);</pre>
<pre>    }</pre>
<pre>    void ShowOrHideEditButton(string currentUser)</pre>
<pre>    {</pre>
<pre>        if (Request.QueryString["user"].Equals(currentUser))</pre>
<pre>        {</pre>
<pre>            EditButton.Enabled = true;</pre>
<pre>        }</pre>
<pre>        else</pre>
<pre>        {</pre>
<pre>            EditButton.Enabled = false;</pre>
<pre>        }</pre>
<pre>    }</pre>
<p>So, what is the problem here? Actually, there are two problems.</p>
<ol>
<li>The ShowOrHideMethod is not only dependant on its input parameters, but also on another member variable. When looking at the method signature, you do not see this, and might be misleaded about what the outcome of the methods is dependent on.</li>
<li>The method does not return any value, but has a side-effect on its environment (setting the edit button visibility).</li>
</ol>
<p>These two issues, makes it troublesome to test the method in a unit test. You have spend time to set up the methods context, and you have to measure the method&#8217;s side effects in order to make assesments about its result.</p>
<p>A much better approach would be something like this:</p>
<pre>    protected void Page_Load(object sender, EventArgs e)</pre>
<pre>    {</pre>
<pre>        EditButton.Enabled = ShowOrHideEditButton(Page.User.Identity.Name, Request.QueryString["user"]);</pre>
<pre>    }</pre>
<pre>    bool ShowOrHideEditButton(string currentUserName, string profilePerson)</pre>
<pre>    {</pre>
<pre>        return (currentUserName.Equals(profilePerson));</pre>
<pre>    }</pre>
<p>This way, we can easily test the ShowOrHideEditButton method in a unit test without having to use a great deal test code to set up the test context.</p>
<p>For increased testability, I would suggest the following for better method purity:</p>
<ul>
<li>A method should evaluate the same result, given the same argument value(s) and object state.</li>
<li>A method execution result should be represented as, in order of preference: 1) a return value, 2) changed object state (mutation), or 3) a side-effect on an I/O device</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/09/19/pure-functions-and-testability/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ASP.NET: Delegate identity from a web application to a back end web application</title>
		<link>http://www.kongsli.net/nblog/2008/08/08/aspnet-delegate-identity-from-a-web-application-to-a-back-end-web-application/</link>
		<comments>http://www.kongsli.net/nblog/2008/08/08/aspnet-delegate-identity-from-a-web-application-to-a-back-end-web-application/#comments</comments>
		<pubDate>Fri, 08 Aug 2008 07:12:51 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Microsoft technologies]]></category>

		<category><![CDATA[Software development]]></category>

		<category><![CDATA[asp.net]]></category>

		<category><![CDATA[authentication]]></category>

		<category><![CDATA[delegation]]></category>

		<category><![CDATA[identity]]></category>

		<category><![CDATA[iis]]></category>

		<category><![CDATA[kerberos]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=66</guid>
		<description><![CDATA[One of the things that seem very simple on a Powerpoint presentation, but are not that simple in practice, is having a web user&#8217;s identity forwarded from a calling web application to another web application when using Kerberos.
The case is as follows: I have an intranet application A which uses Integrated Windows Authentication to authenticate [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that seem very simple on a Powerpoint presentation, but are not that simple in practice, is having a web user&#8217;s identity forwarded from a calling web application to another web application when using Kerberos.</p>
<p>The case is as follows: I have an intranet application A which uses Integrated Windows Authentication to authenticate the user. During processing of a request from a web users, application A then makes an HTTP request to intranet application B. Application B requires the web user to be authenticated to process the request. The often most attractive solution for solving this is what Microsoft refers to as identity delegation. Simple in a Powerpoint presentation, but alas, not so simple in practice.</p>
<p>First of all, there are a number of preconditions in the computing environment configuration that need to be fulfilled. I found a very good summary of gotchas in this respect <a href="http://forums.asp.net/p/163508/400236.aspx#163797">here</a>. In my case, the points 2 and 6 was  missing (I knew about the other once beforehand). So, when all configuration stuff set up, then the only thing left is the code and configuration in the application A.</p>
<p>Basically, you need to make the application impersonate the web user (meaning that it will run with the credentials of the web user). There are two ways to do this. If you wish the entire request to run as the web user, you can insert an &lt;identity impersonate=&#8221;true&#8221; /&gt; element under &lt;system.web&gt; in the application&#8217;s web.config. Or, if you wish only the request to application B to run as the web user, you can do this programmatically:</p>
<pre>using System.Security.Principal;</pre>
<pre>...</pre>
<pre>WindowsIdentity identity = (WindowsIdentity)HttpContext.Current.User.Identity();</pre>
<pre>using (identity.Impersonate())</pre>
<pre>{</pre>
<pre>    // ... code to call application B goes here ...</pre>
<pre>}</pre>
<p>Then, the next task is to call application B itself. You can do this by creating a web request:</p>
<pre>HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.somethingcompletelydifferent.com");</pre>
<pre>request.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;</pre>
<pre>request.UseDefaultCredentials = true;</pre>
<pre>...</pre>
<pre>HttpWebResponse response = request.GetResponse();</pre>
<pre>...</pre>
<p>The important things to notice here is that we set the ImpersonationLevel property to &#8220;Delegation&#8221; and that we set the UseDefaultCredentials property to &#8220;true&#8221;. So, it together, we get:</p>
<pre>using System.Security.Principal;</pre>
<pre>...</pre>
<pre>WindowsIdentity identity = (WindowsIdentity)HttpContext.Current.User.Identity();</pre>
<pre>using (identity.Impersonate())</pre>
<pre>{</pre>
<pre>    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.somethingcompletelydifferent.com");</pre>
<pre>    request.ImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation;</pre>
<pre>    request.UseDefaultCredentials = true;</pre>
<pre>    ...</pre>
<pre>    HttpWebResponse response = request.GetResponse();</pre>
<pre>    ...</pre>
<pre>}</pre>
<p>You can then test that it works in application B by checking the name in HttpContext.Current.User.Identity.Name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/08/08/aspnet-delegate-identity-from-a-web-application-to-a-back-end-web-application/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Spring.NET: programatically add objects to the existing (XML) application context</title>
		<link>http://www.kongsli.net/nblog/2008/08/07/springnet-programatically-add-objects-to-the-existing-xml-application-context/</link>
		<comments>http://www.kongsli.net/nblog/2008/08/07/springnet-programatically-add-objects-to-the-existing-xml-application-context/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 13:10:01 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Microsoft technologies]]></category>

		<category><![CDATA[Software development]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[context]]></category>

		<category><![CDATA[spring]]></category>

		<category><![CDATA[spring.net]]></category>

		<category><![CDATA[wiring]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=65</guid>
		<description><![CDATA[My experience is that Spring.NET configuration files tend to grow very large. As far as I can figure, there are two principal problems that arise from this:

The configuration files get difficult to read and maintain
It gets easier to introduce errors in the configuration because of its size

In general, I am in favour of keeping configuration [...]]]></description>
			<content:encoded><![CDATA[<p>My experience is that Spring.NET configuration files tend to grow very large. As far as I can figure, there are two principal problems that arise from this:</p>
<ol>
<li>The configuration files get difficult to read and maintain</li>
<li>It gets easier to introduce errors in the configuration because of its size</li>
</ol>
<p>In general, I am in favour of keeping configuration files as small as possible. I often work with web applications that can (quite) easily be redeployed to the production environment, hence I always ask the question &#8220;will this value ever change between environments or deployments&#8221; when considering introducing a new configuration part.</p>
<p>Now, the Spring XML configuration usually serves two main purposes; to wire together the application, and to provide values that should be possible to change between deployments of the application or for different environments. The first purpose, I would argue does not necessarily need to be in the XML configuration. Rather, if this is done in code, we get the benefit that the compiler will tell us right away if there are typos or missing references. If this wiring is in the XML configuration file, such errors will not surface until the application starts.</p>
<p>So, the question that I had, was how Spring context wiring could be combined in code and in XML. I found one way of doing it, but it is only applicable to singleton objects.</p>
<p>Say, for instance that we have an object &#8220;something&#8221; that we wish to have configured in XML:</p>
<pre>  &lt;object id="something" type="SpringTest.Something, SpringTest" singleton="false"/&gt;
</pre>
<p>Then, we have a class that we want to initialize in code:</p>
<pre>class Foo</pre>
<pre>{</pre>
<pre>    public Foo() { }
    private Something _s;</pre>
<pre>    Something S</pre>
<pre>    {</pre>
<pre>        set { _s = value; }</pre>
<pre>        get { return _s; }</pre>
<pre>    }</pre>
<pre>}</pre>
<p>Now, we see that Foo has a dependency on Something; it needs an instance of Something to be injected. We can use the Spring context to do this after we have created the instance of Foo:</p>
<pre style="padding-left: 30px;">IApplicationContext context = ContextRegistry.GetContext();</pre>
<pre style="padding-left: 30px;">Foo f = new Foo();</pre>
<pre style="padding-left: 30px;">context.ConfigureObject(f, "fooPrototype");</pre>
<p>But Spring does not yet know that the Foo instance needs to be injected Something. Hence, we need to tell Spring that by creating what I would call a &#8220;prototype&#8221; or &#8220;template&#8221; object configuration:</p>
<pre style="padding-left: 30px;">&lt;object id="fooPrototype" type="ContextTestProject.Foo, ContextTestProject"&gt;</pre>
<pre style="padding-left: 30px;">   &lt;property name="S" ref="something"&gt;&lt;/property&gt;</pre>
<pre style="padding-left: 30px;">&lt;/object&gt;</pre>
<p>The final step is then to register our newly created object in the Spring context:</p>
<pre style="padding-left: 30px;">XmlApplicationContext xmlContext = context as XmlApplicationContext;</pre>
<pre style="padding-left: 30px;">xmlContext.ObjectFactory.RegisterSingleton("foo", f);</pre>
<p>After this, the Foo instance is available for the application in the Spring context.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/08/07/springnet-programatically-add-objects-to-the-existing-xml-application-context/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Internet Explorer automation/Watin: catching navigation error codes</title>
		<link>http://www.kongsli.net/nblog/2008/07/08/internet-explorer-automationwatin-catching-navigation-error-codes/</link>
		<comments>http://www.kongsli.net/nblog/2008/07/08/internet-explorer-automationwatin-catching-navigation-error-codes/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 12:20:02 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Software testing]]></category>

		<category><![CDATA[.net]]></category>

		<category><![CDATA[automation]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[internet explorer]]></category>

		<category><![CDATA[internetexplorer]]></category>

		<category><![CDATA[statuscode]]></category>

		<category><![CDATA[watin]]></category>

		<category><![CDATA[web test]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=64</guid>
		<description><![CDATA[One question have troubled me for some time when automating Internet Explorer (actually, I am doing web testing with Watin): how to test for HTTP status codes. Finally, I figured out how to do this. The lies in an event that the InternetExplorer object raises when navigation is unsuccessful.
I ended up with writing a C# [...]]]></description>
			<content:encoded><![CDATA[<p>One question have troubled me for some time when automating Internet Explorer (actually, I am doing web testing with Watin): how to test for HTTP status codes. Finally, I figured out how to do this. The lies in an event that the InternetExplorer object raises when navigation is unsuccessful.</p>
<p>I ended up with writing a C# helper class:</p>
<pre>using System.Net;</pre>
<pre>using WatiN.Core;</pre>
<pre>using SHDocVw;</pre>
<pre>using Microsoft.VisualStudio.TestTools.UnitTesting;</pre>
<pre>using System.Globalization;</pre>
<pre>namespace Test</pre>
<pre>{</pre>
<pre>    public class NavigationObserver</pre>
<pre>    {</pre>
<pre>        private HttpStatusCode _statusCode;</pre>
<pre>        public NavigationObserver(IE ie)</pre>
<pre>        {</pre>
<pre>            InternetExplorer internetExplorer = (InternetExplorer)ie.InternetExplorer;</pre>
<pre>            internetExplorer.NavigateError += new DWebBrowserEvents2_NavigateErrorEventHandler(IeNavigateError);</pre>
<pre>        }</pre>
<pre>        public void ShouldHave(HttpStatusCode expectedStatusCode)</pre>
<pre>        {</pre>
<pre>            if (!_statusCode.Equals(expectedStatusCode))</pre>
<pre>            {</pre>
<pre>                Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Wrong status code. Expected {0}, but was {1}",</pre>
<pre>                    expectedStatusCode, _statusCode));</pre>
<pre>            }</pre>
<pre>        }</pre>
<pre>        private void IeNavigateError(object pDisp, ref object URL, ref object Frame, ref object StatusCode, ref bool Cancel)</pre>
<pre>        {</pre>
<pre>            _statusCode = (HttpStatusCode)StatusCode;</pre>
<pre>        }</pre>
<pre>    }</pre>
<pre>}</pre>
<p>Note that I use Visual Studio test runner to run my web tests. Then, I can use this in my test:</p>
<pre>using (IE ie = new IE())</pre>
<pre>{</pre>
<pre>    NavigationObserver observer = new NavigationObserver(ie);</pre>
<pre>    ie.GoTo("http://some.where.com");</pre>
<pre>    observer.ShouldHave(HttpStatusCode.NotFound);</pre>
<pre>}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/07/08/internet-explorer-automationwatin-catching-navigation-error-codes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sending POST requests with Watin</title>
		<link>http://www.kongsli.net/nblog/2008/07/07/sending-post-requests-with-watin/</link>
		<comments>http://www.kongsli.net/nblog/2008/07/07/sending-post-requests-with-watin/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 17:25:47 +0000</pubDate>
		<dc:creator>vidarkongsli</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Software testing]]></category>

		<category><![CDATA[automation]]></category>

		<category><![CDATA[com]]></category>

		<category><![CDATA[internet explorer]]></category>

		<category><![CDATA[watin]]></category>

		<category><![CDATA[web test]]></category>

		<guid isPermaLink="false">http://www.kongsli.net/nblog/?p=63</guid>
		<description><![CDATA[When doing web testing using Watin, it is not trivial to be able to do a POST request to the server. However, with the help this article on microsoft.com, I was able to figure out how. I ended up with writing this class:
public class Navigator
{
    private IE _ie;

    public Navigator(IE ie) { _ie = ie; [...]]]></description>
			<content:encoded><![CDATA[<p>When doing web testing using Watin, it is not trivial to be able to do a POST request to the server. However, with the help <a href="http://support.microsoft.com/kb/313068/">this</a> article on microsoft.com, I was able to figure out how. I ended up with writing this class:</p>
<pre style="padding-left: 30px;">public class Navigator
{
    private IE _ie;

    public Navigator(IE ie) { _ie = ie; }

    public void Post(Uri baseUri, params KeyValuePair&lt;string, object&gt;[] postData)
    {
        object flags = null;
        object targetFrame = null;
        object headers = "Content-Type: application/x-www-form-urlencoded" + Convert.ToChar(10) + Convert.ToChar(13);
        object postDataBytes = MakeByteStreamOf(postData);
        object resourceLocator = baseUri.ToString();
        IWebBrowser2 browser = (IWebBrowser2)_ie.InternetExplorer;
        browser.Navigate2(ref resourceLocator, ref flags, ref targetFrame, ref postDataBytes, ref headers);
        _ie.WaitForComplete();
    }

    private static byte[] MakeByteStreamOf(KeyValuePair&lt;string, object&gt;[] postData)
    {
        StringBuilder sb = new StringBuilder();
        if (postData.Length &gt; 0)
        {
            foreach (KeyValuePair&lt;string, object&gt; postDataEntry in postData)
            {
                sb.Append(postDataEntry.Key).Append('=').Append(postDataEntry.Value).Append('&amp;');
            }
            sb.Remove(sb.Length - 1, 1);
        }
        return ASCIIEncoding.ASCII.GetBytes(sb.ToString());
    }
}</pre>
<p>For example, I can use it like so:</p>
<pre>using (IE ie = new IE())</pre>
<pre>{</pre>
<pre>    Navigator navigator = new Navigator(ie);</pre>
<pre>    navigator.Post(new Uri("http://www.foo.com/"), new KeyValuePair&lt;string, object&gt;("p", 1));</pre>
<pre>    Assert.AreEqual("OK", ie.Text);</pre>
<pre>}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kongsli.net/nblog/2008/07/07/sending-post-requests-with-watin/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
