text:
// Copyright 2009 The original authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.googlecode.bumblebee.beans;

import com.googlecode.bumblebee.dto.Assembler;
import com.googlecode.bumblebee.dto.AssemblyException;
import com.googlecode.bumblebee.dto.DataObject;
import net.sf.jdpa.NotEmpty;
import net.sf.jdpa.NotNull;

import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;

/**
 * Utility class the provides some support for managing java beans.
 *
 * @author Andreas Nilsson
 */
public class BeanUtil {

    public static final List<String> ACCESSOR_PREFIXES = Arrays.asList(
            "get", "is", "has", "was", "can", "may", "will", "could", "had", "have"
    );

    public static String getPropertyName(@NotNull Method method) {
        String methodName = method.getName();
        String prefix = null;

        for (Iterator<String> i = ACCESSOR_PREFIXES.iterator(); i.hasNext() && prefix == null;) {
            String currentPrefix = i.next();

            if (methodName.startsWith(currentPrefix)) {
                if (methodName.length() <= currentPrefix.length()) {
                    throw new InvalidAccessorException("Method " + method.getDeclaringClass().getSimpleName()
                            + "." + methodName + " is not a property");
                } else if (Character.isUpperCase(methodName.charAt(currentPrefix.length()))) {
                    prefix = currentPrefix;
                }
            }
        }

        if (prefix == null) {
            throw new InvalidAccessorException("Method " + method.getDeclaringClass().getSimpleName() + "."
                    + method.getName() + " does not have a valid accessor prefix");
        } else if (method.getParameterTypes().length > 0) {
            throw new InvalidAccessorException("Accessor " + method.getDeclaringClass().getSimpleName() + "."
                    + method.getName() + " should have an empty parameter list");
        } else if (method.getReturnType().equals(void.class)) {
            throw new InvalidAccessorException("Accessor " + method.getDeclaringClass().getSimpleName() + "."
                    + method.getName() + " cannot have void return type");
        } else {
            return Character.toLowerCase(methodName.charAt(prefix.length())) + methodName.substring(prefix.length() + 1);
        }
    }

    /**
     * Evaluates the specified property on the provided object. All valid prefixes will be tested in priority
     * order according to the following list: get, is, has, was, can, may, will, could, had, have.
     *
     * @param object       The object on which the property should be evaluated.
     * @param propertyName The property to fetch from the provided object.
     * @return The property value.
     */
    @SuppressWarnings("unchecked")
    public static Object getProperty(@NotNull Object object, @NotEmpty String propertyName) {
        if (object instanceof Collection) {
            Collection collection = (Collection) object;
            Collection intermediate = (object instanceof Set ? new HashSet(collection.size()) : new ArrayList(collection.size()));

            for (Object element : collection) {
                intermediate.add(getProperty(element, propertyName));
            }

            return intermediate;
        } else if (object.getClass().isArray()) {
            int length = Array.getLength(object);
            Collection intermediate = new ArrayList(length);

            for (int i = 0; i < length; i++) {
                intermediate.add(getProperty(Array.get(object, i), propertyName));
            }

            return intermediate;
        } else {
            Method method = null;
            String intermediate = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);

            for (String prefix : ACCESSOR_PREFIXES) {
                try {
                    method = object.getClass().getDeclaredMethod(prefix + intermediate);
                } catch (NoSuchMethodException e) {
                    // Ignore
                }
            }

            if (method == null) {
                throw new PropertyAccessException("No accessor for property " + object.getClass().getSimpleName() + "." + propertyName + " could be found.");
            }

            try {
                method.setAccessible(true);
            } catch (SecurityException e) {
                // Ignore this exception. If the method is public, we'll manage to invoke it anyway. If it is not public
                // we want an exception that describes the access violation properly.
            }

            try {
                return method.invoke(object);
            } catch (IllegalAccessException e) {
                throw new PropertyAccessException("Failed to access property " + object.getClass().getSimpleName() + "." +
                        propertyName + ". Make sure the accessor " + method.getName() + " is public.", e);
            } catch (InvocationTargetException e) {
                throw new PropertyAccessException("Accessor of property " + object.getClass().getSimpleName() + "." +
                        propertyName + " caused an exception. Check the stack trace for details.", e);
            }
        }
    }

    public static Object getUnwrappableValue(@NotNull Object value, @NotEmpty String wrapperType) {
        // TODO Cast if e.g. value is an Integer and wrapperType is Double
        return value;
    }

    @SuppressWarnings("unchecked")
    public static Object copy(Object object, @NotNull Class propertyType, @NotNull Class componentType, @NotNull Assembler assembler) {
        if (propertyType.isArray()) {
            if (!(object instanceof Collection) && object instanceof Iterable) {
                object = ((Iterable) object).iterator();
            }

            if (object instanceof Iterator) {
                object = copyIterator(object);
            }

            if (object instanceof Collection) {
                Collection collection = (Collection) object;
                Object array = Array.newInstance(componentType, collection.size());
                int index = 0;

                for (Object element : collection) {
                    Array.set(array, index++, copy(element, componentType, componentType, assembler));
                }

                return array;
            } else if (object != null && object.getClass().isArray()) {
                int length = Array.getLength(object);
                Object array = Array.newInstance(componentType, length);

                for (int i = 0; i < length; i++) {
                    Array.set(array, i, copy(Array.get(object, i), componentType, componentType, assembler));
                }

                return array;
            } else {
                throw new IllegalArgumentException("Can't copy " + (object == null ? "null" : object.getClass().getName()) + " to " + componentType.getName() + "[]");
            }
        } else if (Collection.class.isAssignableFrom(propertyType)) {
            if (!(object instanceof Collection) && object instanceof Iterable) {
                object = ((Iterable) object).iterator();
            }

            if (object instanceof Iterator) {
                object = copyIterator(object);

            }

            if (object instanceof Collection) {
                Collection source = (Collection) object;
                Collection target = newCollection(propertyType, source.size());

                for (Object element : source) {
                    Object copy = copy(element, componentType, componentType, assembler);

                    if (!componentType.isInstance(copy)) {
                        throw new AssemblyException("Incompatible element in collection " + source + ": element " + element + " is not assignable to " + componentType.getName());
                    }

                    target.add(copy);
                }

                return target;
            } else if (object.getClass().isArray()) {
                if (!componentType.isAssignableFrom(object.getClass().getComponentType())) {
                    throw new AssemblyException("Invalid component type " + object.getClass().getComponentType().getName() + ": expected " + componentType.getName());
                } else {
                    int length = Array.getLength(object);
                    Collection target = newCollection(propertyType, length);

                    for (int i = 0; i < length; i++) {
                        target.add(Array.get(object, i));
                    }

                    return target;
                }
            }
        } else if (propertyType.getAnnotation(DataObject.class) != null && object != null) {
            object = assembler.assemble(object, propertyType);
        }

        return object;
    }

    protected static Object copyIterator(Object object) {
        List collection = new LinkedList();
        Iterator i = (Iterator) object;

        while (i.hasNext()) {
            collection.add(i.next());
        }

        object = collection;
        return object;
    }

    protected static Collection newCollection(Class<?> type, int size) {
        if (type.equals(Collection.class) || type.equals(List.class)) {
            return new ArrayList(size);
        } else if (type.equals(Set.class)) {
            return new HashSet(size);
        } else if (type.isInterface()) {
            throw new AssemblyException("Unsupported collection type " + type.getName());
        } else if ((type.getModifiers() & Modifier.ABSTRACT) != 0) {
            throw new AssemblyException("Unsupported collection type " + type.getName() + ": type is not recognized and can't be instantiated");
        } else {
            try {
                return (Collection) type.newInstance();
            } catch (InstantiationException e) {
                throw new IllegalArgumentException("Failed to instantiate collection type " + type.getName(), e);
            } catch (IllegalAccessException e) {
                throw new IllegalArgumentException("Default constructor of collection type " + type.getName() + " is not accessible", e);
            }
        }
    }

    /**
     * Extracts the component type of a field or a return value with type java.util.Collection. The format
     * of the generic type is e.g. "java.util.Collection<java.lang.String>".
     *
     * @param genericType The generic type declaration.
     * @return The component type of the collection.
     */
    public static Class<?> getCollectionComponentType(@NotEmpty String genericType) {
        int n = genericType.indexOf('<');
        String componentTypeName = Object.class.getName();

        if (n != -1) {
            int m = genericType.lastIndexOf('>');

            if (m == -1) {
                throw new IllegalArgumentException("Type clause is not closed in generic declaration: " + genericType);
            } else if (m != genericType.length() - 1) {
                throw new IllegalArgumentException("Type clause did not terminate at EOF in generic declaration: " + genericType);
            } else {
                componentTypeName = genericType.substring(n + 1, m);
                n = componentTypeName.indexOf('<');

                if (n != -1) {
                    // Strip generics on component type
                    componentTypeName = componentTypeName.substring(0, n);
                }
            }
        }

        if (componentTypeName.equals("?")) {
            // Default to java.lang.Object if the component type is not defined
            componentTypeName = Object.class.getName();
        }

        try {
            return Class.forName(componentTypeName);
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException("Invalid generic declaration: " + genericType + ": component type " + componentTypeName + " could not be found");
        }
    }

    public static Class<?> getComponentTypeOfProperty(@NotNull Class<?> type, @NotEmpty String propertyName) {
        String getterName = "get" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
        Method method = null;
        Class returnType = null;

        try {
            method = type.getDeclaredMethod(getterName);
        } catch (NoSuchMethodException e) {
            throw new PropertyAccessException("No property [" + propertyName + "] exists in class [" + type.getName() + "]");
        }

        returnType = method.getReturnType();

        if (returnType.isArray()) {
            return returnType.getComponentType();
        } else if (Collection.class.isAssignableFrom(returnType)) {
            return getCollectionComponentType(method.getGenericReturnType().toString());
        }

        return null;
    }

}


