Class XltProperties


  • public abstract class XltProperties
    extends java.lang.Object
    The property keeper. Loads and stores the properties of the entire tool. Single instance implementation.

    The process of looking up a property uses multiple fall-backs. When resolving the value for the key "foo.bar", for instance, the following effective keys are tried, in this order:

    1. the test user name plus simple key, e.g. "TOrder.foo.bar"
    2. the test class name plus simple key, e.g. "posters.loadtest.tests.TOrder.foo.bar"
    3. the simple key, i.e. "foo.bar"
    This multi-step process allows for test-user-specific or test-class-specific overrides of certain settings, while falling back to the globally defined values if such specific settings are absent.
    • Constructor Summary

      Constructors 
      Constructor Description
      XltProperties()  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      abstract boolean containsKey​(java.lang.String key)
      Checks whether there is a mapping for the specified key in this property list.
      static XltProperties getInstance()
      Returns the one and only XltProperties instance.
      abstract java.util.Properties getProperties()
      Returns a copy of all the internally stored properties, with any placeholder resolved.
      abstract java.util.Map<java.lang.String,​java.lang.String> getPropertiesForKey​(java.lang.String domainKey)
      Returns all properties whose name starts with the given domain key.
      abstract java.lang.String getProperty​(java.lang.String key)
      Searches for the property with the specified key in this property list.
      abstract boolean getProperty​(java.lang.String key, boolean defaultValue)
      Searches for the property with the specified key in this property list.
      abstract int getProperty​(java.lang.String key, int defaultValue)
      Searches for the property with the specified key in this property list.
      abstract long getProperty​(java.lang.String key, long defaultValue)
      Searches for the property with the specified key in this property list.
      abstract java.lang.String getProperty​(java.lang.String key, java.lang.String defaultValue)
      Searches for the property with the specified key in this property list.
      abstract java.lang.String getPropertyRandomValue​(java.lang.String key, java.lang.String defaultValue)
      Returns one value of the given multi-value property.
      abstract java.util.List<java.lang.String> getResolvedPropertyFiles()
      Deprecated.
      For internal use only.
      abstract long getStartTime()
      Returns the start time of the test in milliseconds since 1970.
      abstract java.lang.String getVersion()
      Returns the product version.
      abstract void removeProperty​(java.lang.String key)
      Removes the property with the given key from the internal properties store.
      static void reset()
      Deprecated.
      For internal use only.
      abstract void setProperties​(java.io.File file)
      Defines a source for property data.
      abstract void setProperties​(java.util.Properties newProperties)
      Method for changing the properties during runtime.
      abstract void setProperties​(org.apache.commons.vfs2.FileObject file)
      Defines a source for property data.
      abstract void setProperty​(java.lang.String key, java.lang.String value)
      Sets a property during runtime.
      abstract void update()
      Updates the properties.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • XltProperties

        public XltProperties()
    • Method Detail

      • getInstance

        public static XltProperties getInstance()
        Returns the one and only XltProperties instance.
        Returns:
        the XltProperties singleton
      • reset

        @Deprecated
        public static void reset()
        Deprecated.
        For internal use only.
        Resets the properties framework. This is mainly needed for testing.
      • containsKey

        public abstract boolean containsKey​(java.lang.String key)
        Checks whether there is a mapping for the specified key in this property list.
        Parameters:
        key - the property key
        Returns:
        true if there is a mapping, false otherwise
      • getProperties

        public abstract java.util.Properties getProperties()
        Returns a copy of all the internally stored properties, with any placeholder resolved.
        Returns:
        the properties
      • getPropertiesForKey

        public abstract java.util.Map<java.lang.String,​java.lang.String> getPropertiesForKey​(java.lang.String domainKey)
        Returns all properties whose name starts with the given domain key. The domain is stripped from the resulting property names.
        Parameters:
        domainKey - domain for the properties
        Returns:
        a map with all matching properties
      • getProperty

        public abstract java.lang.String getProperty​(java.lang.String key)
        Searches for the property with the specified key in this property list. The method returns null if the property is not found.
        Parameters:
        key - the property key
        Returns:
        the value of the key
      • getProperty

        public abstract boolean getProperty​(java.lang.String key,
                                            boolean defaultValue)
        Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.
        Parameters:
        key - the property key
        defaultValue - the defaultValue if key not found
        Returns:
        the value of the key as a boolean
      • getProperty

        public abstract int getProperty​(java.lang.String key,
                                        int defaultValue)
        Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.
        Parameters:
        key - the property key
        defaultValue - the defaultValue if key not found
        Returns:
        the value of the key as an int
      • getProperty

        public abstract long getProperty​(java.lang.String key,
                                         long defaultValue)
        Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.
        Parameters:
        key - the property key
        defaultValue - the defaultValue if key not found
        Returns:
        the value of the key as a long
      • getProperty

        public abstract java.lang.String getProperty​(java.lang.String key,
                                                     java.lang.String defaultValue)
        Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found. The key is upper-cased before the property will be searched.
        Parameters:
        key - the property key
        defaultValue - the defaultValue if key not found
        Returns:
        the value of the key
      • getPropertyRandomValue

        public abstract java.lang.String getPropertyRandomValue​(java.lang.String key,
                                                                java.lang.String defaultValue)
        Returns one value of the given multi-value property. Multiple values are separated by comma, semicolon, or space. The returned value is chosen randomly from the set of values.
        Parameters:
        key - the name of the property
        defaultValue - the default property value (a multi-value)
        Returns:
        one of the values, chosen randomly
      • getStartTime

        public abstract long getStartTime()
        Returns the start time of the test in milliseconds since 1970.
        Returns:
        the start time of the test in milliseconds
      • getVersion

        public abstract java.lang.String getVersion()
        Returns the product version.
        Returns:
        the version string, e.g. "1.1.0"
      • removeProperty

        public abstract void removeProperty​(java.lang.String key)
        Removes the property with the given key from the internal properties store.
        Parameters:
        key - the property key
      • setProperties

        public abstract void setProperties​(java.io.File file)
                                    throws java.io.IOException
        Defines a source for property data. If properties are already loaded, these new properties will be added. If a property already exists it will be overwritten. Last one wins. Automatically adds java system properties afterwards.
        Parameters:
        file - the file that contains the properties to be loaded
        Throws:
        java.io.IOException - thrown when opening the file or reading from the file failed
      • setProperties

        public abstract void setProperties​(org.apache.commons.vfs2.FileObject file)
                                    throws java.io.IOException
        Defines a source for property data. If properties are already loaded, these new properties will be added. If a property already exists it will be overwritten. Last one wins. Automatically adds java system properties afterwards.
        Parameters:
        file - the file that contains the properties to be loaded
        Throws:
        java.io.IOException - thrown when opening the file or reading from the file failed
      • setProperties

        public abstract void setProperties​(java.util.Properties newProperties)
        Method for changing the properties during runtime. Can be called multiple times to add additional properties. Automatically adds java system properties afterwards.
        Parameters:
        newProperties - complete new set of properties, will be added to existing properties and overwrites already defined properties with new values. None existing properties will be added.
      • setProperty

        public abstract void setProperty​(java.lang.String key,
                                         java.lang.String value)
        Sets a property during runtime. Overwrites an existing property with the same name. Does not re-apply any java system settings.
        Parameters:
        key - new property key
        value - new property value
      • update

        public abstract void update()
        Updates the properties.
      • getResolvedPropertyFiles

        @Deprecated
        public abstract java.util.List<java.lang.String> getResolvedPropertyFiles()
        Deprecated.
        For internal use only.
        Returns the absolute paths to the resolved property files. This means the property files which are there by default and the property files transitively included by "includes" in these property files. However note that some of the default files are optional (as "dev.properties") and the returned list only contains existing files.
        Returns:
        the resolved property files as described above