text:
<?php

namespace Ffcms\Core\Helper\Type;

class StrTest extends \Codeception\TestCase\Test
{
    /**
     * @var \Ffcms\Core\UnitTester
     */
    protected $tester;

    public function testLikeEmpty()
    {
        $this->assertTrue(Str::likeEmpty(null));
        $this->assertTrue(Str::likeEmpty(false));
        $this->assertTrue(Str::likeEmpty(''));
        $this->assertFalse(Str::likeEmpty(true));
        $this->assertFalse(Str::likeEmpty(1));
        $this->assertFalse(Str::likeEmpty(0));
        $this->assertFalse(Str::likeEmpty('data'));
    }

    public function testStartsWith()
    {
        $this->assertTrue(Str::startsWith('th', 'this'));
        $this->assertTrue(Str::startsWith('эт', 'этотест')); // utf8
        $this->assertFalse(Str::startsWith('th', 'isht'));
    }

    public function testEndsWith()
    {
        $this->assertTrue(Str::endsWith('is', 'this'));
        $this->assertTrue(Str::endsWith('то', 'тестэто')); // utf8
        $this->assertFalse(Str::endsWith('is', 'isht'));
        $this->assertTrue(Str::endsWith('1', 'this1'));
    }

    public function testFirstIn()
    {
        $this->assertSame('test', Str::firstIn('test.me', '.'));
        $this->assertSame('test', Str::firstIn('test.me.baby.tonight', '.'));
        $this->assertSame('это', Str::firstIn('это проверка', ' ')); //utf8
        $this->assertSame('', Str::firstIn('t', 'ttttt'));
    }

    public function testLastIn()
    {
        $this->assertSame('me', Str::lastIn('test.me', '.', true));
        $this->assertSame('.me', Str::lastIn('test.it.for.me', '.'));
        $this->assertSame('тестер', Str::lastIn('привет тестер', ' ', true));
    }

    public function testCleanExtension()
    {
        $this->assertSame('file', Str::cleanExtension('file.sh'));
        $this->assertSame('file.tag', Str::cleanExtension('file.tag.gz'));
        $this->assertSame('some string', Str::cleanExtension('some string'));
    }

    public function testLength()
    {
        $this->assertSame(4, Str::length('this'));
        $this->assertSame(3, Str::length(123));
        $this->assertSame(4, Str::length(10.5));
        $this->assertSame(3, Str::length('это'));
    }

    public function testLowerCase()
    {
        $this->assertSame('this is test', Str::lowerCase('ThIs iS tEST'));
        $this->assertSame('это тест', Str::lowerCase('ЭтО ТЕст'));
        $this->assertSame('123', Str::lowerCase(123));
    }

    public function testUpperCase()
    {
        $this->assertSame('THIS IS TEST', Str::upperCase('ThIs iS tEST'));
        $this->assertSame('ЭТО ТЕСТ', Str::upperCase('ЭтО ТЕст'));
        $this->assertSame('123', Str::upperCase(123));
    }

    public function testEntryCount()
    {
        $this->assertSame(3, Str::entryCount('this is test', 's'));
        $this->assertSame(0, Str::entryCount('this is test', 'a'));
        $this->assertSame(1, Str::entryCount('this is 1 test', '1'));
    }

    public function testSplitCamelCase()
    {
        $this->assertSame('This is test', Str::splitCamelCase('thisIsTest'));
    }

    public function testSub()
    {
        $this->assertSame('th', Str::sub('this', 0, 2));
        $this->assertSame('эт', Str::sub('это', 0, 2));
        $this->assertSame('abcdef', Str::sub('abcdef', 0));
        $this->assertSame('abcdef', Str::sub('abcdef', 0, null));
        $this->assertSame('de',     Str::sub('abcdef', 3, 2));
        $this->assertSame('def',    Str::sub('abcdef', 3));
        $this->assertSame('def',    Str::sub('abcdef', 3, null));
        $this->assertSame('cd',     Str::sub('abcdef', -4, 2));
        $this->assertSame('cdef',   Str::sub('abcdef', -4));
        $this->assertSame('cdef',   Str::sub('abcdef', -4, null));
        $this->assertSame('',   Str::sub('abcdef', 4, 0));
        $this->assertSame('',   Str::sub('abcdef', -4, 0));
        $this->assertSame('это', Str::sub('это', 0));
        $this->assertSame('это', Str::sub('это', 0, null));
        $this->assertSame('то',     Str::sub('это', 1, 2));
        $this->assertSame('о',    Str::sub('это', 2));
        $this->assertSame('о',    Str::sub('это', 2, null));
    }

    public function testReplace()
    {
        $this->assertSame('this not test', Str::replace('are', 'not', 'this are test'));
        $this->assertSame('yooy oy test', Str::replace(['th', 'is'], ['yo', 'oy'], 'this is test'));
    }

    public function testContains()
    {
        $this->assertTrue(Str::contains('is', 'this is test'));
        $this->assertFalse(Str::contains('is', 'test'));
        $this->assertTrue(Str::contains('то', 'это тест'));
    }

    public function testIsUrl()
    {
        $this->assertTrue(Str::isUrl('http://ffcms.org'));
        $this->assertTrue(Str::isUrl('https://ffcms.org'));
        $this->assertFalse(Str::isUrl('ffcms.org'));
        $this->assertFalse(Str::isUrl('www.ffcms.org'));
        $this->assertFalse(Str::isUrl('main@gmail.com'));
    }

    public function testRandomLatinNumeric()
    {
        $this->assertSame(32, strlen(Str::randomLatinNumeric(32)));
        $this->assertNotRegExp('/[^A-Za-z0-9]/', Str::randomLatinNumeric(32));
    }

    public function testRandomLatin()
    {
        $this->assertSame(32, strlen(Str::randomLatin(32)));
        $this->assertNotRegExp('/[^A-Za-z]/', Str::randomLatin(32));
    }

    public function testIsEmail()
    {
        $this->assertTrue(Str::isEmail('root@ffcms.org'));
        $this->assertFalse(Str::isEmail('ffcms.org'));
        $this->assertFalse(Str::isEmail('root.ffcms.org'));
        $this->assertTrue(Str::isEmail('root-not@ffcms.org'));
        $this->assertTrue(Str::isEmail('root.not@ffcms.org'));
    }

    public function testIsPhone()
    {
        $this->assertTrue(Str::isPhone('+71234567890'));
        $this->assertTrue(Str::isPhone('88004567890'));
        $this->assertTrue(Str::isPhone('+38004567890'));
    }

    public function testConcat()
    {
        $this->assertSame('this.test', Str::concat('.', 'this', 'test'));
        $this->assertSame('hello my world', Str::concat(' ', 'hello', 'my', 'world'));
        $this->assertSame('привет мир', Str::concat(' ', 'привет', 'мир'));
    }

    public function testEqualIngoreCase()
    {
        $this->assertTrue(Str::equalIgnoreCase('HeLlO', 'hello'));
        $this->assertFalse(Str::equalIgnoreCase('HeLlO123', 'hello'));
        $this->assertFalse(Str::equalIgnoreCase('ПрИвЕт', 'привет')); // not support utf8
    }

}


text:
/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2005-2012, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.feature.collection;

import java.io.IOException;
import java.util.Collection;

import org.geotools.data.DataUtilities;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.store.FilteringFeatureCollection;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.feature.Feature;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.feature.type.FeatureType;
import org.opengis.filter.Filter;
import org.opengis.filter.sort.SortBy;
import org.opengis.geometry.BoundingBox;

/**
 * Implement a feature collection just based on provision of a {@link org.geotools.feature.FeatureIterator}.
 *

 * This implementation asks you to implement:
 *

 *
{@link #features()}

 *

 * This is the direct decentent of the origional {@link org.geotools.feature.collection.AbstractFeatureCollection}
 * and represents the easiest way to package your content as a FeatureCollection.
 *

 * As this class provides no optimization, it is strongly recommended that you implement
 * the following methods (which require a whole collection traversal):
 *

 *
{@link #size()}

 *
{@link #getBounds()

 *

 *
 * @author Jody Garnett (LISAsoft)
 * @source $URL$
 */
public abstract class BaseFeatureCollection<T extends FeatureType, F extends Feature> implements FeatureCollection<T,F> {
    /**
     * id used when serialized to gml
     */
    protected String id;
    protected T schema;

    protected BaseFeatureCollection(){
        this( null, null );
    }
    protected BaseFeatureCollection(T schema) {
        this( schema, null );
    }
    protected BaseFeatureCollection(T schema, String id) {
        this.id = id == null ? "featureCollection" : id;
        this.schema = schema;
    }

    public String getID() {
        return id;
    }

    public T getSchema() {
        return schema;
    }

    //
    // FeatureCollection - Feature Access
    //
    /**
     * Subclasses required to implement this method to traverse FeatureCollection contents.
     *

     * Note that {@link org.geotools.feature.FeatureIterator<F>#close()} is available to clean up
     * after any resource use required during traversal.
     */
    public abstract FeatureIterator<F> features();

    /**
     * Returns <tt>true</tt> if this collection contains the specified element. <tt></tt>.
     *

     *
     * This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.
     *
     * @param o object to be checked for containment in this collection.
     * @return <tt>true</tt> if this collection contains the specified element.
     */
    public boolean contains(Object o) {
        FeatureIterator<F> e = features();
        try {
            if (o == null) {
                while (e.hasNext()){
                    if (e.next() == null){
                        return true;
                    }
                }
            } else {
                while (e.hasNext()){
                    if (o.equals(e.next())){
                        return true;
                    }
                }
            }
            return false;
        } finally {
            e.close();
        }
    }