text:
\hypertarget{ui__test_8py}{
\section{ui\_\-test.py File Reference}
\label{ui__test_8py}\index{ui\_\-test.py@{ui\_\-test.py}}
}
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item
class \hyperlink{classmmasgis_1_1ui__test_1_1Ui__test}{mmasgis::ui\_\-test::Ui\_\-test}
\end{DoxyCompactItemize}
\subsection*{Namespaces}
\begin{DoxyCompactItemize}
\item
namespace \hyperlink{namespacemmasgis_1_1ui__test}{mmasgis::ui\_\-test}
\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item
\hyperlink{namespacemmasgis_1_1ui__test_ac3357b8b712a74d7fe2a8f05653fbe4e}{mmasgis::ui\_\-test::\_\-fromUtf8} = QtCore.QString.fromUtf8
\end{DoxyCompactItemize}

redpajama_set_name: RedPajamaGithub


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<name>Flowable - Engine</name>
	<artifactId>flowable-engine</artifactId>

	<parent>
		<groupId>org.flowable</groupId>
		<artifactId>flowable-root</artifactId>
		<relativePath>../..</relativePath>
		<version>6.1.0-SNAPSHOT</version>
	</parent>

	<dependencies>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-bpmn-converter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-process-validation</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-image-generator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-engine-common-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-engine-common</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-idm-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-idm-engine</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-dmn-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-form-model</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-form-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flowable</groupId>
			<artifactId>flowable-content-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-email</artifactId>
		</dependency>
		<dependency>
			<groupId>commons-codec</groupId>
		    <artifactId>commons-codec</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-lang3</artifactId>
		</dependency>
		<dependency>
			<groupId>org.mybatis</groupId>
			<artifactId>mybatis</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.codehaus.groovy</groupId>
			<artifactId>groovy-all</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.drools</groupId>
			<artifactId>drools-core</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.drools</groupId>
			<artifactId>drools-compiler</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.persistence</groupId>
			<artifactId>persistence-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.geronimo.specs</groupId>
			<artifactId>geronimo-jta_1.1_spec</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.enterprise.concurrent</groupId>
			<artifactId>javax.enterprise.concurrent-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.openjpa</groupId>
			<artifactId>openjpa</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.subethamail</groupId>
			<artifactId>subethasmtp-wiser</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>net.sourceforge.jtds</groupId>
			<artifactId>jtds</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.uuid</groupId>
			<artifactId>java-uuid-generator</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<!-- required for DiagramQueryTest -->
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>joda-time</groupId>
			<artifactId>joda-time</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>jcl-over-slf4j</artifactId>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.googlecode.catch-exception</groupId>
			<artifactId>catch-exception</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- Required for testing JTA -->
		<dependency>
			<groupId>org.codehaus.btm</groupId>
			<artifactId>btm</artifactId>
			<version>2.1.3</version>
			<scope>test</scope>
		</dependency>

	</dependencies>

	<properties>
		<flowable.artifact>
			org.flowable.engine
		</flowable.artifact>
		<flowable.osgi.export.additional>
			org.flowable.db.mapping.entity
		</flowable.osgi.export.additional>
		<flowable.osgi.import.additional>
			junit*;resolution:=optional,
			org.junit*;resolution:=optional,
			com.sun*;resolution:=optional,
			javax.activation*;resolution:=optional,
			javax.persistence*;resolution:=optional,
			org.apache.commons.mail*;resolution:=optional,
			org.apache.xerces*;resolution:=optional,
			org.flowable.camel;resolution:=optional,
			org.flowable.camel.impl;resolution:=optional,
			org.springframework*;resolution:=optional,
			org.drools*;resolution:=optional,
			com.fasterxml*;resolution:=optional,
			javax.transaction;resolution:=optional,
			javax.enterprise.concurrent;resolution:=optional,
		</flowable.osgi.import.additional>
	</properties>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>**/*TestCase.java</exclude>
						<exclude>**/RepeatingServiceTaskTest.java</exclude>
					</excludes>
					<runOrder>alphabetical</runOrder>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<archive>
						<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>cleanVersions</goal>
						</goals>
					</execution>
					<execution>
						<id>bundle-manifest</id>
						<phase>process-classes</phase>
						<goals>
							<goal>manifest</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<!--This plugin's configuration is used to store Eclipse m2e settings
					only. It has no influence on the Maven build itself. -->
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>org.apache.felix</groupId>
										<artifactId>
											maven-bundle-plugin
										</artifactId>
										<versionRange>
											[2.1.0,)
										</versionRange>
										<goals>
											<goal>cleanVersions</goal>
											<goal>manifest</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore></ignore>
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>

	<profiles>

		<profile>
			<id>checkspring</id>
			<properties>
				<skipTests>true</skipTests>
			</properties>
		</profile>

		<profile>
			<id>create-test-jar</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>2.2</version>
						<executions>
							<execution>
								<goals>
									<goal>test-jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>upgradeDatabase</id>
			<activation>
				<property>
					<name>upgradeDatabase</name>
				</property>
			</activation>
			<properties>
				<skipTests>true</skipTests>
			</properties>
		</profile>
		<profile>
			<id>distro</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-source-plugin</artifactId>
						<version>2.1.1</version>
						<executions>
							<execution>
								<id>attach-sources</id>
								<phase>package</phase>
								<goals>
									<goal>jar-no-fork</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- database qa profile -->
		<profile>
			<id>database</id>
			<activation>
				<property>
					<name>database</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<!-- only worked with this version, there might be a bug with antrun
							see http://jira.codehaus.org/browse/MANTRUN-109 -->
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="updating flowable configuration to db ${database}" />
										<copy file="${basedir}/../../qa/db/flowable.cfg.xml"
											todir="target/test-classes" overwrite="true">
											<filterset
												filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${database}.properties" />
										</copy>
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${database}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>databasewithschema</id>
			<activation>
				<property>
					<name>databasewithschema</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<!-- only worked with this version, there might be a bug with antrun
							see http://jira.codehaus.org/browse/MANTRUN-109 -->
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration to db ${databasewithschema}" />
										<copy file="${basedir}/../../qa/db/schema/flowable.cfg.xml"
											todir="target/test-classes" overwrite="true">
											<filterset
												filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${databasewithschema}.properties" />
										</copy>
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${databasewithschema}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>databasemssql</id>
			<activation>
				<property>
					<name>databasemssql</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<!-- only worked with this version, there might be a bug with antrun
							see http://jira.codehaus.org/browse/MANTRUN-109 -->
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="updating flowable configuration to db ${databasemssql}" />
										<copy file="${basedir}/../../qa/db/mssql/flowable.cfg.xml"
											todir="target/test-classes" overwrite="true">
											<filterset
												filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${databasemssql}.properties" />
										</copy>
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
            <id>databaseasynchistory</id>
            <activation>
                <property>
                    <name>databaseasynchistory</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <!-- only worked with this version, there might be a bug with antrun
                            see http://jira.codehaus.org/browse/MANTRUN-109 -->
                        <version>1.4</version>
                        <executions>
                            <execution>
                                <id>database-test-create-schema</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo message="updating flowable configuration to db ${databaseasynchistory}" />
                                        <copy file="${basedir}/../../qa/asynchistory/flowable.cfg.xml"
                                            todir="target/test-classes" overwrite="true">
                                            <filterset
                                                filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${databaseasynchistory}.properties" />
                                        </copy>
                                    </tasks>
                                </configuration>
                            </execution>
                            <execution>
                                <id>database-test-drop-schema</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo message="dropping schema in ${databaseasynchistory}" />
                                        <java classname="org.flowable.engine.impl.db.DbSchemaDrop"
                                            classpathref="maven.test.classpath" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>databasewithschemaasynchistory</id>
            <activation>
                <property>
                    <name>databasewithschemaasynchistory</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <!-- only worked with this version, there might be a bug with antrun
                            see http://jira.codehaus.org/browse/MANTRUN-109 -->
                        <version>1.4</version>
                        <executions>
                            <execution>
                                <id>database-test-create-schema</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo
                                            message="updating flowable configuration to db ${databasewithschemaasynchistory}" />
                                        <copy file="${basedir}/../../qa/asynchistory/schema/flowable.cfg.xml"
                                            todir="target/test-classes" overwrite="true">
                                            <filterset
                                                filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${databasewithschemaasynchistory}.properties" />
                                        </copy>
                                    </tasks>
                                </configuration>
                            </execution>
                            <execution>
                                <id>database-test-drop-schema</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo message="dropping schema in ${databasewithschemaasynchistory}" />
                                        <java classname="org.flowable.engine.impl.db.DbSchemaDrop"
                                            classpathref="maven.test.classpath" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>databasemssqlasynchistory</id>
            <activation>
                <property>
                    <name>databasemssqlasynchistory</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <!-- only worked with this version, there might be a bug with antrun
                            see http://jira.codehaus.org/browse/MANTRUN-109 -->
                        <version>1.4</version>
                        <executions>
                            <execution>
                                <id>database-test-create-schema</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo message="updating flowable configuration to db ${databasemssqlasynchistory}" />
                                        <copy file="${basedir}/../../qa/asynchistory/mssql/flowable.cfg.xml"
                                            todir="target/test-classes" overwrite="true">
                                            <filterset
                                                filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${databasemssqlasynchistory}.properties" />
                                        </copy>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

		<!-- Config qa profile -->
		<profile>
			<id>configSpring</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<!-- only worked with this version, there might be a bug with antrun
							see http://jira.codehaus.org/browse/MANTRUN-109 -->
						<version>1.4</version>
						<executions>
							<execution>
								<id>configExecution</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration config to db ${database}" />
										<copy
											file="${basedir}/../../qa/spring/${database}/flowable.cfg.xml"
											todir="target/test-classes" overwrite="true">
											<filterset
												filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${database}.properties" />
										</copy>
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${database}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<excludes>
								<exclude>**/*TestCase.java</exclude>

								<!-- Disabling tests that run exclusively using standalone config -->
								<exclude>**/ProcessDiagramRetrievalTest.java</exclude>
								<exclude>org/flowable/standalone/**</exclude>
							</excludes>
							<runOrder>alphabetical</runOrder>
						</configuration>
					</plugin>
				</plugins>
			</build>
			<dependencies>
				<dependency>
					<groupId>org.flowable</groupId>
					<artifactId>flowable-spring</artifactId>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<profile>
			<id>configJta</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<!-- only worked with this version, there might be a bug with antrun
							see http://jira.codehaus.org/browse/MANTRUN-109 -->
						<version>1.4</version>
						<executions>
							<execution>
								<id>configExecution</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="Copying jta enabled Flowable configuration file to target/test-classes" />
										<echo
											message="Updating flowable configuration config to db ${database}" />
										<copy file="${basedir}/../../qa/jta/${database}/flowable.cfg.xml"
											todir="target/test-classes" overwrite="true">
											<filterset
												filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${database}.properties" />
										</copy>
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${database}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<excludes>
								<exclude>**/*TestCase.java</exclude>

								<!-- Disabling tests that run exclusively using standalone config -->
								<exclude>**/ProcessDiagramRetrievalTest.java</exclude>
								<exclude>org/flowable/standalone/**</exclude>
							</excludes>
							<runOrder>alphabetical</runOrder>
						</configuration>
					</plugin>
				</plugins>
			</build>
			<dependencies>
				<dependency>
					<groupId>org.slf4j</groupId>
					<artifactId>slf4j-jdk14</artifactId>
					<version>1.7.6</version>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<!-- check history full -->
		<profile>
			<id>cfghistoryfull</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration to qa/cfg/historyfull.flowable.cfg.xml" />
										<copy file="${basedir}/../../qa/cfg/historyfull.flowable.cfg.xml"
											tofile="target/test-classes/flowable.cfg.xml" overwrite="true" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<excludes>
								<exclude>**/*TestCase.java</exclude>
								<exclude>**/CompetingJobAcquisitionTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-234 -->
								<exclude>**/WSDLImporterTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-315 -->
								<exclude>**/JobExecutorTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-427 -->
								<exclude>**/HistoricTaskInstanceUpdateTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-485 -->
								<exclude>**/RepeatingServiceTaskTest.java</exclude>
								<exclude>org/flowable/standalone/**</exclude>
							</excludes>
							<runOrder>alphabetical</runOrder>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>databasehistoryfull</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<!-- only worked with this version, there might be a bug with antrun
							see http://jira.codehaus.org/browse/MANTRUN-109 -->
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration to db ${database}, using FULL history" />
										<copy file="${basedir}/../../qa/db/historyfull.flowable.cfg.xml"
											todir="target/test-classes" overwrite="true">
											<filterset
												filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${database}.properties" />
										</copy>
										<rename src="target/test-classes/historyfull.flowable.cfg.xml"
											dest="target/test-classes/flowable.cfg.xml" />
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema-before</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${database}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema-after</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${database}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Same as databasehistoryfull, but for databases that need a schema
			in the config -->
		<profile>
			<id>databasehistoryfullwithschema</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<!-- only worked with this version, there might be a bug with antrun
							see http://jira.codehaus.org/browse/MANTRUN-109 -->
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration to db ${database}, using FULL history" />
										<copy
											file="${basedir}/../../qa/db/historyfull-with-schema.flowable.cfg.xml"
											todir="target/test-classes" overwrite="true">
											<filterset
												filtersfile="${user.home}/.flowable/jdbc/build.flowable6.${databasewithschema}.properties" />
										</copy>
										<rename
											src="target/test-classes/historyfull-with-schema.flowable.cfg.xml"
											dest="target/test-classes/flowable.cfg.xml" />
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema-before</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${databasewithschema}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema-after</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${databasewithschema}" />
										<java classname="org.flowable.engine.impl.db.DbSchemaDrop"
											classpathref="maven.test.classpath" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- check history full -->
		<profile>
			<id>cfghistoryaudit</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration to qa/cfg/historyaudit.flowable.cfg.xml" />
										<copy file="${basedir}/../../qa/cfg/historyaudit.flowable.cfg.xml"
											tofile="target/test-classes/flowable.cfg.xml" overwrite="true" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<excludes>
								<exclude>**/*TestCase.java</exclude>
								<exclude>**/CompetingJobAcquisitionTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-234 -->
								<exclude>**/WSDLImporterTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-315 -->
								<exclude>**/JobExecutorTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-427 -->
								<exclude>**/HistoricTaskInstanceUpdateTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-485 -->
								<exclude>**/RepeatingServiceTaskTest.java</exclude>
								<exclude>org/flowable/standalone/**</exclude>
							</excludes>
							<runOrder>alphabetical</runOrder>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- check history none -->
		<profile>
			<id>cfghistorynone</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration to qa/cfg/historynone.flowable.cfg.xml" />
										<copy file="${basedir}/../../qa/cfg/historynone.flowable.cfg.xml"
											tofile="target/test-classes/flowable.cfg.xml" overwrite="true" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<excludes>
								<exclude>**/*TestCase.java</exclude>
								<exclude>**/CompetingJobAcquisitionTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-234 -->
								<exclude>**/WSDLImporterTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-315 -->
								<exclude>**/JobExecutorTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-427 -->
								<exclude>**/HistoricTaskInstanceUpdateTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-485 -->
								<exclude>**/Historic*InstanceTest.java</exclude>
								<exclude>**/HistoryServiceTest.java</exclude>
								<exclude>**/RepeatingServiceTaskTest.java</exclude>
								<exclude>**/ProcessInstanceLogQueryTest.java</exclude>
								<exclude>org/flowable/standalone/**</exclude>
								<exclude>**/HistoricProcessInstanceQueryVersionTest.java</exclude>
								<exclude>**/NonCascadeDeleteTest.java</exclude>
								<exclude>**/HistoricProcessInstanceQueryAndWithExceptionTest.java</exclude>
								<exclude>**/HistoricJPAVariableTest.java</exclude>
								<exclude>**/VerifyDatabaseOperationsTest.java</exclude>
							</excludes>
							<runOrder>alphabetical</runOrder>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>cfghistoryasync</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo
											message="updating flowable configuration to qa/cfg/historyasync.flowable.cfg.xml" />
										<copy file="${basedir}/../../qa/cfg/historyasync.flowable.cfg.xml"
											tofile="target/test-classes/flowable.cfg.xml" overwrite="true" />
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<excludes>
								<exclude>**/*TestCase.java</exclude>
								<exclude>**/CompetingJobAcquisitionTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-234 -->
								<exclude>**/WSDLImporterTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-315 -->
								<exclude>**/JobExecutorTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-427 -->
								<exclude>**/HistoricTaskInstanceUpdateTest.java</exclude> <!-- http://jira.codehaus.org/browse/ACT-485 -->
								<exclude>**/RepeatingServiceTaskTest.java</exclude>
								<exclude>org/flowable/standalone/**</exclude>
							</excludes>
							<runOrder>alphabetical</runOrder>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>testSchemaMetaData</id>
			<activation>
				<property>
					<name>metadatabase</name>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<includes>
								<include>**/JdbcMetaDataTest.java</include>
							</includes>
							<excludes />
							<runOrder>alphabetical</runOrder>
						</configuration>
					</plugin>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.4</version>
						<executions>
							<execution>
								<id>database-test-create-schema</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="creating db schema in ${metadatabase}" />
										<ant antfile="${basedir}/../../qa/db/build.xml" target="create.db.schema">
											<property name="test_classpath" refid="maven.test.classpath" />
											<property name="database" value="${metadatabase}" />
										</ant>
										<echo message="updating flowable cfg to ${metadatabase}" />
										<ant antfile="${basedir}/../../qa/db/build.xml" target="create.cfg">
											<property name="database" value="${metadatabase}" />
										</ant>
									</tasks>
								</configuration>
							</execution>
							<execution>
								<id>database-test-drop-schema</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<tasks>
										<echo message="dropping schema in ${metadatabase}" />
										<ant antfile="${basedir}/../../qa/db/build.xml" target="drop.db.schema"
											inheritAll="false">
											<property name="test_classpath" refid="maven.test.classpath" />
											<property name="database" value="${metadatabase}" />
										</ant>
									</tasks>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!--  check with optimization flags set -->
    <profile>
      <id>cfgOptimizations</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <id>database-test-create-schema</id>
                <phase>process-test-classes</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <tasks>
                    <echo message="updating flowable configuration to qa/cfg/optimizations.flowable.cfg.xml" />
                    <copy file="${basedir}/../../qa/cfg/optimizations.flowable.cfg.xml" tofile="target/test-classes/flowable.cfg.xml" overwrite="true" />
                  </tasks>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

		<profile>
			<id>oracle</id>
			<activation>
				<property>
					<name>database</name>
					<value>oracle</value>
				</property>
			</activation>
			<dependencies>
				<dependency>
					<groupId>com.oracle.jdbc</groupId>
					<artifactId>ojdbc7</artifactId>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<profile>
			<id>oraclewithschema</id>
			<activation>
				<property>
					<name>databasewithschema</name>
					<value>oracle</value>
				</property>
			</activation>
			<dependencies>
				<dependency>
					<groupId>com.oracle.jdbc</groupId>
					<artifactId>ojdbc7</artifactId>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<profile>
            <id>oraclewithschemaasynchistory</id>
            <activation>
                <property>
                    <name>databasewithschemaasynchistory</name>
                    <value>oracle</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.oracle.jdbc</groupId>
                    <artifactId>ojdbc7</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

		<profile>
			<id>db2</id>
			<activation>
				<property>
					<name>database</name>
					<value>db2</value>
				</property>
			</activation>
			<dependencies>
				<dependency>
					<groupId>com.ibm.db2.jcc</groupId>
					<artifactId>db2jcc4</artifactId>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<profile>
            <id>db2asynchistory</id>
            <activation>
                <property>
                    <name>databaseasynchistory</name>
                    <value>db2</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.ibm.db2.jcc</groupId>
                    <artifactId>db2jcc4</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

		<profile>
			<id>mssql</id>
			<activation>
				<property>
					<name>databasemssql</name>
					<value>mssql</value>
				</property>
			</activation>
			<dependencies>
				<dependency>
					<groupId>net.sourceforge.jtds</groupId>
					<artifactId>jtds</artifactId>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<profile>
			<id>mysql</id>
			<activation>
				<property>
					<name>database</name>
					<value>mysql</value>
				</property>
			</activation>
			<dependencies>
				<dependency>
					<groupId>mysql</groupId>
					<artifactId>mysql-connector-java</artifactId>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<profile>
			<id>hsql</id>
			<activation>
				<property>
					<name>database</name>
					<value>hsql</value>
				</property>
			</activation>
			<dependencies>
				<dependency>
					<groupId>org.hsqldb</groupId>
					<artifactId>hsqldb</artifactId>
					<scope>test</scope>
				</dependency>
			</dependencies>
		</profile>

		<profile>
            <id>hsqlasynchistory</id>
            <activation>
                <property>
                    <name>databaseasynchistory</name>
                    <value>hsql</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.hsqldb</groupId>
                    <artifactId>hsqldb</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
	</profiles>

