Could not capture screenshot when test failed on windows

Problems:

We have configured to capture screenshot when selenium (or any web based automation test, e.g. web driver, sahi, etc… ) tests failed, but each time we got is a blank image which only has a black background. The CI agent runs on Windows 2008 in a virtual machine

blank black ground image

Reason:

There is no any real window opened because nobody logged on this machine, Continue reading “Could not capture screenshot when test failed on windows”

Google Search 技巧之 矫正发音

自己知道英语水平不高,但一直也没有人认真的说我的发音有问题。直到有一天,到了美国,发现经常需要把单词拼出来,别人才知道什么意思,于是忽然意识到了问题的严重性。

第一反应就是google一下语音矫正,发现了一篇帖子: http://www.ewedu.net/f/t/10131/35788.html

更加震撼,于是想着找一些软件来提高口语,但没有找到合适的, 突然想起(发现)google search是支持语音的,马上试验了一下,找出了发音比较简单的单词,试了一下效果,识别正确。 于是开始实验别人听不懂的单词,发现google也听不懂 :-)

接下来就把google不能识别的单词记下来,查词典看音标,不断尝试,感觉改进了不少。

两天后,再向别人说起以前发音有问题的单词,已经几乎没有问题了。

注:

1. 在google Search 输入框的右侧,有个麦克风的图标,点击就可以语音输入了。

2. 有网站介绍说,不能迷信语音输入,个人感觉至少可以帮助我们一定程度上发现问题

3. 另一个参考网站:http://www.accentschool.com

Could not compile libxml2: /bin/rm: cannot remove `libtoolT’: No such file or directory

When I compile libxml2-2.7.8 under Ubuntu 11.04, it always complain that:

/bin/rm: cannot remove `libtoolT’: No such file or directory.

I did a search on google, but none of them works.

From the console output, I found that it failed because removing a file which does not exists.

So I edit the configure file, find the line which contains $RM “$cfgfile”, and replace it with $RM -f “$cfgfile”, then everything works.

(‘rm -f’ means do not stop even if the file doesn’t exists)

Connection always successful when installed anti-virus application

When I try to use URLConnection to check if a url is accessible using the following code:

try {
    URL url = new URL("http://169.254.169.254/latest");

    URLConnection connection = url.openConnection();
    connection.setConnectTimeout(5000);
    connection.connect();
    System.out.println("Connected successfully using url");
} catch (IOException e) {
        e.printStackTrace();
}

I expected the behavior is: connect should be success if the host is reachable, else throw exception. It works fine without the anti-virus application, but always print “connected successfully” even the host is not reachable. Continue reading “Connection always successful when installed anti-virus application”

Adding text to an image using Preview on Mac 10.5 (Most difficult to use feature I have met in ten years)

Preview support edit images, but the menu item is disabled by default when I open an image file. I thought it was because the Preview does not support this kind of file type. Recently, when I try to find a simple image editor only for add some text, oval or rectangle, I found that the Preview support it perfectly.

After customized the toolbar, the buttons enabled, and it’s very easy to add comments, but the menu item still disabled.

The following is what I found about how to customize the toolbar from the Preview Help.

Adding text to an image

You can add text to an image to describe what’s in it or when the image was created.

After you save the image, you can’t edit, move, or delete any text you added to it. If you think you’ll need to edit the text, convert the image to a PDF document, and then add notes to the PDF document. Notes added to a PDF document can be edited after they’re saved.

To add text to an image:

  1. If the Annotate pop-up menu isn’t in the toolbar, choose View > Customize Toolbar and drag the Annotate pop-up menu to the toolbar.
  2. Choose Note from the Annotate pop-up menu in the toolbar.
  3. Drag over the area where you want the text to appear.
  4. Enter your text.

Before you save the image, you can move, resize, edit, or delete the text. First choose Text Annotation from the Annotation pop-up menu in the toolbar. Then to edit the text, double-click it. To delete the text, click it so resize handles appear, and then press Delete.

基于JavaScript的代码自动生成工具

JavaScript Based Code Generator – codegen

工具主页

http://thelei.sourceforge.net

目的

快速生成程序代码, 比如Struts, Spring, Jdbc/Hibernate所有前后台的代码.

简单介绍