    /**
     * Returns <tt>true</tt> if this collection contains all of the elements in the specified collection.
     *

     *
     * @param c collection to be checked for containment in this collection.
     * @return <tt>true</tt> if this collection contains all of the elements in the specified collection.
     * @throws NullPointerException if the specified collection is null.
     *
     * @see #contains(Object)
     */
    public boolean containsAll(Collection<?> c) {
        FeatureIterator<F> e = features();
        try {
            while (e.hasNext()){
                Feature feature = e.next();
                if (!c.contains(feature)){
                    return false;
                }
            }
            return true;
        } finally {
            e.close();
        }
    }

    /**
     * @return <tt>true</tt> if this collection contains no elements.
     */
    public boolean isEmpty() {
        FeatureIterator<F> iterator = features();
        try {
            return !iterator.hasNext();
        } finally {
            iterator.close();
        }
    }

    /**
     * Array of all the elements.
     *
     * @return an array containing all of the elements in this collection.
     */
    public Object[] toArray() {
        Object[] result = new Object[size()];
        FeatureIterator<F> e = null;
        try {
            e = features();
            for (int i = 0; e.hasNext(); i++)
                result[i] = e.next();
            return result;
        } finally {
            e.close();
        }
    }

    @SuppressWarnings("unchecked")
    public <O> O[] toArray(O[] a) {
        int size = size();
        if (a.length < size) {
            a = (O[]) java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), size);
        }
        FeatureIterator<F> it = features();
        try {
            Object[] result = a;
            for (int i = 0; i < size; i++)
                result[i] = it.next();
            if (a.length > size)
                a[size] = null;
            return a;
        } finally {
            it.close();
        }
    }

    public void accepts(org.opengis.feature.FeatureVisitor visitor,
            org.opengis.util.ProgressListener progress) throws IOException {
        DataUtilities.visit(this, visitor, progress);
    }

    //
    // Feature Collections API
    //
    /**
     * Convenience implementation that just wraps this collection into a
     * {@link org.geotools.data.store.FilteringFeatureCollection}. Subclasses might want to override this in case the filter
     * can be cascaded to their data sources.
     *
     * @param filter
     * @return
     */
    public FeatureCollection<T,F> subCollection(Filter filter) {
        if (filter == Filter.INCLUDE) {
            return this;
        }
        return new FilteringFeatureCollection<T, F>(this, filter);
    }
    /**
     * Obtained sorted contents, only implemented for SimpleFeature at present.
     *

     * This method only supports SimpleFeature at present, consider use of FeatureSource.features( Query ).
     *
     * @param order Sort order
     * @return FeatureCollection sorted in the indicated order
     */
    @SuppressWarnings("unchecked")
    public FeatureCollection<T,F> sort(SortBy order) {
        if (getSchema() instanceof SimpleFeatureType) {
            // go for the most efficient way if possible, otherwise rely on pure in memory
            // sorting...
            SimpleFeatureCollection simple = DataUtilities.simple((FeatureCollection<SimpleFeatureType, SimpleFeature>) this);
            return (FeatureCollection<T, F>) new SortedSimpleFeatureCollection(simple,new SortBy[] { order });
        } else {
            // hmm... we don't even have a basic non simple collection... need to implement one
            // before going here
            throw new UnsupportedOperationException("Cannot sort on complex features at the moment");
        }
    }

    /**
     * Returns the number of elements in this collection.
     *
     * @return Number of items, or Interger.MAX_VALUE
     */
    public int size(){
        int count = 0;
        FeatureIterator<F> it = features();
        try {
            while( it.hasNext() ){
                @SuppressWarnings("unused")
                Feature feature = it.next();
                count++;
            }
        } finally {
            it.close();
        }
        return count;
    }

    /**
     * Full collection traversal to obtain bounds of FeatureCollection.
     * Subclasees are strong encouraged to override this expensive method
     * (even if just to implement caching).
     */
    public ReferencedEnvelope getBounds(){
        ReferencedEnvelope bounds = null;
        FeatureIterator<F> it = features();
        try {
            while( it.hasNext() ){
                Feature feature = it.next();
                BoundingBox bbox = feature.getBounds();
                if( bbox != null ){
                    if( bounds == null ){
                        bounds = new ReferencedEnvelope( bbox );
                    }
                    else {
                        bounds.include( bbox );
                    }
                }
            }
        } finally {
            it.close();
        }
        return bounds;
    }

}

redpajama_set_name: RedPajamaGithub


text:
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 *  (C) 2009 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#include "hydra.h"
#include "bsci.h"
#include "bscu.h"
#include "sge.h"

static HYD_status process_mfile_token(char *token, int newline, struct HYD_node **node_list)
{
    int num_procs;
    static int entry_count = 0;
    static char *hostname;
    HYD_status status = HYD_SUCCESS;

    entry_count++;

    if (newline) {      /* The first entry gives the hostname */
        entry_count = 1;
        if (hostname)
            HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "unexpected token %s\n", token);
        hostname = HYDU_strdup(token);
    }
    else {      /* Not a new line */
        if (entry_count != 2)
            goto fn_exit;

        num_procs = atoi(token);

        status = HYDU_add_to_node_list(hostname, num_procs, node_list);
        HYDU_ERR_POP(status, "unable to initialize proxy\n");

        hostname = NULL;
    }

  fn_exit:
    return status;

  fn_fail:
    goto fn_exit;
}

HYD_status HYDT_bscd_sge_query_node_list(struct HYD_node **node_list)
{
    char *hostfile;
    HYD_status status = HYD_SUCCESS;

    HYDU_FUNC_ENTER();

    if (MPL_env2str("PE_HOSTFILE", (const char **) &hostfile) == 0)
        hostfile = NULL;

    if (hostfile == NULL) {
        *node_list = NULL;
        HYDU_ERR_SETANDJUMP(status, HYD_INTERNAL_ERROR, "No SGE nodefile found\n");
    }
    else {
        status = HYDU_parse_hostfile(hostfile, node_list, process_mfile_token);
        HYDU_ERR_POP(status, "error parsing hostfile\n");
    }

  fn_exit:
    HYDU_FUNC_EXIT();
    return status;

  fn_fail:
    goto fn_exit;
}


text:
.class Landroid/service/dreams/IDreamManager$Stub$Proxy;
.super Ljava/lang/Object;
.source "IDreamManager.java"

# interfaces
.implements Landroid/service/dreams/IDreamManager;

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Landroid/service/dreams/IDreamManager$Stub;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0xa
    name = "Proxy"
.end annotation

# instance fields
.field private mRemote:Landroid/os/IBinder;

# direct methods
.method constructor <init>(Landroid/os/IBinder;)V
    .locals 0
    .parameter "remote"

    .prologue
    .line 129
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 130
    iput-object p1, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    .line 131
    return-void
.end method

# virtual methods
.method public asBinder()Landroid/os/IBinder;
    .locals 1

    .prologue
    .line 134
    iget-object v0, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    return-object v0
.end method

.method public awaken()V
    .locals 5
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 156
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 157
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 159
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v2, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 160
    iget-object v2, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/4 v3, 0x2

    const/4 v4, 0x0

    invoke-interface {v2, v3, v0, v1, v4}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 161
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 164
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 165
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 167
    return-void

    .line 164
    :catchall_0
    move-exception v2

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 165
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v2
.end method

.method public dream()V
    .locals 5
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 142
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 143
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 145
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v2, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 146
    iget-object v2, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/4 v3, 0x1

    const/4 v4, 0x0

    invoke-interface {v2, v3, v0, v1, v4}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 147
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 150
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 151
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 153
    return-void

    .line 150
    :catchall_0
    move-exception v2

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 151
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v2
.end method

.method public finishSelf(Landroid/os/IBinder;)V
    .locals 5
    .parameter "token"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 262
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 263
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 265
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v2, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 266
    invoke-virtual {v0, p1}, Landroid/os/Parcel;->writeStrongBinder(Landroid/os/IBinder;)V

    .line 267
    iget-object v2, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/16 v3, 0x8

    const/4 v4, 0x0

    invoke-interface {v2, v3, v0, v1, v4}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 268
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 271
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 272
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 274
    return-void

    .line 271
    :catchall_0
    move-exception v2

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 272
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v2
.end method