</project>


text:
import { END, START } from '../constants/Iterator'
import { IDENTITY } from '../constants/Function'
import anyIsResolved from './anyIsResolved'
import anyResolveWith from './anyResolveWith'
import unresolvedResolveWith from './unresolvedResolveWith'

const iterateAt = (iterator, history, pending, index, withFunc) => {
  if (history[index]) {
    return history[index]
  }
  if (pending[index]) {
    return pending[index]
  }
  const next = iterator.next()
  pending[index] = next
  history[index] = null
  return anyResolveWith(next, (resolvedNext) => {
    resolvedNext = withFunc(resolvedNext)
    pending[index] = null
    if (!resolvedNext.done) {
      history[index] = resolvedNext
    }
    return resolvedNext
  })
}

const fastForward = (histIterator) => {
  let next = { done: false }
  while (!next.done) {
    next = histIterator.next()
    if (!anyIsResolved(next)) {
      return unresolvedResolveWith(next, (resolvedNext) => {
        if (!resolvedNext.done) {
          return fastForward(histIterator)
        }
        return histIterator
      })
    }
  }
  return histIterator
}

const iterAt = (index, history) => {
  if (index >= 0 && history[index]) {
    const iter = history[index]
    return {
      index,
      pik: index,
      ...iter
    }
  }
  return {
    done: true
  }
}

