Mencoba paket data Xplore Monday, Dec 31 2007 

Setelah mendaftarkan diri pada paket mega data Xplore (250Mb : Rp. 99,000 + pajak) tentu yang membuat penasaran adalah kecepatannya.
Oleh karena itu maka saya langsung menuju http://www.speedtest.net/ untuk mengetest.
Test 1, koneksi ke server di Indonesia (Jakarta):

  • Ping : 323 ms
  • Download : 197 kb/s
  • Upload : 28 kb/s

Test 2, koneksi ke server di Singapore:

  • Ping : 772 ms
  • Download : 351 kb/s
  • Upload : 20 kb/s

Yang membingungkan kenapa test download ke Singapore (351 kbps) lebih cepat dari pada Jakarta (197 kbps) ?
Dan kenapa ping ke server Jakarta sangat lama (323 ms)?

Pengalaman pemakaian selama beberapa hari (dengan ponsel k800i sebagai modem) :

  • Browsing : kecepatan cukup cepat, dan nyaman. Walau tidak termasuk sangat cepat.
  • Download file : mencoba download file dari website luar, kecepatan : 20 – 25 kilobytes/s
  • Game online Counter Strike, wcg server indonesia (csx.vivagamers.com:2701x) : ping terlalu tinggi (>150) lag dan akhirnya di kick dari server.

Untuk hasil test download ke Singapore yang tinggi (351 kbps) mungkin karena XL bekerja sama dengan SingTel di Singapore.
Dari mencoba melakukan tracert ke yahoo.com, terlihat dari server Excelcomindo di Indonesia di lanjutkan ke server SingTel di Singapore.

Maka perlu di coba melakukan test ke negara lain.
Test 3, Server Australia (Sydney) :

  • Ping : 403 ms
  • Download : 379 kb/s
  • Upload : 19 kb/s

Hasil ini semakin membingungkan, kenapa test ke server di Indonesia juga lebih kecil dari ke Sydney?
Kalo begitu kita test ke server Indonesia di kota lain.

Test 4, Server Indonesia (Surabaya) :

  • Ping : 241 ms
  • Download : 379 kb/s
  • Upload : 47 kb/s

Lebih cepat dari Jakarta. Ada apa dengan server di Jakarta, atau speedtest.net kurang akurat dalam melakukan test kecepatan internet dari XL ini.
Mencoba lagi test ke Server Jakarta, hasilnya tetap sama (download dikisaran 19x kbps).

Saat ini baru test-test ini yang sudah dilakukan, mungkin kesempatan lain bisa di test di web lain atau dengan cara lain supaya bisa menyimpulkan kualitas paket data Xplore ini.

NetBeans 6 T-shirt Friday, Dec 28 2007 

NetBeans 6 T-shirt (front)NetBeans 6 T-shirt (back)

After waiting for 16 days finally the NetBeans T-shirt arrived.
They sent me this t-shirt because my participation in NetBeans Community Docs program although I only contribute 1 article (this) :p

Thanks to Sun and James Branam (NetBeans Community Docs Manager) for this cool t-shirt 😉
It’s a great pleasure to be part of the NetBeans community & I would love to contribute more.

Using mock object with jmock 2 Wednesday, Dec 26 2007 

Okay, finally you decide it’s time to create a unit testing for your project (after a long ad hoc programming life :p).
When you create a sample unit testing, it’s all seem so simple.. you fascinate by the junit easiness, how it can do reflection and make it simple.

When you want to create a real unit testing for your project, you realize that a ‘real’ method is not like just adding 2 int argument and return a result. It’s more complex and using interface as parameter is common…
Now a thought cross your mind “do I have to create all stupid classes to implement all the interface I need?”, you starting to think that creating unit testing is really waste of time & you don’t want to do it anymore :p

It’s time mock object framework come to rescue… before you fall to the darkness of untested code 🙂
There’re several mock object framework like jMock, easymock, etc

Here’s an example creatin HttpMethod mock-object with jMock 2 & JUnit 3

