The Atom Exerciser on Heroku 1

Posted by david

From some time I've been getting some visits in this blog from Tim's page and I didn't know why, until this morning when I needed to use his Ape instance and I came across it was down.

I needed to use it from outside my private network, I thought on deploy it on Google App Engine, so I took the oportunity to move the repository to a more cool home, get rid of the old mongrel code and use a Rackable framework to manage its server and move its realeases to gemcutter.

All in all, after almost an hour trying to deploy it in GAE I realized I couldn't use it because its restrictions policy, so in the 10 minutes between I wrote these two tweets, I downloaded heroku gem, wrote a rack config file and deploy Atom Exerciser on Heroku. Enjoy it.

Abdera gets the graduation 0

Posted by david

Although I don't speak pretty much on Apache Abdera, I've been involved in the project for more than a year.

Today, two years later Abdera is finally graduated and in the next weeks we're moving our home to abdera.apache.org as a Top Level Project in the ASF. So, now the question is... when will we release a new version of Abdera? and the answer is... we're working on fix every major bug that we have in our jira, and we have to look over our documentation, but we'd like to release a new version as soon as our infrastructure will be migrated.

Meanwhile contributions are welcome, if you find a bug or you think that you can improve our documentation, please don't hesitate to drop us a line.

Google Test Automation Conference 08 3

Posted by david

Yesterday, the third edition of the Google Test Automation Conference finished, and, although my speech was a little disaster, I'm glad. It was a challenge, this was the first time that I gave a speech in english and I chose to do it in front of the main experts in testing in the world.

I'm trying to upload the slides to slideshare but I have several problems converting the file, so, if you want to get them you can download the pdf from my server.

Update: I finally got to upload the presentation to slideshare, you can take it a look here:

The ape 1.5 released 0

Posted by david

Yesterday I released a new version of The atom protocol exerciser. We have been working in order to simplify its architecture and create a modular system that anyone may extend.

Now it works from the command line as well the web interface. We've added some rake tasks that you can use for exercise your server implementation and you can select the output format just invoking the correct option:


 $ rake ape:go:text['service document uri']
 $ rake ape:go:html['service document uri']
 $ rake ape:go:atom['service document uri']

It allows some configuration options through its config file $APE_HOME/aperc:


Ape.conf[:REQUESTED_ENTRY_COLLECTION] = 'collection name'
Ape.conf[:REQUESTED_MEDIA_COLLECTION] = 'collection name'

And finally, this last release allows to create and add new tests easily. The test cases must to extend the Ape Validator class and override the validate method.


module Ape
  class CustomValidator < Validator
    def validate(opts = {}) end
  end
end

We've implemented a little system for select the variables to use in your tests, just call the requires_presence_of method into the class declaration and pass the variable name that you require.


module Ape
  class CustomValidator < Validator
    requires_presence_of :entry_collection #OR
    requires_presence_of :entry_collection => 'comments' #OR
    requires_presence_of :media_collection => {:accept => 'image/png'}
    #...

Once your custom validator is ready you just need to move it to $APE_HOME/validators.

But if you really want to learn how to write your custom validator you just need to take a look at the source code.

The APE meets RubyGems 2

Posted by david

When I talked about the ape in the past Conferencia Rails 07 I remarked that it wasn't quite easy to install and configure. Today I can announce that this is no longer true.

We've transformed a lot of scripts in a ruby gem that provides a Mongrel based server. Once the ape gem is installed and this server is running, the web interface is available in the port 4000 of your localhost.


  $ sudo gem install ape && ape_server

Moreover, the new ape gem uses the erubis library to load the atom entry templates that it uses to test the atomPub server. These templates can be overrided by the user, the gem searchs the APE_HOME enviromment variable or the .ape directory into the user home directory. Within this directory the user can leave his atom entry templates with the names mini_entry.eruby, basic_entry.eruby or unclean_xhtml_entry.eruby.

We are excited with this release and we are working hard to eliminate possible bugs and add documentation in addition to new capabilities in order to test any atomPub server behaviour.

Enjoy it!

Update: I just put an instance of The Ape running on Heroku to use it online, you can see more details in the announcement.

Rails plugin: atom_pub_server 0

Posted by david

Update: he cambiado el repositorio y ahora el plugin se puede instalar desde GitHub:

   $script/plugin install git://github.com/calavera/atompub-server.git

Coincidiendo con el lanzamiento de la api de 11870.com tenía ganas de liberar un plugin para Rails que me ha ayudado a experimentar con AtomPub.

Como no soy muy original con los nombres lo he llamado atom_pub_server y básicamente sirve para empezar a implementar AtomPub dentro de una aplicación desarrollada con Rails. Ya que el punto de entrada del protocolo es su documento de servicio este plugin sirve para generar un documento de servicio a partir de los controllers de una aplicación. A partir de ahí, y gracias al genial soporte de REST por parte de rails y a alguna de las novedades de la versión 2.0 implementar un servidor de Atom Publishing Protocol con una aplicación rails es francamente sencillo.

Pero para ver como funciona el plugin lo mejor es ver un ejemplo. Empezaremos instalándolo en la aplicación desde el repositorio:

    $script/plugin install http://svn.thinkincode.net/rails/plugins/atom_pub_server

Supongamos que nuestra aplicación tiene dos controllers, uno llamado PostsController y otro llamado ServicesController. El primero será en encargado de gestionar una colección de recursos, así que le añadiremos el siguiente método:

    class PostsController < ApplicationController
      acts_as_collection :title => 'posts', :workspace => 'blog',
        :href=> 'http://myblog', :accept => Mime::ATOM_ENTRY
    ...

Al marcar este primer controlador para que actúe como una colección automáticamente se le añade un filtro anterior a los métodos de crear y actualizar un elemento. El método que invoca el filtro se debe llamar filter_content_type y los nombres de los métodos sobre los que se ejecuta se pueden configurar como variables de entorno, siendo por defecto create y update.

El segundo controlador será el encargado de generar el documento de servicio, así que lo marcaremos como tal:

    class ServicesController < ApplicationController
        acts_as_service_document
    ...

Finalmente, para que el controlador genere el documento de servicio solo tendremos que llamar al método "service_document" que le aporta el plugin dentro de otro de los métodos del controlador:

    def index
      render :xml => service_document
    end

y nos generará un xml parecido a este:

  <service xmlns:atom='http://www.w3.org/2005/Atom' xmlns='http://www.w3.org/2007/app'>
    <workspace>
      <atom:title>blog</atom:title>
      <collection href='http://myblog'>
          <atom:title>posts</atom:title>
          <accept>application/atom+xml;type=entry</accept>
     </collection>
    </workspace>
  </service>

Además, este plugin añade varios tipos Mime necesarios para la cumplir especificación de AtomPub:

    Mime::ATOM_ENTRY == 'application/atom+xml;type=entry'
    Mime::ATOM_SVC == 'application/atomsvc+xml'
    Mime::ATOM_CAT == 'application/atomcat+xml'

Para finalizar, he decidido sobreescribir uno de los nuevos helpers de rails, concretamente el que nos ayuda a escribir documentos Atom. El método original no permite añadir nuevos espacios de nombres siendo su llamada tal que así:

    atom_feed do |feed|
    ...

mientras que con este plugin podríamos escribir:

    atom_feed( 'xmlns:app' => 'http://www.w3.org/2007/app') do |feed|
    ...

Cabe decir que el método para sobreescribir 'atom_feed' sólo funciona con la versión actual de Rails (2.0RC) y posteriores. En el fichero README del plugin se puede encontrar una documentación mucho más detallada. Cualquier duda, sugerencia o mejora es bienvenida.