You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/01/28 23:21:13 UTC

[03/96] [abbrv] [partial] Change package namespace to org.apache.usergrid

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/MapUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/MapUtils.java b/stack/core/src/main/java/org/usergrid/utils/MapUtils.java
deleted file mode 100644
index bf1e1b8..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/MapUtils.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;
-
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import static org.apache.commons.lang.StringUtils.isNotBlank;
-
-import static org.usergrid.utils.ClassUtils.cast;
-
-
-public class MapUtils extends org.apache.commons.collections.MapUtils {
-
-    public static <A, B> void addMapSet( Map<A, Set<B>> map, A a, B b ) {
-        addMapSet( map, false, a, b );
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static <A, B> void addMapSet( Map<A, Set<B>> map, boolean ignoreCase, A a, B b ) {
-
-        Set<B> setB = map.get( a );
-        if ( setB == null ) {
-            if ( ignoreCase && ( b instanceof String ) ) {
-                setB = ( Set<B> ) new TreeSet<String>( String.CASE_INSENSITIVE_ORDER );
-            }
-            else {
-                setB = new LinkedHashSet<B>();
-            }
-            map.put( a, setB );
-        }
-        setB.add( b );
-    }
-
-
-    public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, A a, B b, C c ) {
-        addMapMapSet( map, false, a, b, c );
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static <A, B, C> void addMapMapSet( Map<A, Map<B, Set<C>>> map, boolean ignoreCase, A a, B b, C c ) {
-
-        Map<B, Set<C>> mapB = map.get( a );
-        if ( mapB == null ) {
-            if ( ignoreCase && ( b instanceof String ) ) {
-                mapB = ( Map<B, Set<C>> ) new TreeMap<String, Set<C>>( String.CASE_INSENSITIVE_ORDER );
-            }
-            else {
-                mapB = new LinkedHashMap<B, Set<C>>();
-            }
-            map.put( a, mapB );
-        }
-        addMapSet( mapB, ignoreCase, b, c );
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static <A, B, C, D> void addMapMapMapSet( Map<A, Map<B, Map<C, Set<D>>>> map, boolean ignoreCase, A a, B b,
-                                                     C c, D d ) {
-        Map<B, Map<C, Set<D>>> mapB = map.get( a );
-        if ( mapB == null ) {
-            if ( ignoreCase && ( b instanceof String ) ) {
-                mapB = ( Map<B, Map<C, Set<D>>> ) new TreeMap<String, Map<C, Set<D>>>( String.CASE_INSENSITIVE_ORDER );
-            }
-            else {
-                mapB = new LinkedHashMap<B, Map<C, Set<D>>>();
-            }
-            map.put( a, mapB );
-        }
-        addMapMapSet( mapB, ignoreCase, b, c, d );
-    }
-
-
-    public static <A, B, C> C getMapMap( Map<A, Map<B, C>> map, A a, B b ) {
-
-        Map<B, C> mapB = map.get( a );
-        if ( mapB == null ) {
-            return null;
-        }
-        return mapB.get( b );
-    }
-
-
-    public static <A, B> void addMapList( Map<A, List<B>> map, A a, B b ) {
-
-        List<B> listB = map.get( a );
-        if ( listB == null ) {
-            listB = new ArrayList<B>();
-            map.put( a, listB );
-        }
-        listB.add( b );
-    }
-
-
-    public static <A, B> void addListToMapList( Map<A, List<B>> map, A a, List<B> b ) {
-
-        List<B> listB = map.get( a );
-        if ( listB == null ) {
-            listB = new ArrayList<B>();
-            map.put( a, listB );
-        }
-        listB.addAll( b );
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static <K, V> V getValue( Map<K, ?> map, K k ) {
-        V v = null;
-        try {
-            v = ( V ) map.get( k );
-        }
-        catch ( ClassCastException e ) {
-            //LOG.war( "Map value {} was not the expected class", map.get( k ), e );
-        }
-
-        return v;
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static <K, V> Map<?, ?> map( Object... objects ) {
-        Map<K, V> map = new LinkedHashMap<K, V>();
-        int i = 0;
-        while ( i < objects.length ) {
-            if ( objects[i] instanceof Map.Entry ) {
-                Map.Entry<K, V> entry = ( Entry<K, V> ) objects[i];
-                map.put( entry.getKey(), entry.getValue() );
-                i++;
-            }
-            else if ( objects[i] instanceof Map ) {
-                map.putAll( ( Map<? extends K, ? extends V> ) objects[i] );
-                i++;
-            }
-            else if ( i < ( objects.length - 1 ) ) {
-                K k = ( K ) objects[i];
-                V v = ( V ) objects[i + 1];
-                map.put( k, v );
-                i += 2;
-            }
-            else {
-                break;
-            }
-        }
-        return map;
-    }
-
-
-    private static class SimpleMapEntry<K, V> implements Map.Entry<K, V> {
-
-        private final K k;
-        private V v;
-
-
-        public SimpleMapEntry( K k, V v ) {
-            this.k = k;
-            this.v = v;
-        }
-
-
-        @Override
-        public K getKey() {
-            return k;
-        }
-
-
-        @Override
-        public V getValue() {
-            return v;
-        }
-
-
-        @Override
-        public V setValue( V v ) {
-            V oldV = this.v;
-            this.v = v;
-            return oldV;
-        }
-    }
-
-
-    public static <K, V> Map.Entry<K, V> entry( K k, V v ) {
-        return new SimpleMapEntry<K, V>( k, v );
-    }
-
-
-    public static <K, V> K getFirstKey( Map<K, V> map ) {
-        if ( map == null ) {
-            return null;
-        }
-        Entry<K, V> e = map.entrySet().iterator().next();
-        if ( e != null ) {
-            return e.getKey();
-        }
-        return null;
-    }
-
-
-    public static <V> Map<String, V> filter( Map<String, V> map, String prefix, boolean removePrefix ) {
-        Map<String, V> filteredMap = new LinkedHashMap<String, V>();
-        for ( Entry<String, V> entry : map.entrySet() ) {
-            if ( entry.getKey().startsWith( prefix ) ) {
-                if ( removePrefix ) {
-                    filteredMap.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
-                }
-                else {
-                    filteredMap.put( entry.getKey(), entry.getValue() );
-                }
-            }
-        }
-        return filteredMap;
-    }
-
-
-    public static <V> Map<String, V> filter( Map<String, V> map, String prefix ) {
-        return filter( map, prefix, false );
-    }
-
-
-    public static Properties filter( Properties properties, String prefix, boolean removePrefix ) {
-        Properties filteredProperties = new Properties();
-        for ( Entry<String, String> entry : asMap( properties ).entrySet() ) {
-            if ( entry.getKey().startsWith( prefix ) ) {
-                if ( removePrefix ) {
-                    filteredProperties.put( entry.getKey().substring( prefix.length() ), entry.getValue() );
-                }
-                else {
-                    filteredProperties.put( entry.getKey(), entry.getValue() );
-                }
-            }
-        }
-        return filteredProperties;
-    }
-
-
-    public static Properties filter( Properties properties, String prefix ) {
-        return filter( properties, prefix, false );
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static Map<String, String> asMap( Properties properties ) {
-        return cast( properties );
-    }
-
-
-    public static <S, T> HashMapBuilder<S, T> hashMap( S key, T value ) {
-        return new HashMapBuilder<S, T>().map( key, value );
-    }
-
-
-    public static class HashMapBuilder<S, T> extends HashMap<S, T> {
-        private static final long serialVersionUID = 1L;
-
-
-        public HashMapBuilder() {
-        }
-
-
-        public HashMapBuilder<S, T> map( S key, T value ) {
-            put( key, value );
-            return this;
-        }
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static Map<String, List<?>> toMapList( Map<String, ?> m ) {
-        Map<String, List<Object>> mapList = new LinkedHashMap<String, List<Object>>();
-
-        for ( Entry<String, ?> e : m.entrySet() ) {
-            if ( e.getValue() instanceof List ) {
-                addListToMapList( mapList, e.getKey(), ( List<Object> ) e.getValue() );
-            }
-            else {
-                addMapList( mapList, e.getKey(), e.getValue() );
-            }
-        }
-
-        return cast( mapList );
-    }
-
-
-    public static Map<String, ?> putPath( String path, Object value ) {
-        return putPath( null, path, value );
-    }
-
-
-    @SuppressWarnings("unchecked")
-    public static Map<String, ?> putPath( Map<String, ?> map, String path, Object value ) {
-
-        if ( map == null ) {
-            map = new HashMap<String, Object>();
-        }
-
-        int i = path.indexOf( '.' );
-        if ( i < 0 ) {
-            ( ( Map<String, Object> ) map ).put( path, value );
-            return map;
-        }
-        String segment = path.substring( 0, i ).trim();
-        if ( isNotBlank( segment ) ) {
-            Object o = map.get( segment );
-            if ( ( o != null ) && ( !( o instanceof Map ) ) ) {
-                return map;
-            }
-            Map<String, Object> subMap = ( Map<String, Object> ) o;
-            if ( subMap == null ) {
-                subMap = new HashMap<String, Object>();
-                ( ( Map<String, Object> ) map ).put( segment, subMap );
-            }
-            String subPath = path.substring( i + 1 );
-            if ( isNotBlank( subPath ) ) {
-                putPath( subMap, subPath, value );
-            }
-        }
-
-        return map;
-    }
-
-
-    public static <K, V> Map<K, V> emptyMapWithKeys( Map<K, V> map ) {
-        Map<K, V> newMap = new HashMap<K, V>();
-
-        for ( K k : map.keySet() ) {
-            newMap.put( k, null );
-        }
-
-        return newMap;
-    }
-
-
-    public static boolean hasKeys( Map<?, ?> map, String... keys ) {
-        if ( map == null ) {
-            return false;
-        }
-        for ( String key : keys ) {
-            if ( !map.containsKey( key ) ) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-
-    public static boolean hasKeys( Map<?, ?> map, Set<String> keys ) {
-        if ( map == null ) {
-            return false;
-        }
-        return map.keySet().containsAll( keys );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/NumberUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/NumberUtils.java b/stack/core/src/main/java/org/usergrid/utils/NumberUtils.java
deleted file mode 100644
index 562ada1..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/NumberUtils.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;
-
-
-public class NumberUtils {
-    public static int sign( int i ) {
-        if ( i < 0 ) {
-            return -1;
-        }
-        if ( i > 0 ) {
-            return 1;
-        }
-        return 0;
-    }
-
-
-    public static long roundLong( long l, long r ) {
-        return ( l / r ) * r;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/PasswordUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/PasswordUtils.java b/stack/core/src/main/java/org/usergrid/utils/PasswordUtils.java
deleted file mode 100644
index a5eb2a5..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/PasswordUtils.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;
-
-
-import org.apache.commons.codec.digest.DigestUtils;
-
-
-public class PasswordUtils {
-
-    public static String mongoPassword( String username, String password ) {
-        return DigestUtils.md5Hex( username + ":mongo:" + password );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/StringUtils.java b/stack/core/src/main/java/org/usergrid/utils/StringUtils.java
deleted file mode 100644
index 373748a..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/StringUtils.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;
-
-
-import java.util.Arrays;
-
-import org.apache.commons.io.IOUtils;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.usergrid.utils.ConversionUtils.string;
-
-
-public class StringUtils extends org.apache.commons.lang.StringUtils {
-
-    private static final Logger LOG = LoggerFactory.getLogger( StringUtils.class );
-
-
-    public static Object lower( Object obj ) {
-        if ( !( obj instanceof String ) ) {
-            return obj;
-        }
-        return ( ( String ) obj ).toLowerCase();
-    }
-
-
-    public static String stringOrSubstringAfterLast( String str, char c ) {
-        if ( str == null ) {
-            return null;
-        }
-        int i = str.lastIndexOf( c );
-        if ( i != -1 ) {
-            return str.substring( i + 1 );
-        }
-        return str;
-    }
-
-
-    public static String stringOrSubstringBeforeLast( String str, char c ) {
-        if ( str == null ) {
-            return null;
-        }
-        int i = str.lastIndexOf( c );
-        if ( i != -1 ) {
-            return str.substring( 0, i );
-        }
-        return str;
-    }
-
-
-    public static String stringOrSubstringBeforeFirst( String str, char c ) {
-        if ( str == null ) {
-            return null;
-        }
-        int i = str.indexOf( c );
-        if ( i != -1 ) {
-            return str.substring( 0, i );
-        }
-        return str;
-    }
-
-
-    public static String stringOrSubstringAfterFirst( String str, char c ) {
-        if ( str == null ) {
-            return null;
-        }
-        int i = str.indexOf( c );
-        if ( i != -1 ) {
-            return str.substring( i + 1 );
-        }
-        return str;
-    }
-
-
-    public static String compactWhitespace( String str ) {
-        if ( str == null ) {
-            return null;
-        }
-        boolean prevWS = false;
-        StringBuilder builder = new StringBuilder();
-        for ( int i = 0; i < str.length(); i++ ) {
-            char c = str.charAt( i );
-            if ( Character.isWhitespace( c ) ) {
-                if ( !prevWS ) {
-                    builder.append( ' ' );
-                }
-                prevWS = true;
-            }
-            else {
-                prevWS = false;
-                builder.append( c );
-            }
-        }
-        return builder.toString().trim();
-    }
-
-
-    /** @return new string with replace applied */
-    public static String replaceAll( String source, String find, String replace ) {
-        if ( source == null ) {
-            return null;
-        }
-        while ( true ) {
-            String old = source;
-            source = source.replaceAll( find, replace );
-            if ( source.equals( old ) ) {
-                return source;
-            }
-        }
-    }
-
-
-    public static String toString( Object obj ) {
-        return string( obj );
-    }
-
-
-    public static String toStringFormat( Object obj, String format ) {
-        if ( obj != null ) {
-            if ( format != null ) {
-                if ( obj.getClass().isArray() ) {
-                    return String.format( format, Arrays.toString( ( Object[] ) obj ) );
-                }
-                return String.format( format, string( obj ) );
-            }
-            else {
-                return string( obj );
-            }
-        }
-        return "";
-    }
-
-
-    public static boolean isString( Object obj ) {
-        return obj instanceof String;
-    }
-
-
-    public static boolean isStringOrNull( Object obj ) {
-        if ( obj == null ) {
-            return true;
-        }
-        return obj instanceof String;
-    }
-
-
-    public static String readClasspathFileAsString( String filePath ) {
-        try {
-            return IOUtils.toString( StringUtils.class.getResourceAsStream( filePath ) );
-        }
-        catch ( Exception e ) {
-            LOG.error( "Error getting file from classpath: " + filePath, e );
-        }
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/TimeUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/TimeUtils.java b/stack/core/src/main/java/org/usergrid/utils/TimeUtils.java
deleted file mode 100644
index 92dabf1..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/TimeUtils.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;
-
-
-import com.google.common.base.CharMatcher;
-import com.google.common.base.Splitter;
-
-
-public class TimeUtils {
-    /**
-     * Jira-style duration parser. Supported duration strings are: <ul> <li>'S': milliseconds</li> <li>'s': seconds</li>
-     * <li>'m': minutes</li> <li>'h': hours</li> <li>'d': days</li> </ul>
-     * <p/>
-     * Durations can be compound statements in any order as long as they are separated by a ',' (comma). Eg. "1d,14h,3s"
-     * to get the millisecond equivalent of one day, fourteen hours and 3 seconds.
-     * <p/>
-     * Numbers with no durations will be treated as raw millisecond values
-     *
-     * @return the number of milliseconds representing the duration
-     */
-    public static long millisFromDuration( String durationStr ) {
-        long total = 0;
-        MultiplierToken mt;
-        long dur;
-        for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) {
-            dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) );
-            mt = MultiplierToken.from( val.charAt( val.length() - 1 ) );
-            total += ( mt.multiplier * dur );
-        }
-        return total;
-    }
-
-
-    private enum MultiplierToken {
-        MILSEC_TOKEN( 'S', 1L ),
-        SEC_TOKEN( 's', 1000L ),
-        MIN_TOKEN( 'm', 60000L ),
-        HOUR_TOKEN( 'h', 3600000L ),
-        DAY_TOKEN( 'd', 86400000L );
-
-        final char token;
-        final long multiplier;
-
-
-        MultiplierToken( char token, long multiplier ) {
-            this.token = token;
-            this.multiplier = multiplier;
-        }
-
-
-        static MultiplierToken from( char c ) {
-            switch ( c ) {
-                case 's':
-                    return SEC_TOKEN;
-                case 'm':
-                    return MIN_TOKEN;
-                case 'h':
-                    return HOUR_TOKEN;
-                case 'd':
-                    return DAY_TOKEN;
-                case 'S':
-                    return MILSEC_TOKEN;
-                default:
-                    break;
-            }
-
-            if ( CharMatcher.DIGIT.matches( c ) ) {
-                return MILSEC_TOKEN;
-            }
-            throw new IllegalArgumentException( "Duration token was not on of [S,s,m,h,d] but was " + c );
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/UUIDUtils.java b/stack/core/src/main/java/org/usergrid/utils/UUIDUtils.java
deleted file mode 100644
index 110a20c..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/UUIDUtils.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;
-
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReentrantLock;
-
-import com.fasterxml.uuid.EthernetAddress;
-import com.fasterxml.uuid.UUIDComparator;
-
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_HI;
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_LO;
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_MID;
-import static com.fasterxml.uuid.impl.UUIDUtil.BYTE_OFFSET_CLOCK_SEQUENCE;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.commons.codec.binary.Base64.decodeBase64;
-import static org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString;
-
-import static org.usergrid.utils.ConversionUtils.bytes;
-import static org.usergrid.utils.ConversionUtils.uuid;
-
-
-public class UUIDUtils {
-    private static final Logger LOG = LoggerFactory.getLogger( UUIDUtils.class );
-    private static final int[] MICROS = new int[1000];
-
-
-    static {
-        for ( int x = 0; x < 1000; x++ ) {
-            MICROS[x] = x * 10;
-        }
-    }
-
-
-    private static ReentrantLock tsLock = new ReentrantLock( true );
-
-    public static final UUID MIN_TIME_UUID = UUID.fromString( "00000000-0000-1000-8000-000000000000" );
-
-    public static final UUID MAX_TIME_UUID = UUID.fromString( "ffffffff-ffff-1fff-bfff-ffffffffffff" );
-
-    public static final UUID ZERO_UUID = new UUID( 0, 0 );
-
-    private static long timestampMillisNow = System.currentTimeMillis();
-
-    private static AtomicInteger currentMicrosPoint = new AtomicInteger( 0 );
-    private static AtomicInteger customMicrosPointer = new AtomicInteger( 0 );
-
-
-    /**
-     * Return the "next" UUID in micro second resolution. <b>WARNING</b>: this is designed to return the next unique
-     * timestamped UUID for this JVM. Depending on velocity of the call, this method may block internally to insure that
-     * "now" is kept in sync with the UUIDs being generated by this call.
-     * <p/>
-     * In other words, we will intentionally burn CPU insuring that this method is not executed more than 10k -1 times
-     * per millisecond and guarantee that those microseconds held within are sequential.
-     * <p/>
-     * If we did not do this, you would get <b>timestamp collision</b> even though the UUIDs will technically be
-     * 'unique.'
-     */
-    public static java.util.UUID newTimeUUID() {
-        // get & inc counter, but roll on 1k (because we divide by 10 on retrieval)
-        // if count + currentMicro > 1k, block and roll
-        tsLock.lock();
-        long ts = System.currentTimeMillis();
-        if ( ts > timestampMillisNow ) {
-            timestampMillisNow = ts;
-            currentMicrosPoint.set( 0 );
-        }
-        int pointer = currentMicrosPoint.getAndIncrement();
-        try {
-            if ( pointer > 990 ) {
-                TimeUnit.MILLISECONDS.sleep( 1L );
-            }
-        }
-        catch ( Exception ex ) {
-            ex.printStackTrace();
-        }
-        finally {
-            tsLock.unlock();
-        }
-        return newTimeUUID( ts, MICROS[pointer] );
-    }
-
-
-    private static final long KCLOCK_OFFSET = 0x01b21dd213814000L;
-    private static final long KCLOCK_MULTIPLIER_L = 10000L;
-
-    private static final Random CLOCK_SEQ_RANDOM = new Random();
-
-
-    // 14 bits of randomness
-    private static int getRandomClockSequence() {
-        return CLOCK_SEQ_RANDOM.nextInt() & 0x3FFF;
-    }
-
-
-    private static void setTimestamp( long timestamp, byte[] uuidBytes, int clockSeq, int timeOffset ) {
-
-        timestamp *= KCLOCK_MULTIPLIER_L;
-        timestamp += KCLOCK_OFFSET;
-        timestamp += timeOffset;
-
-        // Set random clock sequence
-        uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] = ( byte ) ( clockSeq >> 8 );
-        uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE + 1] = ( byte ) clockSeq;
-
-        // Set variant
-        uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] &= 0x3F;
-        uuidBytes[BYTE_OFFSET_CLOCK_SEQUENCE] |= 0x80;
-        setTime( uuidBytes, timestamp );
-    }
-
-
-    @SuppressWarnings("all")
-    private static void setTime( byte[] uuidBytes, long timestamp ) {
-
-        // Time fields aren't nicely split across the UUID, so can't just
-        // linearly dump the stamp:
-        int clockHi = ( int ) ( timestamp >>> 32 );
-        int clockLo = ( int ) timestamp;
-
-        uuidBytes[BYTE_OFFSET_CLOCK_HI] = ( byte ) ( clockHi >>> 24 );
-        uuidBytes[BYTE_OFFSET_CLOCK_HI + 1] = ( byte ) ( clockHi >>> 16 );
-        uuidBytes[BYTE_OFFSET_CLOCK_MID] = ( byte ) ( clockHi >>> 8 );
-        uuidBytes[BYTE_OFFSET_CLOCK_MID + 1] = ( byte ) clockHi;
-
-        uuidBytes[BYTE_OFFSET_CLOCK_LO] = ( byte ) ( clockLo >>> 24 );
-        uuidBytes[BYTE_OFFSET_CLOCK_LO + 1] = ( byte ) ( clockLo >>> 16 );
-        uuidBytes[BYTE_OFFSET_CLOCK_LO + 2] = ( byte ) ( clockLo >>> 8 );
-        uuidBytes[BYTE_OFFSET_CLOCK_LO + 3] = ( byte ) clockLo;
-
-        // Set version
-        uuidBytes[BYTE_OFFSET_CLOCK_HI] &= 0x0F;
-        uuidBytes[BYTE_OFFSET_CLOCK_HI] |= 0x10;
-    }
-
-
-    /**
-     * Generate a timeuuid with the given timestamp in milliseconds and the time offset. Useful when you need to
-     * generate sequential UUIDs for the same period in time. I.E
-     * <p/>
-     * newTimeUUID(1000, 0) <br/> newTimeUUID(1000, 1) <br /> newTimeUUID(1000, 2) <br />
-     * <p/>
-     * etc.
-     * <p/>
-     * Only use this method if you are absolutely sure you need it. When it doubt use the method without the timestamp
-     * offset
-     *
-     * @param ts The timestamp in milliseconds
-     * @param timeoffset The offset, which should always be <= 10000. If you go beyond this range, the millisecond will
-     * be incremented since this is beyond the possible values when coverrting from millis to 1/10 microseconds stored
-     * in the time uuid.
-     */
-    public static UUID newTimeUUID( long ts, int timeoffset ) {
-        if ( ts == 0 ) {
-            return newTimeUUID();
-        }
-
-        byte[] uuidBytes = new byte[16];
-        // 47 bits of randomness
-        EthernetAddress eth = EthernetAddress.constructMulticastAddress();
-        eth.toByteArray( uuidBytes, 10 );
-        setTimestamp( ts, uuidBytes, getRandomClockSequence(), timeoffset );
-
-        return uuid( uuidBytes );
-    }
-
-
-    /**
-     * Generate a new UUID with the given time stamp in milliseconds. This method guarantees that subsequent calls will
-     * be of increasing value chronologically. If a large number of subsequent calls are made to this method (>1000)
-     * with the same timestamp, you will have non-unique temporal values stored in your UUID.
-     */
-    public static UUID newTimeUUID( long ts ) {
-        tsLock.lock();
-        int pointer = customMicrosPointer.getAndIncrement();
-        try {
-            if ( pointer > 990 ) {
-                customMicrosPointer.set( 0 );
-            }
-        }
-        finally {
-            tsLock.unlock();
-        }
-        return newTimeUUID( ts, MICROS[pointer] );
-    }
-
-
-    public static UUID minTimeUUID( long ts ) {
-        byte[] uuidBytes = new byte[16];
-        setTimestamp( ts, uuidBytes, 0, 0 );
-
-        return uuid( uuidBytes );
-    }
-
-
-    public static UUID maxTimeUUID( long ts ) {
-        byte[] uuidBytes = new byte[16];
-        uuidBytes[10] = ( byte ) 0xFF;
-        uuidBytes[11] = ( byte ) 0xFF;
-        uuidBytes[12] = ( byte ) 0xFF;
-        uuidBytes[13] = ( byte ) 0xFF;
-        uuidBytes[14] = ( byte ) 0xFF;
-        uuidBytes[15] = ( byte ) 0xFF;
-        setTimestamp( ts, uuidBytes, 0x3FFF, 0x1FFF );
-
-        return uuid( uuidBytes );
-    }
-
-
-    /** Returns the minimum UUID */
-    public static UUID min( UUID first, UUID second ) {
-        if ( first == null ) {
-            if ( second == null ) {
-                return null;
-            }
-            return second;
-        }
-
-        if ( second == null ) {
-            return first;
-        }
-
-        if ( compare( first, second ) < 0 ) {
-            return first;
-        }
-        return second;
-    }
-
-
-    /** Returns the minimum UUID */
-    public static UUID max( UUID first, UUID second ) {
-        if ( first == null ) {
-            if ( second == null ) {
-                return null;
-            }
-            return second;
-        }
-
-        if ( second == null ) {
-            return first;
-        }
-
-        if ( compare( first, second ) < 0 ) {
-            return second;
-        }
-        return first;
-    }
-
-
-    /** Returns a UUID that is -1 of the passed uuid, sorted by time uuid only */
-    public static UUID decrement( UUID uuid ) {
-        if ( !isTimeBased( uuid ) ) {
-            throw new IllegalArgumentException( "The uuid must be a time type" );
-        }
-
-
-        //timestamp is in the 60 bit timestamp
-        long timestamp = uuid.timestamp();
-        timestamp--;
-
-        if ( timestamp < 0 ) {
-            throw new IllegalArgumentException( "You must specify a time uuid with a timestamp > 0" );
-        }
-
-        //get our bytes, then set the smaller timestamp into it
-        byte[] uuidBytes = bytes( uuid );
-
-        setTime( uuidBytes, timestamp );
-
-        return uuid( uuidBytes );
-    }
-
-
-    public static boolean isTimeBased( UUID uuid ) {
-        if ( uuid == null ) {
-            return false;
-        }
-        return uuid.version() == 1;
-    }
-
-
-    public static long getTimestampInMillis( UUID uuid ) {
-        if ( uuid == null ) {
-            return 0;
-        }
-        long t = uuid.timestamp();
-        return ( t - KCLOCK_OFFSET ) / KCLOCK_MULTIPLIER_L;
-    }
-
-
-    public static long getTimestampInMicros( UUID uuid ) {
-        if ( uuid == null ) {
-            return 0;
-        }
-        long t = uuid.timestamp();
-        return ( t - KCLOCK_OFFSET ) / 10;
-    }
-
-
-    public static UUID tryGetUUID( String s ) {
-        if ( s == null ) {
-            return null;
-        }
-        if ( s.length() != 36 ) {
-            return null;
-        }
-        // 8-4-4-4-12
-        // 0-7,8,9-12,13,14-17,18,19-22,23,24-35
-        if ( s.charAt( 8 ) != '-' ) {
-            return null;
-        }
-        if ( s.charAt( 13 ) != '-' ) {
-            return null;
-        }
-        if ( s.charAt( 18 ) != '-' ) {
-            return null;
-        }
-        if ( s.charAt( 23 ) != '-' ) {
-            return null;
-        }
-        UUID uuid = null;
-        try {
-            uuid = UUID.fromString( s );
-        }
-        catch ( Exception e ) {
-            LOG.info( "Could not convert String {} into a UUID", s, e );
-        }
-        return uuid;
-    }
-
-
-    public static boolean isUUID( String s ) {
-        return tryGetUUID( s ) != null;
-    }
-
-
-    public static UUID tryExtractUUID( String s ) {
-        if ( s == null ) {
-            return null;
-        }
-        if ( s.length() < 36 ) {
-            return null;
-        }
-        return tryGetUUID( s.substring( 0, 36 ) );
-    }
-
-
-    public static UUID tryExtractUUID( String s, int offset ) {
-        if ( s == null ) {
-            return null;
-        }
-        if ( ( s.length() - offset ) < 36 ) {
-            return null;
-        }
-        return tryGetUUID( s.substring( offset, offset + 36 ) );
-    }
-
-
-    public static String toBase64( UUID id ) {
-        if ( id == null ) {
-            return null;
-        }
-        return encodeBase64URLSafeString( bytes( id ) );
-    }
-
-
-    public static UUID fromBase64( String str ) {
-        if ( str == null ) {
-            return null;
-        }
-        byte[] bytes = decodeBase64( str );
-        if ( bytes.length != 16 ) {
-            return null;
-        }
-        return uuid( bytes );
-    }
-
-
-    public static int compare( UUID u1, UUID u2 ) {
-        return UUIDComparator.staticCompare( u1, u2 );
-    }
-
-
-    public static List<UUID> sort( List<UUID> uuids ) {
-        Collections.sort( uuids, new UUIDComparator() );
-        return uuids;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/Version.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/Version.java b/stack/core/src/main/java/org/usergrid/utils/Version.java
deleted file mode 100644
index 0c4ac32..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/Version.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;
-
-/*******************************************************************************
- * Copyright (c) 2010, Schley Andrew Kutz All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * - Neither the name of the Schley Andrew Kutz nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- ******************************************************************************/
-
-import java.io.Serializable;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.lang.StringUtils;
-
-
-/**
- * The Version class can be used to parse a standard version string into its four components,
- * MAJOR.MINOR.BUILD.REVISION.
- */
-public class Version implements Serializable, Cloneable, Comparable<Version> {
-    /** A serial version UID. */
-    private static final long serialVersionUID = -4316270526722986552L;
-
-    /** A pattern to match the standard version format MAJOR.MINOR.BUILD.REVISION. */
-    private static final Pattern STD_VERSION_PATT =
-            Pattern.compile( "^([^\\d]*?)(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:\\.(\\d+))?(.*)$" );
-
-
-    /** Initialize a new Version object that is set to "0.0.0.0". */
-    public Version() {
-    }
-
-
-    /** Everything before the version in the string that was parsed. */
-    private String prefix;
-
-    /** Everything after the version in the string that was parsed. */
-    private String suffix;
-
-    /** The String that was parsed to create this version object. */
-    private String rawVersion;
-
-
-    /**
-     * Gets everything before the version in the string that was parsed.
-     *
-     * @return Everything before the version in the string that was parsed.
-     */
-    public String getPrefix() {
-        return prefix;
-    }
-
-
-    /**
-     * Parses a new Version object from a String.
-     *
-     * @param toParse The String object to parse.
-     *
-     * @return A new Version object.
-     *
-     * @throws Exception When there is an error parsing the String.
-     */
-    public static Version parse( String toParse ) throws Exception {
-        Matcher m = STD_VERSION_PATT.matcher( toParse );
-
-        if ( !m.find() ) {
-            throw new Exception( String.format( "Error parsing version from '%s'", toParse ) );
-        }
-
-        Version v = new Version();
-        v.rawVersion = toParse;
-        v.prefix = m.group( 1 );
-
-        if ( StringUtils.isNotEmpty( m.group( 2 ) ) ) {
-            v.setMajor( m.group( 2 ) );
-        }
-
-        if ( StringUtils.isNotEmpty( m.group( 3 ) ) ) {
-            v.setMinor( m.group( 3 ) );
-        }
-
-        if ( StringUtils.isNotEmpty( m.group( 4 ) ) ) {
-            v.setBuild( m.group( 4 ) );
-        }
-
-        if ( StringUtils.isNotEmpty( m.group( 5 ) ) ) {
-            v.setRevision( m.group( 5 ) );
-        }
-
-        v.suffix = m.group( 6 );
-
-        return v;
-    }
-
-
-    /** The version's MAJOR component. */
-    private String major = "0";
-
-
-    /**
-     * Sets the version's MAJOR component.
-     *
-     * @param toSet The version's MAJOR component.
-     *
-     * @throws IllegalArgumentException When a null or non-numeric value is given.
-     */
-    public void setMajor( String toSet ) throws IllegalArgumentException {
-        if ( StringUtils.isEmpty( toSet ) ) {
-            throw new IllegalArgumentException( "Argument is null" );
-        }
-
-        if ( !toSet.matches( "\\d+" ) ) {
-            throw new IllegalArgumentException( "Argument is not numeric" );
-        }
-
-        if ( numberOfComponents < 1 ) {
-            numberOfComponents = 1;
-        }
-
-        major = toSet;
-    }
-
-
-    /** The version's MAJOR component as an integer. */
-    private int getMajorAsInt() {
-        return Integer.parseInt( major );
-    }
-
-
-    /** The version's MINOR component. */
-    private String minor = "0";
-
-
-    /**
-     * Sets the version's MINOR component.
-     *
-     * @param toSet The version's MINOR component.
-     *
-     * @throws IllegalArgumentException When a null or non-numeric value is given.
-     */
-    public void setMinor( String toSet ) throws IllegalArgumentException {
-        if ( StringUtils.isEmpty( toSet ) ) {
-            throw new IllegalArgumentException( "Argument is null" );
-        }
-
-        if ( !toSet.matches( "\\d+" ) ) {
-            throw new IllegalArgumentException( "Argument is not numeric" );
-        }
-
-        if ( numberOfComponents < 2 ) {
-            numberOfComponents = 2;
-        }
-
-        minor = toSet;
-    }
-
-
-    /** The version's MINOR component as an integer. */
-    private int getMinorAsInt() {
-        return Integer.parseInt( minor );
-    }
-
-
-    /** The version's BUILD component. */
-    private String build = "0";
-
-
-    /** The version's BUILD component as an integer. */
-    private int getBuildAsInt() {
-        return Integer.parseInt( build );
-    }
-
-
-    /**
-     * Gets the version's BUILD component.
-     *
-     * @return The version's BUILD component.
-     */
-    public String getBuild() {
-        return build;
-    }
-
-
-    /**
-     * Sets the version's BUILD component.
-     *
-     * @param toSet The version's BUILD component.
-     *
-     * @throws IllegalArgumentException When a null or non-numeric value is given.
-     */
-    public void setBuild( String toSet ) throws IllegalArgumentException {
-        if ( StringUtils.isEmpty( toSet ) ) {
-            throw new IllegalArgumentException( "Argument is null" );
-        }
-
-        if ( !toSet.matches( "\\d+" ) ) {
-            throw new IllegalArgumentException( "Argument is not numeric" );
-        }
-
-        if ( numberOfComponents < 3 ) {
-            numberOfComponents = 3;
-        }
-
-        build = toSet;
-    }
-
-
-    /**
-     * Sets the version's BUILD component.
-     *
-     * @param toSet The version's BUILD component.
-     */
-    public void setBuild( int toSet ) {
-        setBuild( String.valueOf( toSet ) );
-    }
-
-
-    /** The version's REVISION component. */
-    private String revision = "0";
-
-
-    /** The version's REVISION component as an integer. */
-    private int getRevisionAsInt() {
-        return Integer.parseInt( revision );
-    }
-
-
-    /**
-     * Sets the version's REVISION component.
-     *
-     * @param toSet The version's REVISION component.
-     *
-     * @throws IllegalArgumentException When a null or non-numeric value is given.
-     */
-    public void setRevision( String toSet ) throws IllegalArgumentException {
-        if ( StringUtils.isEmpty( toSet ) ) {
-            throw new IllegalArgumentException( "Argument is null" );
-        }
-
-        if ( !toSet.matches( "\\d+" ) ) {
-            throw new IllegalArgumentException( "Argument is not numeric" );
-        }
-
-        if ( numberOfComponents < 4 ) {
-            numberOfComponents = 4;
-        }
-
-        revision = toSet;
-    }
-
-
-    /**
-     * The number of components that make up the version. The value will always be between 1 (inclusive) and 4
-     * (inclusive).
-     */
-    private int numberOfComponents;
-
-
-    @Override
-    @SuppressWarnings("all")
-    public Object clone() throws CloneNotSupportedException {
-        Version v = new Version();
-
-        v.rawVersion = rawVersion;
-        v.prefix = prefix;
-        v.suffix = suffix;
-
-        v.numberOfComponents = numberOfComponents;
-
-        v.major = major;
-        v.minor = minor;
-        v.build = build;
-        v.revision = revision;
-
-        return v;
-    }
-
-
-    @Override
-    public boolean equals( Object toCompare ) {
-        // Compare pointers
-        if ( toCompare == this ) {
-            return true;
-        }
-
-        // Compare types
-        if ( !( toCompare instanceof Version ) ) {
-            return false;
-        }
-
-        return compareTo( ( Version ) toCompare ) == 0;
-    }
-
-
-    @Override
-    public int hashCode() {
-        return toString().hashCode();
-    }
-
-
-    @Override
-    public String toString() {
-        return String.format( "%s.%s.%s.%s", major, minor, build, revision );
-    }
-
-
-    /**
-     * Gets the version as a string using the specified number of components.
-     *
-     * @param components The number of components. Values less than 1 will be treated as 1 and values greater than 4
-     * will be treated as 4.
-     *
-     * @return The version as a string using the specified number of components.
-     */
-    public String toString( int components ) {
-        StringBuilder buff = new StringBuilder();
-        buff.append( major );
-
-        if ( components > 4 ) {
-            components = 4;
-        }
-
-        switch ( components ) {
-            case 2:
-                buff.append( String.format( ".%s", minor ) );
-                break;
-            case 3:
-                buff.append( String.format( ".%s.%s", minor, build ) );
-                break;
-            case 4:
-                buff.append( String.format( ".%s.%s.%s", minor, build, revision ) );
-                break;
-            default:
-                break;
-        }
-
-        return buff.toString();
-    }
-
-
-    private int compareInts( int x, int y ) {
-        if ( x == y ) {
-            return 0;
-        }
-
-        if ( x < y ) {
-            return -1;
-        }
-
-        return 1;
-    }
-
-
-    @Override
-    public int compareTo( Version toCompare ) {
-        int result = toString().compareTo( toCompare.toString() );
-
-        if ( result == 0 ) {
-            return result;
-        }
-
-        result = compareInts( getMajorAsInt(), toCompare.getMajorAsInt() );
-
-        if ( result != 0 ) {
-            return result;
-        }
-
-        result = compareInts( getMinorAsInt(), toCompare.getMinorAsInt() );
-
-        if ( result != 0 ) {
-            return result;
-        }
-
-        result = compareInts( getBuildAsInt(), toCompare.getBuildAsInt() );
-
-        if ( result != 0 ) {
-            return result;
-        }
-
-        result = compareInts( getRevisionAsInt(), toCompare.getRevisionAsInt() );
-
-        if ( result != 0 ) {
-            return result;
-        }
-
-        return result;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/java/org/usergrid/utils/package-info.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/utils/package-info.java b/stack/core/src/main/java/org/usergrid/utils/package-info.java
deleted file mode 100644
index 740805c..0000000
--- a/stack/core/src/main/java/org/usergrid/utils/package-info.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.usergrid.utils;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/resources/usergrid-core-context.xml
----------------------------------------------------------------------
diff --git a/stack/core/src/main/resources/usergrid-core-context.xml b/stack/core/src/main/resources/usergrid-core-context.xml
index 85864b9..67afbbf 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -9,7 +9,7 @@
 	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
 	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
 
-	<context:component-scan base-package="org.usergrid.persistence" />
+	<context:component-scan base-package="org.apache.usergrid.persistence" />
 	<context:annotation-config />
 
     <aop:config proxy-target-class="true"/>
@@ -27,10 +27,10 @@
 	
 	<!-- The Time Resolution used for the cluster -->
 	<bean id="microsecondsTimeResolution" class="me.prettyprint.cassandra.service.clock.MicrosecondsClockResolution" />
-  <bean id="traceTagManager" class="org.usergrid.persistence.cassandra.util.TraceTagManager"/>
-  <bean id="traceTagReporter" class="org.usergrid.persistence.cassandra.util.Slf4jTraceTagReporter"/>
+  <bean id="traceTagManager" class="org.apache.usergrid.persistence.cassandra.util.TraceTagManager"/>
+  <bean id="traceTagReporter" class="org.apache.usergrid.persistence.cassandra.util.Slf4jTraceTagReporter"/>
 
-  <bean id="taggedOpTimer" class="org.usergrid.persistence.cassandra.util.TaggedOpTimer">
+  <bean id="taggedOpTimer" class="org.apache.usergrid.persistence.cassandra.util.TaggedOpTimer">
     <constructor-arg ref="traceTagManager"/>
   </bean>
 
@@ -54,20 +54,20 @@
     <bean id="loadBalancingPolicy" class="me.prettyprint.cassandra.connection.DynamicLoadBalancingPolicy"/>
 
 	<!--  locking for a single node -->	
-	<bean name="lockManager" class="org.usergrid.locking.singlenode.SingleNodeLockManagerImpl" />
+	<bean name="lockManager" class="org.apache.usergrid.locking.singlenode.SingleNodeLockManagerImpl" />
 	
 	<!--  hector based locks -->
 	<!-- Note that if this is deployed in a production cluster, the RF on the keyspace MUST be updated to use an odd number for it's replication Factor.
 		  Even numbers can potentially case the locks to fail, via "split brain" when read at QUORUM on lock verification-->
 	
-	<!--  <bean name="lockManager" class="org.usergrid.locking.cassandra.HectorLockManagerImpl" >
+	<!--  <bean name="lockManager" class="org.apache.usergrid.locking.cassandra.HectorLockManagerImpl" >
 		<property name="cluster" ref="cassandraCluster"/>
 		<property name="keyspaceName" value="${cassandra.lock.keyspace}"/>
 	</bean>-->
 	
 	<!--  zookeeper locks -->
 	<!--
-	<bean name="lockManager" class="org.usergrid.locking.zookeeper.ZooKeeperLockManagerImpl" >
+	<bean name="lockManager" class="org.apache.usergrid.locking.zookeeper.ZooKeeperLockManagerImpl" >
 		<property name="hostPort" value="${zookeeper.url}"/>
 		<property name="sessionTimeout" value="2000"/>
 		<property name="maxAttempts" value="10"/>
@@ -76,7 +76,7 @@
 		
 	
 	<bean id="cassandraService"
-		class="org.usergrid.persistence.cassandra.CassandraService" init-method="init" destroy-method="destroy">
+		class="org.apache.usergrid.persistence.cassandra.CassandraService" init-method="init" destroy-method="destroy">
 		<constructor-arg ref="properties" />
 		<constructor-arg ref="cassandraCluster" />
 		<constructor-arg ref="cassandraHostConfigurator" />
@@ -91,30 +91,30 @@
 	
 
 	<bean id="entityManagerFactory"
-		class="org.usergrid.persistence.cassandra.EntityManagerFactoryImpl">
+		class="org.apache.usergrid.persistence.cassandra.EntityManagerFactoryImpl">
 		<constructor-arg ref="cassandraService" />
         <constructor-arg ref="counterUtils"/>
         <constructor-arg value="${usergrid.counter.skipAggregate}"/>
     </bean>
 
     <bean id="queueManagerFactory"
-          class="org.usergrid.mq.cassandra.QueueManagerFactoryImpl">
+          class="org.apache.usergrid.mq.cassandra.QueueManagerFactoryImpl">
         <constructor-arg ref="cassandraService" />
         <constructor-arg ref="counterUtils"/>
         <constructor-arg ref="lockManager"/>
         <constructor-arg value="${usergrid.queue.lock.timeout}"/>
     </bean>
 
-    <bean id="simpleBatcher" class="org.usergrid.count.SimpleBatcher">
+    <bean id="simpleBatcher" class="org.apache.usergrid.count.SimpleBatcher">
         <property name="batchSubmitter" ref="batchSubmitter"/>
         <property name="batchSize" value="${usergrid.counter.batch.size}"/>
     </bean>
 
-    <bean id="batchSubmitter" class="org.usergrid.count.CassandraSubmitter">
+    <bean id="batchSubmitter" class="org.apache.usergrid.count.CassandraSubmitter">
         <constructor-arg ref="cassandraCounterStore"/>
     </bean>
 
-    <bean id="cassandraCounterStore" class="org.usergrid.count.CassandraCounterStore">
+    <bean id="cassandraCounterStore" class="org.apache.usergrid.count.CassandraCounterStore">
         <constructor-arg>
             <bean id="keyspace"
                   factory-bean="cassandraService"
@@ -122,36 +122,36 @@
         </constructor-arg>
     </bean>
 
-    <bean id="counterUtils" class="org.usergrid.persistence.cassandra.CounterUtils">
+    <bean id="counterUtils" class="org.apache.usergrid.persistence.cassandra.CounterUtils">
         <property name="batcher" ref="simpleBatcher"/>
         <property name="counterType" value="n"/>
     </bean>
 
-    <bean id="usergridSystemMonitor" class="org.usergrid.system.UsergridSystemMonitor">
+    <bean id="usergridSystemMonitor" class="org.apache.usergrid.system.UsergridSystemMonitor">
         <constructor-arg value="${usergrid.version.build}"/>
         <constructor-arg ref="cassandraCluster"/>
         <constructor-arg ref="properties"/>
     </bean>
     
         
-   <bean id="indexBucketLocator" class="org.usergrid.persistence.cassandra.SimpleIndexBucketLocatorImpl">
+   <bean id="indexBucketLocator" class="org.apache.usergrid.persistence.cassandra.SimpleIndexBucketLocatorImpl">
     	<constructor-arg value="${usergrid.index.defaultbucketsize}"/>
     </bean>
     
-    <bean id="mailUtils" class="org.usergrid.utils.MailUtils" />
+    <bean id="mailUtils" class="org.apache.usergrid.utils.MailUtils" />
 
-    <bean id="entityManager" class="org.usergrid.persistence.cassandra.EntityManagerImpl" scope="prototype"/>
+    <bean id="entityManager" class="org.apache.usergrid.persistence.cassandra.EntityManagerImpl" scope="prototype"/>
 
-    <bean id="relationManager" class="org.usergrid.persistence.cassandra.RelationManagerImpl" scope="prototype"/>
+    <bean id="relationManager" class="org.apache.usergrid.persistence.cassandra.RelationManagerImpl" scope="prototype"/>
 
-    <bean id="traceTagAspect" class="org.usergrid.persistence.cassandra.util.TraceTagAspect"/>
+    <bean id="traceTagAspect" class="org.apache.usergrid.persistence.cassandra.util.TraceTagAspect"/>
 
     <aop:config>
       <aop:aspect id="traceParticipant" ref="traceTagAspect">
         <!-- pointcut on the prescense of the TraceParticipant annotation only -->
         <aop:pointcut id="emTraceParticipant"
-            expression="execution(* org.usergrid.persistence.cassandra.EntityManagerImpl.*(..)) and
-            @annotation(org.usergrid.persistence.cassandra.util.TraceParticipant)"/>
+            expression="execution(* org.apache.usergrid.persistence.cassandra.EntityManagerImpl.*(..)) and
+            @annotation(org.apache.usergrid.persistence.cassandra.util.TraceParticipant)"/>
         <aop:around
            pointcut-ref="emTraceParticipant"
            method="applyTrace"/>
@@ -162,7 +162,7 @@
     <!-- Scheduler Settings from removed Scheduler Module's app context -->
     <!-- ============================================================== -->
 
-    <bean id="jobSchedulerBackgroundService" class="org.usergrid.batch.service.JobSchedulerService">
+    <bean id="jobSchedulerBackgroundService" class="org.apache.usergrid.batch.service.JobSchedulerService">
       <property name="jobFactory" ref="jobFactory" />
       <property name="jobAccessor" ref="schedulerService" />
       <property name="workerSize" value="${usergrid.scheduler.job.workers}" />
@@ -170,15 +170,15 @@
       <property name="maxFailCount" value="${usergrid.scheduler.job.maxfail}" />
     </bean>
 
-    <bean id="schedulerService" class="org.usergrid.batch.service.SchedulerServiceImpl">
+    <bean id="schedulerService" class="org.apache.usergrid.batch.service.SchedulerServiceImpl">
       <property name="jobTimeout" value="${usergrid.scheduler.job.timeout}" />
       <property name="jobQueueName" value="${usergrid.scheduler.job.queueName}" />
     </bean>
 
-    <bean id="jobFactory" class="org.usergrid.batch.UsergridJobFactory" />
+    <bean id="jobFactory" class="org.apache.usergrid.batch.UsergridJobFactory" />
 
     <!-- scan all job classes -->
-    <context:component-scan base-package="org.usergrid.batch.job" />
+    <context:component-scan base-package="org.apache.usergrid.batch.job" />
     <context:annotation-config />
 
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/main/resources/usergrid-scheduler-context.xml
----------------------------------------------------------------------
diff --git a/stack/core/src/main/resources/usergrid-scheduler-context.xml b/stack/core/src/main/resources/usergrid-scheduler-context.xml
index 96ef1d9..fd3232c 100644
--- a/stack/core/src/main/resources/usergrid-scheduler-context.xml
+++ b/stack/core/src/main/resources/usergrid-scheduler-context.xml
@@ -6,7 +6,7 @@
 
 	<import resource="classpath:/usergrid-core-context.xml" />
 
-	<bean id="jobSchedulerBackgroundService" class="org.usergrid.batch.service.JobSchedulerService">
+	<bean id="jobSchedulerBackgroundService" class="org.apache.usergrid.batch.service.JobSchedulerService">
 		<property name="jobFactory" ref="jobFactory" />
 		<property name="jobAccessor" ref="schedulerService" />
 		<property name="workerSize" value="${usergrid.scheduler.job.workers}" />
@@ -14,17 +14,17 @@
 		<property name="maxFailCount" value="${usergrid.scheduler.job.maxfail}" />
 	</bean>
 
-	<bean id="schedulerService" class="org.usergrid.batch.service.SchedulerServiceImpl">
+	<bean id="schedulerService" class="org.apache.usergrid.batch.service.SchedulerServiceImpl">
 		<property name="jobTimeout" value="${usergrid.scheduler.job.timeout}" />
 		<property name="jobQueueName" value="${usergrid.scheduler.job.queueName}" />
 	</bean>
 
 
-	<bean id="jobFactory" class="org.usergrid.batch.UsergridJobFactory" />
+	<bean id="jobFactory" class="org.apache.usergrid.batch.UsergridJobFactory" />
 
 
 	<!-- scan all job classes -->
-	<context:component-scan base-package="org.usergrid.batch.job" />
+	<context:component-scan base-package="org.apache.usergrid.batch.job" />
 	<context:annotation-config />
 	
 	<!-- other beans -->

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/io/baas/Simple.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/io/baas/Simple.java b/stack/core/src/test/java/io/baas/Simple.java
deleted file mode 100644
index 14428ad..0000000
--- a/stack/core/src/test/java/io/baas/Simple.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package io.baas;
-
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.usergrid.clustering.hazelcast.HazelcastTest;
-import org.usergrid.persistence.TypedEntity;
-
-
-public class Simple extends TypedEntity {
-
-    private static final Logger logger = LoggerFactory.getLogger( HazelcastTest.class );
-
-
-    public Simple() {
-        super();
-        logger.info( "simple entity" );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/org/apache/usergrid/AbstractCoreIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/AbstractCoreIT.java b/stack/core/src/test/java/org/apache/usergrid/AbstractCoreIT.java
new file mode 100644
index 0000000..57d1698
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/AbstractCoreIT.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2012 Apigee Corporation
+ * 
+ * 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 org.apache.usergrid;
+
+
+import org.apache.usergrid.utils.JsonUtils;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class AbstractCoreIT {
+
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractCoreIT.class );
+    @ClassRule
+    public static CoreITSetup setup = new CoreITSetupImpl( CoreITSuite.cassandraResource );
+    @Rule
+    public CoreApplication app = new CoreApplication( setup );
+
+
+    public void dump( Object obj ) {
+        dump( "Object", obj );
+    }
+
+
+    public void dump( String name, Object obj ) {
+        if ( obj != null && LOG.isInfoEnabled() ) {
+            LOG.info( name + ":\n" + JsonUtils.mapToFormattedJsonString( obj ) );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/org/apache/usergrid/Application.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/Application.java b/stack/core/src/test/java/org/apache/usergrid/Application.java
new file mode 100644
index 0000000..6357138
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/Application.java
@@ -0,0 +1,124 @@
+package org.apache.usergrid;
+
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Results;
+import org.junit.rules.TestRule;
+
+
+/**
+ * A Usergrid Application object used to simplify Test code by making it much more readable and removing unnecessary
+ * clutter due to boilerplate code. Use concrete instances of Application from various modules like {@link
+ * CoreApplication} with the Rule and ClassRule annotations to create unique Applications in Usergrid for use in
+ * testing.
+ */
+public interface Application extends TestRule {
+    /**
+     * Gets the Application's UUID.
+     *
+     * @return the UUID of the application
+     */
+    UUID getId();
+
+    /** Clears the properties associated with this Application. */
+    void clear();
+
+    /**
+     * Gets a property value managed by this Application.
+     *
+     * @param key the key associated with the property
+     *
+     * @return the value of the property
+     */
+    Object get( String key );
+
+    /**
+     * Puts a property value into the Application.
+     *
+     * @param property the key of the property
+     * @param value the value of the property
+     *
+     * @return the last value held by the property
+     */
+    Object put( String property, Object value );
+
+    /**
+     * Gets the Map of properties associated with this Application.
+     *
+     * @return the Map of properties associated with this Application
+     */
+    Map<String, Object> getProperties();
+
+    /**
+     * Gets the name of the organization this Application is associated with.
+     *
+     * @return the name of this Application's organization
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    String getOrgName();
+
+    /**
+     * Gets the name of this Application.
+     *
+     * @return the name of this Application
+     */
+    @SuppressWarnings("UnusedDeclaration")
+    String getAppName();
+
+    /**
+     * Gets an entity associated with this Application based on it's type.
+     *
+     * @param type the type of the entity
+     *
+     * @return the entity
+     *
+     * @throws Exception if something goes wrong accessing the entity
+     */
+    Entity create( String type ) throws Exception;
+
+    /**
+     * Gets an entity associated with this Application by unique id.
+     *
+     * @param id the unique identifier for the entity associated with this Application
+     *
+     * @return the entity associated with this Application
+     *
+     * @throws Exception if anything goes wrong accessing the entity
+     */
+    Entity get( UUID id ) throws Exception;
+
+    /**
+     * Adds an item to a collection associated with this Application.
+     *
+     * @param user the user adding the item
+     * @param collection the collection the item is added to
+     * @param item the entity being added to the collection
+     *
+     * @throws Exception if anything goes wrong adding the item to the specified collection
+     */
+    void addToCollection( Entity user, String collection, Entity item ) throws Exception;
+
+    /**
+     * Searches a collection for items satisfying a Query.
+     *
+     * @param user the user performing the query
+     * @param collection the collection being queried
+     * @param query the query to apply for selecting items in the collection
+     *
+     * @return the set of items resulting from the query
+     *
+     * @throws Exception if anything goes wrong querying the specified collection
+     */
+    Results searchCollection( Entity user, String collection, Query query ) throws Exception;
+
+    /**
+     * Puts all of the properties into this Application's properties.
+     *
+     * @param properties the Map of property key value pairs
+     */
+    void putAll( Map<String, Object> properties );
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreITSuite.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreITSuite.java b/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreITSuite.java
new file mode 100644
index 0000000..dbe165b
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreITSuite.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012 Apigee Corporation
+ * 
+ * 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 org.apache.usergrid;
+
+
+import org.apache.usergrid.cassandra.CassandraResource;
+import org.apache.usergrid.cassandra.Concurrent;
+import org.apache.usergrid.cassandra.ConcurrentSuite;
+import org.apache.usergrid.mq.MessagesIT;
+import org.apache.usergrid.persistence.CollectionIT;
+import org.apache.usergrid.persistence.CounterIT;
+import org.apache.usergrid.persistence.EntityConnectionsIT;
+import org.apache.usergrid.persistence.EntityDictionaryIT;
+import org.apache.usergrid.persistence.EntityManagerIT;
+import org.apache.usergrid.persistence.GeoIT;
+import org.apache.usergrid.persistence.IndexIT;
+import org.apache.usergrid.persistence.PathQueryIT;
+import org.apache.usergrid.persistence.PermissionsIT;
+import org.apache.usergrid.persistence.cassandra.EntityManagerFactoryImplIT;
+import org.apache.usergrid.system.UsergridSystemMonitorIT;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+@RunWith(ConcurrentSuite.class)
+@Suite.SuiteClasses({
+        //        HectorLockManagerIT.class,
+        UsergridSystemMonitorIT.class, CollectionIT.class, CounterIT.class, EntityConnectionsIT.class,
+        EntityDictionaryIT.class, EntityManagerIT.class, GeoIT.class, IndexIT.class, MessagesIT.class,
+        PermissionsIT.class, PathQueryIT.class, EntityManagerFactoryImplIT.class
+})
+@Concurrent()
+public class ConcurrentCoreITSuite {
+    @ClassRule
+    public static CassandraResource cassandraResource = CassandraResource.newWithAvailablePorts( "coreManager" );
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreIteratorITSuite.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreIteratorITSuite.java b/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreIteratorITSuite.java
new file mode 100644
index 0000000..ad1c009
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreIteratorITSuite.java
@@ -0,0 +1,62 @@
+package org.apache.usergrid;
+
+
+import org.apache.usergrid.cassandra.CassandraResource;
+import org.apache.usergrid.cassandra.Concurrent;
+import org.apache.usergrid.cassandra.ConcurrentSuite;
+import org.apache.usergrid.persistence.query.AllInCollectionIT;
+import org.apache.usergrid.persistence.query.AllInConnectionIT;
+import org.apache.usergrid.persistence.query.AllInConnectionNoTypeIT;
+import org.apache.usergrid.persistence.query.MultiOrderByCollectionIT;
+import org.apache.usergrid.persistence.query.MultiOrderByComplexUnionCollectionIT;
+import org.apache.usergrid.persistence.query.MultiOrderByComplexUnionConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByBoundRangeScanAscCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByBoundRangeScanAscConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByBoundRangeScanDescCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByBoundRangeScanDescConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByComplexIntersectionCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByComplexIntersectionConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByComplexUnionCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByComplexUnionConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByLessThanLimitCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByLessThanLimitConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByMaxLimitCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByMaxLimitConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByNoIntersectionCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByNoIntersectionConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByNotCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderByNotConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderBySameRangeScanGreaterCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderBySameRangeScanGreaterConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderBySameRangeScanGreaterThanEqualCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderBySameRangeScanLessCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderBySameRangeScanLessConnectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderBySameRangeScanLessThanEqualCollectionIT;
+import org.apache.usergrid.persistence.query.SingleOrderBySameRangeScanLessThanEqualConnectionIT;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+@RunWith(ConcurrentSuite.class)
+@Suite.SuiteClasses({
+        AllInCollectionIT.class, AllInConnectionIT.class, AllInConnectionNoTypeIT.class, MultiOrderByCollectionIT.class,
+        MultiOrderByComplexUnionCollectionIT.class, MultiOrderByComplexUnionConnectionIT.class,
+        SingleOrderByBoundRangeScanAscCollectionIT.class, SingleOrderByBoundRangeScanAscConnectionIT.class,
+        SingleOrderByBoundRangeScanDescCollectionIT.class, SingleOrderByBoundRangeScanDescConnectionIT.class,
+        SingleOrderByComplexIntersectionCollectionIT.class, SingleOrderByComplexIntersectionConnectionIT.class,
+        SingleOrderByComplexUnionCollectionIT.class, SingleOrderByComplexUnionConnectionIT.class,
+        SingleOrderByLessThanLimitCollectionIT.class, SingleOrderByLessThanLimitConnectionIT.class,
+        SingleOrderByMaxLimitCollectionIT.class, SingleOrderByMaxLimitConnectionIT.class,
+        SingleOrderByNoIntersectionCollectionIT.class, SingleOrderByNoIntersectionConnectionIT.class,
+        SingleOrderByNotCollectionIT.class, SingleOrderByNotConnectionIT.class,
+        SingleOrderBySameRangeScanGreaterCollectionIT.class, SingleOrderBySameRangeScanGreaterConnectionIT.class,
+        SingleOrderBySameRangeScanGreaterThanEqualCollectionIT.class, SingleOrderBySameRangeScanLessCollectionIT.class,
+        SingleOrderBySameRangeScanLessConnectionIT.class, SingleOrderBySameRangeScanLessThanEqualCollectionIT.class,
+        SingleOrderBySameRangeScanLessThanEqualConnectionIT.class
+})
+@Concurrent(threads = 15)
+public class ConcurrentCoreIteratorITSuite {
+    @ClassRule
+    public static CassandraResource cassandraResource = CassandraResource.newWithAvailablePorts( "coreManager" );
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreTestSuite.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreTestSuite.java b/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreTestSuite.java
new file mode 100644
index 0000000..2e429af
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/ConcurrentCoreTestSuite.java
@@ -0,0 +1,33 @@
+package org.apache.usergrid;
+
+
+import org.apache.usergrid.cassandra.Concurrent;
+import org.apache.usergrid.cassandra.ConcurrentSuite;
+import org.apache.usergrid.locking.zookeeper.ZookeeperLockManagerTest;
+import org.apache.usergrid.mq.QueuePathsTest;
+import org.apache.usergrid.persistence.EntityTest;
+import org.apache.usergrid.persistence.QueryTest;
+import org.apache.usergrid.persistence.QueryUtilsTest;
+import org.apache.usergrid.persistence.SchemaTest;
+import org.apache.usergrid.persistence.UtilsTest;
+import org.apache.usergrid.persistence.cassandra.QueryProcessorTest;
+import org.apache.usergrid.persistence.cassandra.SimpleIndexBucketLocatorImplTest;
+import org.apache.usergrid.persistence.query.ir.result.IntersectionIteratorTest;
+import org.apache.usergrid.persistence.query.ir.result.SubtractionIteratorTest;
+import org.apache.usergrid.persistence.query.ir.result.UnionIteratorTest;
+import org.apache.usergrid.persistence.query.tree.GrammarTreeTest;
+import org.apache.usergrid.persistence.query.tree.LongLiteralTest;
+import org.apache.usergrid.persistence.query.tree.StringLiteralTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+
+@RunWith(ConcurrentSuite.class)
+@Suite.SuiteClasses({
+        ZookeeperLockManagerTest.class, QueuePathsTest.class, QueryProcessorTest.class,
+        SimpleIndexBucketLocatorImplTest.class, EntityTest.class, QueryTest.class, QueryUtilsTest.class,
+        SchemaTest.class, UtilsTest.class, IntersectionIteratorTest.class, SubtractionIteratorTest.class,
+        UnionIteratorTest.class, GrammarTreeTest.class, LongLiteralTest.class, StringLiteralTest.class
+})
+@Concurrent()
+public class ConcurrentCoreTestSuite {}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
new file mode 100644
index 0000000..930785e
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2012 Apigee Corporation
+ * 
+ * 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 org.apache.usergrid;
+
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.usergrid.mq.QueueManager;
+import org.apache.usergrid.persistence.Entity;
+import org.apache.usergrid.persistence.EntityManager;
+import org.apache.usergrid.persistence.Query;
+import org.apache.usergrid.persistence.Results;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static junit.framework.Assert.assertNotNull;
+
+
+public class CoreApplication implements Application, TestRule {
+
+    private final static Logger LOG = LoggerFactory.getLogger( CoreApplication.class );
+    protected UUID id;
+    protected String appName;
+    protected String orgName;
+    protected CoreITSetup setup;
+    protected EntityManager em;
+    protected Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+
+    public CoreApplication( CoreITSetup setup ) {
+        this.setup = setup;
+    }
+
+
+    @Override
+    public void putAll( Map<String, Object> properties ) {
+        this.properties.putAll( properties );
+    }
+
+
+    @Override
+    public Object get( String key ) {
+        return properties.get( key );
+    }
+
+
+    @Override
+    public Map<String, Object> getProperties() {
+        return properties;
+    }
+
+
+    @Override
+    public UUID getId() {
+        return id;
+    }
+
+
+    @Override
+    public String getOrgName() {
+        return orgName;
+    }
+
+
+    @Override
+    public String getAppName() {
+        return appName;
+    }
+
+
+    @Override
+    public Entity create( String type ) throws Exception {
+        Entity entity = em.create( type, properties );
+        clear();
+        return entity;
+    }
+
+
+    @Override
+    public Object put( String property, Object value ) {
+        return properties.put( property, value );
+    }
+
+
+    @Override
+    public void clear() {
+        properties.clear();
+    }
+
+
+    @Override
+    public void addToCollection( Entity user, String collection, Entity item ) throws Exception {
+        em.addToCollection( user, collection, item );
+    }
+
+
+    @Override
+    public Results searchCollection( Entity user, String collection, Query query ) throws Exception {
+        return em.searchCollection( user, collection, query );
+    }
+
+
+    @Override
+    public Entity get( UUID id ) throws Exception {
+        return em.get( id );
+    }
+
+
+    @Override
+    public Statement apply( final Statement base, final Description description ) {
+        return new Statement() {
+            @Override
+            public void evaluate() throws Throwable {
+                before( description );
+
+                try {
+                    base.evaluate();
+                }
+                finally {
+                    after( description );
+                }
+            }
+        };
+    }
+
+
+    protected void after( Description description ) {
+        LOG.info( "Test {}: finish with application", description.getDisplayName() );
+    }
+
+
+    protected void before( Description description ) throws Exception {
+        orgName = description.getClassName();
+        appName = description.getMethodName();
+        id = setup.createApplication( orgName, appName );
+        assertNotNull( id );
+
+        em = setup.getEmf().getEntityManager( id );
+        assertNotNull( em );
+
+        LOG.info( "Created new application {} in organization {}", appName, orgName );
+    }
+
+
+    public EntityManager getEm() {
+        return em;
+    }
+
+
+    public QueueManager getQm() {
+        return setup.getQmf().getQueueManager( getId() );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2c2acbe4/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
new file mode 100644
index 0000000..045b204
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2012 Apigee Corporation
+ * 
+ * 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 org.apache.usergrid;
+
+
+import java.util.UUID;
+
+import org.apache.usergrid.mq.QueueManagerFactory;
+import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.IndexBucketLocator;
+import org.apache.usergrid.persistence.cassandra.CassandraService;
+import org.junit.rules.TestRule;
+
+
+public interface CoreITSetup extends TestRule {
+
+    boolean USE_DEFAULT_APPLICATION = false;
+
+    EntityManagerFactory getEmf();
+
+    QueueManagerFactory getQmf();
+
+    IndexBucketLocator getIbl();
+
+    CassandraService getCassSvc();
+
+    UUID createApplication( String organizationName, String applicationName ) throws Exception;
+
+    void dump( String name, Object obj );
+}