Updates from October, 2010 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 11:11 am on October 28, 2010 Permalink |
    Tags: , , , guide, how-to, , simple, tutorial   

    Today’s read: Get Started Developing for Android with Eclipse 

    This one is pretty good. Perhaps one of the very useful how-tos! I read this article in smashingmagazine.com a few days back. I was thinking of sharing it from that moment. It’s better late than never. The article talks a lot of things. From about installing the Android SDK, configuring it and even about writing a sample application.

    There’s a lot to get excited about in mobile application development today. With increasingly sophisticated hardware, tablet PCs and a variety of software platforms (Symbian OS, iOS, WebOS, Windows Phone 7…), the landscape for mobile developers is full of opportunities — and a little complex as well.

    So much choice can be overwhelming when you just want to get started building mobile applications. Which platform should you choose? What programming language should you learn? What kit do you need for your planned project? In this tutorial, you’ll learn how to start writing applications for Android, the open-source mobile operating system popularized by Google.

    Source: Smashing Magazine

    Read the article | http://developer.android.com

     
  • Subinkrishna Gopi 11:01 am on October 13, 2010 Permalink |
    Tags: , archives, build, , , , script, ,   

    How-to: Get timestamp in ANT scripts 

    We use a lot of ANT scripts to build our archives. And archives without version number/timestamp is a big pain. We faced a lot of issues mainly integration issues. This is a small piece of script which can be used to add timestamp to an archive’s name.

    This is done using the tstamp task in ANT. tstamp is highly configurable and uses the java.text.SimpleDateFormat date/time patterns.

    <target name="timestamp.target">
    	<tstamp>
    		<format property="current.time"
    			pattern="yyyyMMdd_HHmmss" />
    		<format property="archive.name"
    			pattern="'MyArchive_'yyyyMMdd_HHmmss'.jar'" />
    	</tstamp>
    	<echo>${current.time}</echo>
    	<echo>${archive.name}</echo>
    </target>
    

    I got the following output when I tried to run the above build script:

    Buildfile: /home/subin/sampleProject/build.xml
    timestamp.target:
         [echo] 20101013_103329
         [echo] MyArchive_20101013_103329.jar
    BUILD SUCCESSFUL
    Total time: 524 milliseconds
    

    So, we have tstamp, which formats (format) the time/date information and assigns the result to the specified property. The echo statements demonstrate how we can use those values further.

    Hope this helps. Have a nice day.

     
  • Subinkrishna Gopi 4:51 pm on June 23, 2010 Permalink |
    Tags: cache, , distributed cache, ehcache,   

    Distributed Ehcache – RMI replication (configuration) 

    I am having some fun with Ehcache esp. in distributed caching. Distributed caching is really important in a clustered environment. Read more about distributed caching here – http://ehcache.org/documentation/distributed_caching.html.

    I have downloaded Ehcache 2.1 from http://sourceforge.net/projects/ehcache/files/ (ehcache-2.1.0-distribution.tar.gz, 48 mb approx.) which contains Ehcache core and the Terracotta libraries. Once if we have these libraries, we can configure the caches, peers and listeners. I have created a basic cache – MyCache – and my configuration file looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="ehcache.xsd"
             updateCheck="true" monitoring="autodetect"
             dynamicConfig="true" >
    
        <diskStore path="java.io.tmpdir"/>
        <cacheManagerEventListenerFactory class="" properties=""/>
    
        <defaultCache
               maxElementsInMemory="0"
               eternal="false"
               timeToIdleSeconds="1200"
               timeToLiveSeconds="1200">
        </defaultCache>
    
            <!-- For RMI replication (Setting the peer provider factory) -->
    	<cacheManagerPeerProviderFactory
    		class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
    		properties="peerDiscovery=manual, rmiUrls=//remoteHostIpAddress:40000/MyCache"
    		propertySeparator="," />
    
    	<!-- For RMI replication (Setting the peer listener factory) -->
    	<cacheManagerPeerListenerFactory
                class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
                properties="hostName=localMachineIpAddress, port=40000, socketTimeoutMillis=120000"
                propertySeparator=","/>
    
    	<cache name="MyCache"
    		maxElementsInMemory="1000"
    		eternal="false"
    		overflowToDisk="true"
    		diskSpoolBufferSizeMB="20"
    		timeToLiveSeconds="3000"
    		timeToIdleSeconds="3000"
    		memoryStoreEvictionPolicy="LFU">
    
    		<!-- Cache event listener -->
    		<cacheEventListenerFactory
    			class="subin.cache.listener.factory.CacheEventListenerFactoryImpl"
    			properties="" />
    
    		<!-- RMI replication listener -->
    		<cacheEventListenerFactory
            	class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
            	properties="replicateAsynchronously=true,
    		         replicatePuts=true,
    		         replicatePutsViaCopy=true,
    		         replicateUpdates=true,
    		         replicateUpdatesViaCopy=true,
    		         replicateRemovals=true" />
    
    		<!-- RMI Cache bootstrap -->
    		<bootstrapCacheLoaderFactory
    			class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
    			properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"
    			propertySeparator="," />
    
    	</cache>
    
    </ehcache>
    

    Initializing the CacheManager & Accessing the cache

    // Testing the cache creation in ver 2.1
    CacheManager manager = new CacheManager("/path/to/config/file.xml");
    
    // Get the instance of "MyCache"
    Cache myCache = manager.getCache("MyCache");
    
    // Add an element to "MyCache". Its preferred to have both key and value
    // serializable
    Element aCacheElement = new Element(key, value);
    myCache.put(aCacheElement);
    

    Useful Links

    RMI replication: http://ehcache.org/documentation/distributed_caching_with_rmi.html
    Configuration: http://ehcache.org/documentation/configuration.html

     
  • Subinkrishna Gopi 11:37 am on February 23, 2010 Permalink |
    Tags: , help, htmlunit, , , , memory leak, ,   

    HTMLUnit issue 

    We are using HTMLUnit in one of our modules and we use it to crawl through the webpages. But we are facing serious memory leak issues with HTMLUnit. We are unable to kill the JavaScript threads even after the functionality is completed. All my search to fix this issue ended up in one solution,

    webClient.closeAllWindows();
    

    But even this did not help us in solving the leak. The method call claims to kill all the running JavaScript threads associated with the WebClient though! If anyone can help us in fixing this, can share their thoughts here. I will update this post as soon as we have a solution.

    Thank you.

     
    • kkperf 11:28 pm on April 9, 2010 Permalink

      We seem to be running into a similar issue.
      We noticed “leaking windows” – always with a scriptable object tied to it. Here is what we did to confirm this (in addition to heap dump analysis)

      System.out.println(“windows size before closeAllWindows: ” + windows.size());
      webClient.closeAllWindows();
      System.out.println(“windows size after closeAllWindows: ” + windows.size());

      List windowsAfterClose = webClient.getWebWindows();
      System.out.println(“windowsAfterClose size: ” + windowsAfterClose.size());
      for (WebWindow ww : windowsAfterClose) {
      System.out.println(“Window name: ” + ww.getName());

      This shows that there is 1 window with no name still open.

      Trying to figure out whats going on. I’m going to perhaps end up logging a bug with htmlunit.
      Let me know if you have found a solution to the problem.
      Thanks
      -KK

    • kswenson 2:53 am on August 3, 2010 Permalink

      I have this exact problem.

      I have iterated through all the of the windows, gotten the ThreadManager, and interrupted all treads managed by those windows.

      Then I close all windows.

      But background JavaScript is still running. Every few seconds it creates a new thread and executes something.

      There is a class JavaScriptBackgroundJob which is running, but this class is not mentioned anywhere in the JavaDoc shipped with the library.

      I would appreciate help from anyone who can tell me how to COMPLETELY shut down all htmlunit processing.

    • Subinkrishna G 12:44 pm on August 4, 2010 Permalink

      We still dont have any solution 😦 I will update this post as soon as I have one.

  • Subinkrishna Gopi 3:40 pm on December 21, 2009 Permalink |
    Tags: beginners, , selenium, testing,   

    A selenium blog for beginners 

    Selenium Logo

    Simple Tech Talks is a very good place for Selenium beginners.The author, Jinesh, well categorized the content in to seven simple posts.

    Part 1: Why Selenium
    Part 2: Why Not Selenium
    Part 3: Selenium Flavors (Components)
    Part 4: How Does Selenium work
    Part 5: Locating the Elements in a Web Page (Objec…
    Part 6: Running The Tests
    Part 7: Beginners How to Start With??

    This is very well written and worth a read for all enthusiasts.

    What is selenium?
    Selenium is a portable software testing framework for web applications. Selenium provides a record/playback tool for authoring tests without learning a test scripting language. Selenium provides a test domain specific language (DSL) to write tests in a number of popular programming languages, including Java, Ruby, Groovy, Python, PHP, and Perl. Test playback is in most modern web browsers. Selenium deploys on Windows, Linux, and Macintosh platforms.

    Source: Wikipedia

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel