<?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>Carl on coding</title>
	<atom:link href="http://carlduevel.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://carlduevel.net</link>
	<description>My personal weblog on whatever catches my interest.</description>
	<lastBuildDate>Sat, 28 Jan 2012 13:07:01 +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>JadClipse and Ubuntu 11.10</title>
		<link>http://carlduevel.net/jadclipse-and-ubuntu-11-10/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jadclipse-and-ubuntu-11-10</link>
		<comments>http://carlduevel.net/jadclipse-and-ubuntu-11-10/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 05:25:05 +0000</pubDate>
		<dc:creator>Carl</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[jad]]></category>

		<guid isPermaLink="false">http://carlduevel.net/?p=63</guid>
		<description><![CDATA[I used the jd-eclipse plugin for some time until it stopped working yesterday without any clue whatsoever (Checked the log files and preferences and whatever people recommended to do on the net). As I really had to look into some class files today I tried to set up JadClipse instead. Turns out it needs JAD [...]]]></description>
			<content:encoded><![CDATA[<p>I used the jd-eclipse plugin for some time until it stopped working yesterday without any clue whatsoever (Checked the log files and preferences and <a href="http://stackoverflow.com/questions/4512066/how-to-get-java-decompiler-jd-jd-eclipse-running-in-eclipse-helios">whatever people recommended to do on the net</a>). As I really had to look into some class files today I tried to set up <a href="http://jadclipse.sourceforge.net/wiki/index.php/Main_Page">JadClipse</a> instead. Turns out it needs JAD to do its work and you have to configure the path to it on the preferences. If you download it from <a href="http://www.varaneckas.com/jad">here</a> and try to run it, it will respond with the following error message:</p>
<p><code>error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory</code></p>
<p>I tried to install the missing package libstdc++2.10-glibc2.2_2.95 via apt-get but it turns out it <a href="https://bugs.launchpad.net/ubuntu/+source/gcc-2.95/+bug/185698">is not included anymore since Hardy</a>.</p>
<p>The simple and stupid solution works though: Get the deb from <a href="http://archive.debian.org/debian/pool/main/g/gcc-2.95/libstdc++2.10-glibc2.2_2.95.4-11woody1_i386.deb">here</a> and install it via dpkg &#8211; jad works fine with it.</p>
<p>After that, I had to fiddle with the editor preferences for the class files in order to get it working (it was opening the right editor but still no decompiled source until I deleted one of the other preferences for class files&#8230; <img src='http://carlduevel.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  ).</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fcarlduevel.net%2Fjadclipse-and-ubuntu-11-10%2F&amp;title=JadClipse%20and%20Ubuntu%2011.10" id="wpa2a_2"><img src="http://carlduevel.net/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://carlduevel.net/jadclipse-and-ubuntu-11-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get selenium to work with proxy authentication</title>
		<link>http://carlduevel.net/get-selenium-to-run-with-proxy-authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=get-selenium-to-run-with-proxy-authentication</link>
		<comments>http://carlduevel.net/get-selenium-to-run-with-proxy-authentication/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 09:17:21 +0000</pubDate>
		<dc:creator>Carl</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[proxy authentication]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://hackbart.net/?p=16</guid>
		<description><![CDATA[The problem at hand is to get Selenium working with an application, that is only reachable via a proxy that requires authentication. I thought that this is a very common setting, as most websites should be hidden until the day of the launch but it is not very well supported by selenium. It was suprisingly [...]]]></description>
			<content:encoded><![CDATA[<p>The problem at hand is to get Selenium working with an application, that is only reachable via a proxy that requires authentication. I thought that this is a very common setting, as most websites should be hidden until the day of the launch but it is not very well supported by selenium.</p>
<p>It was suprisingly hard to get up and running, so I&#8221;ll outline the solution here in order to save my fellow software writers / testers a couple of hours. I used the FirefoxDriver &amp; Java for this one, but it should be applicable for other Drivers as well as Selenium APIs as well.</p>
<p>In short we will start up a proxy server on the machine where the test runs and make the FirefoxDriver use it. In order to make this all self-contained we need the <a title="browsermob-proxy" href="http://opensource.webmetrics.com/browsermob-proxy/">browsermob-proxy</a> and &#8211; of course &#8211; selenium.  So in Maven this means:</p>
<pre class="crayon-plain-tag"><code>&lt;dependencies&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;dependency&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;version&gt;2.12.0&lt;/version&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;scope&gt;test&lt;/scope&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/dependency&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;dependency&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;groupId&gt;biz.neustar&lt;/groupId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;artifactId&gt;browsermob-proxy&lt;/artifactId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;version&gt;2.0-beta-3&lt;/version&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;scope&gt;test&lt;/scope&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/dependency&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;dependency&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;groupId&gt;junit&lt;/groupId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;artifactId&gt;junit&lt;/artifactId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;version&gt;4.10&lt;/version&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;scope&gt;test&lt;/scope&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/dependency&gt;
&nbsp; &nbsp; &lt;/dependencies&gt;
&nbsp; &nbsp; &lt;dependencyManagement&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;dependencies&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;dependency&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;artifactId&gt;httpclient&lt;/artifactId&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;version&gt;4.1.2&lt;/version&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/dependency&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/dependencies&gt;
&nbsp; &nbsp; &lt;/dependencyManagement&gt;</code></pre>
<p>Configuring the proxy server takes a few lines, as we have to rely on reflection in order to configure the proxy to use the proxy <img src='http://carlduevel.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> :</p><pre class="crayon-plain-tag"><code>/**
*
* @param internalPort Port of the local proxy (listening on localhost).
* @param proxyHost The (external) proxy to use.
* @param credentials The credentials needed for the external proxy.
* @return The created proxy server.
* @throws Exception
*/
private ProxyServer createAndConfigureProxyServer(int internalPort,
HttpHost proxyHost, UsernamePasswordCredentials credentials)
throws Exception{
// Set up the internal proxy server and start it, because otherwise the
// http client is not started and we end up with a NP.
ProxyServer server = new ProxyServer(internalPort);
server.start();
DefaultHttpClient httpClient = extract();
AuthScope authScope = new AuthScope(proxyHost.getHostName(),
proxyHost.getPort());
httpClient.getCredentialsProvider().setCredentials(authScope,
credentials);
HttpHost proxy = new HttpHost(proxyHost.getHostName(),
proxyHost.getPort());
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
proxy);
return server;
}

private DefaultHttpClient extract() throws NoSuchFieldException,
IllegalAccessException {
// The httpclient has to be manipulated in order to be configured
// to use the proxy is private, so we have to rely on reflection.
Field clientField = ProxyServer.class.getDeclaredField(&quot;client&quot;);
setFieldAccessible(clientField);
BrowserMobHttpClient client = (BrowserMobHttpClient) clientField
.get(server);
Field httpClientfield = BrowserMobHttpClient.class
.getDeclaredField(&quot;httpClient&quot;);
setFieldAccessible(httpClientfield);
DefaultHttpClient httpClient = (DefaultHttpClient) httpClientfield
.get(client);
return httpClient;
}

private void setFieldAccessible(Field clientField) {
if (!clientField.isAccessible()) {
clientField.setAccessible(true);
}
}</code></pre><p><p>
Ok, almost there &#8211; just a few lines to start up selenium and use the proxy on localhost:</p><pre class="crayon-plain-tag"><code>ProxyServer server = createAndConfigureProxyServer();
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setProxyPreferences(server.seleniumProxy());
FirefoxDriver driver = new FirefoxDriver(firefoxProfile);</code></pre><p>So, happy testing!</p>
<p>PS: If you have a question or comments feel free to contact me or to post below.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fcarlduevel.net%2Fget-selenium-to-run-with-proxy-authentication%2F&amp;title=Get%20selenium%20to%20work%20with%20proxy%20authentication" id="wpa2a_4"><img src="http://carlduevel.net/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://carlduevel.net/get-selenium-to-run-with-proxy-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