const prevIterAt = (index, history) => {
  if (index >= 0 && history[index]) {
    const iter = history[index]
    return {
      index,
      pik: index,
      ...iter
    }
  }
}

const historicIterator = (iterator, start, withFunc) => {
  const history = []
  const pending = []
  let index = 0

  const histIterator = {
    next: () => {
      const iter = iterateAt(iterator, history, pending, index, withFunc)
      return anyResolveWith(iter, (resolvedIter) => {
        const prev = prevIterAt(index - 1, history)
        if (!resolvedIter.done) {
          resolvedIter = iterAt(index, history)
          index += 1
        }
        return {
          ...resolvedIter,
          prev
        }
      })
    },
    previous: () => {
      const iter = iterAt(index - 1, history)
      const prev = prevIterAt(index, history)
      if (index >= 0) {
        index -= 1
      }
      return {
        ...iter,
        prev
      }
    }
  }

  if (start === END) {
    return fastForward(histIterator)
  }
  return histIterator
}

/**
 * Returns iterator capable of resolving iterators that might be async, wrapping it in additional functionality.
 *
 * @private
 * @function
 * @since v0.1.0
 * @category lang.util
 * @param {Iterator} iterator The iterator to wrap
 * @param {string} start The positin to start at.
 * @return {Iterator} A new iterator for the given iterator
 * @example
 *
 * iteratorResolver(
 *  (['write', 'more'])[Symbol.iterator]()
 * )
 * //=> {
 * //   next: () => ({
 * //     value: *,
 * //     done: boolean,
 * //     pik: integer,
 * //     index: integer
 * //   }),
 * //   previous: () => ({
 * //     value: *,
 * //     done: boolean,
 * //     pik: integer,
 * //     index: integer
 * //   })
 * // }
 */
