laplace's demon

Author Archive

My personal website is online

by on Jan.05, 2012, under Dear diary

Finally my personal website is online. here is the link

Leave a Comment more...

Unit Testing Asynchronous Operations with OCTest

by on Sep.21, 2011, under Programming

I have experienced problems while I write the unit tests for a RESTLike web service client. The client class is basically a wrapper around NSURLConnection which asynchronously fetch/download data from a server. Unit tests are synchronously operations and will not work in this context.

The test case is the following: connect to a server via its URL and fetches some data from it. I have used a loop while the downloading operation continues to force the test method to wait for the connection class to finish its job. Following is the test case method:

- (void)testConnection {
    // the custom strategy class to encapsulate the behavior of the rest client
    WSRestClientDefaultStrategy* strategy = [[WSRestClientDefaultStrategy alloc] init];
    // create the rest client under testing
    WSRestClient* client = [WSRestClient restClientWithStrategy:strategy withMethodName:@"anymethod" andParams:nil andHttpMethod:@"GET"];
    [client execute];
    [strategy release];

    // this is a workaround in order to test async requests
    NSRunLoop* runLoop = [NSRunLoop currentRunLoop];

    // wait while the connection class does its job
    while ([client loading] && [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
}

Please note that the unit test normally should not fetch any data from any external service. Please consider to use mock classes to reduce the dependency. You can use a framework like OSMock for creating the mock classes

Leave a Comment :, more...

Geek talk

by on Apr.23, 2011, under Uncategorized

I just like that sense of humor

Source: http://xkcd.com

Leave a Comment more...

a netbeans bug on jax-rpc

by on Apr.19, 2011, under Programming

I have tried to write a rpc web service client in java using a wsdl file on netbeans, but a ittle bug drives me crazy. If you come across the following error during the compilation, then the following solution might save your time.

taskdef class com.sun.xml.rpc.tools.ant.Wscompile cannot be found

open up /nbproject/project.properties
Change:

wscompile.classpath=${wscompile.tools.classpath}:${j2ee.platform.wscompile.classpath}

To:

wscompile.classpath=${wscompile.tools.classpath}:${j2ee.platform.wscompile.classpath}:${javac.classpath}

woila

Leave a Comment more...

rest vs rpc

by on Apr.01, 2011, under Programming

Well, i came across a great comparison article and i want to share it. Well this is because my bookmarking system sucks. So when i need to save a document, i post it in my blog. Yeah it sucks.

http://md314159265.wordpress.com/2006/10/30/comparison-of-rest-vs-xml-rpc/

1 Comment more...

Noob guide to marketing chart

by on Mar.25, 2011, under Tech

I’m not a marketing guy, but the following cool chart will be very helpful anyone in the industry. I put it down here to remember. Yep, primitive way of bookmarking. (inner voice: i want delicious back)

Leave a Comment more...

Twitter Updates

by on Feb.08, 2011, under Uncategorized

I guess it would be kinda cool if my posts are published as twitter entries. I have installed a new plugin. And this is my first post to test it out.

1 Comment more...

Getting PHP headers without apache mod headers

by on Feb.08, 2011, under php, Programming

It sometimes happen. You are in a restricted environment -like a shared hosting- and somehow you want to reach the custom headers without enabling the apache module “mod_headers”. Than following little function will do your job.

function getHeaders()
    {
        $headers = array();
        foreach ($_SERVER as $k => $v)
        {
            if (substr($k, 0, 5) == "HTTP_")
            {
                $k = str_replace('_', ' ', substr($k, 5));
                $k = str_replace(' ', '_', strtolower($k));
                $headers[$k] = $v;
            }
        }
        return $headers;
    }

P.S. If you have the possibility to use the mod_headers, than you’re free to use apache_get_headers() function.

Leave a Comment more...

Mac Maintenance Scripts

by on Jan.03, 2011, under mac

Mac OSX schedules and runs some kind of maintenance scripts. Those scripts only removes some invisible system log files that is not a big deal. But the thing is, it schedules the scripts at 3:30 am of the day, week or month. But off course you can manually run them via following command

sudo periodic daily weekly monthly

It’s ok not to see a output when you run the command.

Leave a Comment more...

Think beyond DB

by on Nov.12, 2010, under php, Programming, Tech

I found a good presentation by the project lead of Zend Framework. He explains the data persistance and why good OO programming instead of refactoring is saves a lot of time.

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...