public class sampleJMockTest extends MockObjectTestCase {
  public void testCreateHTTPMethod() {
    final HttpMethod httpMethod = mock(HttpMethod.class);
    checking(new Expectations() {
    {
      allowing(httpMethod).getResponseBodyAsString();
      will(returnValue("sample response"));
    }
    });
    SomeObject someObject = new SomeObject();
    someObject.someMethod(httpMethod);
  }
}

This sample will create an instance of HttpMethod (which is an interface) and when this mock object’s ‘getResponseBodyAsString’ method called it’ll return “sample response”.
So now we can easily create all interface implementation we need.Of course there’re more in jMock than just this simple feature, check it more at jMock Cookbook

Java – Adding new Classpath at Runtime Wednesday, Dec 19 2007 

There are cases where we need to add classpath at runtime. For example adding jar to classpath, but depends on configuration or some logic at runtime.

The class who responsible for handling classpath list is URLClassloader.
You can get current system URLClassLoader with:
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();

If you check javadoc about this class you’ll see:

protected void addURL(URL url)
Appends the specified URL to the list of URLs to search for classes and resources.

So you’ll just need to call the addUrl method to add new path/jar file.
But wait a minute, the method is protected… 😦 do I need to create a subclass or put the caller class on same package?
Creating a subclass is one way to do it, but there’s simpler way (I’ll create article about creating URLClassLoader subclass next time :p)

Here come the savior : Reflection
By using reflection we can break OOP concept about encapsulating method. It’s feel good to break the rules right (warning : use this at your own risk, you know you’re breaking the OO rule. So I won’t responsible if your computer explode or you’ll fighting with OO fans because of this)

Here a sample how to called it with reflection:

public static void addPath(String s) throws Exception {
  File f = new File(s);
  URL u = f.toURL();
  URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
  Class urlClass = URLClassLoader.class;
  Method method = urlClass.getDeclaredMethod("addURL", new Class[]{URL.class});
  method.setAccessible(true);
  method.invoke(urlClassLoader, new Object[]{u});
}

Happy reflecting.. 🙂

NetBeans 6 Bug – ConfigurationException Class in Apache Common Configuration is not Throwable? Wednesday, Dec 12 2007 

When I using Netbeans 6 (final released) and using Apache Common Configuration library, I encounter this bug.
Here’s how I found the bug :

  • Create a java application project
  • Add the library, I create a library name ‘Apache_Common_Configuration’ and add commons-configuration-1.5.jar to that library
  • Then I wrote the code

public static void main(String[] args) {
try {
INIConfiguration ini = new INIConfiguration("sample.ini");
} catch (ConfigurationException ex) {
ex.printStackTrace();
}
}

  • But the editor showing error on ‘ConfigurationException ex’ saying that ConfigurationException is not subclass of Throwable Class (I’ve upload the screenshot)

NetBeans 6 Bug - ConfigurationException Class

  • When I try to build it’s showing different error “class file for org.apache.commons.lang.exception.NestableException not found”
  • It’s look like Apache Common Configuration is using Apache Common Lang library (I also look to the source-code ‘ConfigurationException extends NestableException’). Error when compile showing me more help than error in editor.
  • So I create a library name ‘Apache_Common_Lang’ and add commons-lang-2.3.jar to that library
  • After add the library the editor still showing the same error : “ConfigurationException is not subclass of Throwable Class”
  • But when I run build, it run successful . No error at all. (Now I confused)
  • It’s look like there’s a bug in the Editor. And that red line & error icon in project window really bugging me, although I know it’s the editor bug not my code error.
  • So to make this ‘red-line’ disappeared, I combined commons-configuration-1.5.jar & commons-lang-2.3.jar into 1 jar file. And set a library to this jar (instead using 2 library or 2 jar file).
  • After this combined the editor not showing the error again.

Anyone having this problem too?

You can vote for this bug on : http://www.netbeans.org/issues/show_bug.cgi?id=124241

NetBeans IDE 6 final released Tuesday, Dec 4 2007 

Finally Netbeans 6 final released 🙂
Download it at NetBeans 6 Download

Can’t wait to download and install it.
I hope they’ve already fixed bugs in previous release (RC2).