const iteratorResolver = (iterator, start = START, withFunc = IDENTITY) => {
  // TODO BRN: Break apart the historic iterator and the resolver portion of the
  // iterator so that both can be separately reused
  // NOTE BRN: Optimization here of reassigning histIterator so that we don't have to resolve it on every iteration.
  let histIterator
  histIterator = anyResolveWith(
    historicIterator(iterator, start, withFunc),
    (resolvedIterator) => {
      histIterator = resolvedIterator
      return histIterator
    }
  )

  // TODO BRN: Figure out a more efficient way of doing this rather than
  // resolving the iterator every time
  return {
    next: () =>
      anyResolveWith(histIterator, (resolvedIterator) =>
        resolvedIterator.next()
      ),
    previous: () =>
      anyResolveWith(histIterator, (resolvedIterator) =>
        resolvedIterator.previous()
      ),
    resolver: true
  }
}

export default iteratorResolver


text:
Some APIs (for example, the Nominatim API) have usage policies dictating the amount of requests you are allowed to make.
To avoid hitting these limits, it's recommended to use `ProviderCache` provider.

Since the limits on the Nominatim API are not hard limits, rate limiting outbound requests is one solution.
This could also be used to ensure that massive bills are not accidentally created (for example, due to a bug/loop issue).

## Example using Spatie's Guzzle Rate Limiter with Geocoder

First off, you'll need to install the package:
```bash
composer require spatie/guzzle-rate-limiter-middleware
```

Then create a geocoder instance using the rate limit (and in this example, the cache provider)

```php
$stack = \GuzzleHttp\HandlerStack::create();
$stack->push(\Spatie\GuzzleRateLimiterMiddleware\RateLimiterMiddleware::perSecond(1));

$httpClient = new \GuzzleHttp\Client(['handler' => $stack, 'timeout' => 30.0]);
$psr6Cache = new \Cache\Adapter\PHPArray\ArrayCachePool();
$provider = new \Geocoder\Provider\Nominatim\Nominatim($httpClient, 'https://nominatim.openstreetmap.org', 'Geocoder test');
$cachedProvider = new \Geocoder\Provider\Cache\ProviderCache($provider, $psr6Cache);
$geocoder = new \Geocoder\StatefulGeocoder($cachedProvider, 'en');

$formatter = new \Geocoder\Formatter\StringFormatter();

$gps_coords = [
    [
        'lat' => 52.516275,
        'lgn' => 13.377704,
    ],
    [
        'lat' => 51.503396,
        'lgn' => -0.12764,
    ],
    [
        'lat' => 52.516275,
        'lgn' => 13.377704,
    ]
];
foreach ($gps_coords as $gps_coord) {
    $result_list = $geocoder->reverseQuery(\Geocoder\Query\ReverseQuery::fromCoordinates($gps_coord['lat'], $gps_coord['lgn']));
    $result = $result_list->first();
    echo $formatter->format($result, '%S %n, %z %L').PHP_EOL;
}
```


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace STL
{
    /// <summary>
    /// Format
    /// </summary>
    public enum SolidFormat
    {
        /// <summary>
        /// Object created on memory
        /// </summary>
        Memory,
        /// <summary>
        /// Loaded/Saved in text format
        /// </summary>
        Ascii,
        /// <summary>
        /// Loaded/Saved in binary format
        /// </summary>
        Binary
    }
}


text:
package pubui;

import java.util.*;
import javax.swing.ImageIcon;

public class Resources
{
  private static Resources instance_ = null;
  private static ResourceBundle res_;

  private Resources()
  {
    // expects file "Resources.properties" is findable in the classpath
    res_ = ResourceBundle.getBundle( "Resources" );
  }

  public String get( String key )
  {
    return res_.getString( key );
  }

  public ImageIcon icon( String path )
  {
    try {
      return new ImageIcon( Resources.class.getResource(path) );
    }
    catch( Exception e ) {
      return null;
    }
  }

  public static Resources instance()
  {
    if (null == instance_)
      instance_ = new Resources();

    return instance_;
  }
}


text:
export function noProject(project: string) {
  return `Unable to find project '${project}' in the workspace`;
}

export function unsupportedStyles(styleFilePath: string) {
  return `Project style file found has unsupported extension: '${styleFilePath}'\nAdding 'bootstrap.min.css' to 'angular.json'`;
}

export function noMainFile(projectName: string) {
  return `Unable to find 'build.options.main' file path for project "${projectName}"`;
}

export function noModuleFile(moduleFilePath: string) {
  return `File '${moduleFilePath}' does not exist.`;
}


text:
from django.shortcuts import render
from testproject.notes.forms import NoteForm
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def create_note(request):
    if request.method == 'POST':
        form = NoteForm(None, request.POST)
        if form.is_valid():
            return None
    else:
        form = NoteForm(None)

    resp = '<form method="POST" action=".">%s<input type="submit" value="submit" /></form>' % form
    return HttpResponse(resp)


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<meta name="generator" content="JDiff v1.1.0">

<meta name="description" content="JDiff is a Javadoc doclet which generates an HTML report of all the packages, classes, constructors, methods, and fields which have been removed, added or changed in any way, including their documentation, when two APIs are compared.">
<meta name="keywords" content="diff, jdiff, javadiff, java diff, java difference, API difference, difference between two APIs, API diff, Javadoc, doclet">
<TITLE>
Field Additions Index
</TITLE>
<link href="../../../../assets/android-developer-docs.css" rel="stylesheet" type="text/css" />
<link href="../stylesheet-jdiff.css" rel="stylesheet" type="text/css" />

    Filter the Index:

All Fields

Removals

Additions

Changes

Listed as: Added,  Removed,  Changed

A
B
C
D
E
I
R
S
T
U
W
 TOP

<nobr>abc_alert_dialog_button_bar_material
</nobr>

<nobr>abc_allow_stacked_button_bar
</nobr>

<nobr>abc_btn_default_material
</nobr>

<nobr>abc_capital_off
</nobr>

<nobr>abc_capital_on
</nobr>

<nobr>abc_dialog_fixed_height_major
</nobr>

<nobr>abc_dialog_fixed_height_minor
</nobr>

<nobr>abc_dialog_fixed_width_major
</nobr>

<nobr>abc_dialog_fixed_width_minor
</nobr>