.method public getDefaultDreamComponent()Landroid/content/ComponentName;
    .locals 6
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 202
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 203
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 206
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v3, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v3}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 207
    iget-object v3, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/4 v4, 0x5

    const/4 v5, 0x0

    invoke-interface {v3, v4, v0, v1, v5}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 208
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V

    .line 209
    invoke-virtual {v1}, Landroid/os/Parcel;->readInt()I

    move-result v3

    if-eqz v3, :cond_0

    .line 210
    sget-object v3, Landroid/content/ComponentName;->CREATOR:Landroid/os/Parcelable$Creator;

    invoke-interface {v3, v1}, Landroid/os/Parcelable$Creator;->createFromParcel(Landroid/os/Parcel;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/content/ComponentName;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 217
    .local v2, _result:Landroid/content/ComponentName;
    :goto_0
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 218
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 220
    return-object v2

    .line 213
    .end local v2           #_result:Landroid/content/ComponentName;
    :cond_0
    const/4 v2, 0x0

    .restart local v2       #_result:Landroid/content/ComponentName;
    goto :goto_0

    .line 217
    .end local v2           #_result:Landroid/content/ComponentName;
    :catchall_0
    move-exception v3

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 218
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v3
.end method

.method public getDreamComponents()[Landroid/content/ComponentName;
    .locals 6
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 185
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 186
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 189
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v3, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v3}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 190
    iget-object v3, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/4 v4, 0x4

    const/4 v5, 0x0

    invoke-interface {v3, v4, v0, v1, v5}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 191
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V

    .line 192
    sget-object v3, Landroid/content/ComponentName;->CREATOR:Landroid/os/Parcelable$Creator;

    invoke-virtual {v1, v3}, Landroid/os/Parcel;->createTypedArray(Landroid/os/Parcelable$Creator;)[Ljava/lang/Object;

    move-result-object v2

    check-cast v2, [Landroid/content/ComponentName;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 195
    .local v2, _result:[Landroid/content/ComponentName;
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 196
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 198
    return-object v2

    .line 195
    .end local v2           #_result:[Landroid/content/ComponentName;
    :catchall_0
    move-exception v3

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 196
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v3
.end method

.method public getInterfaceDescriptor()Ljava/lang/String;
    .locals 1

    .prologue
    .line 138
    const-string v0, "android.service.dreams.IDreamManager"

    return-object v0
.end method

.method public isDreaming()Z
    .locals 6
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    const/4 v2, 0x0

    .line 245
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 246
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 249
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v3, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v3}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 250
    iget-object v3, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/4 v4, 0x7

    const/4 v5, 0x0

    invoke-interface {v3, v4, v0, v1, v5}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 251
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V

    .line 252
    invoke-virtual {v1}, Landroid/os/Parcel;->readInt()I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    move-result v3

    if-eqz v3, :cond_0

    const/4 v2, 0x1

    .line 255
    .local v2, _result:Z
    :cond_0
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 256
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 258
    return v2

    .line 255
    .end local v2           #_result:Z
    :catchall_0
    move-exception v3

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 256
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v3
.end method

.method public setDreamComponents([Landroid/content/ComponentName;)V
    .locals 5
    .parameter "componentNames"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 170
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 171
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 173
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v2, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 174
    const/4 v2, 0x0

    invoke-virtual {v0, p1, v2}, Landroid/os/Parcel;->writeTypedArray([Landroid/os/Parcelable;I)V

    .line 175
    iget-object v2, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/4 v3, 0x3

    const/4 v4, 0x0

    invoke-interface {v2, v3, v0, v1, v4}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 176
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 179
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 180
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 182
    return-void

    .line 179
    :catchall_0
    move-exception v2

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 180
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v2
.end method

.method public testDream(Landroid/content/ComponentName;)V
    .locals 5
    .parameter "componentName"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/os/RemoteException;
        }
    .end annotation

    .prologue
    .line 224
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v0

    .line 225
    .local v0, _data:Landroid/os/Parcel;
    invoke-static {}, Landroid/os/Parcel;->obtain()Landroid/os/Parcel;

    move-result-object v1

    .line 227
    .local v1, _reply:Landroid/os/Parcel;
    :try_start_0
    const-string v2, "android.service.dreams.IDreamManager"

    invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInterfaceToken(Ljava/lang/String;)V

    .line 228
    if-eqz p1, :cond_0

    .line 229
    const/4 v2, 0x1

    invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInt(I)V

    .line 230
    const/4 v2, 0x0

    invoke-virtual {p1, v0, v2}, Landroid/content/ComponentName;->writeToParcel(Landroid/os/Parcel;I)V

    .line 235
    :goto_0
    iget-object v2, p0, Landroid/service/dreams/IDreamManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;

    const/4 v3, 0x6

    const/4 v4, 0x0

    invoke-interface {v2, v3, v0, v1, v4}, Landroid/os/IBinder;->transact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z

    .line 236
    invoke-virtual {v1}, Landroid/os/Parcel;->readException()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 239
    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 240
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    .line 242
    return-void

    .line 233
    :cond_0
    const/4 v2, 0x0

    :try_start_1
    invoke-virtual {v0, v2}, Landroid/os/Parcel;->writeInt(I)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    .line 239
    :catchall_0
    move-exception v2

    invoke-virtual {v1}, Landroid/os/Parcel;->recycle()V

    .line 240
    invoke-virtual {v0}, Landroid/os/Parcel;->recycle()V

    throw v2
.end method


text:
/*
 * Copyright 1999-2004 The Apache Software Foundation.
 *
 * 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.
 */
/*
 * $Id: XMLMessages.java,v 1.2.4.1 2005/09/15 07:45:48 suresh_emailid Exp $
 */
package com.sun.org.apache.xml.internal.res;

import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

/**
 * A utility class for issuing XML error messages.
 * @xsl.usage internal
 */
public class XMLMessages
{

  /** The local object to use.  */
  protected Locale fLocale = Locale.getDefault();

  /** The language specific resource object for XML messages.  */
  private static ListResourceBundle XMLBundle = null;

  /** The class name of the XML error message string table.    */
  private static final String XML_ERROR_RESOURCES =
    "com.sun.org.apache.xml.internal.res.XMLErrorResources";

  /** String to use if a bad message code is used. */
  protected static final String BAD_CODE = "BAD_CODE";

  /** String to use if the message format operation failed.  */
  protected static final String FORMAT_FAILED = "FORMAT_FAILED";

  /**
   * Set the Locale object to use.
   *
   * @param locale non-null reference to Locale object.
   */
   public void setLocale(Locale locale)
  {
    fLocale = locale;
  }

  /**
   * Get the Locale object that is being used.
   *
   * @return non-null reference to Locale object.
   */
  public Locale getLocale()
  {
    return fLocale;
  }

  /**
   * Creates a message from the specified key and replacement
   * arguments, localized to the given locale.
   *
   * @param msgKey    The key for the message text.
   * @param args      The arguments to be used as replacement text
   *                  in the message created.
   *
   * @return The formatted message string.
   */
  public static final String createXMLMessage(String msgKey, Object args[])
  {
    if (XMLBundle == null)
      XMLBundle = loadResourceBundle(XML_ERROR_RESOURCES);

    if (XMLBundle != null)
    {
      return createMsg(XMLBundle, msgKey, args);
    }
    else
      return "Could not load any resource bundles.";
  }

  /**
   * Creates a message from the specified key and replacement
   * arguments, localized to the given locale.
   *
   * @param fResourceBundle The resource bundle to use.
   * @param msgKey  The message key to use.
   * @param args      The arguments to be used as replacement text
   *                  in the message created.
   *
   * @return The formatted message string.
   */
  public static final String createMsg(ListResourceBundle fResourceBundle,
        String msgKey, Object args[])  //throws Exception
  {

    String fmsg = null;
    boolean throwex = false;
    String msg = null;

    if (msgKey != null)
      msg = fResourceBundle.getString(msgKey);

    if (msg == null)
    {
      msg = fResourceBundle.getString(BAD_CODE);
      throwex = true;
    }

    if (args != null)
    {
      try
      {

        // Do this to keep format from crying.
        // This is better than making a bunch of conditional
        // code all over the place.
        int n = args.length;

        for (int i = 0; i < n; i++)
        {
          if (null == args[i])
            args[i] = "";
        }

        fmsg = java.text.MessageFormat.format(msg, args);
      }
      catch (Exception e)
      {
        fmsg = fResourceBundle.getString(FORMAT_FAILED);
        fmsg += " " + msg;
      }
    }
    else
      fmsg = msg;

    if (throwex)
    {
      throw new RuntimeException(fmsg);
    }

    return fmsg;
  }

  /**
   * Return a named ResourceBundle for a particular locale.  This method mimics the behavior
   * of ResourceBundle.getBundle().
   *
   * @param className The class name of the resource bundle.
   * @return the ResourceBundle
   * @throws MissingResourceException
   */
  public static ListResourceBundle loadResourceBundle(String className)
          throws MissingResourceException
  {
    Locale locale = Locale.getDefault();

    try
    {
      return (ListResourceBundle)ResourceBundle.getBundle(className, locale);
    }
    catch (MissingResourceException e)
    {
      try  // try to fall back to en_US if we can't load
      {

        // Since we can't find the localized property file,
        // fall back to en_US.
        return (ListResourceBundle)ResourceBundle.getBundle(
          className, new Locale("en", "US"));
      }
      catch (MissingResourceException e2)
      {

        // Now we are really in trouble.
        // very bad, definitely very bad...not going to get very far
        throw new MissingResourceException(
          "Could not load any resource bundles." + className, className, "");
      }
    }
  }

  /**
   * Return the resource file suffic for the indicated locale
   * For most locales, this will be based the language code.  However
   * for Chinese, we do distinguish between Taiwan and PRC
   *
   * @param locale the locale
   * @return an String suffix which can be appended to a resource name
   */
  protected static String getResourceSuffix(Locale locale)
  {

    String suffix = "_" + locale.getLanguage();
    String country = locale.getCountry();

    if (country.equals("TW"))
      suffix += "_" + country;

    return suffix;
  }
}


text:
//
//  LocationTracker.h
//  backendlessAPI

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#import <UIKit/UIKit.h>
#endif

// Location Tracker invokes the ILocationTrackerListener methods from default global dispatch queue (DISPATCH_QUEUE_PRIORITY_DEFAULT) -
// so if the listener uses UI in its callbckacs, it MUST get the main dispatch queue.
@protocol ILocationTrackerListener <NSObject>
-(void)onLocationChanged:(CLLocation *)location;
-(void)onLocationFailed:(NSError *)error;
@end

#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
@interface LocationTracker : NSObject <UIApplicationDelegate>
// location manager options
@property(assign, nonatomic) CLActivityType activityType;
@property(assign, nonatomic) BOOL pausesLocationUpdatesAutomatically;

-(BOOL)isBackgroundRefreshAvailable;
-(BOOL)isSuspendedRefreshAvailable;
#else
@interface LocationTracker : NSObject
#endif
// location manager options
@property(assign, nonatomic) BOOL monitoringSignificantLocationChanges;
@property(assign, nonatomic) CLLocationDistance distanceFilter;
@property(assign, nonatomic) CLLocationAccuracy desiredAccuracy;

// Singleton accessor:  this is how you should ALWAYS get a reference to the class instance.  Never init your own.
+(LocationTracker *)sharedInstance;

-(BOOL)isContainListener:(NSString *)name;
-(id <ILocationTrackerListener>)findListener:(NSString *)name;
-(NSString *)addListener:(id <ILocationTrackerListener>)listener;
-(BOOL)addListener:(NSString *)name listener:(id <ILocationTrackerListener>)listener;
-(BOOL)removeListener:(NSString *)name;

-(void)startLocationManager;
-(CLLocation *)getLocation;

@end


text:
<title>Zend Framework API Documentation</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><link rel="stylesheet" href="css/black-tie/jquery-ui-1.8.2.custom.css" type="text/css"></link><link rel="stylesheet" href="css/jquery.treeview.css" type="text/css"></link><link rel="stylesheet" href="css/theme.css" type="text/css"></link>

API Documentation

Test/PHPUnit/ControllerTestCase.php

Global

                      Classes

\Zend_Test_PHPUnit_ControllerTestCase

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to license@zend.com so we can send you a copy immediately.

category

Zend

copyright

Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)

license

New BSD License

package

Zend_Test

version

$Id: ControllerTestCase.php 24213 2011-07-08 21:16:45Z rdohms $

\Zend_Test_PHPUnit_ControllerTestCase
jump to top

Functional testing scaffold for MVC applications

Extends from

\PHPUnit_Framework_TestCase

category

Zend

copyright

Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)

license

New BSD License

package

Zend_Test

subpackage

PHPUnit

uses

\PHPUnit_Framework_TestCase

Properties

\Zend_Controller_Front
                 $_frontController= ''

Details

Type

\Zend_Controller_Front

\Zend_Dom_Query
                 $_query= ''

Details

Type

\Zend_Dom_Query

\Zend_Controller_Request_Abstract
                 $_request= ''

Details

Type

\Zend_Controller_Request_Abstract

\Zend_Controller_Response_Abstract
                 $_response= ''

Details

Type

\Zend_Controller_Response_Abstract

array
                 $_xpathNamespaces= 'array'

XPath namespaces

Default valuearrayDetails

Type

array

mixed
                 $bootstrap= ''

Bootstrap file path or callback

Details

Type

mixed

Methods

__construct(

          )

        :
          void

Inherited from:

__get(
          mixed $name
          )

        :
          void

Overloading for common properties

Provides overloading for request, response, and frontController objects.

Parameters

Name
Type
Description

$name
mixed

__set(
          string $name, mixed $value
          )

        :
          void

Overloading: prevent overloading to special properties

Parameters

Name
Type
Description

$name
string

$value
mixed

_incrementAssertionCount(

          )

        :
          void

Increment assertion count

_resetPlaceholders(

          )

        :
          void

Rest all view placeholders

addToAssertionCount(

          )

        :
          void

Inherited from:

any(

          )

        :
          void

static

Inherited from:

anything(

          )

        :
          void

static

Inherited from:

arrayHasKey(

          )

        :
          void

static

Inherited from:

assertAction(
          string $action, string $message
          )

        :
          void

Assert that the last handled request used the given action

Parameters

Name
Type
Description

$action
string

$message
string

assertArrayHasKey(

          )

        :
          void

static

Inherited from:

assertArrayNotHasKey(

          )

        :
          void

static

Inherited from:

assertAttributeContains(

          )

        :
          void

static

Inherited from:

assertAttributeContainsOnly(

          )

        :
          void

static

Inherited from:

assertAttributeEmpty(

          )

        :
          void

static

Inherited from:

assertAttributeEquals(

          )

        :
          void

static

Inherited from:

assertAttributeGreaterThan(

          )

        :
          void

static

Inherited from:

assertAttributeGreaterThanOrEqual(

          )

        :
          void

static

Inherited from:

assertAttributeInstanceOf(

          )

        :
          void

static

Inherited from:

assertAttributeInternalType(

          )

        :
          void

static

Inherited from:

assertAttributeLessThan(

          )

        :
          void

static

Inherited from:

assertAttributeLessThanOrEqual(

          )

        :
          void

static

Inherited from:

assertAttributeNotContains(

          )

        :
          void

static

Inherited from:

assertAttributeNotContainsOnly(

          )

        :
          void

static

Inherited from:

assertAttributeNotEmpty(

          )

        :
          void

static

Inherited from:

assertAttributeNotEquals(

          )

        :
          void

static

Inherited from:

assertAttributeNotInstanceOf(

          )

        :
          void

static

Inherited from:

assertAttributeNotInternalType(

          )

        :
          void

static

Inherited from:

assertAttributeNotSame(

          )

        :
          void

static

Inherited from:

assertAttributeNotType(

          )

        :
          void

static

Inherited from:

assertAttributeSame(

          )

        :
          void

static

Inherited from:

assertAttributeType(

          )

        :
          void

static

Inherited from:

assertClassHasAttribute(

          )

        :
          void

static

Inherited from:

assertClassHasStaticAttribute(

          )

        :
          void

static

Inherited from:

assertClassNotHasAttribute(

          )

        :
          void

static

Inherited from:

assertClassNotHasStaticAttribute(

          )

        :
          void

static

Inherited from:

assertContains(

          )

        :
          void

static

Inherited from:

assertContainsOnly(

          )

        :
          void

static

Inherited from:

assertController(
          string $controller, string $message
          )

        :
          void

Assert that the last handled request used the given controller

Parameters

Name
Type
Description

$controller
string

$message
string

assertEmpty(

          )

        :
          void

static

Inherited from:

assertEqualXMLStructure(

          )

        :
          void

static

Inherited from:

assertEquals(

          )

        :
          void

static

Inherited from:

assertFalse(

          )

        :
          void

static

Inherited from:

assertFileEquals(

          )

        :
          void

static

Inherited from:

assertFileExists(

          )

        :
          void

static

Inherited from:

assertFileNotEquals(

          )

        :
          void

static

Inherited from:

assertFileNotExists(

          )

        :
          void

static

Inherited from:

assertGreaterThan(

          )

        :
          void

static

Inherited from:

assertGreaterThanOrEqual(

          )

        :
          void

static

Inherited from:

assertHeader(
          string $header, string $message
          )

        :
          void

Assert response header exists

Parameters

Name
Type
Description

$header
string

$message
string

assertHeaderContains(
          string $header, string $match, string $message
          )

        :
          void

Assert response header exists and contains the given string

Parameters

Name
Type
Description

$header
string

$match
string

$message
string

assertHeaderRegex(
          string $header, string $pattern, string $message
          )

        :
          void

Assert response header exists and matches the given pattern

Parameters

Name
Type
Description

$header
string

$pattern
string

$message
string

assertInstanceOf(

          )

        :
          void

static

Inherited from:

assertInternalType(

          )

        :
          void

static

Inherited from:

assertLessThan(

          )

        :
          void

static

Inherited from:

assertLessThanOrEqual(

          )

        :
          void

static

Inherited from:

assertModule(
          string $module, string $message
          )

        :
          void

Assert that the last handled request used the given module

Parameters

Name
Type
Description

$module
string

$message
string

assertNotAction(
          string $action, string $message
          )

        :
          void

Assert that the last handled request did NOT use the given action

Parameters

Name
Type
Description

$action
string

$message
string

assertNotContains(

          )

        :
          void

static

Inherited from:

assertNotContainsOnly(

          )

        :
          void

static

Inherited from:

assertNotController(
          string $controller, string $message
          )

        :
          void

Assert that the last handled request did NOT use the given controller

Parameters

Name
Type
Description

$controller
string

$message
string

assertNotEmpty(

          )

        :
          void

static

Inherited from:

assertNotEquals(

          )

        :
          void

static

Inherited from:

assertNotHeader(
          string $header, string $message
          )

        :
          void

Assert response header does not exist

Parameters

Name
Type
Description

$header
string

$message
string

assertNotHeaderContains(
          string $header, string $match, string $message
          )

        :
          void

Assert response header does not exist and/or does not contain the given string

Parameters

Name
Type
Description

$header
string

$match
string

$message
string

assertNotHeaderRegex(
          string $header, string $pattern, string $message
          )

        :
          void

Assert response header does not exist and/or does not match the given regex

Parameters

Name
Type
Description

$header
string

$pattern
string

$message
string

assertNotInstanceOf(

          )

        :
          void

static

Inherited from:

assertNotInternalType(

          )

        :
          void

static

Inherited from:

assertNotModule(
          string $module, string $message
          )

        :
          void

Assert that the last handled request did NOT use the given module

Parameters

Name
Type
Description

$module
string

$message
string

assertNotNull(

          )

        :
          void

static

Inherited from:

assertNotQuery(
          string $path, string $message
          )

        :
          void

Assert against DOM selection

Parameters

Name
Type
Description

$path
string
CSS selector path

$message
string

assertNotQueryContentContains(
          string $path, string $match, string $message
          )

        :
          void

Assert against DOM selection; node should NOT contain content

Parameters

Name
Type
Description

$path
string
CSS selector path

$match
string
content that should NOT be contained in matched nodes

$message
string

assertNotQueryContentRegex(
          string $path, string $pattern, string $message
          )

        :
          void

Assert against DOM selection; node should NOT match content

Parameters

Name
Type
Description

$path
string
CSS selector path

$pattern
string
pattern that should NOT be contained in matched nodes

$message
string

assertNotQueryCount(
          string $path, string $count, string $message
          )

        :
          void

Assert against DOM selection; should NOT contain exact number of nodes

Parameters

Name
Type
Description

$path
string
CSS selector path

$count
string
Number of nodes that should NOT match

$message
string

assertNotRedirect(
          string $message
          )

        :
          void

Assert that response is NOT a redirect

Parameters

Name
Type
Description

$message
string

assertNotRedirectRegex(
          string $pattern, string $message
          )

        :
          void

Assert that redirect location does not match pattern

Parameters

Name
Type
Description

$pattern
string

$message
string

assertNotRedirectTo(
          string $url, string $message
          )

        :
          void

Assert that response does not redirect to given URL

Parameters

Name
Type
Description

$url
string

$message
string

assertNotRegExp(

          )

        :
          void

static

Inherited from:

assertNotResponseCode(
          int $code, string $message
          )

        :
          void

Assert response code

Parameters

Name
Type
Description

$code
int

$message
string

assertNotRoute(
          string $route, string $message
          )

        :
          void

Assert that the route matched is NOT as specified

Parameters

Name
Type
Description

$route
string

$message
string

assertNotSame(

          )

        :
          void

static

Inherited from:

assertNotTag(

          )

        :
          void

static

Inherited from:

assertNotType(

          )

        :
          void

static

Inherited from:

assertNotXpath(
          string $path, string $message
          )

        :
          void

Assert against XPath selection

Parameters

Name
Type
Description

$path
string
XPath path

$message
string

assertNotXpathContentContains(
          string $path, string $match, string $message
          )

        :
          void

Assert against XPath selection; node should NOT contain content

Parameters

Name
Type
Description

$path
string
XPath path

$match
string
content that should NOT be contained in matched nodes

$message
string

assertNotXpathContentRegex(
          string $path, string $pattern, string $message
          )

        :
          void

Assert against XPath selection; node should NOT match content

Parameters

Name
Type
Description

$path
string
XPath path

$pattern
string
pattern that should NOT be contained in matched nodes

$message
string

assertNotXpathCount(
          string $path, string $count, string $message
          )

        :
          void

Assert against XPath selection; should NOT contain exact number of nodes

Parameters

Name
Type
Description

$path
string
XPath path

$count
string
Number of nodes that should NOT match

$message
string

assertNull(

          )

        :
          void

static

Inherited from:

assertObjectHasAttribute(

          )

        :
          void

static

Inherited from:

assertObjectNotHasAttribute(

          )

        :
          void

static

Inherited from:

assertPostConditions(

          )

        :
          void

Inherited from:

assertPreConditions(

          )

        :
          void

Inherited from:

assertQuery(
          string $path, string $message
          )

        :
          void

Assert against DOM selection

Parameters

Name
Type
Description

$path
string
CSS selector path

$message
string

assertQueryContentContains(
          string $path, string $match, string $message
          )

        :
          void

Assert against DOM selection; node should contain content

Parameters

Name
Type
Description

$path
string
CSS selector path

$match
string
content that should be contained in matched nodes

$message
string

assertQueryContentRegex(
          string $path, string $pattern, string $message
          )

        :
          void

Assert against DOM selection; node should match content

Parameters

Name
Type
Description

$path
string
CSS selector path

$pattern
string
Pattern that should be contained in matched nodes

$message
string

assertQueryCount(
          string $path, string $count, string $message
          )

        :
          void

Assert against DOM selection; should contain exact number of nodes

Parameters

Name
Type
Description

$path
string
CSS selector path

$count
string
Number of nodes that should match

$message
string

assertQueryCountMax(
          string $path, string $count, string $message
          )

        :
          void

Assert against DOM selection; should contain no more than this number of nodes

Parameters

Name
Type
Description

$path
string
CSS selector path

$count
string
Maximum number of nodes that should match

$message
string

assertQueryCountMin(
          string $path, string $count, string $message
          )

        :
          void

Assert against DOM selection; should contain at least this number of nodes

Parameters

Name
Type
Description

$path
string
CSS selector path

$count
string
Minimum number of nodes that should match

$message
string

assertRedirect(
          string $message
          )

        :
          void

Assert that response is a redirect

Parameters

Name
Type
Description

$message
string

assertRedirectRegex(
          string $pattern, string $message
          )

        :
          void

Assert that redirect location matches pattern

Parameters

Name
Type
Description

$pattern
string

$message
string

assertRedirectTo(
          string $url, string $message
          )

        :
          void

Assert that response redirects to given URL

Parameters

Name
Type
Description

$url
string

$message
string

assertRegExp(

          )

        :
          void

static

Inherited from:

assertResponseCode(
          int $code, string $message
          )

        :
          void

Assert response code

Parameters

Name
Type
Description

$code
int

$message
string

assertRoute(
          string $route, string $message
          )

        :
          void

Assert that the specified route was used

Parameters

Name
Type
Description

$route
string

$message
string

assertSame(

          )

        :
          void

static

Inherited from:

assertSelectCount(

          )

        :
          void

static

Inherited from:

assertSelectEquals(

          )

        :
          void

static

Inherited from:

assertSelectRegExp(

          )

        :
          void

static

Inherited from:

assertStringEndsNotWith(

          )

        :
          void

static

Inherited from:

assertStringEndsWith(

          )

        :
          void

static

Inherited from:

assertStringEqualsFile(

          )

        :
          void

static

Inherited from:

assertStringMatchesFormat(

          )

        :
          void

static

Inherited from:

assertStringMatchesFormatFile(

          )

        :
          void

static

Inherited from:

assertStringNotEqualsFile(

          )

        :
          void

static

Inherited from:

assertStringNotMatchesFormat(

          )

        :
          void

static

Inherited from:

assertStringNotMatchesFormatFile(

          )

        :
          void

static

Inherited from:

assertStringStartsNotWith(

          )

        :
          void

static

Inherited from:

assertStringStartsWith(

          )

        :
          void

static

Inherited from:

assertTag(

          )

        :
          void

static

Inherited from:

assertThat(

          )

        :
          void

static

Inherited from:

assertTrue(

          )

        :
          void

static

Inherited from:

assertType(

          )

        :
          void

static

Inherited from:

assertXmlFileEqualsXmlFile(

          )

        :
          void

static

Inherited from:

assertXmlFileNotEqualsXmlFile(

          )

        :
          void

static

Inherited from:

assertXmlStringEqualsXmlFile(

          )

        :
          void

static

Inherited from:

assertXmlStringEqualsXmlString(

          )

        :
          void

static

Inherited from:

assertXmlStringNotEqualsXmlFile(

          )

        :
          void

static

Inherited from:

assertXmlStringNotEqualsXmlString(

          )

        :
          void

static

Inherited from:

assertXpath(
          string $path, string $message
          )

        :
          void

Assert against XPath selection

Parameters

Name
Type
Description

$path
string
XPath path

$message
string

assertXpathContentContains(
          string $path, string $match, string $message
          )

        :
          void

Assert against XPath selection; node should contain content

Parameters

Name
Type
Description

$path
string
XPath path

$match
string
content that should be contained in matched nodes

$message
string

assertXpathContentRegex(
          string $path, string $pattern, string $message
          )

        :
          void

Assert against XPath selection; node should match content

Parameters

Name
Type
Description

$path
string
XPath path

$pattern
string
Pattern that should be contained in matched nodes

$message
string

assertXpathCount(
          string $path, string $count, string $message
          )

        :
          void

Assert against XPath selection; should contain exact number of nodes

Parameters

Name
Type
Description

$path
string
XPath path

$count
string
Number of nodes that should match

$message
string

assertXpathCountMax(
          string $path, string $count, string $message
          )

        :
          void

Assert against XPath selection; should contain no more than this number of nodes

Parameters

Name
Type
Description

$path
string
XPath path

$count
string
Maximum number of nodes that should match

$message
string

assertXpathCountMin(
          string $path, string $count, string $message
          )

        :
          void

Assert against XPath selection; should contain at least this number of nodes

Parameters

Name
Type
Description

$path
string
XPath path

$count
string
Minimum number of nodes that should match

$message
string

at(

          )

        :
          void

static

Inherited from:

atLeastOnce(

          )

        :
          void

static

Inherited from:

attribute(

          )

        :
          void

static

Inherited from:

attributeEqualTo(

          )

        :
          void

static

Inherited from:

bootstrap(

          )

        :
          void

final
Bootstrap the front controller

Resets the front controller, and then bootstraps it.

If {@link $bootstrap} is a callback, executes it; if it is a file, it include's
it. When done, sets the test case request and response objects into the
front controller.

classHasAttribute(

          )

        :
          void

static

Inherited from:

classHasStaticAttribute(

          )

        :
          void

static

Inherited from:

contains(

          )

        :
          void

static

Inherited from:

containsOnly(

          )

        :
          void

static

Inherited from:

count(

          )

        :
          void

Inherited from:

createResult(

          )

        :
          void

Inherited from:

dataToString(

          )

        :
          void

Inherited from:

dispatch(
          string|null $url
              =
              null
          )

        :
          void

Dispatch the MVC

If a URL is provided, sets it as the request URI in the request object.
Then sets test case request and response objects in front controller,
disables throwing exceptions, and disables returning the response.
Finally, dispatches the front controller.

Parameters

Name
Type
Description

$url
string|null

equalTo(

          )

        :
          void

static

Inherited from:

exactly(

          )

        :
          void

static

Inherited from:

fail(

          )

        :
          void

static

Inherited from:

fileExists(

          )

        :
          void

static

Inherited from:

getAnnotations(

          )

        :
          void

Inherited from:

getCount(

          )

        :
          void

static

Inherited from:

getDataSetAsString(

          )

        :
          void

Inherited from:

getExpectedException(

          )

        :
          void

Inherited from:

getFrontController(

          )

        :
          \Zend_Controller_Front

Retrieve front controller instance

Returns

Type
Description

\Zend_Controller_Front

getMock(

          )

        :
          void

Inherited from:

getMockBuilder(

          )

        :
          void

Inherited from:

getMockClass(

          )

        :
          void

Inherited from:

getMockForAbstractClass(

          )

        :
          void

Inherited from:

getMockFromWsdl(

          )

        :
          void

Inherited from:

getName(

          )

        :
          void

Inherited from:

getNumAssertions(

          )

        :
          void

Inherited from:

getQuery(

          )

        :
          \Zend_Dom_Query

Retrieve DOM query object

Returns

Type
Description

\Zend_Dom_Query

getRequest(

          )

        :
          \Zend_Controller_Request_HttpTestCase

Retrieve test case request object

Returns

Type
Description

\Zend_Controller_Request_HttpTestCase

getResponse(

          )

        :
          \Zend_Controller_Response_HttpTestCase

Retrieve test case response object

Returns

Type
Description

\Zend_Controller_Response_HttpTestCase

getResult(

          )

        :
          void

Inherited from:

getStatus(

          )

        :
          void

Inherited from:

getStatusMessage(

          )

        :
          void

Inherited from:

getTestResultObject(

          )

        :
          void

Inherited from:

greaterThan(

          )

        :
          void

static

Inherited from:

greaterThanOrEqual(

          )

        :
          void

static

Inherited from:

handleDependencies(

          )

        :
          void

Inherited from:

hasFailed(

          )

        :
          void

Inherited from:

identicalTo(

          )

        :
          void

static

Inherited from:

iniSet(

          )

        :
          void

Inherited from:

isEmpty(

          )

        :
          void

static

Inherited from:

isFalse(

          )

        :
          void

static

Inherited from:

isInstanceOf(

          )

        :
          void

static

Inherited from:

isNull(

          )

        :
          void

static

Inherited from:

isTrue(

          )

        :
          void

static

Inherited from:

isType(

          )

        :
          void

static

Inherited from:

lessThan(

          )

        :
          void

static

Inherited from:

lessThanOrEqual(

          )

        :
          void

static

Inherited from:

logicalAnd(

          )

        :
          void

static

Inherited from:

logicalNot(

          )

        :
          void

static

Inherited from:

logicalOr(

          )

        :
          void

static

Inherited from:

logicalXor(

          )

        :
          void

static

Inherited from:

markTestIncomplete(

          )

        :
          void

static

Inherited from:

markTestSkipped(

          )

        :
          void

static

Inherited from:

matches(

          )

        :
          void

static

Inherited from:

matchesRegularExpression(

          )

        :
          void

static

Inherited from:

never(

          )

        :
          void

static

Inherited from:

objectHasAttribute(

          )

        :
          void

static

Inherited from:

onConsecutiveCalls(

          )

        :
          void

static

Inherited from:

onNotSuccessfulTest(

          )

        :
          void

Inherited from:

once(

          )

        :
          void

static

Inherited from:

prepareTemplate(

          )

        :
          void

Inherited from:

readAttribute(

          )

        :
          void

static

Inherited from:

registerXpathNamespaces(
          array $xpathNamespaces
          )

        :
          void

Register XPath namespaces

Parameters

Name
Type
Description

$xpathNamespaces
array

reset(

          )

        :
          void

Reset MVC state

Creates new request/response objects, resets the front controller
instance, and resets the action helper broker.

Details

todo

Need to update Zend_Layout to add a resetInstance() method

resetCount(

          )

        :
          void

static

Inherited from:

resetRequest(

          )

        :
          \Zend_Test_PHPUnit_ControllerTestCase

Reset the request object

Useful for test cases that need to test multiple trips to the server.

Returns

Type
Description

\Zend_Test_PHPUnit_ControllerTestCase

resetResponse(

          )

        :
          \Zend_Test_PHPUnit_ControllerTestCase

Reset the response object

Useful for test cases that need to test multiple trips to the server.

Returns

Type
Description

\Zend_Test_PHPUnit_ControllerTestCase

returnArgument(

          )

        :
          void

static

Inherited from:

returnCallback(

          )

        :
          void

static

Inherited from:

returnValue(

          )

        :
          void

static

Inherited from:

run(

          )

        :
          void

Inherited from:

runBare(

          )

        :
          void

Inherited from:

runTest(

          )

        :
          void

Inherited from:

setBackupGlobals(

          )

        :
          void

Inherited from:

setBackupStaticAttributes(

          )

        :
          void

Inherited from:

setDependencies(

          )

        :
          void

Inherited from:

setDependencyInput(

          )

        :
          void

Inherited from:

setExpectedException(

          )

        :
          void

Inherited from:

setExpectedExceptionFromAnnotation(

          )

        :
          void

Inherited from:

setInIsolation(

          )

        :
          void

Inherited from:

setLocale(

          )

        :
          void

Inherited from:

setName(

          )

        :
          void

Inherited from:

setPreserveGlobalState(

          )

        :
          void

Inherited from:

setResult(

          )

        :
          void

Inherited from:

setRunTestInSeparateProcess(

          )

        :
          void

Inherited from:

setUp(

          )

        :
          void

Set up MVC app

Calls {@link bootstrap()} by default

setUpBeforeClass(

          )

        :
          void

static

Inherited from:

setUseErrorHandler(

          )

        :
          void

Inherited from:

setUseErrorHandlerFromAnnotation(

          )

        :
          void

Inherited from:

setUseOutputBuffering(

          )

        :
          void

Inherited from:

setUseOutputBufferingFromAnnotation(

          )

        :
          void

Inherited from:

stringContains(

          )

        :
          void

static

Inherited from:

stringEndsWith(

          )

        :
          void

static

Inherited from:

stringStartsWith(

          )

        :
          void

static

Inherited from:

syntheticFail(

          )

        :
          void

static

Inherited from:

tearDown(

          )

        :
          void

Inherited from:

tearDownAfterClass(

          )

        :
          void

static

Inherited from:

throwException(

          )

        :
          void

static

Inherited from:

toString(

          )

        :
          void

Inherited from:

url(
          array $urlOptions
              =
              array, string $name
              =
              null, bool $reset
              =
              false, bool $encode
              =
              true
          )

        :
          void

URL Helper

Parameters

Name
Type
Description

$urlOptions
array

$name
string

$reset
bool

$encode
bool

urlizeOptions(
           $urlOptions,  $actionControllerModuleOnly
              =
              true
          )

        :
          void

Parameters

Name
Type
Description

$urlOptions

$actionControllerModuleOnly

verifyMockObjects(

          )

        :
          void

Inherited from:

Documentation was generated by DocBlox 0.13.3.


text:
layout: post97
title:  Step One - Using Processing Units for Scaling
categories: XAP97
weight: 200
parent: your-first-xtp-application.html
---

**Summary:** {% excerpt %}In this step we will use a car wash analogy to compare the traditional tier based approach for architecting enterprise application with GigaSpaces' Space Based approach, and explain the concept of _Processing Units_.{% endexcerpt %}

#### Preface

Once in a while you need to wash your car. Some people keep their car in superb condition and wash it very often, while others transform it skillfully into a mega-junk-mobile and take it to the car wash very rarely, if ever. But the fact remains that most people will bring their car to the car wash at one stage or another

#### Washing Your Car The Tier-Based Way

In a tier-based architecture, our system is composed of several disparate physical tiers - meaning the database, the messaging queue and the application server. So every time your application needs to get something done, it typically goes through all these components. Imagine using this approach to wash your car. Each tier is analogous to a phase in our washing process: Firstly, the dirty car is transported to a soaping warehouse, where it is covered with soap. The next stop is transporting the "soaped" car to a different warehouse, where it is watered to rinse off the soap. The last step is transporting the car to yet another warehouse, which specializes in drying water marks, to dry and wipe all the water off of it.

Fortunately, we don't clean cars this way, because transporting the car to each of the warehouses (which might be geographically remote from one another) would take a considerable amount of time.

{% align center %}![Tierbased2.jpg](/attachment_files/Tierbased2.jpg){% endalign %}
{% align center %}**{% sub %}Diagram 1. Car wash, the tier based way: a different warehouse for each step in the process.{% endsub %}**{% endalign %}

#### Washing the Car Using Space-Based Architecture

What we actually do, is send the car a single warehouse, which has all the services available in the same place (we call this colocation). That way this services can be accessed much faster. One local machine soaps it, another local washing machine waters it, and finally a third local machine uses hot air to dry it and remove all the water marks. This an all-in-one warehouse, containing a depot to hold the car and all the collocated services for washing, rinsing and drying it. In the GigaSpaces language, we call this a _Processing Unit_ - in this case a carwash processing unit.

Going back to the real world (where enterprise applications live...), imagine that your application will have all the services it needs in the same location (operating system process to be specific). So it will not go through separate physical layers just to access the data or send and receive messages. This is the concept behind GigaSpaces' Processing Unit.

{% align center %}![Spacebased.jpg](/attachment_files/Spacebased.jpg){% endalign %}
{% align center %}**{% sub %}Diagram 2. An all-in-one "washing unit" containing soaping, watering and drying services.{% endsub %}**{% endalign %}

#### Scaling Easily with Self Contained Processing Units

Self contained Processing Units also have the advantage that they can be easily scaled. If we have more cars to wash than a single unit can handle, the system can be scaled almost linearly, by simply adding more car washing units.

{% align center %}![Spacebasedscaled.jpg](/attachment_files/Spacebasedscaled.jpg){% endalign %}
{% align center %}**{% sub %}Diagram 3. Scaling the system by adding more "car washing units".{% endsub %}**{% endalign %}

#### A GigaSpaces Processing Unit

{% c %}
---------------SHOW FOR JAVA---------
{% endc %}
Now let's translate this to the enterprise application terminology. In the diagram below you can see a GigaSpaces Processing Unit instance, which runs within a Processing Unit Container. (This is in fact a JVM with a thin layer that knows how to run processing units.)
You can see the _Space_ (the "car depot") in the center of the processing unit. The space holds objects in the local JVM memory, making them accessible to all the local services (the "washing services"). The space can also act as a messaging layer, by notifying the relevant service when a particular object is written to it. The services can then respond to the message by processing it, and writing it back to the space. They can also use the space to retrieve additional pieces of information needed for the processing. A client application can interact with the space-side services by writing objects to the Processing Unit's space and reading them after they are processed. We can linearly scale the system by simply adding more Processing Unit instances, since the processing units are entirely independent of one another.

{% align center %}![Spacebasedreal.jpg](/attachment_files/Spacebasedreal.jpg){% endalign %}
{% align center %}**{% sub %}Diagram 4. A Processing Unit with 3 services collocated with a space.{% endsub %}**{% endalign %}

{% comment %}
#### What About My Data?

In many cases, the space cannot store all of the relevant data that your application needs within the memory of a single JVM. In such cases we need to divide the data between the instances intelligently. We call this _Data Partitioning_. Let's return to the carwash example to illustrate this.
Imagine that each car model has to be washed in a slightly different manner to achieve optimal results. So we actually have a plan specific to each model that needs to stored in the car wash warehouse and be accessed by each of the services. In the tier based approach, we would put all of the plans in a central plan repository (which is the database)
{% endcomment %}

## What's Next?

![Jump arrow green.bmp](/attachment_files/Jump arrow green.bmp)
{% color green %}Next Page{% endcolor %}
 - [Step two - Creating the Hello World Application](./step-two---creating-the-hello-world-application.html). Shows how to create your first GigaSpaces application and run it on your local machine.

Or return to the [Your First XTP Application](./your-first-xtp-application.html) page.


text:
class TestNodeB : public MPxNode
{
public:
	TestNodeB();
	virtual			~TestNodeB();

	static  void *	creator();
	virtual MStatus	compute( const MPlug&, MDataBlock& );
	static  MStatus	initialize();

	// postConstructor:
	// The postConstructor method allows us to call MPxNode member
	// functions during initialization. Internally maya creates two
	// objects when a user defined node is created, the internal MObject
	// and the user derived object. The association between the these
	// two objects is not made until after the MPxNode constructor is
	// called. This implies that no MPxNode member function can be called
	// from the MPxNode constructor. The postConstructor will get called
	// immediately after the constructor when it is safe to call any
	// MPxNode member function.
	//

	virtual void	postConstructor();

	static MString cTypeName();
	static MTypeId cTypeId();
	static MPxNode::Type cType();
	static const MString& classification();

protected:
	static MTypeId   m_id;  // The IFF type id
	static MString   m_classification;
	static VersionHelper    m_version_helper;

	// Surface color
	static MObject  aAttribute0;

	// Output color
	static MObject  aOutColor;

};


text:
module TokyoMetro::Modules::ToFactory::Api::Convert::Customize::TrainTimetable::TerminalStation::Info

  # Constructor
  def initialize( *variables )
    super( *variables )
    ::TokyoMetro::Factory::Convert::Customize::Api::TrainTimetable::TerminalStation::Info.process( self )
  end

end


text:
local hdf5 = require("hdf5")
local ffi = require("ffi")

do
  local N = 1000
  local pos = ffi.new("struct { double x, y, z; }[?]", N)
  math.randomseed(42)
  for i = 0, N - 1 do
    pos[i].x = math.random()
    pos[i].y = math.random()
    pos[i].z = math.random()
  end
  local file = hdf5.create_file("dataset.h5")
  local datatype = hdf5.double
  local dataspace = hdf5.create_simple_space({N, 3})
  local dataset = file:create_dataset("particles/solvent/position", datatype, dataspace)
  dataset:write(pos, datatype, dataspace)
  dataset:close()
  file:close()
end

do
  local file = hdf5.open_file("dataset.h5")
  local dataset = file:open_dataset("particles/solvent/position")
  local filespace = dataset:get_space()
  local dims = filespace:get_simple_extent_dims()
  local N, D = dims[1], dims[2]
  assert(N == 1000)
  assert(D == 3)
  local pos = ffi.new("struct { float x, y, z; }[?]", N)
  local memtype = hdf5.float
  local memspace = hdf5.create_simple_space({N, 3})
  dataset:read(pos, memtype, memspace)
  dataset:close()
  file:close()
  math.randomseed(42)
  for i = 0, N - 1 do
    assert(math.abs(pos[i].x - math.random()) < 1e-7)
    assert(math.abs(pos[i].y - math.random()) < 1e-7)
    assert(math.abs(pos[i].z - math.random()) < 1e-7)
  end
end


text:
Ext.define('Ext.grid.plugin.DivRenderer', {
    alias: 'plugin.divrenderer',
    extend: 'Ext.AbstractPlugin',

    tableTpl: [
        '
',
            '{%',
                'values.view.renderRows(values.rows, values.viewStartIndex, out);',
            '%}',
        '
',
        {
            priority: 0
        }
    ],

    rowTpl: [
        '{%',
            'var dataRowCls = values.recordIndex === -1 ? "" : " ' + Ext.baseCSSPrefix + 'grid-data-row";',
        '%}',
        '
',
            '<tpl for="columns">' +
                '{%',
                    'parent.view.renderCell(values, parent.record, parent.recordIndex, xindex - 1, out, parent)',
                 '%}',
            '</tpl>',
        '
',
        {
            priority: 0
        }
    ],

    cellTpl: [
        '
',
            '<div {unselectableAttr} class="' + Ext.baseCSSPrefix + 'grid-cell-inner"',
                'style="text-align:{align};<tpl if="style">{style}</tpl>" {ariaCellInnerAttr}>{value}
',
        '
', {
            priority: 0
        }
    ],

    selectors: {
        // Outer table
        bodySelector: 'div',

        // Element which contains rows
        nodeContainerSelector: 'div',

        // view item (may be a wrapper)
        itemSelector: 'dl.' + Ext.baseCSSPrefix + 'grid-row',

        // row which contains cells as opposed to wrapping rows
        dataRowSelector: 'dl.' + Ext.baseCSSPrefix + 'grid-data-row',

        // cell
        cellSelector: 'dt.' + Ext.baseCSSPrefix + 'grid-cell',

        innerSelector: 'div.' + Ext.baseCSSPrefix + 'grid-cell-inner',

        getNodeContainerSelector: function() {
            return this.getBodySelector();
        },

        getNodeContainer: function() {
            return this.el.getById(this.id + '-table', true);
        }
    },

    init: function(grid) {
        var view = grid.getView();
        view.tableTpl = Ext.XTemplate.getTpl(this, 'tableTpl');
        view.rowTpl   = Ext.XTemplate.getTpl(this, 'rowTpl');
        view.cellTpl  = Ext.XTemplate.getTpl(this, 'cellTpl');
        Ext.apply(view, this.selectors);
    }
});


text:
require File.expand_path("../../../../base", __FILE__)

describe "VagrantPlugins::Shell::Config" do
  let(:described_class) do
    VagrantPlugins::Shell::Plugin.components.configs[:provisioner][:shell]
  end

  let(:machine)          { double('machine', env: Vagrant::Environment.new) }
  let(:file_that_exists) { File.expand_path(__FILE__)                       }

  subject { described_class.new }

  describe "validate" do
    it "passes with no args" do
      subject.path = file_that_exists
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([])
    end

    it "passes with string args" do
      subject.path = file_that_exists
      subject.args = "a string"
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([])
    end

    it "passes with integer args" do
      subject.path = file_that_exists
      subject.args = 1
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([])
    end

    it "passes with array args" do
      subject.path = file_that_exists
      subject.args = ["an", "array"]
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([])
    end

    it "returns an error if args is neither a string nor an array" do
      neither_array_nor_string = Object.new

      subject.path = file_that_exists
      subject.args = neither_array_nor_string
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([
        I18n.t("vagrant.provisioners.shell.args_bad_type")
      ])
    end

    it "handles scalar array args" do
      subject.path = file_that_exists
      subject.args = ["string", 1, 2]
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([])
    end

    it "returns an error if args is an array with non-scalar types" do
      subject.path = file_that_exists
      subject.args = [[1]]
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([
        I18n.t("vagrant.provisioners.shell.args_bad_type")
      ])
    end

    it "returns an error if elevated_interactive is true but privileged is false" do
      subject.path = file_that_exists
      subject.powershell_elevated_interactive = true
      subject.privileged = false
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to eq([
        I18n.t("vagrant.provisioners.shell.interactive_not_elevated")
      ])
    end

    it "returns an error if the environment is not a hash" do
      subject.env = "foo"
      subject.finalize!

      result = subject.validate(machine)

      expect(result["shell provisioner"]).to include(
        I18n.t("vagrant.provisioners.shell.env_must_be_a_hash")
      )
    end

    it "returns an error if file and script are unset" do
      subject.finalize!
      result = subject.validate(machine)
      expect(result["shell provisioner"]).to include(
        I18n.t("vagrant.provisioners.shell.no_path_or_inline")
      )
    end

    it "returns an error if inline and path are both set" do
      subject.inline = "script"
      subject.path = "script"
      result = subject.validate(machine)
      expect(result["shell provisioner"]).to include(
        I18n.t("vagrant.provisioners.shell.path_and_inline_set")
      )
    end

    it "returns no error when inline and path are unset but reset is true" do
      subject.reset = true
      subject.finalize!

      result = subject.validate(machine)
      expect(result["shell provisioner"]).to be_empty
    end

    it "returns no error when inline and path are unset but reboot is true" do
      subject.reboot = true
      subject.finalize!

      result = subject.validate(machine)
      expect(result["shell provisioner"]).to be_empty
    end
  end

  describe 'finalize!' do
    it 'changes integer args into strings' do
      subject.path = file_that_exists
      subject.args = 1
      subject.finalize!

      expect(subject.args).to eq '1'
    end

    it 'changes integer args in arrays into strings' do
      subject.path = file_that_exists
      subject.args = ["string", 1, 2]
      subject.finalize!

      expect(subject.args).to eq ["string", '1', '2']
    end

    context "with sensitive option enabled" do
      it 'marks environment variable values sensitive' do
        subject.env = {"KEY1" => "VAL1", "KEY2" => "VAL2"}
        subject.sensitive = true

        expect(Vagrant::Util::CredentialScrubber).to receive(:sensitive).with("VAL1")
        expect(Vagrant::Util::CredentialScrubber).to receive(:sensitive).with("VAL2")
        subject.finalize!
      end
    end

    context "with sensitive option disabled" do
      it 'does not mark environment variable values sensitive' do
        subject.env = {"KEY1" => "VAL1", "KEY2" => "VAL2"}
        subject.sensitive = false

        expect(Vagrant::Util::CredentialScrubber).not_to receive(:sensitive)
        subject.finalize!
      end
    end
  end
end


text:
<?php
declare(strict_types = 1);

namespace Domain\ValueObject;

/**
 * Class Password
 *
 * @author Vasil Dakov <vasildakov@gmail.com>
 */
final class Password
{
    /**
     * @var string
     */
    private $value;

    /**
     * @param string $value
     */
    public function __construct(string $value)
    {
        $this->value = $value;
    }

    public function getValue()
    {
        return $this->value;
    }

    public function __toString()
    {
        return $this->getValue();
    }
}


text:
'use strict';

let Gulp = require('gulp'),
	Nodemon = require('nodemon'),
	TSC = require('gulp-typescript');

var CONFIGURATION = {
	sourceDirectory: __dirname+'/src',
	sourceDirectoryAssets: __dirname+'/src/assets',
	deploymentDirectory: __dirname+'/app',
	deploymentDirectoryAssets: __dirname+'/app/assets',
	serverReloadWatchFileTypes: ['js', 'html'],
	tsLintConfig: {
		configuration: './tslint.json'
	}
};
var STATIC_FILES = [ 'js', 'html', 'png', 'jpg', 'svg', 'css' ].map(
	(format) => CONFIGURATION.sourceDirectory+'/**/*.'+format
);

var tsProject = TSC.createProject('tsconfig.json');
Gulp.task('typescript', function() {
	var compilerOptions = JSON.parse(JSON.stringify(tsProject.config.compilerOptions));
	delete compilerOptions.outDir;

	var tsResult = Gulp.src(tsProject.config.include)
		.pipe(TSC(compilerOptions));

    return tsResult.js.pipe(Gulp.dest(tsProject.config.compilerOptions.outDir));
});

Gulp.task('tslint', function() {
	Gulp.src([CONFIGURATION.sourceDirectory + '/**/*.ts'])
		.pipe(tslint(CONFIGURATION.tsLintConfig))
		.pipe(tslint.report());
});

Gulp.task('watch', function() {
	Gulp.watch(CONFIGURATION.sourceDirectory+'/**/*.ts', ['typescript']);
	Gulp.watch(STATIC_FILES, ['deploy static']);
});

Gulp.task('deploy', ['typescript', 'deploy static'], function() {});

Gulp.task('serve', ['deploy','watch'], function() {
	Nodemon({
		script: CONFIGURATION.deploymentDirectory+'/index.js',
		ext: CONFIGURATION.serverReloadWatchFileTypes.join(' ')
	})
});

Gulp.task('deploy static', [], function() {
	return Gulp.src(STATIC_FILES, {
			base: CONFIGURATION.sourceDirectory
		})
		.pipe(Gulp.dest(CONFIGURATION.deploymentDirectory));
});

Gulp.task('default', ['serve']);


text:
import assert from "assert";
import _ from "lodash";

import Sueca from "../../../models/games/sueca";

describe("Sueca", function () {
  let game;

  let startNewGame = function () {
    game = new Sueca({});
  };

  let quickPlay = function (n) {
    for (let i = 0; i < n; i++) {
      game.move(game.getNextPlayer(), validCard());
    }
  };

  let isCard = function (card) {
    return card.suit && card.value;
  };

  let isSameCard = function (card) {
    return c => c.suit === card.suit && c.value === card.value;
  };

  let validCard = function () {
    let state = game.getState(game.getNextPlayer());
    return _.find(state.hand, c => c.suit === state.trickSuit) || state.hand[0];
  };

  let invalidCard = function () {
    let state = game.getState(game.getNextPlayer());
    let invalidCards = _.filter(state.hand, c => c.suit !== state.trickSuit);
    return invalidCards.length === state.hand.length ? null : invalidCards[0];
  };

  let prevPlayer = function (player) { return (player + 2) % 4 + 1; };
  let nextPlayer = function (player) { return player % 4 + 1; };

  beforeEach(startNewGame);

  it("should have a player count of 4", function () {
    assert.equal(game.getPlayerCount(), 4);
  });

  it("should start out with a correct initial state", function () {
    assert.equal(game.isEnded(), false);
    assert.equal(game.isError(), false);
    assert.equal(game.getWinners(), null);

    let player = game.getNextPlayer();
    assert(player >= 1 && player <= 4);

    let initialState = game.getFullState();
    assert.equal(initialState.nextPlayer, player);

    let seenCards = {};
    assert.equal(initialState.hands.length, 4);
    _.chain(initialState.hands).flatten().every(c => {
      assert(!seenCards[`${c.suit}-${c.value}`]);
      seenCards[`${c.suit}-${c.value}`] = true;
    });

    assert.equal(initialState.trumpPlayer, prevPlayer(player));
    assert(isCard(initialState.trump));
    assert(_.some(game.getState(initialState.trumpPlayer).hand, isSameCard(initialState.trump)));

    assert.equal(initialState.lastTrick, null);
    assert.deepEqual(initialState.currentTrick, [null, null, null, null]);
    assert.equal(initialState.trickSuit, null);
    assert.equal(initialState.tricksDone, 0);

    assert.deepEqual(initialState.score, [0, 0]);

    for (let i = 1; i <= 4; i++) {
      assert.deepEqual(game.getState(i).hand, initialState.hands[i - 1]);
    }
  });

  it("should update correctly the state with valid moves until the end", function () {
    for (let t = 0; t < 40; t++) {
      let player = game.getNextPlayer();
      let card = validCard();

      game.move(player, card);
      assert.equal(game.isError(), false);

      if (t < 39) {
        assert.equal(game.getWinners(), null);
        assert.equal(game.isEnded(), false);
      }

      if (t % 4 !== 3) {
        assert.equal(game.getNextPlayer(), nextPlayer(player));
        assert.deepEqual(game.getFullState().currentTrick[player - 1], card);
      }

      assert.equal(game.getFullState().tricksDone, Math.floor((t + 1) / 4));
    }

    assert.equal(game.isError(), false);
    assert.equal(game.isEnded(), true);
    assert.equal(game.getNextPlayer(), null);

    let finalState = game.getFullState();
    let isDraw = finalState.score[0] === finalState.score[1];
    assert.equal(game.getWinners().length === 0, isDraw);
  });

  it("should set the state as error when an invalid move is made", function () {
    // card not in player's hand
    game.move(game.getNextPlayer(), game.getState(nextPlayer(game.getNextPlayer())).hand[0]);
    assert.equal(game.isError(), true);

    startNewGame();

    // not the correct player
    game.move(nextPlayer(game.getNextPlayer()), validCard());
    assert.equal(game.isError(), true);

    startNewGame();

    while (!invalidCard()) {
      game.move(game.getNextPlayer(), validCard());
      // this can happen, but requires an insanely rare card distribution
      if (game.isEnded()) return;
    }
    // card not from the trick's suit
    game.move(game.getNextPlayer(), invalidCard());
    assert.equal(game.isError(), true);
  });

  it("should evaluate correctly valid and invalid moves", function () {
    assert.equal(game.isValidMove(game.getNextPlayer(), validCard()), true);

    // card not in player's hand
    assert.equal(game.isValidMove(game.getNextPlayer(),
        game.getState(nextPlayer(game.getNextPlayer())).hand[0]), false);

    // not the correct player
    assert.equal(game.isValidMove(nextPlayer(game.getNextPlayer()), validCard()), false);

    // card not from the trick's suit
    game.move(game.getNextPlayer(), validCard());
    assert.equal(game.isValidMove(game.getNextPlayer(), invalidCard()), false);
  });

  it("should consider the opponent the winner when a move timeout occurs", function () {
    let player = game.getNextPlayer();
    assert.equal(game.onMoveTimeout(), true);
    assert.equal(game.getNextPlayer(), null);
    assert.deepEqual(game.getWinners(), player % 2 ? [1, 3] : [2, 4]);
  });

  it("update correctly the score after a move", function () {
    quickPlay(4);

    let trickPoints = _.reduce(game.getFullState().lastTrick, (sum, c) => {
      switch (c.value) {
        case "A": return sum + 11;
        case "7": return sum + 10;
        case "K": return sum + 4;
        case "J": return sum + 3;
        case "Q": return sum + 2;
        default: return sum;
      }
    }, 0);

    let state = game.getFullState();
    assert(state.score[0] === 0 && state.score[1] === trickPoints ||
        state.score[1] === 0 && state.score[0] === trickPoints);

    quickPlay(36);
    state = game.getFullState();
    assert.equal(state.score[0] + state.score[1], 120);
  });
});