<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>java-6 &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/java-6/</link>
	<description>Feed of posts on WordPress.com tagged "java-6"</description>
	<pubDate>Thu, 31 Dec 2009 03:00:04 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Sams Teach Yourself JAVA 6 in 21 Days, Fifth Edition]]></title>
<link>http://thebooksworld.wordpress.com/2009/11/29/sams-teach-yourself-java-6-in-21-days-fifth-edition/</link>
<pubDate>Sun, 29 Nov 2009 03:47:48 +0000</pubDate>
<dc:creator>thebooksworld</dc:creator>
<guid>http://thebooksworld.wordpress.com/2009/11/29/sams-teach-yourself-java-6-in-21-days-fifth-edition/</guid>
<description><![CDATA[Sams Teach Yourself JAVA 6 in 21 Days, Fifth Edition By Rogers Cadenhead, Laura Lemay, * Publisher: ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><h2 style="text-align:center;"><span style="color:#000000;"><strong>Sams Teach Yourself JAVA 6 in 21 Days,<br />
Fifth Edition</strong></span></h2>
<p style="text-align:center;"><strong>By Rogers Cadenhead, Laura Lemay,</strong></p>
<p style="text-align:center;"><img class="aligncenter" src="http://img25.imageshack.us/img25/7429/06723294335000772427.gif" alt="" /></p>
<blockquote><p>* Publisher:   Sams<br />
* Number Of Pages:   720<br />
* Publication Date:   2007-05-25<br />
* Sales Rank:   41691<br />
* ISBN / ASIN:   0672329433<br />
* EAN:   9780672329432<br />
* Binding:   Paperback<br />
* Manufacturer:   Sams<br />
* Studio:   Sams<br />
* Average Rating:<br />
* Total Reviews:</p></blockquote>
<p><strong>Book Description:</strong><br />
“If you get only one Java book, it should be Sams Teach Yourself Java in 21 Days” –PC Magazine<br />
In just 21 days, you can acquire the knowledge and skills necessary to develop three kinds of programs with Java:<br />
applications on your computer, servlets on a web server, and browser-launched Java Web Start applications.<br />
No previous programming experience required. By following the 21 carefully organized lessons in this book, anyone can learn the basics of Java programming.<br />
Learn at your own pace. You can work through each chapter sequentially to make sure you thoroughly understand all of the concepts and methodologies, or you can focus on specific lessons to learn the techniques that interest you most.<br />
Test your knowledge. Each chapter ends with a Workshop section filled with questions, answers, and exercises for further study. There are even certification practice questions.<br />
“Sams Teach Yourself Java is one of the best introductions to hands-on Java programming. If you buy one book on Java, this is the one to buy!” –Independent Web Review</p>
<p>* Completely revised, updated, and expanded to cover the latest features of Java 6<br />
* Learn to develop standalone Java applications, web servlets, JavaServer Pages, and Java Web Start applications<br />
* Easy-to-understand, practical examples clearly illustrate the fundamentals of Java programming<br />
* Discover how Swing can help you quickly develop programs with a graphical user interface<br />
* Find out about JDBC database programming, Internet client/server programming, and XML parsing with the open source XOM class library<br />
* Covers new features of version 6 such as Java DB, the new relational database that is now a built-in<br />
* part of Java<br />
Rogers Cadenhead is a web application developer who has written 22 books on Internet-related topics, including Sams Teach Yourself Java 2 in 24 Hours. He maintains this book’s official website at http://www.java21days.com.<br />
Laura Lemay is one of the world’s most popular authors on Web development topics. She is the author of the<br />
bestselling Sams Teach Yourself Web Publishing with HTML, as well as Sams Teach Yourself Perl in 21 Days.</p>
<p>PDF &#124; 5.45 MB &#124; 721 Pages<br />
<a href="http://rapidshare.com/files/313773273/Sams.Teach.Yourself.Java.6.in.21.Days.rar"><strong>Download</strong></a><br />
<strong>More Books here..</strong></p>
<table>
<tbody>
<tr>
<td valign="top">
<a href="http://tinyurl.com/yzmsb2a" target="_blank"><strong><i>Over 350,000 BRAND NEW books are 50% OFF. Save on shipping too!</strong></i></a><br />
<img src="http://www.tqlkg.com/b274elpdjh26A4CAC32435BCB87" border="0" alt="" width="1" height="1" /></td>
<td valign="top"><a href="http://tinyurl.com/y863hxp" target="_blank"><img class="aligncenter" src="http://www.lduhtrp.net/image-3719790-10501751" alt="" width="234" height="60" /></a></td>
</tr>
</tbody>
</table>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Basic Hibernate @OneToOne @PrimaryKeyJoinColumn Example With Maven and MySQL]]></title>
<link>http://devblog.point2.com/2009/11/14/basic-hibernate-onetoone-primarykeyjoincolumn-example-with-maven-and-mysql/</link>
<pubDate>Sat, 14 Nov 2009 15:33:04 +0000</pubDate>
<dc:creator>Damien Gabrielson</dc:creator>
<guid>http://devblog.point2.com/2009/11/14/basic-hibernate-onetoone-primarykeyjoincolumn-example-with-maven-and-mysql/</guid>
<description><![CDATA[Recently we had a story which involved improving one of our data models. The table for the model had]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Recently we had a <a href="http://www.agilemodeling.com/artifacts/userStory.htm">story</a> which involved improving one of our data models. The table for the model had grown quite wide and we wanted to improve normalization and performance. We wanted to move a few columns from our original table (Listing) to a new table with the primary key of the new table (ListingLocation) also being a foreign key to the primary key of the original table, our <a href="http://www.xylax.net/hibernate/onetoone.html">one-to-one relationship</a>. I will try to detail how we accomplished this change using a simplified example. Source code is linked at the bottom of this post.</p>
<p>Here is the entity relationship diagram of the old, single table structure:<br />
<img class="alignnone size-full wp-image-1080" title="ERD-old" src="http://point2blog.wordpress.com/files/2009/11/erd-old.png" alt="Old ER Diagram" width="175" height="98" /><br />
And here is the entity relationship diagram of the new, two table structure:<br />
<img class="alignnone size-full wp-image-1081" title="ERD-new" src="http://point2blog.wordpress.com/files/2009/11/erd-new.png" alt="New ER Diagram" width="377" height="82" /></p>
<p>As you can see, it is a very simple example of a very common relationship in the database. However, what we found when implementing this in <a href="https://www.hibernate.org/">Hibernate</a> was not a simple as I had hoped.</p>
<p>To get started here is the SQL used to represent our new tables:<br />
<code><br />
CREATE TABLE Listing<br />
(<br />
id BIGINT(20) NOT NULL AUTO_INCREMENT,<br />
price DECIMAL(10,2),<br />
PRIMARY KEY (id)<br />
) TYPE = INNODB;</code><br />
<code><br />
CREATE TABLE ListingLocation<br />
(<br />
listingID BIGINT(20) NOT NULL,<br />
address VARCHAR(255),<br />
PRIMARY KEY(listingID),<br />
INDEX (listingID),<br />
FOREIGN KEY (listingID) REFERENCES Listing (id)<br />
) TYPE = INNODB;<br />
</code></p>
<p>I&#8217;ve used MySQL for this example because it is free and easy to setup. InnoDB table types have been because they allow <a href="http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html">foreign keys</a>, which is crucial to this example.</p>
<p>Our old Listing entity was pretty basic; it looked something like this (imports &#38; getters/setters excluded):<br />
<code><br />
@Entity<br />
@Table<br />
public class Listing implements Serializable {<br />
@Id<br />
@GeneratedValue<br />
private long id;<br />
@Column(columnDefinition= "DECIMAL(10,2)")<br />
private double price;<br />
private String address;<br />
...<br />
</code><br />
In this case, creating a new instance of Listing and persisting it is very easy. When we split the entities, it becomes a little more complicated. Here is what our entities looked like after being split:<br />
<code><br />
@Entity<br />
@Table<br />
public class Listing implements Serializable {<br />
@Id<br />
@GeneratedValue<br />
private long id;<br />
@Column(columnDefinition= "DECIMAL(10,2)")<br />
private double price;<br />
@OneToOne<br />
@PrimaryKeyJoinColumn<br />
private ListingLocation listingLocation;<br />
...<br />
</code><br />
and<br />
<code><br />
@Entity<br />
@Table<br />
public class ListingLocation implements Serializable {<br />
@Id<br />
@Column(name = "listingID")<br />
private Long id;<br />
private String address;<br />
...<br />
</code></p>
<p>The differences are not large, but there are a couple important points to note:</p>
<ul>
<li>Adding ListingLocation to Listing with @OneToOne &#38; @PrimaryKeyJoinColumn annotations tells Hibernate the Listing has a one-to-one mapping with ListingLocation by using the Primary Key as the join column.</li>
<li>Adding @Id &#38; @Column(name = &#8220;listingID&#8221;) annotations to our id field in ListingLocation tells Hibernate that id is, well, an ID, but that column should not be called &#8220;id&#8221; in the DB, but &#8220;listingID&#8221; as that will help an observer see the relationship quickly without looking closely at the schema. Also, it is good to note that the @GeneratedValue is not on &#8220;id&#8221; in ListingLocation as it is in Listing as we want to specify exactly what goes in that field.</li>
</ul>
<p>The biggest gripe I have with using the one-to-one relationship is that we can no longer save Listing only. Our REAL Listing entity is far more complex with several relationships, but this was the first one-to-one relationship with Hibernate. Previously we could do something like:<br />
<code><br />
Listing listing = new Listing();<br />
listing.setPrice(price);<br />
listing.setAddress(address);<br />
listing.setFoo(foo); // where foo is a @OneToMany annotated entity<br />
...<br />
<strong>session.save(listing);</strong><br />
</code><br />
Now, we must save Listing and ListingLocation separately like this:<br />
<code><br />
ListingLocation listingLocation = new ListingLocation();<br />
listingLocation.setAddress(address);<br />
Listing listing = new Listing();<br />
listing.setPrice(price);<br />
listing.setListingLocation(listingLocation);<br />
...<br />
<strong>session.save(listing);</strong><br />
if (listing.getListingLocation() != null) {<br />
listing.getListingLocation().setId(listing.getId());<br />
<strong>session.save(listing.getListingLocation()); // save ListingLocation</strong><br />
}<br />
</code></p>
<p>I guess I&#8217;m just a bit spoiled, but I was hoping that this would bit more automatic, as it is with the one-to-many/many-to-one relationships.</p>
<p style="text-align:left;">I have written a small app that uses these two entities and inserts a row into each table, the link is available at the bottom of this post. The config (hibernate.cfg.xml) expects that you have MySQL running on 127.0.0.1 with a DB named &#8216;OneToOneDemo&#8217; with a user named &#8216;root&#8217; and a password of &#8216;password&#8217;; I have included the SQL (Setup-OneToOneDemo.sql) to setup the DB. Just extract the contents of the archive, navigate to the project directory, and from the command line/terminal run:<br />
<code><br />
mvn clean compile exec:java -Dexec.mainClass=com.point2.onetoonedemo.App -e<br />
</code></p>
<p>You should see the following output:<br />
<code><br />
@OneToOne @PrimaryKeyJoinColumn Hibernate Demo<br />
----------------------------------------------<br />
...<br />
Hibernate:<br />
insert into Listing (price) values (?)</code></p>
<p><code>Hibernate:<br />
insert into ListingLocation (address, listingID) values (?, ?)<br />
Saved listing ID: 1<br />
</code></p>
<p><a href="http://sites.google.com/site/gabrielsond/home/OneToOneDemo.zip?attredirects=0&#38;d=1">Download Source Code</a> (12 KB .ZIP)</p>
<p>If you have any questions, comments, or suggestions on how to do better accomplish one-to-one Hibernate mappings, I would love to hear about them. If you have any problems getting the code to compile and/or run, please let me know and I will make the necessary changes. Everything should just work, providing you modify the hibernate config or setup your DB. I had a difficult time finding complete and recent documentation on this subject so I hope this post and the maven project will help.</p>
<p>By: <a href="http://devblog.point2.com/author/dgp2/" target="_blank">Damien Gabrielson</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Java SE 6: Top 10 Features]]></title>
<link>http://interopy.in/2009/11/10/java-se-6-top-10-features/</link>
<pubDate>Tue, 10 Nov 2009 11:09:31 +0000</pubDate>
<dc:creator>Ranjan Kumar</dc:creator>
<guid>http://interopy.in/2009/11/10/java-se-6-top-10-features/</guid>
<description><![CDATA[A very good summary of top 10 features of Java SE 6 by Sang Shin &#8211; Sun Microsystems Inc. : Jav]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>A very good summary of top 10 features of Java SE 6 by Sang Shin &#8211; Sun Microsystems Inc. : <a href="http://www.box.net/shared/5f1iz2p8t5" target="_blank">Java SE 6: Top 10 Features</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Java 6 Platform Revealed]]></title>
<link>http://esal.wordpress.com/2009/10/14/java-6-platform-revealed/</link>
<pubDate>Wed, 14 Oct 2009 14:03:10 +0000</pubDate>
<dc:creator>esal</dc:creator>
<guid>http://esal.wordpress.com/2009/10/14/java-6-platform-revealed/</guid>
<description><![CDATA[Java 6 Platform Revealed by John Zukowski]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:center;"><strong>Java 6 Platform Revealed</strong></p>
<p style="text-align:center;">by John Zukowski</p>
<p><img class="aligncenter size-full wp-image-1018" title="Apress.Java.6.Platform.Revealed.Jul.2006.1000th.Release" src="http://esal.wordpress.com/files/2009/10/apress-java-6-platform-revealed-jul-2006-1000th-release.jpg" alt="Apress.Java.6.Platform.Revealed.Jul.2006.1000th.Release" width="272" height="358" /></p>
<p style="text-align:center;"><span style="color:#0000ff;"><a href="http://www.ziddu.com/download/6743475/s.Java.6.Platform.Revealed.Jul.2006.1000th.Release.pdf.html"><img src="http://bse.depdiknas.go.id/images_gif/download.gif" border="0" alt="" width="91" height="31" /></a></span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Book Recommendation]]></title>
<link>http://caytin.wordpress.com/2009/09/22/book-recommendation/</link>
<pubDate>Tue, 22 Sep 2009 19:13:42 +0000</pubDate>
<dc:creator>caytin</dc:creator>
<guid>http://caytin.wordpress.com/2009/09/22/book-recommendation/</guid>
<description><![CDATA[I am currently having to learn Java 6 to create a website for a job. After browsing through all of H]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I am currently having to learn Java 6 to create a website for a job.  After browsing through all of Hastings, Barnes and Noble&#8217;s, and Safari&#8217;s shelves I settled on &#8220;Sams Teach Yourself Java 6 in 21 Days&#8221;.  This was the only book I found with a full chapter dedicated to communication between websites.  So far I have completed up to Day 3, and have learned more about programming than three semesters of C++ in college.  I recommend this to anyone that wants to learn a programming language.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Functional HTTP testing revisited using JUnit 4.7 Interceptors]]></title>
<link>http://alistairisrael.wordpress.com/2009/09/03/functional-http-testing-revisited-using-junit-interceptors/</link>
<pubDate>Thu, 03 Sep 2009 03:07:13 +0000</pubDate>
<dc:creator>Alistair</dc:creator>
<guid>http://alistairisrael.wordpress.com/2009/09/03/functional-http-testing-revisited-using-junit-interceptors/</guid>
<description><![CDATA[(I originally planned this to be a single article, but because of the scope decided to split it into]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>(I originally planned this to be a single article, but because of the scope decided to split it into two parts. Read the <a href="http://alistairisrael.wordpress.com/2009/09/02/functional-testing-with-sun-java-6-httpserver/">first part</a> for the the basics of using Sun&#8217;s <code>HttpServer</code> to conduct functional HTTP testing. Here we revisit our functional test and rewrite it using JUnit 4.7&#8217;s new Interceptors feature.)</p>
<h3>Recap</h3>
<p>In my <a href="http://alistairisrael.wordpress.com/2009/09/02/functional-testing-with-sun-java-6-httpserver/">previous post</a>, I demonstrated how to use Sun&#8217;s <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html">HttpServer</a></code> API to write a functional test of an HTTP &#8216;conversation&#8217;.</p>
<p>Recall that I thought my initial solution seemed inelegant. It was verbose, with some start up and shutdown code that would have to be repeated for each test, and which I felt cluttered the actual test code.</p>
<p>It was also tedious, in the sense that the raw <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpHandler.html">HttpHandler</a></code> and <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpExchange.html">HttpExchange</a></code> API required us to do quite a few things manually, and unintuitively (such as having to compute and write out the length of our response <i>before</i> the response itself).</p>
<p>In this post, we&#8217;ll explore how to use the new Interceptors feature &#8216;quietly&#8217; released with JUnit 4.7 to write reusable, portable pre and post-test behaviour. I&#8217;ll also exhibit a convenient <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpHandler.html">HttpHandler</a></code> implementation that simplifies some of the effort required in responding to HTTP requests.</p>
<p><!--more--></p>
<h3>JUnit Interceptors at a glance</h3>
<p>Developers familiar to JUnit will know that prior to JUnit 4.x, to perform pre/post test behaviour such as setting up and tearing down test scaffolding or external resources, we had no choice but to override <code><a href="http://junit.org/apidocs/junit/framework/TestCase.html#setUp%28%29">TestCase#setup()</a></code> and <code><a href="http://junit.org/apidocs/junit/framework/TestCase.html#tearDown%28%29">TestCase#tearDown()</a></code>. To make this reusable across test classes, we had to extend <code><a href="http://junit.org/apidocs/junit/framework/TestCase.html">TestCase</a></code> and our actual tests had to extend that custom class.</p>
<p>JUnit 4.x introduced annotation-driven testing using the <code><a href="http://junit.org/apidocs/org/junit/Test.html">@Test</a></code> annotation, which allowed us to write tests that were simple POJOs. However, this didn&#8217;t help when we wanted reusable pre/post test behavior. We still had to write our custom base class, this time with methods annotated with <code><a href="http://junit.org/apidocs/org/junit/Before.html">@Before</a></code> and <code><a href="http://junit.org/apidocs/org/junit/After.html">@After</a></code>.</p>
<p>JUnit 4.7 introduces a new feature called &#8220;Interceptors&#8221; that aims to bring back to JUnit the ability to to &#8216;meta-testing&#8217; with a much cleaner and simpler API. See Kent Beck&#8217;s<sup><a href="#f1">1</a></sup> and David Saff&#8217;s<sup><a href="#f2">2</a></sup> blog posts for more of the inside scoop.</p>
<h3>Writing an Interceptor</h3>
<p>A good place to start is to look at the source for <code><a href="http://github.com/KentBeck/junit/blob/a8629da96207e1ce71ead9ba9f85bc324f09bcab/src/main/java/org/junit/rules/ExternalResource.java">ExternalResource</a></code>.</p>
<p>If we need complete control over our interceptor&#8217;s behavior, we&#8217;d need to implement <code><a href="http://github.com/KentBeck/junit/blob/a8629da96207e1ce71ead9ba9f85bc324f09bcab/src/main/java/org/junit/rules/MethodRule.java">MethodRule</a></code> from scratch.</p>
<p>In our case, we can get by simply by extending <code>ExternalResource</code>. We setup our HTTP server in the <code>before()</code> method, and tear it down in our <code>after()</code> method. We also provide a way to specify the port to listen on in our constructor:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;"><span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000000;font-weight:bold;">class</span> HttpServerInterceptor <span style="color:#000000;font-weight:bold;">extends</span> ExternalResource <span style="color:#009900;">&#123;</span></p>
<p>&#160; &#160; <span style="color:#000000;font-weight:bold;">private</span> <span style="color:#000000;font-weight:bold;">final</span> InetSocketAddress address<span style="color:#339933;">;</span></p>
<p>&#160; &#160; <span style="color:#000000;font-weight:bold;">private</span> HttpServer httpServer<span style="color:#339933;">;</span></p>
<p>&#160; &#160; <span style="color:#000000;font-weight:bold;">public</span> HttpServerInterceptor<span style="color:#009900;">&#40;</span><span style="color:#000000;font-weight:bold;">final</span> <span style="color:#000066;font-weight:bold;">int</span> port<span style="color:#009900;">&#41;</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; <span style="color:#000000;font-weight:bold;">this</span>.<span style="color:#006633;">address</span> <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> InetSocketAddress<span style="color:#009900;">&#40;</span>port<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span></p>
<p>&#160; &#160; <span style="color:#000000;font-weight:bold;">protected</span> <span style="color:#000000;font-weight:bold;">final</span> <span style="color:#000066;font-weight:bold;">void</span> before<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#000000;font-weight:bold;">throws</span> <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Athrowable+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">Throwable</span></a> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; <span style="color:#000000;font-weight:bold;">super</span>.<span style="color:#006633;">before</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; httpServer <span style="color:#339933;">=</span> HttpServer.<span style="color:#006633;">create</span><span style="color:#009900;">&#40;</span>address, 0<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; httpServer.<span style="color:#006633;">start</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span></p>
<p>&#160; &#160; <span style="color:#000000;font-weight:bold;">protected</span> <span style="color:#000000;font-weight:bold;">final</span> <span style="color:#000066;font-weight:bold;">void</span> after<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; httpServer.<span style="color:#006633;">stop</span><span style="color:#009900;">&#40;</span>0<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; <span style="color:#000000;font-weight:bold;">super</span>.<span style="color:#006633;">after</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span></div>
<p>Next, we provide a delegate method to register handlers:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; <span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000066;font-weight:bold;">void</span> addHandler<span style="color:#009900;">&#40;</span><a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Astring+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">String</span></a> path, HttpHandler handler<span style="color:#009900;">&#41;</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; httpServer.<span style="color:#006633;">createContext</span><span style="color:#009900;">&#40;</span>path, handler<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span></div>
<h3>Using Interceptors</h3>
<p>To use our new JUnit interceptor, all we need to do is annotate a public field with the <code>org.junit.Rule</code> annotation. Note that the field has to be <i>public</i>&#8212;this might raise a warning if you use Checkstyle and personally, I wish JUnit would allow private <code>@Rule</code>s.</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">@Rule<br />
<span style="color:#000000;font-weight:bold;">public</span> HttpServerInterceptor httpServer <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> HttpServerInterceptor<span style="color:#009900;">&#40;</span>8000<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span>
</div>
<p>The JUnit runner does the rest. It&#8217;ll transparently call our interceptor&#8217;s <code>before()</code> method, run the <code>@Test</code> then call our interceptor&#8217;s <code>after()</code> method.</p>
<p>Armed with this, we can rewrite the rest of our HTTP functional test as:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">
@Test<br />
<span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000066;font-weight:bold;">void</span> testHttpServer<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#000000;font-weight:bold;">throws</span> <span style="color:#003399;">Exception</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; httpServer.<span style="color:#006633;">addHandler</span><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;/1234.xml&#34;</span>, <span style="color:#000000;font-weight:bold;">new</span> HttpHandler<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#009900;">&#123;</span></p>
<p>&#160; &#160; &#160; &#160; <span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000066;font-weight:bold;">void</span> handle<span style="color:#009900;">&#40;</span>HttpExchange exchange<span style="color:#009900;">&#41;</span> <span style="color:#000000;font-weight:bold;">throws</span> <span style="color:#003399;">IOException</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <span style="color:#000066;font-weight:bold;">byte</span><span style="color:#009900;">&#91;</span><span style="color:#009900;">&#93;</span> response <span style="color:#339933;">=</span> <span style="color:#0000ff;">&#34;&#60;?xml version=<span style="color:#000099;font-weight:bold;">\&#34;</span>1.0<span style="color:#000099;font-weight:bold;">\&#34;</span>?&#62;<span style="color:#000099;font-weight:bold;">\n</span>&#60;resource id=<span style="color:#000099;font-weight:bold;">\&#34;</span>1234<span style="color:#000099;font-weight:bold;">\&#34;</span> name=<span style="color:#000099;font-weight:bold;">\&#34;</span>test<span style="color:#000099;font-weight:bold;">\&#34;</span> /&#62;<span style="color:#000099;font-weight:bold;">\n</span>&#34;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; .<span style="color:#006633;">getBytes</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">sendResponseHeaders</span><span style="color:#009900;">&#40;</span><span style="color:#003399;">HttpURLConnection</span>.<span style="color:#006633;">HTTP_OK</span>, response.<span style="color:#006633;">length</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">getResponseBody</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span>.<span style="color:#006633;">write</span><span style="color:#009900;">&#40;</span>response<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">close</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; <span style="color:#009900;">&#125;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></p>
<p>&#160; &#160; <span style="color:#666666;font-style:italic;">// exercise our client code</span><br />
&#160; &#160; <span style="color:#003399;">URL</span> url <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> <span style="color:#003399;">URL</span><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;http://localhost:8000/1234.xml&#34;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <span style="color:#003399;">URLConnection</span> conn <span style="color:#339933;">=</span> url.<span style="color:#006633;">openConnection</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <span style="color:#003399;">BufferedReader</span> in <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> <span style="color:#003399;">BufferedReader</span><span style="color:#009900;">&#40;</span><span style="color:#000000;font-weight:bold;">new</span> <span style="color:#003399;">InputStreamReader</span><span style="color:#009900;">&#40;</span>conn.<span style="color:#006633;">getInputStream</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; assertEquals<span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;?xml version=<span style="color:#000099;font-weight:bold;">\&#34;</span>1.0<span style="color:#000099;font-weight:bold;">\&#34;</span>?&#62;&#34;</span>, in.<span style="color:#006633;">readLine</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; assertEquals<span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;resource id=<span style="color:#000099;font-weight:bold;">\&#34;</span>1234<span style="color:#000099;font-weight:bold;">\&#34;</span> name=<span style="color:#000099;font-weight:bold;">\&#34;</span>test<span style="color:#000099;font-weight:bold;">\&#34;</span> /&#62;&#34;</span>, in.<span style="color:#006633;">readLine</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
<span style="color:#009900;">&#125;</span></div>
<p></p>
<h3>Simplifying our Handlers</h3>
<p>We&#8217;ve managed to cut out some of our test scaffolding code. Now let&#8217;s simplify our actual handler. For this, I wrote <code><a href="http://github.com/AlistairIsrael/junit-rules/blob/e9377a9d19eb2fc1d6dad35404555407baacb947/src/main/java/junit/interceptors/httpserver/SimpleHttpHandler.java">SimpleHttpHandler</a></code>, which is an <code>HttpHandler</code> which provides delegate methods to the actual <code>HttpExchange</code>. That is, by extending <code>SimpleHttpHandler</code> we can simply go <code>getRequestURI()</code> instead of having to go <code>httpExchange.getRequestURI()</code>.</p>
<p>Additionally, <code><a href="http://github.com/AlistairIsrael/junit-rules/blob/e9377a9d19eb2fc1d6dad35404555407baacb947/src/main/java/junit/interceptors/httpserver/SimpleHttpHandler.java">SimpleHttpHandler</a></code> uses an internal <code>ByteArrayOutputStream</code>, exposed via a <code>PrintWriter</code> in the <code>getResponse()</code> method. This lets us simply write our response as if, say, to <code>System.out</code>, and it takes care of computing the total response length later on when we call the <code>sendResponse()</code> method.</p>
<p>Here&#8217;s the same handler above rewritten using <code>SimpleHttpHandler</code>:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; httpServer.<span style="color:#006633;">addHandler</span><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;/&#34;</span>, <span style="color:#000000;font-weight:bold;">new</span> SimpleHttpHandler<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#009900;">&#123;</span></p>
<p>&#160; &#160; &#160; &#160; <span style="color:#000000;font-weight:bold;">protected</span> <span style="color:#000066;font-weight:bold;">void</span> onGet<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#000000;font-weight:bold;">throws</span> <span style="color:#003399;">IOException</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; getResponse<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span>.<span style="color:#006633;">println</span><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;?xml version=<span style="color:#000099;font-weight:bold;">\&#34;</span>1.0<span style="color:#000099;font-weight:bold;">\&#34;</span>?&#62;&#34;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; getResponse<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span>.<span style="color:#006633;">println</span><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;resource id=<span style="color:#000099;font-weight:bold;">\&#34;</span>1234<span style="color:#000099;font-weight:bold;">\&#34;</span> name=<span style="color:#000099;font-weight:bold;">\&#34;</span>test<span style="color:#000099;font-weight:bold;">\&#34;</span> /&#62;&#34;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; sendResponse<span style="color:#009900;">&#40;</span>HTTP_OK<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; <span style="color:#009900;">&#125;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></div>
<p>The complete source to <code>HttpServerInterceptor</code> and <code>SimpleHttpHandler</code> are provided as part of <code><a href="http://wiki.github.com/AlistairIsrael/junit-rules">junit-rules</a></code>, a &#8216;pet&#8217; project I&#8217;ve made to explore and showcase JUnit Rules.</p>
<p>Hopefully, I&#8217;ll be able to add other, useful rules to <code><a href="http://wiki.github.com/AlistairIsrael/junit-rules">junit-rules</a></code>. Feel free to download, study and use it. Better yet, if you want to share any useful rules of your own, by all means, please fork or contribute to it!</p>
<p>(Edit 2009/10/16: Changed links/references to <code>junit-interceptors</code> to <code>junit-rules</code>, all because I misread Kent Beck&#8217;s post—they were renaming it <em>to</em> Rules <em>from</em> Interceptors, and not the other way around!)</p>
<h3>References</h3>
<p><sup><a name="f1">1</a></sup> <a href="http://www.threeriversinstitute.org/blog/?p=155">Interceptors in JUnit</a><br />
<sup><a name="f2">2</a></sup> <a href="http://greenbar.saff.net/?p=17">JUnit 4.7: Interceptors: expected exceptions</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using Sun Java 6 HttpServer to write a functional HTTP test]]></title>
<link>http://alistairisrael.wordpress.com/2009/09/02/functional-http-testing-with-sun-java-6-httpserver/</link>
<pubDate>Wed, 02 Sep 2009 15:23:33 +0000</pubDate>
<dc:creator>Alistair</dc:creator>
<guid>http://alistairisrael.wordpress.com/2009/09/02/functional-http-testing-with-sun-java-6-httpserver/</guid>
<description><![CDATA[(I originally planned this to be a single article, but because of the scope decided to split it into]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>(I originally planned this to be a single article, but because of the scope decided to split it into two parts. This first part explores the basics of using Sun&#8217;s <code>HttpServer</code> to conduct functional HTTP testing. <a href="http://alistairisrael.wordpress.com/2009/09/03/functional-http-testing-revisited-using-junit-interceptors/">Part 2</a> revisits the following test using JUnit 4.7&#8217;s new interceptors (rules) feature and demonstrates a simpler HTTP handler.)</p>
<h3>Forces</h3>
<p>At work, we recently had the need to perform functional testing of a custom client that used HTTP as a transport. This isn&#8217;t strictly unit testing since we&#8217;re conducting actual HTTP over a socket &#38; port instead of stubbing out or mocking the server, but in this case that was the only real way to test the client.</p>
<p>I could&#8217;ve fired up a standalone Web server and used that, but decided against it for a couple of reasons.</p>
<p>First, I wanted to have the server respond in a specific way to a particular client request. For example, if the request was for <code>GET /1234.xml</code> I might want to respond with an <code>HTTP 200</code> and an XML response body. Another request for <code>GET /0.xml</code> might return an <code>HTTP 404</code> instead.</p>
<p>To do that using, say, a Servlet container would mean writing multiple Servlets (mapped to various request URI) or a &#8216;rich&#8217; Servlet with additional complexity. I didn&#8217;t want to have to write tests to test my test scaffolding!</p>
<p>Secondly, a standalone server would have to be started and stopped outside of our standard compile/test/package process (using <a href="http://maven.apache.org/">Maven</a>). Other people wouldn&#8217;t be able to run the tests successfully without having the test server up as well.</p>
<p>Clearly, the best way to go was to use an embedded HTTP server, which would allow us to provide specific responses tailored for each unit test.</p>
<p>As luck would have it, it turns out that Sun&#8217;s Java 6 implementation comes with a lightweight HTTP server API built in. Read on as I demonstrate the basic use of Sun&#8217;s HTTP server classes to write a functional test.</p>
<p><!--more--></p>
<h3>HTTP server in a box</h3>
<p>The heart of our test solution involves taking advantage of the lightweight HTTP server API included in Sun&#8217;s Java 6 implementation. Note that since this isn&#8217;t part of the Java core API this package may not be available on all Java platforms. If this is a problem, you might be better off using another embedded HTTP server such as <a href="http://www.mortbay.org/jetty/">Jetty</a>.</p>
<p>The class itself is <a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html">com.sun.net.httpserver.HttpServer</a>, and here&#8217;s how to use it in a nutshell:</p>
<ol>
<li>Create the server</li>
<li>Create a server context and register a request handler</li>
<li>Start the server</li>
<li>Perform your test</li>
<li>Stop the server, and verify/assert your expected behavior</li>
</ol>
<p>Now let&#8217;s look at each step in detail with corresponding code.</p>
<h4>Create the server</h4>
<p>We create an <code>HttpServer</code> using <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html#create%28%29">HttpServer.create()</a></code>. To specify a port, we need to pass in an <code><a href="http://java.sun.com/javase/6/docs/api/java/net/InetSocketAddress.html">InetSocketAddress</a></code>:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; InetSocketAddress address <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> InetSocketAddress<span style="color:#009900;">&#40;</span>8000<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; HttpServer httpServer <span style="color:#339933;">=</span> HttpServer.<span style="color:#006633;">create</span><span style="color:#009900;">&#40;</span>address, 0<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></div>
<p>The second parameter to <code>HttpServer.create()</code> is the &#8216;backlog&#8217;, &#8220;the maximum number of queued incoming connections to allow on the listening socket&#8221;. Since that doesn&#8217;t really affect us, we can just pass in a <code>0</code> and a system default value is used.</p>
<h3>Creating and registering a request handler</h3>
<p>Now we get to the meat of actually stubbing our server&#8217;s behavior by creating and registering a request handler. <code>HttpServer</code> provides the <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html#createContext%28java.lang.String,%20com.sun.net.httpserver.HttpHandler%29">createContext(String path, HttpHandler handler)</a></code> method to do just that.</p>
<p>Now, <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpHandler.html">HttpHandler</a></code> is an interface which declares one method: <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpHandler.html#handle%28com.sun.net.httpserver.HttpExchange%29">handle(HttpExchange)</a></code></p>
<p>Obviously, <code><a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpExchange.html">HttpExchange</a></code> is the class we need to work with when responding to HTTP requests. Let&#8217;s look at some code and I&#8217;ll explain what it does afterwards:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; HttpHandler handler <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> HttpHandler<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#009900;">&#123;</span></p>
<p>&#160; &#160; &#160; &#160; <span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000066;font-weight:bold;">void</span> handle<span style="color:#009900;">&#40;</span>HttpExchange exchange<span style="color:#009900;">&#41;</span> <span style="color:#000000;font-weight:bold;">throws</span> <span style="color:#003399;">IOException</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <span style="color:#000066;font-weight:bold;">byte</span><span style="color:#009900;">&#91;</span><span style="color:#009900;">&#93;</span> response <span style="color:#339933;">=</span> <span style="color:#0000ff;">&#34;&#60;?xml version=<span style="color:#000099;font-weight:bold;">\&#34;</span>1.0<span style="color:#000099;font-weight:bold;">\&#34;</span>?&#62;<span style="color:#000099;font-weight:bold;">\n</span>&#60;resource id=<span style="color:#000099;font-weight:bold;">\&#34;</span>1234<span style="color:#000099;font-weight:bold;">\&#34;</span> name=<span style="color:#000099;font-weight:bold;">\&#34;</span>test<span style="color:#000099;font-weight:bold;">\&#34;</span> /&#62;<span style="color:#000099;font-weight:bold;">\n</span>&#34;</span>.<span style="color:#006633;">getBytes</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">sendResponseHeaders</span><span style="color:#009900;">&#40;</span><a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Ahttpurlconnection+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">HttpURLConnection</span></a>.<span style="color:#006633;">HTTP_OK</span>, <br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; response.<span style="color:#006633;">length</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">getResponseBody</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span>.<span style="color:#006633;">write</span><span style="color:#009900;">&#40;</span>response<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">close</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; <span style="color:#009900;">&#125;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span><span style="color:#339933;">;</span></div>
<p>Basically: we convert our response string into a byte array. We send an <code>HTTP 200</code> (OK) along with the number of bytes we&#8217;re about to send as the response body. We then write out the bytes of our response body, then close the <code>HttpExchange</code>. The complete <code>HttpExchange</code> life cycle is detailed in its <a href="http://java.sun.com/javase/6/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpExchange.html">API documentation</a>.</p>
<p>We now create a context for the URI we&#8217;re interested in, passing in our newly created <code>HttpHandler</code>, then start the server:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; httpServer.<span style="color:#006633;">createContext</span><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;/1234.xml&#34;</span>, handler<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; httpServer.<span style="color:#006633;">start</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></div>
<p>At this point, an actual HTTP server will start running in a background thread ready to respond to requests. Let&#8217;s exercise our client code:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Aurl+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">URL</span></a> url <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Aurl+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">URL</span></a><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;http://localhost:8000/1234.xml&#34;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Aurlconnection+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">URLConnection</span></a> conn <span style="color:#339933;">=</span> url.<span style="color:#006633;">openConnection</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Abufferedreader+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">BufferedReader</span></a> in <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Abufferedreader+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">BufferedReader</span></a><span style="color:#009900;">&#40;</span><span style="color:#000000;font-weight:bold;">new</span> <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Ainputstreamreader+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">InputStreamReader</span></a><span style="color:#009900;">&#40;</span>conn.<span style="color:#006633;">getInputStream</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; assertEquals<span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;?xml version=<span style="color:#000099;font-weight:bold;">\&#34;</span>1.0<span style="color:#000099;font-weight:bold;">\&#34;</span>?&#62;&#34;</span>, in.<span style="color:#006633;">readLine</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; assertEquals<span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;resource id=<span style="color:#000099;font-weight:bold;">\&#34;</span>1234<span style="color:#000099;font-weight:bold;">\&#34;</span> name=<span style="color:#000099;font-weight:bold;">\&#34;</span>test<span style="color:#000099;font-weight:bold;">\&#34;</span> /&#62;&#34;</span>, in.<span style="color:#006633;">readLine</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></div>
<p>Our client code connects to our server, retrieves the associated URI, then, using a <code>BufferedReader</code> reads in lines from the input stream. We make a few JUnit assertions on what we received.</p>
<p>The only thing left to do is to stop our <code>HttpServer</code>:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; &#160;httpServer.<span style="color:#006633;">stop</span><span style="color:#009900;">&#40;</span>0<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></div>
<p>The parameter is the number of <i>seconds</i> (NOTE: not milliseconds) to block to wait for our <code>HttpServer</code> to shutdown properly. Since we know we&#8217;re not serving any other requests, we can safely tell our <code>HttpServer</code> to shut down immediately.</p>
<h3>At a glance</h3>
<p>Here&#8217;s our functional test at a glance:</p>
<div class="java" style="font-family:monospace;color:#006;border:1px solid #d0d0d0;background-color:#f0f0f0;">&#160; &#160; <span style="color:#666666;font-style:italic;">// create the HttpServer</span><br />
&#160; &#160; InetSocketAddress address <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> InetSocketAddress<span style="color:#009900;">&#40;</span>8000<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; HttpServer httpServer <span style="color:#339933;">=</span> HttpServer.<span style="color:#006633;">create</span><span style="color:#009900;">&#40;</span>address, 0<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></p>
<p>&#160; &#160; <span style="color:#666666;font-style:italic;">// create and register our handler</span><br />
&#160; &#160; HttpHandler handler <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> HttpHandler<span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span> <span style="color:#009900;">&#123;</span></p>
<p>&#160; &#160; &#160; &#160; <span style="color:#000000;font-weight:bold;">public</span> <span style="color:#000066;font-weight:bold;">void</span> handle<span style="color:#009900;">&#40;</span>HttpExchange exchange<span style="color:#009900;">&#41;</span> <span style="color:#000000;font-weight:bold;">throws</span> <span style="color:#003399;">IOException</span> <span style="color:#009900;">&#123;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; <span style="color:#000066;font-weight:bold;">byte</span><span style="color:#009900;">&#91;</span><span style="color:#009900;">&#93;</span> response <span style="color:#339933;">=</span> <span style="color:#0000ff;">&#34;&#60;?xml version=<span style="color:#000099;font-weight:bold;">\&#34;</span>1.0<span style="color:#000099;font-weight:bold;">\&#34;</span>?&#62;<span style="color:#000099;font-weight:bold;">\n</span>&#60;resource id=<span style="color:#000099;font-weight:bold;">\&#34;</span>1234<span style="color:#000099;font-weight:bold;">\&#34;</span> name=<span style="color:#000099;font-weight:bold;">\&#34;</span>test<span style="color:#000099;font-weight:bold;">\&#34;</span> /&#62;<span style="color:#000099;font-weight:bold;">\n</span>&#34;</span>.<span style="color:#006633;">getBytes</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">sendResponseHeaders</span><span style="color:#009900;">&#40;</span><a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Ahttpurlconnection+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">HttpURLConnection</span></a>.<span style="color:#006633;">HTTP_OK</span>,<br />
&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; response.<span style="color:#006633;">length</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">getResponseBody</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span>.<span style="color:#006633;">write</span><span style="color:#009900;">&#40;</span>response<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; &#160; &#160; exchange.<span style="color:#006633;">close</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; &#160; &#160; <span style="color:#009900;">&#125;</span><br />
&#160; &#160; <span style="color:#009900;">&#125;</span><span style="color:#339933;">;</span><br />
&#160; &#160; httpServer.<span style="color:#006633;">createContext</span><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;/1234.xml&#34;</span>, handler<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></p>
<p>&#160; &#160; <span style="color:#666666;font-style:italic;">// start the server</span><br />
&#160; &#160; httpServer.<span style="color:#006633;">start</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></p>
<p>&#160; &#160; <span style="color:#666666;font-style:italic;">// verify our client code</span><br />
&#160; &#160; <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Aurl+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">URL</span></a> url <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Aurl+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">URL</span></a><span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;http://localhost:8000/1234.xml&#34;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Aurlconnection+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">URLConnection</span></a> conn <span style="color:#339933;">=</span> url.<span style="color:#006633;">openConnection</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Abufferedreader+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">BufferedReader</span></a> in <span style="color:#339933;">=</span> <span style="color:#000000;font-weight:bold;">new</span> <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Abufferedreader+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">BufferedReader</span></a><span style="color:#009900;">&#40;</span><span style="color:#000000;font-weight:bold;">new</span> <a style="color:#000060;" href="http://www.google.com/search?hl=en&#38;q=allinurl%3Ainputstreamreader+java.sun.com&#38;btnI=I%27m%20Feeling%20Lucky"><span style="color:#003399;">InputStreamReader</span></a><span style="color:#009900;">&#40;</span>conn.<span style="color:#006633;">getInputStream</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; assertEquals<span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;?xml version=<span style="color:#000099;font-weight:bold;">\&#34;</span>1.0<span style="color:#000099;font-weight:bold;">\&#34;</span>?&#62;&#34;</span>, in.<span style="color:#006633;">readLine</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span><br />
&#160; &#160; assertEquals<span style="color:#009900;">&#40;</span><span style="color:#0000ff;">&#34;&#60;resource id=<span style="color:#000099;font-weight:bold;">\&#34;</span>1234<span style="color:#000099;font-weight:bold;">\&#34;</span> name=<span style="color:#000099;font-weight:bold;">\&#34;</span>test<span style="color:#000099;font-weight:bold;">\&#34;</span> /&#62;&#34;</span>, in.<span style="color:#006633;">readLine</span><span style="color:#009900;">&#40;</span><span style="color:#009900;">&#41;</span><span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></p>
<p>&#160; &#160; <span style="color:#666666;font-style:italic;">// stop the server</span><br />
&#160; &#160; httpServer.<span style="color:#006633;">stop</span><span style="color:#009900;">&#40;</span>0<span style="color:#009900;">&#41;</span><span style="color:#339933;">;</span></div>
<p>While functional, I find the above code rather verbose. If I want to write more HTTP tests, I certainly don&#8217;t want to keep repeating myself going <code>httpServer.start();</code> &#8230; <code>httpServer.stop(0);</code>. I especially find it tedious to have to compute the length of the HTTP response body beforehand, then send it along with our HTTP response code <i>before</i> writing out the actual body.</p>
<p>In the <a href="http://alistairisrael.wordpress.com/2009/09/03/functional-http-testing-revisited-using-junit-interceptors/">next part</a> of this article, we look at using some shiny new features in JUnit 4.7 that lets us write cleaner, more reusable tests that involve pre and post test behavior. Also, I&#8217;ll exhibit a helper class that simplifies some of the effort involved in implementing an <code>HttpHandler</code>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Snow Leopard and Java compatibility issues]]></title>
<link>http://codingnaked.wordpress.com/2009/08/30/snow-leopard-and-java-issues/</link>
<pubDate>Sun, 30 Aug 2009 08:16:51 +0000</pubDate>
<dc:creator>Wei-ju Wu</dc:creator>
<guid>http://codingnaked.wordpress.com/2009/08/30/snow-leopard-and-java-issues/</guid>
<description><![CDATA[Contrary to my regular habits, I bought the latest update to Mac OS X, &#8220;Snow Leopard&#8221; on]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Contrary to my regular habits, I bought the latest update to Mac OS X, &#8220;Snow Leopard&#8221; on the first day of release. Our local Apple store opened early (I think around 8-ish) on the 28th and I picked up my copy as soon as I saw the doors opened.</p>
<p>The truth is, since the days of the Amiga, I have not been as excited for an operating system release. My confidence in the quality that comes out Apple is also almost limitless, so I just popped the DVD into my computer and waited about an hour for the install to finish, hoping that there would be 7 GB magically reclaimed from my hard disk. I was wrong &#8211; it turned out to be a whopping 14 GB, which I thought was pretty impressive.</p>
<p>The next thing was for me to look for apparent problems, but apart from my &#8220;A Lot of Water&#8221; screen saver stopping to work (some changes to OpenGL in Snow Leopard might have caused this *sniff*), I did not notice any problems, just the &#8220;it just works&#8221; that I am used to from Apple. Well &#8211; until I started to do some development in Java. The Snow Leopard installation seems to remove  an installation of Java SE 5 and instead link the Java SE 6 version to it.</p>
<p>So what&#8217;s the problem, Java SE 6 is compatible to Java SE 5, some would say. Yes, almost. Unfortunately there are some incompatible changes in JDBC (in my case, the Connection interface) that requires me to work on a Java SE 5.</p>
<p>Luckily <a href="http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard">someone</a> had the same problem and has published a solution for that problem: The bottom line is to download a Leopard version of Java 5 and redirect the symbolic links to that downloaded version.</p>
<p>After following the instructions, I could continue working on my Java project as before.</p>
<p><strong>Update:</strong> I had another issue with maven even though I had already changed the version in Java Preferences. This could be fixed by adding a line</p>
<p>JAVA_VERSION=1.5</p>
<p>to the  ~/.mavenrc file.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Java: Too many open files]]></title>
<link>http://joehalliwell.wordpress.com/2009/07/10/java-too-many-open-files/</link>
<pubDate>Fri, 10 Jul 2009 15:13:59 +0000</pubDate>
<dc:creator>joehalliwell</dc:creator>
<guid>http://joehalliwell.wordpress.com/2009/07/10/java-too-many-open-files/</guid>
<description><![CDATA[Looks like the Ubuntu (jaunty amd64) build of Java 6 (1.6.0_13) has a problem closing files. Upgradi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Looks like the Ubuntu (jaunty amd64) build of Java 6 (1.6.0_13) has a problem closing files. Upgrading to 1.6.0_14 from karmic backports Works For Me.</p>
<p>Seems like it would be a big obvious bug, but I couldn&#8217;t find any reports. Have you run across it?</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Java-kehittäjillä kiintoisa vuosi]]></title>
<link>http://tieturi.wordpress.com/2009/05/08/java-kehittajilla-kiintoisa-vuosi/</link>
<pubDate>Fri, 08 May 2009 09:43:48 +0000</pubDate>
<dc:creator>Producer</dc:creator>
<guid>http://tieturi.wordpress.com/2009/05/08/java-kehittajilla-kiintoisa-vuosi/</guid>
<description><![CDATA[Java-kehittäjälle vuosi 2009 on kiintoisaa aikaa. Viime vuoden puolella esitellyt uudistukset kuten ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Java-kehittäjälle vuosi 2009 on kiintoisaa aikaa. </strong></p>
<p>Viime vuoden puolella esitellyt uudistukset kuten Java 6 update 10 ja JavaFX pistävät uusiksi Java-sovellusten asennusta ja käytettävyyttä. Teemana on entistä kevyempää, helpompaa ja näyttävämpää. Selaimesta ruudulle ladattavat appletit, widgetit ja JavaFX sovelmat tuovat rikkautta käyttöliittymiin ja Web Start teknologian avulla Java-sovellukset saadaan helposti levitettyä työasemiin.<br />
Tänä vuonna JavaFX-teknologia siirtyy myös mobiili- ja digitv-alustalle.<br />
Ajan myötä näemme kumpi vetää enemmän, Google Android vai tuleva MIDP 3 + JavaFX -yhdistelmä. Molempia koodataan kuitenkin Java-kielellä.</p>
<p>Palvelinpuolella Java EE 5 -alusta auttaa suunnittelemaan ja toteuttamaan palvelinsovellukset entistä helpommin. Yksinkertaistunut EJB 3.0 -malli auttaa pitämään ylläpidon helppona. JavaServer Faces -tekniikalla saadaan web-käyttöliittymät koottua valmiskomponenteista entistä nopeammin. AJAX-piirteitä on rakennettu JSF-komponenttien sisään. Jos haluaa kattavamman AJAX-ratkaisun, Google Web Toolkit auttaa tekemään senkin ammattimaisesti.<br />
Hype on vaimentunut Web Services -tekniikoiden osalta. Niitä käytetään integraatioratkaisuissa, joita tehdään organisaatioiden välillä.</p>
<p>Kestotrendejä myös Java-puolella ovat mm. Agile menetelmät kuten Scrum ja XP, sekä Test Driven Development (TDD), joilla pyritään pitämään ohjelmistoprojektien tavoitteet selvillä ja näkyvissä, kulut kurissa ja tuottavuus maksimissa mm. JUnit yksikkötestauksella.</p>
<p>Jos olet koskaan kokenut, että ohjelmistoprojektissa on turhia viiveitä, myöhästymisiä tai riskejä niin käy katsomassa miten homman voi tehdä järkevämmin.</p>
<p>Toukokuun <strong>Java One</strong> seminaarissa San Franciscossa on uusia julkistuksia, puheenaiheina mm. Java 7 uudistukset kuten Jigsaw moduulimalli sekä Java EE 6.0 standardi ja EJB 3.1.</p>
<p><strong>Lisätietoja</strong><br />
Arto Santala, Tieturi Oy,  <a href="mailto:arto.santala@tieturi.fi">arto.santala@tieturi.fi</a></p>
<p><strong>P.S.</strong> Nyt viimeistään on paikallaan päivittää osaaminen nykypäivän tasalle ja hakea sovelluskehitykseen tuottavuutta ja ryhtiä!<br />
Valitse mielenkiintoisimmat kurssit <a href="http://www.tieturi.fi/java">www.tieturi.fi/java</a></p>
<p><!--  html .fb_share_link { padding:2px 0 0 20px; height:16px; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top left; } --><a class="fb_share_link" href="http://www.facebook.com/share.php?u=http://tieturi.wordpress.com" target="_blank">Share on Facebook</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Junior J2EE Architect for sale]]></title>
<link>http://spillerlaszlo.wordpress.com/2009/03/02/junior-j2ee-architect-for-sale/</link>
<pubDate>Mon, 02 Mar 2009 11:23:45 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/2009/03/02/junior-j2ee-architect-for-sale/</guid>
<description><![CDATA[Has been working as a Java developer for 3 years now. Experienced in developing banking software and]]></description>
<content:encoded><![CDATA[Has been working as a Java developer for 3 years now. Experienced in developing banking software and]]></content:encoded>
</item>
<item>
<title><![CDATA[Defaulting To JDK 1.6 In NetBeans 6.5 On OSX]]></title>
<link>http://devblog.point2.com/2009/02/17/defaulting-to-jdk-16-in-netbeans-65-on-osx/</link>
<pubDate>Tue, 17 Feb 2009 15:18:09 +0000</pubDate>
<dc:creator>Damien Gabrielson</dc:creator>
<guid>http://devblog.point2.com/2009/02/17/defaulting-to-jdk-16-in-netbeans-65-on-osx/</guid>
<description><![CDATA[We try to stay current with our technologies at Point2. An example of this is using the most recent ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>We try to stay current with our technologies at Point2. An example of this is using the most recent Java platform, Java 6 (JDK 1.6) and modern IDEs such as NetBeans 6.5. However, staying up to date with technology is not always as simple as it could be. Java 6 was released in December 2006 and NetBeans 6.5 was released almost 2 years later in November 2008 and yet it still wants to use Java 5 (JDK 1.5) as the default Java Platform, regardless of what you have set in the OSX Java preferences. Here is how you can set NetBeans 6.5 to use JDK 1.6 by default.</p>
<ul>
<li>Ensure that JDK 1.6 and NetBeans 6.5 are installed</li>
<li>Locate the NetBeans config file, typically located at &#8220;/Applications/NetBeans/NetBeans 6.5.app/Contents/Resources/NetBeans/etc/netbeans.conf&#8221; and open the file in your favourite editor</li>
<li>Set the &#8220;netbeans_jdkhome&#8221; parameter to the JDK 1.6 home directory (ie. netbeans_jdkhome=<br />
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home)</li>
<li>In NetBeans, right click on the project in the project window and select &#8220;Properties&#8221;</li>
<li>Ensure the &#8220;Source/Binary Format&#8221; is set to &#8220;1.6&#8243;<br />
<a href="http://i43.tinypic.com/oh60ep.png" target="_blank"><img src="http://i44.tinypic.com/2ptueeu.png" border="0" alt="" /></a></li>
<li>Click on &#8220;Tools&#8221; on the toolbar and select &#8220;Java Platforms&#8221;</li>
<li>Under &#8220;J2SE&#8221; the default platform should now be &#8220;JDK 1.6&#8243;<br />
<a href="http://i41.tinypic.com/2wp7bxi.png" target="_blank"><img src="http://i43.tinypic.com/v66qzn.png" border="0" alt="" /></a></li>
</ul>
<p>By: <a href="http://devblog.point2.com/author/dgp2/" target="_blank">Damien Gabrielson</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Running Eclipse on MacBooks with Java 6]]></title>
<link>http://blog.kischuk.com/2008/05/08/running-eclipse-on-macbooks-with-java-6/</link>
<pubDate>Thu, 08 May 2008 21:50:27 +0000</pubDate>
<dc:creator>rkischuk</dc:creator>
<guid>http://blog.kischuk.com/2008/05/08/running-eclipse-on-macbooks-with-java-6/</guid>
<description><![CDATA[The title of this post is a bit misleading in that you apparently cannot run Eclipse on a MacBook Pr]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The title of this post is a bit misleading in that you apparently cannot run Eclipse on a MacBook Pro with Java 6 set as the default JDK.  Never mind that it took Apple a year and a half after the release of Java 6 for Apple to support Java 6 on OS X in the first place.  I thought Apple was &#8220;developer friendly&#8221;?  My experience on a Mac has usually been slightly better than working on a PC, except that the failings of a PC can usually be dismissed as Microsoft&#8217;s incompetence.  Apple seems to act more like a highly-opinionated jerk.</p>
<p>After I upgraded to Java 6 (and then had to manually change my JDK symlink even after the upgrade), Eclipse refused to start.  The system log showed:</p>
<p><code>[0x0-0xa90a9].org.eclipse.eclipse[4265]: _NSJVMLoadLibrary: NSAddLibrary failed for /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Libraries/libjvm.dylib<br />
[0x0-0xa90a9].org.eclipse.eclipse[4265]: JavaVM FATAL: Failed to load the jvm library.</code></p>
<p>To resolve the issue, I edited <code>/Applications/eclipse/Eclipse.app/Contents/Info.plist</code>, and uncommented this line:</p>
<p><code>/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Commands/java</code></p>
<p>Problem solved.  Apparently Eclipse uses 32-bit SWT-Cocoa bindings, and Apple just decided that they weren&#8217;t going to support 32-bit SWT any more in Java 6, breaking any app that uses them in the process.  So the fix is to just run Eclipse under Java 5 (Java 6 projects still work in this setup).  I&#8217;m starting to lose track of the consumer-unfriendly attitudes I&#8217;ve experienced from Apple.  Their version of Java 6 is late, incomplete, and lazy.</p>
<p>I will declare this now &#8211; <strong>Apple is every bit as evil as Microsoft</strong>.  If Apple EVER gets the market share that Microsoft once held, Microsoft&#8217;s anti-trust violations will seem like trivial misdemeanors compared to what Apple would do with such power.  I need to gather my thoughts on this soon and elaborate on this point.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Java6 disponible para Mac]]></title>
<link>http://boleranet.wordpress.com/2008/05/07/java6-disponible-para-mac/</link>
<pubDate>Wed, 07 May 2008 11:16:49 +0000</pubDate>
<dc:creator>boleranet</dc:creator>
<guid>http://boleranet.wordpress.com/2008/05/07/java6-disponible-para-mac/</guid>
<description><![CDATA[De las pocas cosas que me mantenían usando otro sistema operativo era que para OS X no disponía de j]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>De las pocas cosas que me mantenían usando otro sistema operativo era que para OS X no disponía de java6, mientras que en Linux y Windows lleva un año mas o menos usandolo. Los usuarios de Mac OS X ya podemos descargarnos la versión 6 de Java en la web de <a href="http://developer.apple.com/" target="_blank">Apple Development</a>, más concretamente <a href="http://developer.apple.com/java/download/" target="_blank">aquí</a>.</p>
<p>Para mas información visitar <a href="http://developer.apple.com/java/" target="_self">http://developer.apple.com/java/</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Na? Was ist Pi?]]></title>
<link>http://kenny1987.wordpress.com/2008/03/17/na-was-ist-pi/</link>
<pubDate>Mon, 17 Mar 2008 07:54:09 +0000</pubDate>
<dc:creator>kenny1987</dc:creator>
<guid>http://kenny1987.wordpress.com/2008/03/17/na-was-ist-pi/</guid>
<description><![CDATA[Nicht 3.14&#8230; , nicht 3 und auch nicht 42. Sondern 12 : zumindest in den SGML-Klassen von Java6.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Nicht 3.14&#8230; , nicht 3 und auch nicht <a href="http://de.wikipedia.org/wiki/42_(Antwort)">42</a>. Sondern 12 :</p>
<p><img src="http://img.thedailywtf.com/images/200803/pi.png" height="301" width="382" /></p>
<p>zumindest in den <a href="http://en.wikipedia.org/wiki/SGML">SGML</a>-<a href="http://java.sun.com/javase/6/docs/api/javax/swing/text/html/parser/DTDConstants.html#PI">Klassen</a> von <a href="http://en.wikipedia.org/wiki/Java_6">Java6</a>. Dort meint PI allerdings etwas anderes als die Zahl, nämlich eine Document <i>P</i>rocessing <i>I</i>nstruction. Trotzdem lustig <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Sun Tech Days: WorldWide Developer Conference]]></title>
<link>http://letmeknow.wordpress.com/2008/02/28/sun-tech-days-worldwide-developer-conference/</link>
<pubDate>Thu, 28 Feb 2008 00:30:14 +0000</pubDate>
<dc:creator>Mohamed Sanaulla</dc:creator>
<guid>http://letmeknow.wordpress.com/2008/02/28/sun-tech-days-worldwide-developer-conference/</guid>
<description><![CDATA[Event: Sun Tech Days (Website) Organized By: Sun Microsystems Venue: Hyderabad International Convent]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><b>Event</b>: Sun Tech Days (<a href="http://www.sercononline.com/suntechdays08/home.htm" target="_blank">Website</a>)<br />
<img src="http://www.sercononline.com/suntechdays08/images/int_03.jpg" alt="Sun Tech Days" align="right" height="66" width="122" /><br />
<b>Organized By</b>: Sun Microsystems</p>
<p><b>Venue</b>: Hyderabad International Convention Center</p>
<p><b>Key Dates: </b><br />
Event: February 27-29, 2008</p>
<p><!--more--><br />
Sun Tech Days is a worldwide developer conference organized by Sun Microsystems. There are numerous opportunities at the Tech Days: developing skills in Web 2.0, sharing knowledge and growing network, participating in communities changing the face of technology.</p>
<p>Tech Days are one&#8217;s opportunity to hear from and meet with some of the brightest technology experts from around the world. It&#8217;s a chance to network with peers, understand more about what&#8217;s going on from Sun and the industry. Key Note speakers for the event are Rich Green, Ian Murdock, and David Axmark.</p>
<p>Tech Days travels the globe to share expertise with the community about Solaris OS, the Java EE, SE, and ME platforms, the NetBeans IDE, Sun Studio, Open Source and more.</p>
<p>(<a href="http://www.sercononline.com/suntechdays08/feestr.htm" target="_blank">Fee Structure</a>)</p>
<p><i>Subscribe to Gyaan RSS Feed <a href="http://letmeknow.wordpress.com/category/what/gyaan/feed" target="_blank" title="Gyaan">here</a>.</i><br />
<span class="q"><i>Subscribe to International RSS Feed <a href="http://letmeknow.wordpress.com/category/what/international/feed" title="International" target="_blank">here</a>.</i></span><i><br />
Subscribe to the combined Let Me Know RSS Feed <a href="http://letmeknow.wordpress.com/feed/" title="Let Me Know" target="_blank">here</a>.</i></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[BEA WebLogic Server 10.0 läuft nicht mit Java 6]]></title>
<link>http://murygin.wordpress.com/2008/01/11/bea-weblogic-server-100-lauft-nicht-mit-java-6/</link>
<pubDate>Fri, 11 Jan 2008 09:41:39 +0000</pubDate>
<dc:creator>murygin</dc:creator>
<guid>http://murygin.wordpress.com/2008/01/11/bea-weblogic-server-100-lauft-nicht-mit-java-6/</guid>
<description><![CDATA[Obwohl wir seit Jahren erfolgreich JBoss einsetzen muss ich für einen neuen Kunden WebLogic von BEA ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Obwohl wir seit Jahren erfolgreich <a href="http://labs.jboss.com/jbossas/">JBoss</a> einsetzen muss ich für einen neuen Kunden <a href="http://bea.com/framework.jsp?CNT=index.htm&#38;FP=/content/products/weblogic/server/">WebLogic</a> von BEA testen. Der Kunde nutzt die aktuelle Version 10.0. Vorsicht: WebLogic 10.0 (veröffentlicht am 10.04.07) läuft nicht mit Java 6 (veröffentlicht am 11.12.06).  Hm, das alleine ist zumindest merkwürdig. Neue Java Versionen sind in der Regel abwärtskompatibel. So läuft z.B. JBoss-4.0.2, der vor Jahren veröffentlicht wurde, problemlos mit Java 6. Richtig ärgerlich ist aber, dass in der WebLogic Dokumentation nicht darauf hingewiesen wird. Es gibt viele <a href="http://edocs.bea.com/wls/docs100/index.html">Megabyte Dokumentation</a> zur Version 10.0, z.B. <a href="http://edocs.bea.com/common/docs100/install/prepare.html#wp1130320">Installation Prerequisites mit System Requirements</a> oder<a href="http://e-docs.bea.com/platform/suppconfigs/configs100/100_over/overview.html"> Supported Configurations for BEA WebLogic Platform 10.0</a> mit Hinweisen zu Betriebssystemen, Web Servern, Datenbanken und sogar <a href="http://www.springframework.org">Spring</a> Versionen. Es gibt aber keine Hinweise welche JDK Versionen unterstützt werden. Nur indirekt wird darauf hingewiesen. Die <a href="http://commerce.bea.com/showproduct.jsp?family=WLS&#38;major=10.3Tech&#38;minor=-1&#38;DL=www_WLS_10-3TechPreview_icon&#38;WT.ac=DL_www_WLS_10.3_TechPreviewicon">WebLogic Server 10.3 Tech Preview</a> unterstützt <em>erstmals</em> Java 6:</p>
<blockquote><p>
This Technology Preview includes select new features, standards updates and performance improvements. Version 10.3 TP remains fully Java EE 5 compatible and adds new support for Java SE 6.
</p></blockquote>
<p>Vielleicht ist es BEA etwas peinlich, dass ihr 10000$-Server sich nicht mir Java 6 verträgt. Ich habe einen ganzen Tag damit verschwendet die 10.0 mit Java 6 zu testen bis ich endlich den Hinweis gefunden habe.</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
