Avoid temp session file with Arquillian Drone


By default drone uses a session file. It is by default created in $HOME and it is not always useful. You can override it by a system property but if you don’t want such a file and can’t wait for the fix (should be in Drone 2) then you can write a small Arquillian extension to skip it:

import org.jboss.arquillian.core.spi.LoadableExtension;
import org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusedSessionPermanentFileStorage;
import org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusedSessionPermanentStorage;
import org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusedSessionStore;

// no storage so don't share sessions accross tests
public class DroneNoSessionStorageExtension implements LoadableExtension {
    @Override
    public void register(final ExtensionBuilder builder) {
        builder.override(ReusedSessionPermanentStorage.class, ReusedSessionPermanentFileStorage.class, DroneNoSessionStorage.class);
    }

    public static class DroneNoSessionStorage implements ReusedSessionPermanentStorage {
        @Override
        public ReusedSessionStore loadStore() {
            return null;
        }

        @Override
        public void writeStore(final ReusedSessionStore store) {
            // no-op
        }
    }
}

Just add a META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension with the qualified name of this extension and that’s it :). No more session file will be created.

Advertisements

3 thoughts on “Avoid temp session file with Arquillian Drone

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s