<nobr>abc_scrubber_control_off_mtrl_alpha
</nobr>

<nobr>abc_scrubber_control_to_pressed_mtrl_000
</nobr>

<nobr>abc_scrubber_control_to_pressed_mtrl_005
</nobr>

<nobr>abc_scrubber_primary_mtrl_alpha
</nobr>

<nobr>abc_scrubber_track_mtrl_alpha
</nobr>

<nobr>abc_seekbar_thumb_material
</nobr>

<nobr>abc_seekbar_track_background_height_material
</nobr>

<nobr>abc_seekbar_track_material
</nobr>

<nobr>abc_seekbar_track_progress_height_material
</nobr>

<nobr>abc_select_dialog_padding_start_material
</nobr>

<nobr>allowStacking
</nobr>

<nobr>aspectRatio
</nobr>

B
A
C
D
E
I
R
S
T
U
W
 TOP

<nobr>Base_Widget_AppCompat_ImageButton
</nobr>

<nobr>Base_Widget_AppCompat_SeekBar
</nobr>

<nobr>ButtonBarLayout_allowStacking
</nobr>

C
A
B
D
E
I
R
S
T
U
W
 TOP

<nobr>CARD_TYPE_FLAG_CONTENT
</nobr>

<nobr>CARD_TYPE_FLAG_ICON_LEFT
</nobr>

<nobr>CARD_TYPE_FLAG_ICON_RIGHT
</nobr>

<nobr>CARD_TYPE_FLAG_IMAGE_ONLY
</nobr>

<nobr>CARD_TYPE_FLAG_TITLE
</nobr>

<nobr>CONNECTION_STATE_CONNECTED
</nobr>

<nobr>CONNECTION_STATE_CONNECTING
</nobr>

<nobr>CONNECTION_STATE_DISCONNECTED
</nobr>

D
A
B
C
E
I
R
S
T
U
W
 TOP

<nobr>DEVICE_TYPE_SPEAKER
</nobr>

<nobr>DEVICE_TYPE_TV
</nobr>

E
A
B
C
D
I
R
S
T
U
W
 TOP

<nobr>EXTRA_ENABLE_URLBAR_HIDING
</nobr>

<nobr>EXTRA_TINT_ACTION_BUTTON
</nobr>

<nobr>EXTRA_UI_STYLE
</nobr>

I
A
B
C
D
E
R
S
T
U
W
 TOP

<nobr>imageButtonStyle
</nobr>

R
A
B
C
D
E
I
S
T
U
W
 TOP

<nobr>RtlUnderlay_Widget_AppCompat_ActionButton
</nobr>

<nobr>RtlUnderlay_Widget_AppCompat_ActionButton_Overflow
</nobr>

S
A
B
C
D
E
I
R
T
U
W
 TOP

<nobr>SCROLL_FLAG_SNAP
</nobr>

<nobr>SCROLL_INDICATOR_BOTTOM
</nobr>

<nobr>SCROLL_INDICATOR_END
</nobr>

<nobr>SCROLL_INDICATOR_LEFT
</nobr>

<nobr>SCROLL_INDICATOR_RIGHT
</nobr>

<nobr>SCROLL_INDICATOR_START
</nobr>

<nobr>SCROLL_INDICATOR_TOP
</nobr>

<nobr>scrollIndicatorDown
</nobr>

<nobr>scrollIndicatorUp
</nobr>

<nobr>seekBarStyle
</nobr>

<nobr>spacer
</nobr>

T
A
B
C
D
E
I
R
S
U
W
 TOP

<nobr>TAB_HIDDEN
</nobr>

<nobr>TAB_SHOWN
</nobr>

<nobr>TextAppearance_android_shadowColor
</nobr>

<nobr>TextAppearance_android_shadowDx
</nobr>

<nobr>TextAppearance_android_shadowDy
</nobr>

<nobr>TextAppearance_android_shadowRadius
</nobr>

<nobr>Theme_imageButtonStyle
</nobr>

<nobr>Theme_seekBarStyle
</nobr>

U
A
B
C
D
E
I
R
S
T
W
 TOP

<nobr>UI_STYLE_ACTIVITY_ROOT
</nobr>

<nobr>UI_STYLE_DEFAULT
</nobr>

<nobr>UI_STYLE_ENTRANCE
</nobr>

W
A
B
C
D
E
I
R
S
T
U
 TOP

<nobr>Widget_AppCompat_ImageButton
</nobr>

<nobr>Widget_AppCompat_SeekBar
</nobr>


text:
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.network.models;

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.network.fluent.models.NetworkVirtualApplianceSkuInner;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Response for ListNetworkVirtualApplianceSkus API service call. */
@Fluent
public final class NetworkVirtualApplianceSkuListResult {
    /*
     * List of Network Virtual Appliance Skus that are available.
     */
    @JsonProperty(value = "value")
    private List<NetworkVirtualApplianceSkuInner> value;

    /*
     * URL to get the next set of results.
     */
    @JsonProperty(value = "nextLink")
    private String nextLink;

    /** Creates an instance of NetworkVirtualApplianceSkuListResult class. */
    public NetworkVirtualApplianceSkuListResult() {
    }

    /**
     * Get the value property: List of Network Virtual Appliance Skus that are available.
     *
     * @return the value value.
     */
    public List<NetworkVirtualApplianceSkuInner> value() {
        return this.value;
    }

    /**
     * Set the value property: List of Network Virtual Appliance Skus that are available.
     *
     * @param value the value value to set.
     * @return the NetworkVirtualApplianceSkuListResult object itself.
     */
    public NetworkVirtualApplianceSkuListResult withValue(List<NetworkVirtualApplianceSkuInner> value) {
        this.value = value;
        return this;
    }

    /**
     * Get the nextLink property: URL to get the next set of results.
     *
     * @return the nextLink value.
     */
    public String nextLink() {
        return this.nextLink;
    }

    /**
     * Set the nextLink property: URL to get the next set of results.
     *
     * @param nextLink the nextLink value to set.
     * @return the NetworkVirtualApplianceSkuListResult object itself.
     */
    public NetworkVirtualApplianceSkuListResult withNextLink(String nextLink) {
        this.nextLink = nextLink;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (value() != null) {
            value().forEach(e -> e.validate());
        }
    }
}


text:
//: containers/SlowMap.java
// A Map implemented with ArrayLists.
package com.example.doun.chapter17containers;

import java.util.*;

//import net.mindview.util.*;

public class SlowMap<K, V> extends AbstractMap<K, V> {
    private List<K> keys = new ArrayList<K>();
    private List<V> values = new ArrayList<V>();

    public V put(K key, V value) {
        V oldValue = get(key); // The old value or null
        if (!keys.contains(key)) {
            keys.add(key);
            values.add(value);
        } else
            values.set(keys.indexOf(key), value);
        return oldValue;
    }

    public V get(Object key) { // key is type Object, not K
        if (!keys.contains(key))
            return null;
        return values.get(keys.indexOf(key));
    }

    public V remove(Object key) {
        if (!keys.contains(key))
            return null;
        V oldvalue = values.get(keys.indexOf(key));
        values.remove(keys.indexOf(key));
        keys.remove(key);
        return oldvalue;
    }

    public void clear() {
        keys.clear();
        values.clear();
    }

//    public Set<Map.Entry<K, V>> entrySet() {
//        Set<Map.Entry<K, V>> set = new HashSet<Map.Entry<K, V>>();
//        Iterator<K> ki = keys.iterator();
//        Iterator<V> vi = values.iterator();
//        while (ki.hasNext())
//            set.add(new MapEntry<K, V>(ki.next(), vi.next()));
//        return set;
//    }
    private EntrySet entrySet = new EntrySet();
    @Override public Set<Map.Entry<K,V>> entrySet() {
        return entrySet;
    }
    // Uses the 'Flyweight' pattern
    private class EntrySet extends AbstractSet<Map.Entry<K, V>> {
        @Override
        public Iterator<Map.Entry<K, V>> iterator() {
            return new Iterator<Map.Entry<K, V>>() {
                private int index = -1;
                boolean canRemove;

                public boolean hasNext() {
                    return index < keys.size() - 1;
                }

                public Map.Entry<K, V> next() {
                    canRemove = true;
                    ++index;
                    return new MapEntry<K, V>(keys.get(index), values.get(index));
                }

                public void remove() {
                    if (!canRemove) throw new IllegalStateException();
                    canRemove = false;
                    keys.remove(index);
                    values.remove(index--);
                }
            };
        }

