Sunday, 4 December 2011

Video showing how to use m2eclipse plugin

Look here: http://eclipse.org/m2e/

ListPreference with values number type

In my Android application I tried to define preferences list with values of number type.
<ListPreference
      android:key="poll_list"
      android:title="@string/preference_poll_list"
      android:summary="@string/preference_poll_list_summary"
      android:entries="@array/poll_option"
      android:entryValues="@array/poll_option_values"
      android:dialogTitle="@string/preference_poll_list" />
I had to define lists in arrays.xml. But I had to define list poll_option_values as a string-array, like here:
<resources>
    <array name="poll_option">
        <item>1 Minute</item>
        <item>2 Minutes</item>
        <item>5 Minutes</item>
        <item>10 Minutes</item>
        <item>20 Minutes</item>
    </array>
    <string-array name="poll_option_values">
        <item>60</item>
        <item>120</item>
        <item>300</item>
        <item>600</item>
        <item>1200</item>
    </string-array>
</resources>
I couldn't use array type. Just another Android feature ;)

Saturday, 3 December 2011

Testing asynchronous actions using WebDriver (f.e. AJAX)

Here is a code snippet showing how to test ajax actions using WebDriver. You can use WebDriverWait.until method defining condition that checks if web page's structure has changed. In the WebDriverWait constructor you have to define timeout in seconds. If this time passes then method ends with an exception.
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition() {
  public Object apply(Object input) {
      try {
        WebElement elem = driver.findElement(By.id(changedElem));
        boolean condition = Here you can state condition
        return condition;
      } catch (StaleElementReferenceException e) {
        return false;
      }
    }
  });

Monday, 28 November 2011

Spring Roo 1.2.0.RC1 released

New changes are ready for testing in the new Roo release candidate. The most interesting are:
  • Multi-module Maven project support
  • Enhancements in Entity model
See more on: http://blog.springsource.org/2011/11/23/spring-roo-1-2-0-rc1-released/

Sunday, 27 November 2011

ProGuard - obfuscator for Android

How to encode your code written in an Android application?
Use Proguard.

ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names. Finally, it preverifies the processed code for Java 6 or for Java Micro Edition.

More information on the product page: http://proguard.sourceforge.net/

Wednesday, 16 November 2011

How to change MANIFEST.MF generated by maven?

You have to add plugin configuration in pom.xml in section build/plugins:
Here is an example of configuring default class run when executing generated jar:
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
     <archive>
      <manifest>
       <mainClass>package.Class</mainClass>
      </manifest>
     </archive>
    </configuration>
   </plugin>
Here is an example of using already generated MANIFEST.MF file as the manifest file of the jar:
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
     <archive>
      <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
     </archive>
    </configuration>
   </plugin>

More info about plugin parameters on: http://maven.apache.org/maven-1.x/plugins/jar/manifest.html