Recent Notes

Displaying keyword search results 1 - 8
Created by Dr. Xi on September 23, 2013 09:00:22    Last update: September 23, 2013 09:17:55
Tsung is an open-source multi-protocol distributed load testing tool. It's written in Erlang , but don't let that dissuade you. Here are some simple steps to get started. Install Tsung. On Ubuntu, this is simply: sudo apt-get install tsung . Create a config file ( tsung.xml ): <?xml version="1.0" encoding="UTF-8"?> <!DOCTYP... Beware of the dumptraffic attribute. You might want to set it to false for a real load test. Run the test: $ tsung -f tsung.xml start Starting Tsung "L... Generate the reports: $ cd /home/drxi/.tsung/log/20130923-1031 $ /usr... Open the report file in your browser: file:///home/drxi/.tsung/log/20130923-1031/report.html . For HTTPS testing change the server line to: <servers> <server host="192.168.80.160" port="...
Created by freyo on September 07, 2011 16:46:14    Last update: September 07, 2011 19:23:00
The Android unit test framework is based on JUnit 3 , not JUnit 4. Test cases have to extend junit.framework.TestCase or a subclass (such as android.test.InstrumentationTestCase ). Tests are identified by public methods whose name starts with test , not methods annotated with @Test (as in JUnit 4). An Android test suite is packaged as an APK, just like the application being tested. To create a test package, first you need to identify the application package it is testing. Google suggests to put the test package source in a directory named tests/ alongside the src/ directory of the main application. At runtime, Android instrumentation loads both the test package and the application under test into the same process. Therefore, the tests can invoke methods on...
Created by Dr. Xi on June 13, 2011 15:05:27    Last update: June 13, 2011 15:10:24
When you pass parameters from shell to Java, the list arguments may be messed up if there are spaces in the values. Start with a simple Java test class: public class EchoParams { public static voi... Tests: $ java EchoParams a b c Arg: a Arg: b Arg... Now wrap the command in a shell script ( echoparams.sh ): #!/bin/sh java EchoParams $* Tests: $ ./echoparams.sh a b c Arg: a Arg: b Arg... The quotes had no effect on the parameters list. Changing $* to $@ produces the same results. The correct way to quote the args list is: "$@" #!/bin/sh java EchoParams "$@" Test: $ ./echoparams.sh a b "c d" "1 2 3 4 5" Arg: a ...
Created by Dr. Xi on February 28, 2011 15:39:08    Last update: February 28, 2011 15:39:08
For simple projects, archetype:generate seemed too heavy for me, but creating the standard Maven file structure by hand is such a chore. So I created this simple script to ease the pain: #!/bin/sh if [ $# -lt 4 ]; then echo "Us... Example usage: ./initmvn.sh myProject theGroupId theArtifactId co...
Created by Dr. Xi on October 26, 2010 04:47:37    Last update: January 11, 2011 20:00:36
The code presented here is a simple implementation of a tab set. It is used to demo how a tab set could be implemented. The code is stand alone and does not depend on any JavaScript libraries. Multiple tab sets within the same page is supported. The HTML markup is fairly simple: Tabs sets are contained within a DIV element with class name "tabsContainer". Define a UL list for the tabs. Follow the UL list with equal number of DIVs for the tab contents. The Nifty Corners Cube technique is used to draw the rounded corners (original form, not the enhanced JavaScript form). HTML, CSS and JavaScript: <!doctype html> <html> <head> <style typ...
Created by Dr. Xi on November 19, 2008 00:22:27    Last update: January 07, 2010 23:00:36
There is a open source project named [ini4j] for processing Windows .ini configuration files. However, I found it an overkill for my purposes. So here is my simple implementation of a .ini parser. It mimics the standard java.util.Properties class with enhancements to get and set properties by section name. There are only a few simple rules: Leading and trailing spaces are trimmed from section names, property names and property values. Section names are enclosed between [ and ] . Properties following a section header belong to that section Properties defined before the appearance of any section headers are considered global properties and should be set and get with no section names. You can use either equal sign ( = ) or colon ( : )...
Created by Fang on September 07, 2009 16:39:37    Last update: September 07, 2009 18:43:04
It's easiest to use the archetype plugin to start a new Maven project. I'll use struts 1 as example since it's not in the built-in archetypes for archetype:generate . Generate a simple webapp with archetype:generate : C:\work\maven>mvn archetype:generate -DarchetypeAr... It generates a directory structure like this: struts1app struts1app/pom.xml struts1app/src... with a simple POM: <project xmlns="http://maven.apache.org/POM/4.0.0"... Create settings.xml in $HOME/.m2 , add Java.net repository for Java EE dependencies: <?xml version="1.0" encoding="UTF-8"?> <setting... Add Java EE and Struts dependencies in pom.xml . Note that the Java EE dependency has scope provided , meaning that the web app container provides the jars, therefore we don't need to bundle them with our war fie. <project xmlns="http://maven.apache.org/POM/4.0.0"... Create a directory named java under main , create the Struts form and...
Created by Fang on August 13, 2009 04:18:26    Last update: August 13, 2009 04:18:26
To start a simple "Hello World" project in maven, enter: mvn archetype:create -DgroupId=com.example -Dartif... in the command line. It will take a while for Maven to run. But eventually it will create the standard Maven directory structure with a "Hello World" app and a fake JUnit test. Enter mvn package will build the simple App into a jar under the target directory. Run the resulting App: C:\maven\hello-world>java -cp target\hello-world-1... This is the generated pom: <project xmlns="http://maven.apache.org/POM/4.0.0"...