        @SuppressWarnings("unchecked")
        @Override
        public boolean contains(Object o) {
            if (o instanceof MapEntry) {
                MapEntry<K, V> e = (MapEntry<K, V>) o;
                K key = e.getKey();
                if (keys.contains(key))
                    return e.equals(
                            new MapEntry<K, V>(key, get(key)));
            }
            return false;
        }

        @SuppressWarnings("unchecked")
        @Override
        public boolean remove(Object o) {
            if (contains(o)) {
                MapEntry<K, V> e = (MapEntry<K, V>) o;
                K key = e.getKey();
                V val = e.getValue();
                keys.remove(key);
                values.remove(val);
                return true;
            }
            return false;
        }

        @Override
        public int size() {
            return keys.size();
        }

        @Override
        public void clear() {
            keys.clear();
            values.clear();
        }
    }

    public static void main(String[] args) {
//        SlowMap<String, String> m = new SlowMap<String, String>();
//        m.putAll(Countries.capitals(15));
//        System.out.println(m);
//        System.out.println(m.get("BULGARIA"));
//        System.out.println(m.entrySet());

        SlowMap<Object, Object> map = new SlowMap();
        Maps.test(map);
    }
} /* Output:
{CAMEROON=Yaounde, CHAD=N'djamena, CONGO=Brazzaville, CAPE VERDE=Praia, ALGERIA=Algiers, COMOROS=Moroni, CENTRAL AFRICAN REPUBLIC=Bangui, BOTSWANA=Gaberone, BURUNDI=Bujumbura, BENIN=Porto-Novo, BULGARIA=Sofia, EGYPT=Cairo, ANGOLA=Luanda, BURKINA FASO=Ouagadougou, DJIBOUTI=Dijibouti}
Sofia
[CAMEROON=Yaounde, CHAD=N'djamena, CONGO=Brazzaville, CAPE VERDE=Praia, ALGERIA=Algiers, COMOROS=Moroni, CENTRAL AFRICAN REPUBLIC=Bangui, BOTSWANA=Gaberone, BURUNDI=Bujumbura, BENIN=Porto-Novo, BULGARIA=Sofia, EGYPT=Cairo, ANGOLA=Luanda, BURKINA FASO=Ouagadougou, DJIBOUTI=Dijibouti]
*///:~


text:
@interface ActivityDetailCommentsLittleCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *nameLabelWidthConstraint;

@end

@implementation ActivityDetailCommentsLittleCell