本工具生成代码的思想是读取数据库中表的结构, 使用JavaScript作为脚本语言编写模板, 生成各种代码或者文件, 支持各种格式的文本文件, Java, C#, PHP 等, 只要是文本文件, 都可以生成, 因为生成什么是由你完全自己定义的. 对数据库的访问是通过插件的形式进行的, 所以易于扩充, 目前支持Mysql, 以及支持Ado连接的数据库.

本工具开发于2006年, 经过两年的内部使用, 进行了不断改进, 现在把它公布出来, 希望能有更多的人用它, 提意见, 然后把它做的更好.

什么时候用它

有时候在项目开发过程中有大量的简单重复劳动, 以Struts, Spring, Jdbc/Hibernate为例, 对数据库中的每张表, 都有其相对应的Dao(2), Service(2), Action(Class+Validation2), Jsp(list+edit+add=3), 需要新建10多个文件/目录,  而这个过程是很枯燥的, 但又会花不少时间, Continue reading “基于JavaScript的代码自动生成工具”

Introduce a tool to generate code by writing JavaScript

Java Based Code Generator – jbcgen

home page:

http://sourceforge.net/projects/jbcgen/

Short Description:

This code generator generates files from database and templates written in JavaScript. it supports db plugin, and it’s easy to extend and use. It supports mysql and db which support ado connection(under windows only) for now.

When To Use

It should be used especially when the code logic is similar, but the table is different. It will save much of your time by generating code automatically instead of copy&paste. For example, you want to write 5 files for each table, you only need to write lines of javascript code without coding the files lots of time. Continue reading “Introduce a tool to generate code by writing JavaScript”

集成ACEGI 进行权限控制

一. 简单介绍

1.1 本文目的

集成Acegi到自己的项目中, 并且将用户信息和权限放到数据库, 提供方法允许权限动态变化,变化后自动加载最新的权限

本文介绍Acegi例子的时候采用的是acegi-security-samples-tutorial-1.0.6.war

阅读本文需要对Spring有一定的了解, 如果你还没有接触过, 有些地方可能不容易理解, 这时候可能需要参考本文后附的Spring地址, 先了解一下Spring的基本知识.

本文使用的是Mysql数据库, 如果你使用其他的数据库, 可能需要修改相应的SQL.

本文及所附的全部代码放在http://acegi-test.sourceforge.net/

1.2 安装与配置

项目主页: http://www.acegisecurity.org/
Continue reading “集成ACEGI 进行权限控制”

Mapping HTTP Requests to Servlet and Resource Registrations

When an HTTP request comes in from a client, the Http Service checks to
see if the requested URI matches any registered aliases. A URI matches only
if the path part of the URI is exactly the same string. Matching is case sensitive.
If it does match, a matching registration takes place, which is processed as
follows:
1. If the registration corresponds to a servlet, the authorization is verified
by calling the handleSecurity method of the associated HttpContext
object. See Authentication on page 23. If the request is authorized, the servlet
must be called by its service method to complete the HTTP request.
2. If the registration corresponds to a resource, the authorization is verified
by calling the handleSecurity method of the associated HttpContext
object. See Authentication on page 23. If the request is authorized, a target
resource name is constructed from the requested URI by substituting the
alias from the registration with the internal name from the registration
if the alias is not “/”. If the alias is “/”, then the target resource name is constructed
by prefixing the requested URI with the internal name. An internal
name of “/” is considered to have the value of the empty string (“”)
during this process.
3. The target resource name must be passed to the getResource method of
the associated HttpContext object.
4. If the returned URL object is not null, the Http Service must return the
contents of the URL to the client completing the HTTP request. The translated
target name, as opposed to the original requested URI, must also be
used as the argument to HttpContext.getMimeType.
5. If the returned URL object is null, the Http Service continues as if there
was no match.
6. If there is no match, the Http Service must attempt to match sub-strings
of the requested URI to registered aliases. The sub-strings of the
requested URI are selected by removing the last “/” and everything to the
right of the last “/”.

The Http Service must repeat this process until either a match is found or
the sub-string is an empty string. If the sub-string is empty and the alias “/”
is registered, the request is considered to match the alias “/”. Otherwise, the
Http Service must return HttpServletResponse.SC_NOT_FOUND(404) to
the client.