- (void)awakeFromNib {
    // Initialization code

    self.nameLabel.text = @"NSLayoutConstraint";
    CGSize size = TAutoLabelSize(self.nameLabel.text, CGSizeMake(200, self.nameLabel.height), self.nameLabel.font);
    self.nameLabelWidthConstraint.constant = size.width;
    [self layoutIfNeeded];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end


text:
RSpec::Retry adds ``:retry`` option to rspec example.
It is for randomly failing example.
If example has ``:retry``, rspec retry specified times until success.

## Installation

Add this line to your application's Gemfile:

    gem 'rspec-retry'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install rspec-retry

require in ``spec_helper.rb``

```ruby
# spec/spec_helper.rb
require 'rspec/retry'

RSpec.configure do |config|
  config.verbose_retry = true # show retry status in spec process
end
```

## Usage

```ruby
it 'should randomly success', :retry => 3 do
  rand(2).should == 1
end

it 'should succeed after a while', :retry => 3, :retry_wait=>10 do
  command('service myservice status').should == 'started'
end
# run spec (following log is shown if verbose_retry options is true)
# RSpec::Retry: 2nd try ./spec/lib/random_spec.rb:49
# RSpec::Retry: 3rd try ./spec/lib/random_spec.rb:49
```

## Configuration

- __:verbose_retry__(default: *false*) Print retry status
- __:default_retry_count__(default: *1*) If retry count is not set in example, this value is used by default
- __:retry_wait__(default: *0*) Seconds to wait between retries
- __:clear_lets_on_failure__(default: *true*) Clear memoized value for ``let`` before retrying

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


text:
"""
:mod:`ifstate` --- Interface State
=======================================
"""
# External
import capnp  # noqa

# SCION
import proto.if_state_capnp as P
from lib.packet.packet_base import Cerealizable
from lib.packet.path_mgmt.base import PathMgmtPayloadBase
from lib.packet.path_mgmt.rev_info import RevocationInfo
from lib.types import PathMgmtType as PMT

class IFStateInfo(Cerealizable):  # pragma: no cover
    """
    StateInfo is used by the beacon server to inform border routers about any
    state changes of other border routers. It contains the ID of the router, the
    state (up or down), and the current revocation token and proof.
    """
    NAME = "IFStateInfo"
    P_CLS = P.IFStateInfo

    def __init__(self, p):
        super().__init__(p)
        self.rev_info = RevocationInfo(p.revInfo)

    @classmethod
    def from_values(cls, if_id, active, rev_info):
        return cls(cls.P_CLS.new_message(ifID=if_id, active=active,
                                         revInfo=rev_info.p))

class IFStatePayload(PathMgmtPayloadBase):  # pragma: no cover
    """
    Payload for state info messages. List of IFStateInfo objects.
    """
    NAME = "IFStatePayload"
    PAYLOAD_TYPE = PMT.IFSTATE_INFOS
    P_CLS = P.IFStateInfos

    @classmethod
    def from_values(cls, infos):
        """
        :param ifstate_infos: list of IFStateInfo objects
        """
        p = cls.P_CLS.new_message()
        p.init("infos", len(infos))
        for i, info in enumerate(infos):
            p.infos[i] = info.p
        return cls(p)

class IFStateRequest(PathMgmtPayloadBase):  # pragma: no cover
    """
    IFStateRequest encapsulates a request for interface states from an ER to
    the BS.
    """
    NAME = "IFStateRequest"
    PAYLOAD_TYPE = PMT.IFSTATE_REQ
    P_CLS = P.IFStateReq
    ALL_INTERFACES = 0

    @classmethod
    def from_values(cls, if_id=ALL_INTERFACES):
        return cls(cls.P_CLS.new_message(ifID=if_id))


text:
'use strict';

function getUtm(session, requestUtm) {
  return {
    medium: requestUtm || session.utm.medium
  };
}

function saveUtmInSession(req, res, next) {
  req.session.utm = getUtm(req.session, req.param('utm_medium'));
  return next();
}

module.exports = {
  getUtm: getUtm,
  saveUtmInSession: saveUtmInSession
};


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StackExchange.Profiling;
using StackExchange.Redis;

namespace StackExchange.Opserver.Data.Redis
{
    public static class ServerUtils
    {
        public static IServer GetSingleServer(this ConnectionMultiplexer connection)
        {
            var endpoints = connection.GetEndPoints(configuredOnly: true);
            if (endpoints.Length == 1) return connection.GetServer(endpoints[0]);

            var sb = new StringBuilder("expected one endpoint, got ").Append(endpoints.Length).Append(": ");
            foreach (var ep in endpoints)
                sb.Append(ep).Append(", ");
            sb.Length -= 2;
            throw new InvalidOperationException(sb.ToString());
        }
    }
    public partial class RedisInstance
    {
        //Specially caching this since it's accessed so often
        public RedisInfo.ReplicationInfo Replication { get; private set; }

        private Cache<RedisInfo> _info;
        public Cache<RedisInfo> Info
        {
            get
            {
                return _info ?? (_info = new Cache<RedisInfo>
                {
                    CacheForSeconds = 5,
                    UpdateCache = GetFromRedisAsync("INFO", async rc =>
                    {
                        var server = rc.GetSingleServer();
                        string infoStr;
                            //TODO: Remove when StackExchange.Redis gets profiling
                            using (MiniProfiler.Current.CustomTiming("redis", "INFO"))
                        {
                            infoStr = await server.InfoRawAsync();
                        }
                        ConnectionInfo.Features = server.Features;
                        var ri = RedisInfo.FromInfoString(infoStr);
                        if (ri != null) Replication = ri.Replication;
                        return ri;
                    })
                });
            }
        }

        public RedisInfo.RedisInstanceRole Role
        {
            get
            {
                if (AllInstances.Any(r => r.SlaveInstances.Any(s => s == this)))
                    return RedisInfo.RedisInstanceRole.Slave;
                return Replication?.RedisInstanceRole ?? RedisInfo.RedisInstanceRole.Unknown;
            }
        }

        public bool IsMaster => Role == RedisInfo.RedisInstanceRole.Master;
        public bool IsSlave => Role == RedisInfo.RedisInstanceRole.Slave;
        public bool IsSlaving => IsSlave && (Replication.MasterLinkStatus != "up" || Info.SafeData(true).Replication?.MastSyncLeftBytes > 0);

        public RedisInstance TopMaster
        {
            get
            {
                var top = this;
                while (top.Master != null) { top = top.Master; }
                return top;
            }
        }

        public RedisInstance Master
        {
            get
            {
                if (Replication?.MasterHost.HasValue() == true)
                    return GetInstance(Replication.MasterHost, Replication.MasterPort);
                return AllInstances.FirstOrDefault(i => i.SlaveInstances.Contains(this));
            }
        }
        public int SlaveCount => Replication?.ConnectedSlaves ?? 0;

        public int TotalSlaveCount
        {
            get { return SlaveCount + (SlaveCount > 0 && SlaveInstances != null ? SlaveInstances.Sum(s => s?.TotalSlaveCount ?? 0) : 0); }
        }
        public List<RedisInfo.RedisSlaveInfo> SlaveConnections => Replication?.SlaveConnections;

        public List<RedisInstance> SlaveInstances
        {
            get
            {
                if (Info.LastPollStatus == FetchStatus.Success)
                {
                    return (Replication?.SlaveConnections.Select(s => s.GetServer()).ToList() ?? new List<RedisInstance>());
                }
                // If we can't poll this server, ONLY trust the other nodes we can poll
                //return AllInstances.Where(i => i.Master == this).ToList();
                return new List<RedisInstance>();
            }
        }

        public List<RedisInstance> GetAllSlavesInChain()
        {
            var slaves = SlaveInstances;
            return slaves.Union(slaves.SelectMany(i => i?.GetAllSlavesInChain())).Distinct().ToList();
        }

        public class RedisInfoSection
        {
            /// <summary>
            /// Indicates if this section is for the entire INFO
            /// Pretty much means this is from a pre-2.6 release of redis
            /// </summary>
            public bool IsGlobal { get; internal set; }
            public string Title { get; internal set; }

            public List<RedisInfoLine> Lines { get; internal set; }
        }

        public class RedisInfoLine
        {
            public bool Important { get; internal set; }
            public string Key { get; internal set; }
            public string ParsedValue { get; internal set; }
            public string OriginalValue { get; internal set; }
        }
    }
}


text:
require "spec_helper"
require "net/http"
require "net/https"

describe "resource" do
  subject { resource }

  let(:resource)  { Article.new title: "Test Title", rank: 3, body: "Test Body" }

  before { Article.all.destroy }
  before { Comment.all.destroy }

  it { should be_new }
  it { should be_dirty }
  its(:id)          { should be_nil }
  its(:created_at)  { should be_nil }
  its(:updated_at)  { should be_nil }

  context "after save" do
    before { resource.save }

    it { should_not be_nil }
    it { should_not be_dirty }
    its(:id)          { should_not be_nil }
    its(:created_at)  { should_not be_nil }
    its(:updated_at)  { should_not be_nil }

    context "when resource has attachment" do
      let(:resource)    { Article.new attachment: attachment }
      let(:attachment)  { Struct.new(:original_filename, :read, :content_type).new("x.txt", content, "plain/txt") }
      let(:content)     { "xx" }

      describe "its file content" do
        subject { Net::HTTP.get resource.attachment }

        it { should eq(content) }
      end

      context "when resource is persisted" do
        let(:resource)        { Article.create attachment: attachment }
        let(:new_attachment)  { Struct.new(:original_filename, :read, :content_type).new("x.txt", "yy", "plain/txt") }

        before { resource.update(attachment: new_attachment) }

        describe "its file content" do
          subject { Net::HTTP.get resource.attachment }

          it { should eq("yy") }
        end
      end
    end
  end

  context "when resource is a child" do
    let(:resource)  { Comment.create article: parent }
    let(:parent)    { Article.create }

    its(:article) { should be(parent) }
  end
end

describe "collection" do
  subject { collection }

  let(:collection)  { Article.all(:rank.gte => 5, :closed_at.gt => 1.day.from_now, :closed_at.lt => 3.days.from_now, :comments => { :body => /aa/im }) }

  before { Article.all.destroy }
  before { Comment.all.destroy }

  its(:size) { should eq(0) }

  context "when resource in scope is saved" do
    before do
      resource = Article.create rank: 5, closed_at: 2.day.from_now
      resource.comments.create body: "AA"
    end

    its(:size)  { should eq(1) }
    its(:count) { should eq(1) }
  end

  context "when resource out of scope is saved" do
    before { Article.create rank: 4 }

    its(:size) { should eq(0) }
    its(:count) { should eq(0) }
  end

  context "when collection are children" do
    let(:collection)  { parent.comments }
    let(:parent)      { Article.create }
    let!(:comment)    { Comment.create article: parent }

    its(:size)  { should eq(1) }
    its(:first) { should eq(comment) }
  end
end

describe User do
  subject { user }

  before do
    repository :master do
      model.all.destroy
    end
  end

  let(:model)     { described_class }
  let(:username)  { "testuser0" }
  let(:password)  { "abcdefgh" }
  let(:user)      { model.new username: username, password: password }

  it { should be_valid }

  context "when a vaid email is given" do
    let(:user) { model.new username: username, password: password, email: "#{username}@abc.com" }

    it { should be_valid }
  end

  context "when an invalid email is given" do
    let(:user) { model.new username: username, password: password, email: "dafdjlfdsaj" }

    it { should_not be_valid }
  end

  context "when an username is taken" do
    before { model.create username: username, password: password, email: "#{username}@abc.com" }

    it { should_not be_valid }
  end

  describe "class" do
    subject { model }

    let(:user) { model.create! username: username, password: password }

    its(:storage_name) { should eq("_User") }

    describe "#authenticate" do
      subject { model.authenticate username, password }

      it { should eq(user) }

      context "when adapter raise error" do
        before { DataMapper::Adapters::ParseAdapter.any_instance.stub(:sign_in).and_raise(Parse::ParseError) }

        it { should be_nil }
      end
    end
  end
end

describe Company do
  subject { described_class.new attributes }

  let(:attributes)  { { location: location } }
  let(:location)    { { "latitude" => "5.0", "longitude" => "0.0" } }

  it { should be_valid }

  context "when location is invalid" do
    let(:location) { { "latitude" => "", "longitude" => "" } }

    it { should_not be_valid }
  end
end

describe "adapter" do
  subject { adapter }

  let(:adapter) { DataMapper::Repository.adapters[:default] }

  describe "#upload_file" do
    subject { adapter.upload_file filename, content, content_type }

    let(:filename)      { "xf x.txt" }
    let(:content)       { "xx" }
    let(:content_type)  { "plain/txt" }

    it { should be_has_key("name") }
    it { should be_has_key("url") }

    describe "its content" do
      subject { Net::HTTP.get URI(url) }

      let(:url) { adapter.upload_file(filename, content, content_type)["url"] }

      it { should eq(content) }
    end
  end

  describe "#request_password_reset" do
    subject { adapter.request_password_reset email }

    before do
      repository :master do
        User.all.destroy
      end
    end

    let(:email) { user.email }
    let(:user)  { User.create! username: "a", password: "a", email: "a@abc.cn" }

    it { should eq({}) }
  end
end