text:
package com.google.android.libraries.social.circlemembership.ui;

import aaw;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ProgressBar;
import android.widget.TextView;
import efj;
import gxq;
import gxs;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import pju;
import pkf;

public final class CirclesButton
  extends ViewGroup
  implements gxs
{
  private static boolean e;
  private static Drawable f;
  private static Drawable g;
  private static Drawable h;
  private static Drawable i;
  private static Drawable j;
  private static Drawable k;
  private static Drawable l;
  private static Drawable m;
  private static Drawable n;
  private static int o;
  private static int p;
  private static int q;
  private static int r;
  private Rect A = new Rect();
  private boolean B;
  private boolean C;
  private Rect D = new Rect();
  final TextView a;
  List<String> b;
  public boolean c = true;
  int d;
  private int s;
  private Drawable t;
  private boolean u;
  private final TextView v;
  private ProgressBar w;
  private Rect x = new Rect();
  private final StringBuilder y = new StringBuilder();
  private boolean z;

  public CirclesButton(Context paramContext)
  {
    super(paramContext);
    if (!e)
    {
      e = true;
      Resources localResources = getResources();
      o = localResources.getDimensionPixelSize(efj.Gz);
      p = localResources.getDimensionPixelSize(efj.GA);
      q = localResources.getDimensionPixelSize(efj.GC);
      r = localResources.getDimensionPixelSize(efj.GB);
      h = localResources.getDrawable(efj.GI);
      f = localResources.getDrawable(efj.GG);
      g = localResources.getDrawable(efj.GH);
      k = localResources.getDrawable(efj.GK);
      l = localResources.getDrawable(efj.GL);
      i = localResources.getDrawable(efj.GD);
      j = localResources.getDrawable(efj.GE);
      m = localResources.getDrawable(efj.GF);
      n = localResources.getDrawable(efj.GJ);
      h.setFilterBitmap(true);
      f.setFilterBitmap(true);
      g.setFilterBitmap(true);
      k.setFilterBitmap(true);
      i.setFilterBitmap(true);
      j.setFilterBitmap(true);
      m.setFilterBitmap(true);
    }
    Context localContext = getContext();
    this.a = new TextView(localContext);
    this.a.setTextAppearance(localContext, aaw.nL);
    this.a.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
    this.a.setSingleLine();
    this.a.setEllipsize(TextUtils.TruncateAt.END);
    this.a.setGravity(16);
    addView(this.a);
    this.v = new TextView(localContext);
    this.v.setTextAppearance(localContext, aaw.nJ);
    this.v.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
    this.v.setGravity(16);
    this.v.setSingleLine();
    this.v.setEllipsize(TextUtils.TruncateAt.END);
    addView(this.v);
    this.d = 0;
    a(this.d);
  }

  public CirclesButton(Context paramContext, AttributeSet paramAttributeSet)
  {
    super(paramContext, paramAttributeSet);
    if (!e)
    {
      e = true;
      Resources localResources = getResources();
      o = localResources.getDimensionPixelSize(efj.Gz);
      p = localResources.getDimensionPixelSize(efj.GA);
      q = localResources.getDimensionPixelSize(efj.GC);
      r = localResources.getDimensionPixelSize(efj.GB);
      h = localResources.getDrawable(efj.GI);
      f = localResources.getDrawable(efj.GG);
      g = localResources.getDrawable(efj.GH);
      k = localResources.getDrawable(efj.GK);
      l = localResources.getDrawable(efj.GL);
      i = localResources.getDrawable(efj.GD);
      j = localResources.getDrawable(efj.GE);
      m = localResources.getDrawable(efj.GF);
      n = localResources.getDrawable(efj.GJ);
      h.setFilterBitmap(true);
      f.setFilterBitmap(true);
      g.setFilterBitmap(true);
      k.setFilterBitmap(true);
      i.setFilterBitmap(true);
      j.setFilterBitmap(true);
      m.setFilterBitmap(true);
    }
    Context localContext = getContext();
    this.a = new TextView(localContext);
    this.a.setTextAppearance(localContext, aaw.nL);
    this.a.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
    this.a.setSingleLine();
    this.a.setEllipsize(TextUtils.TruncateAt.END);
    this.a.setGravity(16);
    addView(this.a);
    this.v = new TextView(localContext);
    this.v.setTextAppearance(localContext, aaw.nJ);
    this.v.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
    this.v.setGravity(16);
    this.v.setSingleLine();
    this.v.setEllipsize(TextUtils.TruncateAt.END);
    addView(this.v);
    this.d = 0;
    a(this.d);
  }

  public CirclesButton(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    if (!e)
    {
      e = true;
      Resources localResources = getResources();
      o = localResources.getDimensionPixelSize(efj.Gz);
      p = localResources.getDimensionPixelSize(efj.GA);
      q = localResources.getDimensionPixelSize(efj.GC);
      r = localResources.getDimensionPixelSize(efj.GB);
      h = localResources.getDrawable(efj.GI);
      f = localResources.getDrawable(efj.GG);
      g = localResources.getDrawable(efj.GH);
      k = localResources.getDrawable(efj.GK);
      l = localResources.getDrawable(efj.GL);
      i = localResources.getDrawable(efj.GD);
      j = localResources.getDrawable(efj.GE);
      m = localResources.getDrawable(efj.GF);
      n = localResources.getDrawable(efj.GJ);
      h.setFilterBitmap(true);
      f.setFilterBitmap(true);
      g.setFilterBitmap(true);
      k.setFilterBitmap(true);
      i.setFilterBitmap(true);
      j.setFilterBitmap(true);
      m.setFilterBitmap(true);
    }
    Context localContext = getContext();
    this.a = new TextView(localContext);
    this.a.setTextAppearance(localContext, aaw.nL);
    this.a.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
    this.a.setSingleLine();
    this.a.setEllipsize(TextUtils.TruncateAt.END);
    this.a.setGravity(16);
    addView(this.a);
    this.v = new TextView(localContext);
    this.v.setTextAppearance(localContext, aaw.nJ);
    this.v.setLayoutParams(new ViewGroup.LayoutParams(-2, -1));
    this.v.setGravity(16);
    this.v.setSingleLine();
    this.v.setEllipsize(TextUtils.TruncateAt.END);
    addView(this.v);
    this.d = 0;
    a(this.d);
  }

  private final int a()
  {
    if (Build.VERSION.SDK_INT >= 21)
    {
      TypedValue localTypedValue1 = new TypedValue();
      getContext().getTheme().resolveAttribute(16843868, localTypedValue1, true);
      return localTypedValue1.resourceId;
    }
    TypedValue localTypedValue2 = new TypedValue();
    getContext().getTheme().resolveAttribute(16843534, localTypedValue2, true);
    return localTypedValue2.resourceId;
  }

  private final void a(StringBuilder paramStringBuilder, int paramInt)
  {
    int i1 = 0;
    int i2;
    Object localObject;
    if (this.b == null)
    {
      i2 = 0;
      if (paramInt != i2) {
        break label76;
      }
      localObject = this.b;
    }
    for (;;)
    {
      label76:
      ArrayList localArrayList;
      if (i1 < paramInt)
      {
        if (i1 > 0) {
          paramStringBuilder.append(", ");
        }
        paramStringBuilder.append((String)((List)localObject).get(i1));
        i1++;
        continue;
        i2 = this.b.size();
        break;
        localArrayList = new ArrayList(this.b);
        while (localArrayList.size() > paramInt)
        {
          int i3 = 0;
          int i4 = -1;
          int i5 = 0;
          while (i3 < localArrayList.size())
          {
            int i6 = ((String)localArrayList.get(i3)).length();
            if (i6 >= i5)
            {
              i4 = i3;
              i5 = i6;
            }
            i3++;
          }
          localArrayList.remove(i4);
        }
      }
      if (paramInt < i2) {
        paramStringBuilder.append(",…");
      }
      return;
      localObject = localArrayList;
      i1 = 0;
    }
  }

  public final void a(int paramInt)
  {
    this.d = paramInt;
    this.C = false;
    this.s = o;
    this.a.setVisibility(0);
    if (TextUtils.isEmpty(getContentDescription())) {
      setContentDescription(getResources().getString(efj.GP));
    }
    switch (paramInt)
    {
    default:
      return;
    case 0:
    case 14:
      setBackgroundResource(efj.GN);
      this.a.setTextAppearance(getContext(), aaw.nK);
      this.c = true;
      this.t = g;
      this.C = true;
      return;
    case 1:
      setBackgroundResource(efj.GN);
      this.a.setTextAppearance(getContext(), aaw.nK);
      this.c = true;
      this.t = f;
      this.C = true;
      this.a.setVisibility(8);
      this.v.setVisibility(8);
      return;
    case 2:
      setBackgroundResource(efj.GN);
      this.a.setTextAppearance(getContext(), aaw.nK);
      this.c = true;
      this.t = h;
      this.C = true;
      this.a.setVisibility(8);
      this.v.setVisibility(8);
      return;
    case 3:
      setBackgroundResource(a());
      this.c = true;
      this.t = n;
      this.a.setVisibility(8);
      this.v.setVisibility(8);
      setContentDescription(getResources().getString(efj.GS));
      return;
    case 4:
    case 10:
    case 13:
      setBackgroundResource(efj.GM);
      this.a.setTextAppearance(getContext(), aaw.nL);
      this.c = true;
      this.t = j;
      return;
    case 5:
      setBackgroundResource(efj.GN);
      this.a.setTextAppearance(getContext(), aaw.nL);
      this.c = true;
      this.t = k;
      return;
    case 6:
      setBackgroundResource(efj.GM);
      this.a.setTextAppearance(getContext(), aaw.nL);
      this.c = true;
      this.t = j;
      this.s = p;
      return;
    case 7:
      setBackgroundResource(efj.GM);
      this.a.setTextAppearance(getContext(), aaw.nL);
      this.c = true;
      this.t = j;
      return;
    case 8:
      setBackgroundResource(efj.GM);
      this.a.setTextAppearance(getContext(), aaw.nL);
      this.c = true;
      this.t = j;
      this.a.setVisibility(8);
      this.v.setVisibility(8);
      return;
    case 9:
      setBackgroundResource(a());
      this.c = true;
      this.t = l;
      this.a.setVisibility(8);
      this.v.setVisibility(8);
      return;
    case 11:
      setBackgroundResource(efj.GN);
      a(getResources().getString(efj.GR));
      this.a.setTextAppearance(getContext(), aaw.nK);
      this.c = false;
      return;
    }
    TypedValue localTypedValue = new TypedValue();
    getContext().getTheme().resolveAttribute(16843534, localTypedValue, true);
    setBackgroundResource(localTypedValue.resourceId);
    a(getResources().getString(efj.GR));
    this.a.setTextAppearance(getContext(), aaw.nM);
    this.a.setAllCaps(true);
    this.c = false;
  }

  public final void a(String paramString)
  {
    if (!TextUtils.isEmpty(paramString)) {}
    for (boolean bool = true;; bool = false)
    {
      this.u = bool;
      if (!TextUtils.equals(this.a.getText(), paramString))
      {
        this.a.setText(paramString);
        setContentDescription(paramString);
        requestLayout();
      }
      return;
    }
  }

  public final void a(List<String> paramList)
  {
    a(null);
    this.b = paramList;
    if ((this.b != null) && (!this.b.isEmpty()))
    {
      Collections.sort(this.b, String.CASE_INSENSITIVE_ORDER);
      a(0);
    }
    for (;;)
    {
      requestLayout();
      return;
      a(4);
    }
  }

  public final void a(boolean paramBoolean)
  {
    if (this.z != paramBoolean)
    {
      this.z = paramBoolean;
      if (!paramBoolean) {
        break label68;
      }
      if (this.w == null)
      {
        this.w = new ProgressBar(getContext());
        this.w.setIndeterminate(true);
        addView(this.w);
      }
      this.w.setVisibility(0);
    }
    for (;;)
    {
      invalidate();
      return;
      label68:
      if (this.w != null) {
        this.w.setVisibility(8);
      }
    }
  }

  @Deprecated
  public final void b(boolean paramBoolean)
  {
    if (this.B != paramBoolean)
    {
      this.B = paramBoolean;
      requestLayout();
      invalidate();
    }
  }

  protected final void dispatchDraw(Canvas paramCanvas)
  {
    if (this.c)
    {
      this.t.setBounds(this.A);
      this.t.draw(paramCanvas);
    }
    if ((this.B) && (this.C))
    {
      m.setBounds(this.D);
      m.draw(paramCanvas);
    }
    super.dispatchDraw(paramCanvas);
  }

  protected final void onDetachedFromWindow()
  {
    super.onDetachedFromWindow();
  }

  protected final void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    int i1 = paramInt3 - paramInt1;
    int i2 = paramInt4 - paramInt2;
    int i3 = i1 - this.x.left - this.x.right;
    int i4 = i2 - this.x.top - this.x.bottom;
    int i5 = i1 - this.x.right;
    int i6 = i2 - this.x.bottom;
    int i7 = this.a.getMeasuredHeight();
    if (this.z)
    {
      int i23 = this.w.getMeasuredWidth();
      int i24 = this.w.getMeasuredHeight();
      int i25 = (i1 - i23) / 2;
      int i26 = (i2 - i24) / 2;
      this.w.layout(i25, i26, i25 + i23, i23 + i26);
    }
    boolean bool1 = this.c;
    int i8 = 0;
    if (bool1)
    {
      i8 = 0 + this.t.getIntrinsicWidth();
      if (this.a.getVisibility() == 0) {
        i8 += this.s;
      }
    }
    if (this.v.getVisibility() == 0) {
      i8 += this.v.getMeasuredWidth() + q;
    }
    int i9 = i8 + this.a.getMeasuredWidth();
    boolean bool2 = this.B;
    int i10 = 0;
    if (bool2)
    {
      boolean bool3 = this.C;
      i10 = 0;
      if (bool3)
      {
        i10 = m.getIntrinsicWidth();
        i9 += i10 + this.s;
      }
    }
    int i11 = this.x.left + (i3 - i9) / 2;
    if (i11 < this.x.left) {
      i11 = this.x.left;
    }
    int i12 = this.x.top + (i4 - i7) / 2;
    if (i12 < this.x.top) {
      i12 = this.x.top;
    }
    int i13 = i9 + i11;
    if (i13 > i5) {
      i13 = i5;
    }
    int i14 = i12 + Math.min(i2, i7);
    if (i14 > i6) {
      i14 = i6;
    }
    if (this.c)
    {
      int i20 = this.t.getIntrinsicHeight();
      int i21 = this.t.getIntrinsicWidth();
      int i22 = this.x.top + (i4 - i20) / 2;
      this.A.set(i11, i22, i11 + i21, i20 + i22);
      i11 += i21 + this.s;
    }
    if ((this.B) && (this.C))
    {
      int i17 = m.getIntrinsicHeight();
      int i18 = this.x.top + (i4 - i17) / 2;
      int i19 = i13 - i10;
      this.D.set(i19, i18, i10 + i19, i17 + i18);
      i13 = i19 - this.s;
    }
    if (this.v.getVisibility() == 0)
    {
      if (this.a.getVisibility() != 0) {
        break label635;
      }
      int i15 = this.v.getMeasuredWidth();
      int i16 = i13 - i15;
      this.v.layout(i16, i12, i15 + i16, i14);
      i13 = i16 - q;
    }
    for (;;)
    {
      if (this.a.getVisibility() == 0) {
        this.a.layout(i11, i12, i13, i14);
      }
      return;
      label635:
      this.v.layout(i11, i12, i13, i14);
    }
  }

  protected final void onMeasure(int paramInt1, int paramInt2)
  {
    Drawable localDrawable = getBackground();
    int i1 = localDrawable.getMinimumWidth();
    int i2 = localDrawable.getMinimumHeight();
    int i3;
    int i6;
    label92:
    int i8;
    label108:
    int i11;
    label192:
    int i12;
    label220:
    int i13;
    int i16;
    int i17;
    int i19;
    int i20;
    if (this.a.getVisibility() != 8)
    {
      i3 = 1;
      if (localDrawable != null) {
        localDrawable.getPadding(this.x);
      }
      Rect localRect1 = this.x;
      Rect localRect2 = this.x;
      int i4 = r;
      localRect2.right = i4;
      localRect1.left = i4;
      int i5 = View.MeasureSpec.getMode(paramInt1);
      if (i5 != 0) {
        break label600;
      }
      i6 = 2147483647;
      int i7 = View.MeasureSpec.getMode(paramInt2);
      if (i7 != 0) {
        break label609;
      }
      i8 = 2147483647;
      boolean bool = this.c;
      int i9 = 0;
      int i10 = 0;
      if (bool)
      {
        int i28 = this.t.getIntrinsicWidth();
        if (i3 != 0) {
          i28 += this.s;
        }
        int i29 = this.t.getIntrinsicHeight();
        i10 = i28;
        i9 = i29;
      }
      if ((!this.B) || (!this.C)) {
        break label618;
      }
      i11 = m.getIntrinsicWidth() + this.s;
      if (i3 == 0) {
        break label624;
      }
      i12 = i6 - i10 - this.x.left - this.x.right;
      i13 = View.MeasureSpec.makeMeasureSpec(i8, -2147483648);
      if ((i3 != 0) && (this.u))
      {
        this.v.setVisibility(8);
        this.a.measure(View.MeasureSpec.makeMeasureSpec(i12, -2147483648), i13);
        i12 = this.a.getMeasuredWidth();
      }
      if (i5 != 1073741824) {
        i6 = Math.max(i1, i11 + (i12 + i10)) + this.x.left + this.x.right;
      }
      if (i7 != 1073741824) {
        i8 = Math.max(i2, Math.max(i9, this.a.getMeasuredHeight())) + this.x.top + this.x.bottom;
      }
      int i14 = Math.max(i6, getSuggestedMinimumWidth());
      int i15 = Math.max(i8, getSuggestedMinimumHeight());
      i16 = resolveSize(i14, paramInt1);
      i17 = resolveSize(i15, paramInt2);
      if ((i3 != 0) && (!this.u))
      {
        i19 = i16 - i10 - this.x.left - this.x.right;
        if ((this.B) && (this.C)) {
          i19 -= i11 + this.s;
        }
        this.y.setLength(0);
        if (this.b != null) {
          break label630;
        }
        i20 = 0;
        label476:
        a(this.y, i20);
        String str1 = this.y.toString();
        this.a.setText(str1);
        setContentDescription(str1);
        this.a.measure(0, i13);
        if (this.a.getMeasuredWidth() > i19) {
          break label644;
        }
        this.v.setVisibility(8);
      }
    }
    for (;;)
    {
      if (this.z)
      {
        int i18 = View.MeasureSpec.makeMeasureSpec(i17 - this.x.top - this.x.bottom, 1073741824);
        this.w.measure(i18, i18);
      }
      setMeasuredDimension(i16, i17);
      return;
      i3 = 0;
      break;
      label600:
      i6 = View.MeasureSpec.getSize(paramInt1);
      break label92;
      label609:
      i8 = View.MeasureSpec.getSize(paramInt2);
      break label108;
      label618:
      i11 = 0;
      break label192;
      label624:
      i12 = 0;
      break label220;
      label630:
      i20 = this.b.size();
      break label476;
      label644:
      if (i20 == 1)
      {
        this.a.measure(View.MeasureSpec.makeMeasureSpec(i19, -2147483648), i13);
        this.v.setVisibility(8);
      }
      else
      {
        Resources localResources = getResources();
        this.v.setVisibility(0);
        int i21 = i20 - 1;
        int i22 = 2147483647;
        for (int i23 = i21; i23 > 0; i23--)
        {
          this.y.setLength(0);
          a(this.y, i23);
          String str3 = this.y.toString();
          this.a.setText(str3);
          setContentDescription(str3);
          this.a.measure(0, i13);
          int i25 = this.a.getMeasuredWidth();
          int i26 = i20 - i23;
          TextView localTextView = this.v;
          int i27 = efj.GO;
          Object[] arrayOfObject2 = new Object[1];
          arrayOfObject2[0] = Integer.valueOf(i26);
          localTextView.setText(localResources.getQuantityString(i27, i26, arrayOfObject2));
          this.v.measure(0, i13);
          i22 = this.v.getMeasuredWidth() + (i25 + q);
          if (i22 <= i19) {
            break;
          }
        }
        if (i22 > i19)
        {
          this.v.setVisibility(8);
          int i24 = efj.GQ;
          Object[] arrayOfObject1 = new Object[1];
          arrayOfObject1[0] = Integer.valueOf(i20);
          String str2 = localResources.getString(i24, arrayOfObject1);
          this.a.setText(str2);
          setContentDescription(str2);
          this.a.measure(View.MeasureSpec.makeMeasureSpec(i19, -2147483648), i13);
        }
      }
    }
  }

  public final gxq v()
  {
    switch (this.d)
    {
    case 12:
    default:
      return new gxq(pkf.e);
    case 11:
      return new gxq(pkf.f);
    case 14:
      return new gxq(pju.C);
    }
    return new gxq(pju.p);
  }
}

/* Location:           F:\apktool\apktool\com.google.android.apps.plus\classes-dex2jar.jar

 * Qualified Name:     com.google.android.libraries.social.circlemembership.ui.CirclesButton

 * JD-Core Version:    0.7.0.1

 */


text:
import signal
from rabbit2ev.rabbitmq import RabbitHandler

def main():
    def signal_handler(signal, frame):
        server.stop()

    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTERM, signal_handler)

    server = RabbitHandler()
    server.config = 'conf/rabbit2mail.ini'
    server.start()

if __name__ == '__main__':
    main()

redpajama_set_name: RedPajamaGithub


text:
describe("Bancha.scaffold.Util tests",function() {
    var util = Bancha.scaffold.Util;

    it("should pass all Bancha.scaffold.Util.toFirstUpper tests", function() {
        expect('User').toEqual(util.toFirstUpper('user'));
        expect('UserName').toEqual(util.toFirstUpper('userName'));
    });

    it("should pass all Bancha.scaffold.Util.humanize tests", function() {

        // first upper case
        expect('User').toEqual(util.humanize('user'));

        // ids
        expect('User').toEqual(util.humanize('user_id'));

        // underscores
        expect('User name').toEqual(util.humanize('user_name'));
        expect('Name with many spaces').toEqual(util.humanize('name_with_many_spaces'));

        // camel case
        expect('User name').toEqual(util.humanize('userName'));
        expect('Name with many spaces').toEqual(util.humanize('nameWithManySpaces'));

        // shouldn't change normal text
        expect('John Smith').toEqual(util.humanize('John Smith'));
        expect('This is a normal text with spaces, Upper case words and all UPPER CASE words!'
               ).toEqual(util.humanize('This is a normal text with spaces, Upper case words '+
               'and all UPPER CASE words!'));
    });

    it("should humanize class names", function() {
        // Standard namespaced and not namespaced
        expect('User').toEqual(util.humanizeClassName('Bancha.model.User'));
        expect('User').toEqual(util.humanizeClassName('Bancha.User'));
        expect('User').toEqual(util.humanizeClassName('User'));

        // check humanizing part
        expect('Awesome class').toEqual(util.humanizeClassName('Bancha.model.AwesomeClass'));
    });

    it("should replace button placeholder from an button config", function() {

        expect().toEqual(util.replaceButtonPlaceHolders()); //undefined
        expect([]).toEqual(util.replaceButtonPlaceHolders([])); //empty

        var config = {
            createButtonConfig: {
                myCreate: true
            },
            resetButtonConfig: {
                myReset: true
            },
            saveButtonConfig: {
                mySave: true
            },
            onCreate: function(a) {},
            onReset: function(b) {},
            onSave: function(c) {}
        };
        var scope =  {
            scoped:true
        };

        // test create button
        var expected = ['->',{
            myCreate: true,
            scope: scope,
            handler: config.onCreate
        }];
        expect(util.replaceButtonPlaceHolders(['->','create'], config, scope)).toEqual(expected);

        // test reset button
        expected.push({
            myReset: true,
            scope: scope,
            handler: config.onReset
        });
        expect(util.replaceButtonPlaceHolders(['->','create','reset'], config, scope)).toEqual(expected);

        // test save button
        expected.push({
            mySave: true,
            scope: scope,
            handler: config.onSave
        });
        expect(util.replaceButtonPlaceHolders(['->','create','reset','save'], config, scope)).toEqual(expected);

        // test with only the save button
        expected = [expected[3]];
        expect(expected).toEqual(util.replaceButtonPlaceHolders(['save'], config, scope));

        // test support for custom configs
        expected.push({
            myCustom: 'button-config'
        });
        expect(util.replaceButtonPlaceHolders(['save', {myCustom: 'button-config'}], config, scope)).toEqual(expected);
    });

    it("should inject buttons scopes for #replaceButtonPlaceHolders", function() {
        var input = [{
            myButton: true,
            scope: 'scaffold-scope-me'
        }];
        var scope =  {
            scoped:true
        };
        var expected = [{
            myButton: true,
            scope: {
                scoped:true
            }
        }];
        expect(util.replaceButtonPlaceHolders(input, {}, scope)).toEqual(expected);
    });

    it("should return a boolean when calling isModel, given a model or model name", function() {
        // return null if model doesn't exist
        expect(util.isModel(null)).toBeFalsy();
        expect(util.isModel('RANDOM_NONSENSE')).toBeFalsy();

        // return the class is a model is given
        Ext.define('Bancha.model.UtilSpecTestModel1', {
            extend: 'Ext.data.Model'
        });
        expect(util.isModel('Bancha.model.UtilSpecTestModel1')).toBeTruthy();
        expect(util.isModel(Bancha.model.UtilSpecTestModel1)).toBeTruthy();

        // return null if a class, but not a model
        Ext.define('Bancha.model.UtilSpecTestClass1', {
        });
        expect(util.isModel('Bancha.model.UtilSpecTestClass1')).toBeFalsy();
        expect(util.isModel(Bancha.model.UtilSpecTestClass1)).toBeFalsy();
    });

    it("should return a model given when calling getModel, given a model or model name", function() {
        // return null if model doesn't exist
        expect(Ext.Function.bind(util.getModel, util, [null])).toThrow();
        expect(Ext.Function.bind(util.getModel, util, ['RANDOM_NONSENSE'])).toThrow();

        // return the class is a model is given
        Ext.define('Bancha.model.UtilSpecTestModel2', {
            extend: 'Ext.data.Model'
        });
        expect(util.getModel('Bancha.model.UtilSpecTestModel2')).toEqual(Bancha.model.UtilSpecTestModel2);
        expect(util.getModel(Bancha.model.UtilSpecTestModel2)).toEqual(Bancha.model.UtilSpecTestModel2);

        // return null if a class, but not a model
        Ext.define('Bancha.model.UtilSpecTestClass2', {
        });
        expect(Ext.Function.bind(util.getModel, util, ['Bancha.model.UtilSpecTestClass2'])).toThrow();
        expect(Ext.Function.bind(util.getModel, util, [Bancha.model.UtilSpecTestClass2])).toThrow();
    });

});


text:
package org.zstack.storage.primary.smp;

import org.zstack.core.config.GlobalConfig;
import org.zstack.core.config.GlobalConfigDefinition;
import org.zstack.core.config.GlobalConfigValidation;
import org.zstack.header.storage.primary.PrimaryStorageVO;
import org.zstack.resourceconfig.BindResourceConfig;

/**
 * Created by AlanJager on 2017/3/14.
 */
@GlobalConfigDefinition
public class SMPPrimaryStorageGlobalConfig {
    public static final String CATEGORY = "sharedMountPointPrimaryStorage";

    @GlobalConfigValidation
    public static GlobalConfig GC_INTERVAL = new GlobalConfig(CATEGORY, "deletion.gcInterval");

    @GlobalConfigValidation(validValues = {"none", "metadata", "falloc", "full"})
    @BindResourceConfig({PrimaryStorageVO.class})
    public static GlobalConfig QCOW2_ALLOCATION = new GlobalConfig(CATEGORY, "qcow2.allocation");
}


text:
package com.modeln.build.web.forms;

import com.modeln.build.common.data.account.UserData;
import com.modeln.build.web.errors.*;

/**
 * The ValidateUserData class contains field validation methods for
 * the field values used to create a UserData object.  If a value
 * is not valid for its associated field, the appropriate ErrorMap
 * code will be returned indicating the cause of the error.
 *
 * @version            $Revision: 1.1.1.1 $
 * @author             Shawn Stafford
 *
 */
public class ValidateUserData {

    public static final int MIN_USERNAME_LENGTH =  3;
    public static final int MAX_USERNAME_LENGTH = 32;
    public static final int MIN_PASSWORD_LENGTH =  6;
    public static final int MAX_PASSWORD_LENGTH = 32;

    public static final String usernameCharSet =
        "abcdefghijklmnopqrstuvwxyz" +
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
        "1234567890-.";

    public static final String passwordCharSet =
        "abcdefghijklmnopqrstuvwxyz" +
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
        "1234567890-_.~@!#$%^&*?";

    /**
     * Validate the username field.
     *
     * @param   username    Value to be validated
     */
    public static int validateUsername(String username) {
        if ((username != null) && (username.length() > 0)) {
            if (username.length() < MIN_USERNAME_LENGTH) {
                return ErrorMap.LOGIN_TOO_SHORT;
            }

            if (username.length() > MAX_USERNAME_LENGTH) {
                return ErrorMap.LOGIN_TOO_LONG;
            }

            if (!isValidString(username, usernameCharSet)) {
                return ErrorMap.INVALID_LOGIN_CHARACTER;
            }
        } else {
            return ErrorMap.LOGIN_TOO_SHORT;
        }

        return ErrorMap.NO_ERROR;
    }

    /**
     * Validate the password field.
     *
     * @param   password    Value to be validated
     */
    public static int validatePassword(String password) {
        if ((password != null) && (password.length() > 0)) {
            if (password.length() < MIN_PASSWORD_LENGTH) {
                return ErrorMap.PASSWORD_TOO_SHORT;
            }

            if (password.length() > MAX_PASSWORD_LENGTH) {
                return ErrorMap.PASSWORD_TOO_LONG;
            }

            if (!isValidString(password, passwordCharSet)) {
                return ErrorMap.INVALID_PASSWORD_CHARACTER;
            }

        } else {
            return ErrorMap.PASSWORD_TOO_SHORT;
        }

        return ErrorMap.NO_ERROR;
    }

    /**
     * Determine whether the string contains valid characters.
     *
     * @param   str     String to be validated
     * @param   set     Set of valid characters
     * @return  TRUE if the string contains only valid characters
     */
    public static boolean isValidString(String str, String set) {
        boolean valid = true;

        // Check every letter in the string for validity
        for (int idx = 0; idx < str.length(); idx++) {
            char ch = str.charAt(idx);
            if (set.indexOf(ch) < 0) {
                return false;
            }
        }

        return valid;
    }

    /**
     * Determine whether one string is a circular combination of the other.
     * This is most often used to ensure that the password does not contain
     * some combination of another element such as the username.
     *
     * @param   str     String to be validated
     * @param   ref     Reference string
     * @return  TRUE if the string is a circular variation of the reference string
     */
    public static boolean isCircular(String str, String ref) {
        String reverseStr = "";
        int len = str.length();

        //Password = reverse(userid) ?
        for (int o = len - 1; o >= 0; reverseStr += str.charAt(o--));
        if (ref.equals(reverseStr)) { return true; }

        //Password = userid or duseri or seridu etc. ?
        for (int i = 0; i < len; i++) {
            if (ref.equals(str.substring(i, len) + str.substring(0, i))) {
                return true;
            }
        }

        return false;
    }

}


text:
local Cache = require "res.Cache"
local util = require "res.util"
local Pool = require "res.Pool"
local SingltonPool = require "res.SingltonPool"
local MultiPool = require "res.MultiPool"

local Timer = require "common.Timer"
local SimpleEvent = require "common.SimpleEvent"
local res = require "res.res"

local ipairs = ipairs
local unpack = unpack

local resmgr = {}
resmgr.cachePolicyType = 0

function resmgr.dump()
    --ResUpdater.ResDumper.Dump()
    util.dump(Pool, Cache)
    util.dump(Timer)
    util.dump(SimpleEvent)
end

local function purge(Cls)
    for _, cache in ipairs(Cls.all) do
        cache:_purge()
    end
end

function resmgr.setCacheFactor(cacheFactor)
    if res.cacheFactor == cacheFactor then
        return
    end

    res.cacheFactor = cacheFactor
    purge(SingltonPool)
    purge(MultiPool)
    purge(Pool)
    purge(Cache)
end

function resmgr.setCachePolicyParam(cacheOrPool, ...)
    cacheOrPool._cachePolicyParams = { ... }
end

local function setPolicy(Cls)
    for _, cache in ipairs(Cls.all) do
        if cache._cachePolicyParams then
            local param = cache._cachePolicyParams[resmgr.cachePolicyType]
            if param then
                cache:setCachePolicy(unpack(param))
                cache:_purge()
            end
        end
    end
end

function resmgr.chooseCachePolicy(type)
    if resmgr.cachePolicyType == type then
        return
    end
    resmgr.cachePolicyType = type
    setPolicy(SingltonPool)
    setPolicy(MultiPool)
    setPolicy(Pool)
    setPolicy(Cache)
end

function resmgr.purgeOnly(cacheFactor)
    local oldCacheFactor = res.cacheFactor
    resmgr.setCacheFactor(cacheFactor)
    res.cacheFactor = oldCacheFactor
end

return resmgr


text:
package io.takari.bpm;

import io.takari.bpm.api.ExecutionException;
import io.takari.bpm.api.interceptors.ExecutionInterceptor;
import io.takari.bpm.api.interceptors.ExecutionInterceptorAdapter;
import io.takari.bpm.dsl.*;
import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.*;

public class SimpleDSLTest extends AbstractEngineTest {

    @Before
    public void initDsl() {
        SimpleDSL.registerDslTask(getServiceTaskRegistry());
    }

    @Test
    public void testTrivial() throws Exception {
        Flow masterFlow = new Flow("master",
                new TaskStep("shell1"),
                new TaskStep("shell2"));

        deploy(SimpleDSL.from(masterFlow));

        // ---

        String key = "abc";
        getEngine().start(key, "master", null);

        // shuffle a bit

        getEngine().resume(key, "ok_shell1", null);
        getEngine().resume(key, "ok_shell2", null);
    }

    @Test
    public void testSimple() throws Exception {
        Flow masterFlow = new Flow("master",
                new ParallelStep(
                        new TaskStep("shell4"),
                        new TaskStep("shell5"),
                        new TaskStep("shell6")));

        deploy(SimpleDSL.from(masterFlow));

        // ---

        String key = "abc";
        getEngine().start(key, "master", null);

        // shuffle a bit

        getEngine().resume(key, "ok_shell5", null);
        getEngine().resume(key, "ok_shell4", null);
        getEngine().resume(key, "ok_shell6", null);
    }

    @Test
    public void testNested() throws Exception {
        Flow masterFlow = new Flow("master",
                new CallStep("verify"));

        Flow verifyFlow = new Flow("verify",
                new TaskStep("shell1"),
                new TaskStep("shell2"));

        deploy(SimpleDSL.from(masterFlow, verifyFlow));

        // --

        final DelegateInterceptor delegate = mock(DelegateInterceptor.class);
        ExecutionInterceptor interceptor = new ExecutionInterceptorAdapter() {
            @Override
            public void onSuspend() throws ExecutionException {
                delegate.onSuspend();
            }

            @Override
            public void onFinish(String processBusinessKey) throws ExecutionException {
                delegate.onFinish();
            }
        };
        getEngine().addInterceptor(interceptor);

        // ---

        String key = "abc";
        getEngine().start(key, "master", null);
        assertOnSuspend(delegate);

        getEngine().resume(key, "ok_shell1", null);
        assertOnSuspend(delegate);

        getEngine().resume(key, "ok_shell2", null);
        dumpActivations();
        assertOnFinish(delegate);
    }

    @Test
    public void testDeeplyNested() throws Exception {
        Flow masterFlow = new Flow("master",
                new CallStep("verify"));

        Flow setupFlow = new Flow("setup",
                new TaskStep("shell1"));

        Flow verifyFlow = new Flow("verify",
                new CallStep("setup"),
                new TaskStep("shell7"));

        deploy(SimpleDSL.from(masterFlow, setupFlow, verifyFlow));

        // --

        final DelegateInterceptor delegate = mock(DelegateInterceptor.class);
        ExecutionInterceptor interceptor = new ExecutionInterceptorAdapter() {
            @Override
            public void onSuspend() throws ExecutionException {
                delegate.onSuspend();
            }

            @Override
            public void onFinish(String processBusinessKey) throws ExecutionException {
                delegate.onFinish();
            }
        };
        getEngine().addInterceptor(interceptor);

        // ---

        String key = "abc";
        getEngine().start(key, "master", null);
        assertOnSuspend(delegate);

        getEngine().resume(key, "ok_shell1", null);
        assertOnSuspend(delegate);

        // last one

        getEngine().resume(key, "ok_shell7", null);
        assertOnFinish(delegate);
    }

    private static void assertOnSuspend(DelegateInterceptor interceptor) throws Exception {
        verify(interceptor, times(1)).onSuspend();
        verifyNoMoreInteractions(interceptor);
        reset(interceptor);
    }

    private static void assertOnFinish(DelegateInterceptor interceptor) throws Exception {
        verify(interceptor, times(1)).onFinish();
        verifyNoMoreInteractions(interceptor);
        reset(interceptor);
    }

    public interface DelegateInterceptor {

        void onSuspend();

        void onFinish();
    }
}


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Server Application Links</title>

      HTTP Get Example

      HTTP POST Example

      HTTP Defaults Example

      Logging Interceptor Example


text:
This example reads the specified image from the bucket,
runs facial recognition on the faces in the image,
and display attributes of each face,
such as position, age, emotion, and gender.

`go run DetectFaces.go -b BUCKET -i IMAGE`

- _BUCKET_ is the name of the bucket containing the image.
- _IMAGE_ is the name of the JPEG, JPG, or PNG image as the fully-qualified path in the bucket.
  Other formats are not supported.

The unit test accepts similar values in _config.json_.


text:
/** \addtogroup netsocket */
/** @{*/
/* nsapi_dns.h
 * Original work Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de)
 * Modified work Copyright (c) 2015 ARM Limited
 *
 * 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.
 */
#ifndef NSAPI_DNS_H
#define NSAPI_DNS_H

#include "nsapi_types.h"
#ifdef __cplusplus
#include "netsocket/NetworkStack.h"
#endif

#ifndef __cplusplus

/** Query a domain name server for an IP address of a given hostname
 *
 *  @param stack    Network stack as target for DNS query
 *  @param host     Hostname to resolve
 *  @param addr     Destination for the host address
 *  @param version  IP version to resolve
 *  @return         0 on success, negative error code on failure
 *                  NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
        nsapi_addr_t *addr, nsapi_version_t version);

/** Query a domain name server for multiple IP address of a given hostname
 *
 *  @param stack      Network stack as target for DNS query
 *  @param host       Hostname to resolve
 *  @param addr       Array for the host addresses
 *  @param addr_count Number of addresses allocated in the array
 *  @param version    IP version to resolve
 *  @return           Number of addresses found on success, negative error code on failure
 *                    NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack, const char *host,
        nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version);

/** Add a domain name server to list of servers to query
 *
 *  @param addr     Destination for the host address
 *  @return         0 on success, negative error code on failure
 */
nsapi_error_t nsapi_dns_add_server(nsapi_addr_t addr);

#else

/** Query a domain name server for an IP address of a given hostname
 *
 *  @param stack    Network stack as target for DNS query
 *  @param host     Hostname to resolve
 *  @param addr     Destination for the host address
 *  @param version  IP version to resolve (defaults to NSAPI_IPv4)
 *  @return         0 on success, negative error code on failure
 *                  NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
nsapi_error_t nsapi_dns_query(NetworkStack *stack, const char *host,
        SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4);

/** Query a domain name server for an IP address of a given hostname
 *
 *  @param stack    Network stack as target for DNS query
 *  @param host     Hostname to resolve
 *  @param addr     Destination for the host address
 *  @param version  IP version to resolve (defaults to NSAPI_IPv4)
 *  @return         0 on success, negative error code on failure
 *                  NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
extern "C" nsapi_error_t nsapi_dns_query(nsapi_stack_t *stack, const char *host,
        nsapi_addr_t *addr, nsapi_version_t version = NSAPI_IPv4);

/** Query a domain name server for an IP address of a given hostname
 *
 *  @param stack    Network stack as target for DNS query
 *  @param host     Hostname to resolve
 *  @param addr     Destination for the host address
 *  @param version  IP version to resolve (defaults to NSAPI_IPv4)
 *  @return         0 on success, negative error code on failure
 *                  NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
template <typename S>
nsapi_error_t nsapi_dns_query(S *stack, const char *host,
        SocketAddress *addr, nsapi_version_t version = NSAPI_IPv4)
{
    return nsapi_dns_query(nsapi_create_stack(stack), host, addr, version);
}

/** Query a domain name server for multiple IP address of a given hostname
 *
 *  @param stack      Network stack as target for DNS query
 *  @param host       Hostname to resolve
 *  @param addr       Array for the host addresses
 *  @param addr_count Number of addresses allocated in the array
 *  @param version    IP version to resolve (defaults to NSAPI_IPv4)
 *  @return           Number of addresses found on success, negative error code on failure
 *                    NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const char *host,
        SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);

/** Query a domain name server for multiple IP address of a given hostname
 *
 *  @param stack      Network stack as target for DNS query
 *  @param host       Hostname to resolve
 *  @param addr       Array for the host addresses
 *  @param addr_count Number of addresses allocated in the array
 *  @param version    IP version to resolve (defaults to NSAPI_IPv4)
 *  @return           Number of addresses found on success, negative error code on failure
 *                    NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
extern "C" nsapi_size_or_error_t nsapi_dns_query_multiple(nsapi_stack_t *stack, const char *host,
        nsapi_addr_t *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4);

/** Query a domain name server for multiple IP address of a given hostname
 *
 *  @param stack      Network stack as target for DNS query
 *  @param host       Hostname to resolve
 *  @param addr       Array for the host addresses
 *  @param addr_count Number of addresses allocated in the array
 *  @param version    IP version to resolve (defaults to NSAPI_IPv4)
 *  @return           Number of addresses found on success, negative error code on failure
 *                    NSAPI_ERROR_DNS_FAILURE indicates the host could not be found
 */
template <typename S>
nsapi_size_or_error_t nsapi_dns_query_multiple(S *stack, const char *host,
        SocketAddress *addr, nsapi_size_t addr_count, nsapi_version_t version = NSAPI_IPv4)
{
    return nsapi_dns_query_multiple(nsapi_create_stack(stack),
                host, addr, addr_count, version);
}

/** Add a domain name server to list of servers to query
 *
 *  @param addr     Destination for the host address
 *  @return         0 on success, negative error code on failure
 */
extern "C" nsapi_error_t nsapi_dns_add_server(nsapi_addr_t addr);

/** Add a domain name server to list of servers to query
 *
 *  @param addr     Destination for the host address
 *  @return         0 on success, negative error code on failure
 */
static inline nsapi_error_t nsapi_dns_add_server(const SocketAddress &address)
{
    return nsapi_dns_add_server(address.get_addr());
}

/** Add a domain name server to list of servers to query
 *
 *  @param addr     Destination for the host address
 *  @return         0 on success, negative error code on failure
 */
static inline nsapi_error_t nsapi_dns_add_server(const char *address)
{
    return nsapi_dns_add_server(SocketAddress(address));
}

#endif

#endif

/** @}*/


text:
package com.cinnober.msgcodec;

import java.util.Collections;

import org.junit.Assert;
import org.junit.Test;

/**
 *
 *
 * @author fredrik.bromee, Cinnober Financial Technology
 */
public class AnnotatedSchemaTest {

    String executionReportGroupName = "ExecutionReport";
    String clientOrderIdFieldName = "clOrdID";
    String annotationName = "doc";

    @Test
    public void testRawGroupDef() throws Exception {
        GroupDef groupDef = ExecutionReport.groupDef();
        Schema schema = new Schema(Collections.singletonList(groupDef),null);
        String groupLevelDocForExecReport =
                "An execution report is used for a bunch of things, like confirming the receipt of an order";
        Annotations annotations = new Annotations();
        annotations.path(executionReportGroupName).put(annotationName, groupLevelDocForExecReport);
        String fieldLevelDocForClientOrderId = "Unique identifier for Order as assigned by the buy-side";
        annotations.path(executionReportGroupName, clientOrderIdFieldName)
            .put(annotationName, fieldLevelDocForClientOrderId);

        annotations.toProperties().store(System.out, "Annotations");
        System.out.println();

        schema = schema.replaceAnnotations(annotations);
        System.out.println(schema.toString());
        Assert.assertEquals(groupLevelDocForExecReport, schema.getGroup(executionReportGroupName)
                .getAnnotation(annotationName));
        Assert.assertEquals(fieldLevelDocForClientOrderId, getClientOrderId(schema).getAnnotation(annotationName));
    }

    private FieldDef getClientOrderId(Schema schema) {
        return schema.getGroup(executionReportGroupName).getField(clientOrderIdFieldName);
    }

}


text:
describe "IifeFilter" do
  IifeFilter ||= Rake::Pipeline::Web::Filters::IifeFilter
  MemoryFileWrapper ||= Rake::Pipeline::SpecHelpers::MemoryFileWrapper
  MemoryManifest ||= Rake::Pipeline::SpecHelpers::MemoryManifest

  let(:js_input) { <<-HERE }
var name = "Truckasaurus Gates";
HERE

  let(:expected_js_output) { <<-HERE }
(function() {
var name = "Truckasaurus Gates";
})();
HERE

  def input_file(name, content)
    MemoryFileWrapper.new("/path/to/input", name, "UTF-8", content)
  end

  def output_file(name)
    MemoryFileWrapper.new("/path/to/output", name, "UTF-8")
  end

  def setup_filter(filter)
    filter.file_wrapper_class = MemoryFileWrapper
    filter.manifest = MemoryManifest.new
    filter.last_manifest = MemoryManifest.new
    filter.input_files = [input_file("name.js", js_input)]
    filter.output_root = "/path/to/output"
    filter.rake_application = Rake::Application.new
    filter
  end

  it "generates output" do
    filter = setup_filter IifeFilter.new

    filter.output_files.should == [output_file("name.js")]

    tasks = filter.generate_rake_tasks
    tasks.each(&:invoke)

    file = MemoryFileWrapper.files["/path/to/output/name.js"]
    file.body.should == expected_js_output.chomp
    file.encoding.should == "UTF-8"
  end

  describe "naming output files" do
    it "translates .js extensions to .min.js by default" do
      filter = setup_filter IifeFilter.new
      filter.output_files.first.path.should == "name.js"
    end

    it "accepts a block to customize output file names" do
      filter = setup_filter(IifeFilter.new { |input| "octopus" })
      filter.output_files.first.path.should == "octopus"
    end
  end
end


text:
RdfDatasetCatalog
=================

Java component + application that enables one to express relations between RDF datasets - Data and Meta data are treated as data sets.


text:
<?php
class RF_Form_Element_Date extends Zend_Form_Element_Xhtml {

	protected $_dateFormat = '%year%-%month%-%day%';
	protected $_day;
	protected $_month;
	protected $_year;

	public function __construct($spec, $options = null)
    {
        $this->addPrefixPath(
            'RF_Form_Decorator',
            'RF/Form/Decorator',
            'decorator'
        );
        parent::__construct($spec, $options);
    }

    public function setDay($value) {
		$this->_day = ( int ) $value;
		return $this;
	}

	public function getDay() {
		return $this->_day;
	}

	public function setMonth($value) {
		$this->_month = ( int ) $value;
		return $this;
	}

	public function getMonth() {
		return $this->_month;
	}

	public function setYear($value) {
		$this->_year = ( int ) $value;
		return $this;
	}

	public function getYear() {
		return $this->_year;
	}

	public function setValue($value) {
		if (is_int ( $value )) {
			$this->setDay ( date ( 'd', $value ) )->setMonth ( date ( 'm', $value ) )->setYear ( date ( 'Y', $value ) );
		} elseif (is_string ( $value )) {
			$date = strtotime ( $value );
			$this->setDay ( date ( 'd', $date ) )->setMonth ( date ( 'm', $date ) )->setYear ( date ( 'Y', $date ) );
		} elseif (is_array ( $value ) && (isset ( $value ['day'] ) && isset ( $value ['month'] ) && isset ( $value ['year'] ))) {
			$this->setDay ( $value ['day'] )->setMonth ( $value ['month'] )->setYear ( $value ['year'] );
		} else {
			throw new Exception ( 'Invalid date value provided' );
		}

		return $this;
	}

	public function getValue() {
		return str_replace ( array ('%year%', '%month%', '%day%' ), array ($this->getYear (), $this->getMonth (), $this->getDay () ), $this->_dateFormat );
	}

	public function loadDefaultDecorators()
    {

        $decorators = $this->getDecorators();
        if (empty($decorators)) {
            $this->addDecorator('Date')
                 ->addDecorator('Errors')
                 ->addDecorator('Description', array(
                     'tag'   => 'p',
                     'class' => 'description'
                 ))
                 ->addDecorator('HtmlTag', array(
                     'tag' => 'dd',
                     'id'  => $this->getName() . '-element'
                 ))
                 ->addDecorator('Label', array('tag' => 'dt'));
        }
    }
}


text:
<?php

require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Parser.php';

/**
 * Test cases for CodeDefinition nest limits. If an element is nested beyond
 * its CodeDefinition's nest limit, it should be removed from the parse tree.
 *
 * @author jbowens
 * @since May 2013
 */
class NestLimitTest extends PHPUnit_Framework_TestCase
{

    /**
     * Tests that when elements have no nest limits they may be
     * nested indefinitely.
     */
    public function testIndefiniteNesting()
    {
        $parser = new JBBCode\Parser();
        $parser->addBBCode('b', '{param}', false, true, -1);
        $parser->parse('[b][b][b][b][b][b][b][b]bold text[/b][/b][/b][/b][/b][/b][/b][/b]');
        $this->assertEquals('' .
                'bold text' .
                '',
                $parser->getAsHtml());
    }

    /**
     * Test over nesting.
     */
    public function testOverNesting()
    {
        $parser = new JBBCode\Parser();
        $parser->addCodeDefinitionSet(new JBBCode\DefaultCodeDefinitionSet());
        $parser->addBBCode('quote', '
{param}
', false, true, 2);
        $bbcode = '[quote][quote][quote]wut[/quote] huh?[/quote] i don\'t know[/quote]';
        $parser->parse($bbcode);
        $expectedBbcode = '[quote][quote] huh?[/quote] i don\'t know[/quote]';
        $expectedHtml = '

 huh?
 i don\'t know
';
        $this->assertEquals($expectedBbcode, $parser->getAsBBCode());
        $this->assertEquals($expectedHtml, $parser->getAsHtml());
    }

}


text:
package edu.uw.zookeeper.safari.peer.protocol;

import java.util.concurrent.ScheduledExecutorService;

import edu.uw.zookeeper.common.TimeValue;
import edu.uw.zookeeper.net.Connection;
import edu.uw.zookeeper.safari.Identifier;

@SuppressWarnings("rawtypes")
public class ServerPeerConnection<T extends Connection<? super MessagePacket,? extends MessagePacket,?>> extends PeerConnection<T, ServerPeerConnection<T>> {

    public static <T extends Connection<? super MessagePacket,? extends MessagePacket,?>> ServerPeerConnection<T> create(
            Identifier localIdentifier,
            Identifier remoteIdentifier,
            T connection,
            TimeValue timeOut,
            ScheduledExecutorService executor) {
        return new ServerPeerConnection<T>(localIdentifier, remoteIdentifier, connection, timeOut, executor);
    }

    public ServerPeerConnection(
            Identifier localIdentifier,
            Identifier remoteIdentifier,
            T connection,
            TimeValue timeOut,
            ScheduledExecutorService executor) {
        super(localIdentifier, remoteIdentifier, connection, timeOut, executor);
    }
}


text:
namespace RabbitFarm.WebAPI
{
    using System.Net.Http.Headers;
    using System.Web.Http;
    using System.Web.Http.Cors;
    using Microsoft.Owin.Security.OAuth;

    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());

            var cors = new EnableCorsAttribute("http://localhost:4741", "*", "*");
            config.EnableCors(cors);
        }
    }
}


text:
layout: page
title: "About"
description: "I make a living out of this."
header-img: "img/about-bg.jpg"
---

My interested in online casinos started along with the big casino boom year 1998. Ever since, I've been following the various online casinos along their successes.

I am what you would call a bonus shark, I always try to stay up to date whenver a new casino bonus comes along.

Read our articles


text:
using Pallettaro.Revo.i18n;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pallettaro.Revo
{
    public class DateTime
    {
        public const decimal SECONDS_RATIO = 0.864M;
        private const int REPUBLICAN_HOURS_IN_DAY = 10;
        private const int REPUBLICAN_MINUTES_IN_HOUR = 100;
        private const int REPUBLICAN_SECONDS_IN_MINUTE = 100;

        public static DateTime Now
        {
            get
            {
                return new DateTime(System.DateTime.Now);
            }
        }

        private System.DateTime FIRST_DATETIME = new System.DateTime(1980, 9, 22);
        private const int FIRST_YEAR = 189;
        private static List<Int32> bisestili = new List<int>();
        public System.DateTime datetime { get; private set; }
        private int totalRepublicanSecondsInDay = 0;
        private int totalRepublicanDays = 0;
        private int totalMilliSeconds = 0;
        private int DaysInYear(int year)
        {
            var result = 365;
            if (bisestili.Contains(year))
            {
                result = 366;
            }
            return result;
        }
        public String MonthName
        {
            get
            {
                return this.GetMonthName(this.RepublicanMonth);
            }
        }
        public String MonthDescription
        {
            get
            {
                int month = this.RepublicanMonth;
                if (month > 0 && month < 14)
                {
                    return MonthsDes.ResourceManager.GetString("m" + month.ToString("00"));
                }
                return string.Empty;
            }
        }
        public String DayName
        {
            get
            {
                return this.GetDayName(this.RepublicanDayInYear);
            }
        }
        private String GetMonthName(int month)
        {
            if(month > 0 && month < 14)
            {
                return Months.ResourceManager.GetString("m" + month.ToString("00"));
            }
            return string.Empty;
        }
        private String GetDayName(int day)
        {
            if (day > 0 && day < 366)
            {
                return Days.ResourceManager.GetString("d" + day.ToString("000"));
            }
            return string.Empty;
        }
        public DateTime(int year, int month, int day)
        {
            if(year < FIRST_YEAR || month < 1 || month > 13 || day < 1 || day > 30)
            {
                throw new ArgumentException("Parametri di inizializzazione data errati");
            }
            if (!bisestili.Any())
            {
                InitBisestili();
            }
            this.totalMilliSeconds = 0;
            var totalDays = 0;
            for(int i = FIRST_YEAR; i < year; i++)
            {
                if (bisestili.Contains(i))
                {
                    totalDays += 366;
                }
                else
                {
                    totalDays += 365;
                }
            }
            totalDays += ((month - 1) * 30);
            totalDays += day;
            this.totalRepublicanDays = totalDays;
            this.datetime = FIRST_DATETIME.AddDays(totalDays - 1);
            this.InitDate();
        }
        public DateTime(int year, int month, int day, int hour, int minute, int second) : this(year, month, day)
        {
            if(hour < 0 || hour > 9 || minute < 0 || minute > 99 || second < 0 || second > 99)
            {
                throw new ArgumentException("Parametri di inizializzazione data errati");
            }
            totalMilliSeconds = Decimal.ToInt32(second * 1000 * SECONDS_RATIO);
            totalMilliSeconds += Decimal.ToInt32(minute * REPUBLICAN_SECONDS_IN_MINUTE * 1000 * SECONDS_RATIO);
            totalMilliSeconds += Decimal.ToInt32(hour * REPUBLICAN_MINUTES_IN_HOUR * REPUBLICAN_SECONDS_IN_MINUTE * 1000 * SECONDS_RATIO);
            totalRepublicanSecondsInDay = Decimal.ToInt32((totalMilliSeconds / SECONDS_RATIO) / 1000);
            this.InitDate();
        }
        public DateTime(System.DateTime datetime)
        {
            if (!bisestili.Any())
            {
                InitBisestili();
            }
            this.datetime = datetime;
            totalMilliSeconds = (((((datetime.Hour * 60) + datetime.Minute) * 60) + datetime.Second) * 1000) + datetime.Millisecond;
            totalRepublicanSecondsInDay = Decimal.ToInt32((totalMilliSeconds / SECONDS_RATIO) / 1000);
            totalRepublicanDays = (int)Math.Ceiling(datetime.Subtract(FIRST_DATETIME).TotalDays);
            this.InitDate();
        }
        private void InitDate()
        {
            int totalDays = totalRepublicanDays;
            int year = FIRST_YEAR;
            while (totalDays > this.DaysInYear(year))
            {
                totalDays = totalDays - this.DaysInYear(year);
                year++;
            }
            this.RepublicanYear = year;
            if (totalDays > 360)
            {
                this.RepublicanMonth = 13;
                this.RepublicanDay = totalDays - 360;
            }
            else
            {
                this.RepublicanMonth = ((totalDays - 1) / 30) + 1;
                this.RepublicanDay = totalDays % 30;
                if (RepublicanDay == 0) RepublicanDay = 30;
            }
        }
        private void InitBisestili()
        {
			bisestili.Add(189);
			bisestili.Add(193);
			bisestili.Add(197);
			bisestili.Add(201);
			bisestili.Add(206);
			bisestili.Add(210);
			bisestili.Add(214);
			bisestili.Add(218);
			bisestili.Add(222);
            bisestili.Add(226);
            bisestili.Add(230);
        }
        public decimal Milliseconds
        {
            get
            {
                var totalRepMilli = this.totalMilliSeconds / SECONDS_RATIO;
                var subtract = (((((this.RepublicanHours * REPUBLICAN_MINUTES_IN_HOUR) + this.RepublicanMinutes) * REPUBLICAN_SECONDS_IN_MINUTE) + this.RepublicanSeconds) * 1000);
                var mill = totalRepMilli - subtract;
                return mill;
            }
        }
        public int RepublicanSeconds
        {
            get
            {
                return this.totalRepublicanSecondsInDay % (REPUBLICAN_SECONDS_IN_MINUTE);
            }
        }
        public int RepublicanMinutes
        {
            get
            {
                var totalRepMinutes = this.totalRepublicanSecondsInDay / REPUBLICAN_SECONDS_IN_MINUTE;
                return totalRepMinutes % REPUBLICAN_MINUTES_IN_HOUR;
            }
        }
        public int RepublicanHours
        {
            get
            {
                return this.totalRepublicanSecondsInDay / (REPUBLICAN_MINUTES_IN_HOUR * REPUBLICAN_SECONDS_IN_MINUTE);
            }
        }
        public int RepublicanDay { get; private set; }
        public int RepublicanDayInYear {
            get
            {
                int result = RepublicanDay;
                for(int i=2; i<= RepublicanMonth; i++)
                {
                    result += 30;
                }
                return result;
            }
        }
        public int RepublicanMonth { get; private set; }
        public int RepublicanYear { get; private set; }
        public override string ToString()
        {
            return DateTimeFormat.Format(this, "dd-MM-yyy");
        }
        public string ToString(string format)
        {
            if (String.IsNullOrEmpty(format))
            {
                return ToString();
            }
            return DateTimeFormat.Format(this, format);
        }
    }
}


text:
BASE.require(["LG.core.dataModel.core.ManagementSystemDatabase"], function () {
    BASE.namespace("LG.core.dataModel.core");

    var _globalObject = this;

    LG.core.dataModel.core.TAMDatabase = (function (Super) {
        var TAMDatabase = function () {
            var self = this;
            if (self === _globalObject) {
                throw new Error("TAMDatabase constructor invoked with global context.  Say new.");
            }

            Super.call(self);

            self["dataSource"] = null;

            return self;
        };

        BASE.extend(TAMDatabase, Super);

        return TAMDatabase;
    }(LG.core.dataModel.core.ManagementSystemDatabase));
});


text:
<?php
namespace Application\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(
 * name="dukienmb",
 * indexes={
 * @ORM\Index(name="fk_dukienmb_nguoinopthue1_idx", columns={"MaSoThue"}),
 * @ORM\Index(name="fk_dukienmb_muclucngansach1_idx", columns={"Bac"}),
 * @ORM\Index(name="fk_dukienmb_user1_idx", columns={"MaUser"})
 * }
 * )
 */
class dukienmb
{

    /**
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="Application\Entity\nguoinopthue", inversedBy="dukienmbs")
     * @ORM\JoinColumn(name="MaSoThue", referencedColumnName="MaSoThue", nullable=false, onDelete="restrict")
     */
    private $nguoinopthue;

    /**
     * @ORM\Column(type="integer",nullable=false)
     */
    private $DoanhSo;

    /**
     * @ORM\Id
     * @ORM\Column(type="string",length=4,nullable=false)
     */
    private $Nam;

    /**
     * @ORM\ManyToOne(targetEntity="Application\Entity\muclucngansach", inversedBy="dukienmbs")
     * @ORM\JoinColumn(name="Bac", referencedColumnName="TieuMuc", nullable=false, onDelete="restrict")
     */
    private $muclucngansach;

    /**
     * @ORM\Column(type="integer"),nullable=false, options={"default":"0"})
     */
    private $SoTien;

    /**
     * @ORM\Column(type="date", nullable=false)
     */
    private $NgayPhaiNop;

    /**
     * @ORM\Column(type="integer",length=1,nullable=false,options={"default":"0"})
     */
    private $TrangThai;

    /**
     * @ORM\ManyToOne(targetEntity="Application\Entity\user", inversedBy="dukienmbs")
     * @ORM\JoinColumn(name="MaUser", referencedColumnName="MaUser", nullable=false, onDelete="restrict")
     */
    private $user;

 /**
     * @return the $user
     */
    public function getUser()
    {
        return $this->user;
    }

 /**
     * @param field_type $user
     */
    public function setUser($user)
    {
        $this->user = $user;
    }

 /**
     * @return the $DoanhSo
     */
    public function getDoanhSo()
    {
        return $this->DoanhSo;
    }

 /**
     * @param field_type $DoanhSo
     */
    public function setDoanhSo($DoanhSo)
    {
        $this->DoanhSo = $DoanhSo;
    }

 /**
     * @return the $nguoinopthue
     */
    public function getNguoinopthue()
    {
        return $this->nguoinopthue;
    }

 /**
     * @return the $Nam
     */
    public function getNam()
    {
        return $this->Nam;
    }

 /**
     * @return the $muclucngansach
     */
    public function getMuclucngansach()
    {
        return $this->muclucngansach;
    }

 /**
     * @return the $SoTien
     */
    public function getSoTien()
    {
        return $this->SoTien;
    }

 /**
     * @return the $NgayPhaiNop
     */
    public function getNgayPhaiNop()
    {
        return $this->NgayPhaiNop->format('d-m-Y');
    }

 /**
     * @return the $TrangThai
     */
    public function getTrangThai()
    {
        return $this->TrangThai;
    }

 /**
     * @param field_type $nguoinopthue
     */
    public function setNguoinopthue($nguoinopthue)
    {
        $this->nguoinopthue = $nguoinopthue;
    }

 /**
     * @param field_type $Nam
     */
    public function setNam($Nam)
    {
        $this->Nam = $Nam;
    }

 /**
     * @param field_type $muclucngansach
     */
    public function setMuclucngansach($muclucngansach)
    {
        $this->muclucngansach = $muclucngansach;
    }

 /**
     * @param field_type $SoTien
     */
    public function setSoTien($SoTien)
    {
        $this->SoTien = $SoTien;
    }

 /**
     * @param string $NgayPhaiNop
     */
    public function setNgayPhaiNop($NgayPhaiNop)
    {
        $this->NgayPhaiNop = \DateTime::createFromFormat('Y-m-d', $NgayPhaiNop);
    }

 /**
     * @param field_type $TrangThai
     */
    public function setTrangThai($TrangThai)
    {
        $this->TrangThai = $TrangThai;
    }

}


text:
#ifndef _SPOON_COLLECTIONS_HASHTABLE_H
#define _SPOON_COLLECTIONS_HASHTABLE_H

#include <spoon/collections/Collection.h>

/** This is a function which is supposed to return an
 * integer based on the data given. The integer can
 * be any number. It will be normalized by the HashTable.
 */
typedef int (*hash_key)( void *data );

/** This is a comparison function. It must return 0 if
 * the two objects are logically equal. It should
 * return -1 if a is less than b and 1 if a is greater
 * than b.
 */
typedef int (*hash_cmp)( void *a, void *b );

/** \addtogroup collections
 *
 * The HashTable collection is a simple HashTable implementation
 * which allows the user to override the private Hash and Compare
 * methods to do modify the way their HashTable works.
 *
 * This implementation hashes the items by memory address, has a
 * default size of 64 and a percentage of 70%.
 *
 * Setting a percentage of 0 will disable re-hashing, so you can
 * never insert more data than the initial size. A rehash results
 * in a hash table double the size of the current table or half
 * the size of the current table if hashing down.
 *
 */

class HashTable : public Collection
{
	public:
		HashTable( hash_key key_func, hash_cmp cmp_func,
					int size = 64, int percentage = 70 );
		virtual ~HashTable();

		bool  add(void *item);
		void* get(int index) const;
		bool  remove(void *item);
		int   count(void) const;

		void* retrieve( void *sample );

	private:
		hash_key m_key;
		hash_cmp m_cmp;

		int rehash( int size );

		void **m_hTable;		///< The internal hash table, referencing inserted data.

		int m_hSize;			///< The size of the hash table.
		int m_hTotal;		///< The total number of data already inserted into the table.
		int m_hPercent;		///< The configured percentage tolerance of the hash table.

};

#endif


text:
/* globals describe, it, beforeEach */
'use strict';

var assert = require('assert');
var GruntfileEditor = require('..');
var helper = require('./helpers');

describe('#insertConfig()', function () {
  beforeEach(function () {
    this.editor = new GruntfileEditor();
    this.insert = helper.insertConfig;
    this.str = helper.str;
  });

  it('is chainable', function () {
    assert.equal(this.editor.insertConfig('compass', '{}'), this.editor);
  });

  describe('requires a name', function () {
    var msg = /You must provide a task name/;

    it('as a String', function () {
      assert(this.insert('name'));
      assert(this.insert('name    '));
      assert.throws(this.insert(msg));
      assert.throws(this.insert(''), msg);
      assert.throws(this.insert(' '), msg);
      assert.throws(this.insert({}), msg);
      assert.throws(this.insert(42), msg);
      assert.throws(this.insert(false), msg);
      assert.throws(this.insert(true), msg);
      assert.throws(this.insert(0), msg);
      assert.throws(this.insert(-1), msg);
      assert.throws(this.insert(['an', 'array']), msg);
    });
  });

  describe('requires a config body', function () {
    var msg = /You must provide a task configuration body as a String/;

    it('as a String', function () {
      assert(this.insert('name', 'hi there'));
      assert(this.insert('name', '  hi there  '));
      assert.throws(this.insert('name'), msg);
      assert.throws(this.insert('name', ''), msg);
      assert.throws(this.insert('name', ' '), msg);
    });

    describe('does not yet accept:', function () {
      it('an object', function () {
        assert.throws(this.insert('name', {}), msg);
      });

      it('an integer', function () {
        assert.throws(this.insert('name', 4), msg);
      });

      it('a boolean', function () {
        assert.throws(this.insert('name', false), msg);
        assert.throws(this.insert('name', true), msg);
      });

      it('an array', function () {
        assert.throws(this.insert('name', [5, 'la', {b: 'c'}]));
        assert.throws(this.insert('name', []), msg);
      });
    });
  });

  describe('inserts', function () {
    var gf = 'compass: { foo: \'bar\' }';

    beforeEach(function () {
      this.editor.insertConfig(' compass ', ' { foo: "bar" } ');
    });

    it('a task config', function () {
      assert(this.str().indexOf(gf) >= 0);
    });

    it('the last inserted task config taking precedence', function () {
      this.editor.insertConfig('compass', '{ yeo: "man" }');
      assert(this.str().indexOf(gf) < 0);
      assert(this.str().indexOf('compass: { yeo: \'man\' }') >= 0);
    });

    it('an updated task config', function () {
      this.editor.insertConfig('compass', '{ foo: "baz" }');
      assert(this.str().indexOf(gf) < 0);
      assert(this.str().indexOf(gf.replace('bar', 'baz')) >= 0);
    });
  });

  describe('inserts sub task', function () {
    it('add sub task ', function () {
      // Add first sub task. create parent if not exist.
      this.editor.insertConfig('compass.src1', JSON.stringify({
        files: ['./src1/**']
      }));

      this.editor.insertConfig('compass.src2', JSON.stringify({
        files: ['./src2/**']
      }));

      assert.equal(
        this.str().replace(/\s/g, ''), "module.exports=function(grunt){'usestrict';grunt.initConfig({compass:{src1:{'files':['./src1/**']},src2:{'files':['./src2/**']}}});};"
      );
    });
  });
});


text:
This contains a small set of images that can be used in
test applications. Any images used in more than one file should be
added here.


text:
package signal

import (
	"os"
	"os/signal"
	"runtime"
	"syscall"

	log "github.com/sirupsen/logrus"
)

// SetupSignalHandler setup signal handler for TiDB Server
func SetupSignalHandler(shudownFunc func(bool)) {
	usrDefSignalChan := make(chan os.Signal, 1)

	signal.Notify(usrDefSignalChan, syscall.SIGUSR1)
	go func() {
		buf := make([]byte, 1<<16)
		for {
			sig := <-usrDefSignalChan
			if sig == syscall.SIGUSR1 {
				stackLen := runtime.Stack(buf, true)
				log.Printf("\n=== Got signal [%s] to dump goroutine stack. ===\n%s\n=== Finished dumping goroutine stack. ===\n", sig, buf[:stackLen])
			}
		}
	}()

	closeSignalChan := make(chan os.Signal, 1)
	signal.Notify(closeSignalChan,
		syscall.SIGHUP,
		syscall.SIGINT,
		syscall.SIGTERM,
		syscall.SIGQUIT)

	go func() {
		sig := <-closeSignalChan
		log.Infof("Got signal [%s] to exit.", sig)
		shudownFunc(sig == syscall.SIGQUIT)
	}()
}


text:
package com.jtbdevelopment.games.security.spring.security.loginConfigurer;

import com.jtbdevelopment.games.security.spring.redirects.MobileAppChecker;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;

/**
 * Date: 8/29/2015 Time: 2:44 PM
 *
 * Cut-n-paste of spring security class of same name to provide for overriding behaviour in
 * AbstractAuthenticationFilterConfigurer
 */
@SuppressWarnings({"WeakerAccess", "UnusedReturnValue"})
public class MobileAwareFormLoginConfigurer extends AbstractAuthenticationFilterConfigurer {

  public MobileAwareFormLoginConfigurer(MobileAppChecker mobileAppChecker) {
    super(new UsernamePasswordAuthenticationFilter(), null, mobileAppChecker);
    usernameParameter("username");
    passwordParameter("password");
  }

  public MobileAwareFormLoginConfigurer loginPage(String loginPage) {
    return super.loginPage(loginPage);
  }

  public MobileAwareFormLoginConfigurer usernameParameter(String usernameParameter) {
    getAuthenticationFilter().setUsernameParameter(usernameParameter);
    return this;
  }

  public MobileAwareFormLoginConfigurer passwordParameter(String passwordParameter) {
    getAuthenticationFilter().setPasswordParameter(passwordParameter);
    return this;
  }

  @Override
  public void init(HttpSecurity http) throws Exception {
    super.init(http);
    initDefaultLoginFilter(http);
  }

  @Override
  protected RequestMatcher createLoginProcessingUrlMatcher(String loginProcessingUrl) {
    return new AntPathRequestMatcher(loginProcessingUrl, "POST");
  }

  private String getUsernameParameter() {
    return getAuthenticationFilter().getUsernameParameter();
  }

  private String getPasswordParameter() {
    return getAuthenticationFilter().getPasswordParameter();
  }

  private void initDefaultLoginFilter(HttpSecurity http) {
    DefaultLoginPageGeneratingFilter loginPageGeneratingFilter = http
        .getSharedObject(DefaultLoginPageGeneratingFilter.class);
    if (loginPageGeneratingFilter != null && !isCustomLoginPage()) {
      loginPageGeneratingFilter.setFormLoginEnabled(true);
      loginPageGeneratingFilter.setUsernameParameter(getUsernameParameter());
      loginPageGeneratingFilter.setPasswordParameter(getPasswordParameter());
      loginPageGeneratingFilter.setLoginPageUrl(getLoginPage());
      loginPageGeneratingFilter.setFailureUrl(getFailureUrl());
      loginPageGeneratingFilter.setAuthenticationUrl(getLoginProcessingUrl());
    }

  }

}


text:
"""

gists.model
~~~~~~~~~~~

Model defines the two classes that extend of builtin python 'dicts'.
They represent a Gist object and a Gist File. Used to make the code of other
modules clearer.

"""

class Gist(dict):
    """ :class: `Gist <Gist>` Simple Gist object. """

    def __init__(self, parsed_gist={}):
        """ Initialize gist object variables. """

        super(Gist, self).__init__(parsed_gist)

    @property
    def url(self):
        return self['url']

    @property
    def html_url(self):
        return self['html_url']

    @property
    def description(self):
        return self['description']

    @description.setter
    def description(self, description):
        self['description'] = description

    @property
    def identifier(self):
        return self['id']

    @property
    def user(self):
        return self['user']['login']

    @property
    def public(self):
        return self['public']

    @public.setter
    def public(self, public):
        self['public'] = public

    @property
    def files(self):
        """ Parse the 'self['files']' into GistFile objects. """
        if not 'files' in self:
            self['files'] = {}
            return self['files']
        return [GistFile(self['files'][gistfile])
                for gistfile in self['files']
                if self['files'][gistfile] != 'null']

    def getFile(self, requested_filename):
        candidates = [gistfile for gistfile in self.files
                      if gistfile.filename == requested_filename]
        if len(candidates) == 0:
            return None
        return candidates[0]

    def setFile(self, filename, gist_file):
        self['files'][filename] = gist_file

    def addFile(self, gistfile):
        if not 'files' in self:
            self['files'] = {}
        self['files'][gistfile.filename] = gistfile

class GistFile(dict):
    """ :class: `GistFile <GistFile>` File that belongs to a Gist. """

    def __init__(self, parsed_file={}):
        super(GistFile, self).__init__(parsed_file)

    @property
    def raw_url(self):
        return self['raw_url']

    @property
    def language(self):
        return self['language']

    @property
    def filename(self):
        return self['filename']

    @filename.setter
    def filename(self, filename):
        self['filename'] = filename

    @property
    def content(self):
        return self['content']

    @content.setter
    def content(self, content):
        self['content'] = content

    @property
    def mimetype(self):
        return self['type']

    @property
    def size(self):
        return self['size']

class Authorization(dict):
    """ :class: `Authorization <Authorization>` authorization object. """

    def __init__(self, parsed_auth={}):
        super(Authorization, self).__init__(parsed_auth)

    @property
    def id(self):
        return self['id']

    @property
    def url(self):
        return self['url']

    @property
    def app(self):
        return self['app']['name']

    @property
    def app_url(self):
        return self['app']['url']

    @property
    def created(self):
        return self['created_at']

    @property
    def updated(self):
        return self['updated_at']

    @property
    def token(self):
        return self['token']

    @property
    def note(self):
        return self['note']

    @note.setter
    def note(self, note):
        self['note'] = note

    @property
    def note_url(self):
        return self['note_url']

    @note_url.setter
    def note_url(self, note_url):
        self['note_url'] = note_url

    @property
    def scopes(self):
        return self['scopes']

    @scopes.setter
    def scopes(self, scopes):
        self['scopes'] = scopes


text:
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>W26165_text</title>
        <link rel="stylesheet" type="text/css" href="style.css" />

                «

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">STATE OF COLORADO

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">)SS.

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">COUNTY OF DENVER

    <p class="styleSans11.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">T. C. Siirola, being duly sworn, states as follows:
1. 1 am a Regional Land Manager employed by Whiting Oil and Gas Corporation with responsibilities in the State of North Dakota and 1 have personal knowledge of the matters set forth in this affidavit.
2. Sections 5 and 8, Township 140 North, Range 98 West, Stark County, North Dakota, constitute a spacing unit in accordance with the applicable orders for the Bakken pool.
3. Three wells have been drilled in the spacing unit, which are the Zalesky 34-8PH, Zalesky l4-8PH and Zalesky 44-8PH.
4. By NDlC Order # 15848 dated November 18, 2010 all oil and gas interests within the aforementioned spacing unit were pooled. 5. All Working Interests, Royalty Interests and Overriding Royalty Interests in the Zalesky
34-8PH, Zalesky 14-8PH and Zalesky 44-8PH are common.

    <p class="styleSans10.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">Dated this 4') day of December, 2013

    <p class="styleSans21.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">
T. C. Siirola

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">STATE OF COLORADO
COUNTY OF DENVER

    <p class="styleSans14.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">Subscribed to and sworn before me this   réday of December, 2013

    <p class="styleSans25.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">
Notary Public State of Colorado

    <p class="styleSans17.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">My Commission Expires:
l .3651" 1. '7

    <p class="styleSans58.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">
MARSHA L. CARTER NOTARY PUBLIC STATE OF COLm NOTARY ID 2013409353:
WCOMMSSDNEXHRESWEM7

    <p class="styleSans8.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">)ss.


text:
package ru.st.selenium.pages;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.How;

/*
 * Sample page
 *
 * @author Sebastiano Armeli-Battana
 */
public class HomePage extends Page {

	private final String H1_TAG = "h1";

	@FindBy(how = How.TAG_NAME, using = H1_TAG)
	@CacheLookup
	private WebElement h1Element;

	public HomePage(WebDriver webDriver) {
		super(webDriver);
	}

	public String getH1() {
		return h1Element.getText();
	}

}


text:
.class public Lcom/android/internal/http/multipart/FilePart;
.super Lcom/android/internal/http/multipart/PartBase;
.source "FilePart.java"

# static fields
.field public static final DEFAULT_CHARSET:Ljava/lang/String; = "ISO-8859-1"

.field public static final DEFAULT_CONTENT_TYPE:Ljava/lang/String; = "application/octet-stream"

.field public static final DEFAULT_TRANSFER_ENCODING:Ljava/lang/String; = "binary"

.field protected static final FILE_NAME:Ljava/lang/String; = "; filename="

.field private static final FILE_NAME_BYTES:[B

.field private static final LOG:Lorg/apache/commons/logging/Log;

# instance fields
.field private source:Lcom/android/internal/http/multipart/PartSource;

# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 69
    const-class v0, Lcom/android/internal/http/multipart/FilePart;

    invoke-static {v0}, Lorg/apache/commons/logging/LogFactory;->getLog(Ljava/lang/Class;)Lorg/apache/commons/logging/Log;

    move-result-object v0

    sput-object v0, Lcom/android/internal/http/multipart/FilePart;->LOG:Lorg/apache/commons/logging/Log;

    .line 75
    const-string v0, "; filename="

    invoke-static {v0}, Lorg/apache/http/util/EncodingUtils;->getAsciiBytes(Ljava/lang/String;)[B

    move-result-object v0

    sput-object v0, Lcom/android/internal/http/multipart/FilePart;->FILE_NAME_BYTES:[B

    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Lcom/android/internal/http/multipart/PartSource;)V
    .locals 1
    .parameter "name"
    .parameter "partSource"

    .prologue
    const/4 v0, 0x0

    .line 113
    invoke-direct {p0, p1, p2, v0, v0}, Lcom/android/internal/http/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/android/internal/http/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 114
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Lcom/android/internal/http/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V
    .locals 2
    .parameter "name"
    .parameter "partSource"
    .parameter "contentType"
    .parameter "charset"

    .prologue
    .line 93
    if-nez p3, :cond_0

    const-string p3, "application/octet-stream"

    .end local p3
    :cond_0
    if-nez p4, :cond_1

    const-string p4, "ISO-8859-1"

    .end local p4
    :cond_1
    const-string v0, "binary"

    invoke-direct {p0, p1, p3, p4, v0}, Lcom/android/internal/http/multipart/PartBase;-><init>(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    .line 100
    if-nez p2, :cond_2

    .line 101
    new-instance v0, Ljava/lang/IllegalArgumentException;

    const-string v1, "Source may not be null"

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 103
    :cond_2
    iput-object p2, p0, Lcom/android/internal/http/multipart/FilePart;->source:Lcom/android/internal/http/multipart/PartSource;

    .line 104
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/io/File;)V
    .locals 2
    .parameter "name"
    .parameter "file"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    const/4 v1, 0x0

    .line 127
    new-instance v0, Lcom/android/internal/http/multipart/FilePartSource;

    invoke-direct {v0, p2}, Lcom/android/internal/http/multipart/FilePartSource;-><init>(Ljava/io/File;)V

    invoke-direct {p0, p1, v0, v1, v1}, Lcom/android/internal/http/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/android/internal/http/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 128
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;)V
    .locals 1
    .parameter "name"
    .parameter "file"
    .parameter "contentType"
    .parameter "charset"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    .line 145
    new-instance v0, Lcom/android/internal/http/multipart/FilePartSource;

    invoke-direct {v0, p2}, Lcom/android/internal/http/multipart/FilePartSource;-><init>(Ljava/io/File;)V

    invoke-direct {p0, p1, v0, p3, p4}, Lcom/android/internal/http/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/android/internal/http/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 146
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)V
    .locals 2
    .parameter "name"
    .parameter "fileName"
    .parameter "file"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    const/4 v1, 0x0

    .line 160
    new-instance v0, Lcom/android/internal/http/multipart/FilePartSource;

    invoke-direct {v0, p2, p3}, Lcom/android/internal/http/multipart/FilePartSource;-><init>(Ljava/lang/String;Ljava/io/File;)V

    invoke-direct {p0, p1, v0, v1, v1}, Lcom/android/internal/http/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/android/internal/http/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 161
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;)V
    .locals 1
    .parameter "name"
    .parameter "fileName"
    .parameter "file"
    .parameter "contentType"
    .parameter "charset"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/FileNotFoundException;
        }
    .end annotation

    .prologue
    .line 179
    new-instance v0, Lcom/android/internal/http/multipart/FilePartSource;

    invoke-direct {v0, p2, p3}, Lcom/android/internal/http/multipart/FilePartSource;-><init>(Ljava/lang/String;Ljava/io/File;)V

    invoke-direct {p0, p1, v0, p4, p5}, Lcom/android/internal/http/multipart/FilePart;-><init>(Ljava/lang/String;Lcom/android/internal/http/multipart/PartSource;Ljava/lang/String;Ljava/lang/String;)V

    .line 180
    return-void
.end method

# virtual methods
.method protected getSource()Lcom/android/internal/http/multipart/PartSource;
    .locals 2

    .prologue
    .line 239
    sget-object v0, Lcom/android/internal/http/multipart/FilePart;->LOG:Lorg/apache/commons/logging/Log;

    const-string v1, "enter getSource()"

    invoke-interface {v0, v1}, Lorg/apache/commons/logging/Log;->trace(Ljava/lang/Object;)V

    .line 240
    iget-object v0, p0, Lcom/android/internal/http/multipart/FilePart;->source:Lcom/android/internal/http/multipart/PartSource;

    return-object v0
.end method

.method protected lengthOfData()J
    .locals 2

    .prologue
    .line 250
    sget-object v0, Lcom/android/internal/http/multipart/FilePart;->LOG:Lorg/apache/commons/logging/Log;

    const-string v1, "enter lengthOfData()"

    invoke-interface {v0, v1}, Lorg/apache/commons/logging/Log;->trace(Ljava/lang/Object;)V

    .line 251
    iget-object v0, p0, Lcom/android/internal/http/multipart/FilePart;->source:Lcom/android/internal/http/multipart/PartSource;

    invoke-interface {v0}, Lcom/android/internal/http/multipart/PartSource;->getLength()J

    move-result-wide v0

    return-wide v0
.end method

.method protected sendData(Ljava/io/OutputStream;)V
    .locals 7
    .parameter "out"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 210
    sget-object v3, Lcom/android/internal/http/multipart/FilePart;->LOG:Lorg/apache/commons/logging/Log;

    const-string v4, "enter sendData(OutputStream out)"

    invoke-interface {v3, v4}, Lorg/apache/commons/logging/Log;->trace(Ljava/lang/Object;)V

    .line 211
    invoke-virtual {p0}, Lcom/android/internal/http/multipart/FilePart;->lengthOfData()J

    move-result-wide v3

    const-wide/16 v5, 0x0

    cmp-long v3, v3, v5

    if-nez v3, :cond_0

    .line 216
    sget-object v3, Lcom/android/internal/http/multipart/FilePart;->LOG:Lorg/apache/commons/logging/Log;

    const-string v4, "No data to send."

    invoke-interface {v3, v4}, Lorg/apache/commons/logging/Log;->debug(Ljava/lang/Object;)V

    .line 231
    :goto_0
    return-void

    .line 220
    :cond_0
    const/16 v3, 0x1000

    new-array v2, v3, [B

    .line 221
    .local v2, tmp:[B
    iget-object v3, p0, Lcom/android/internal/http/multipart/FilePart;->source:Lcom/android/internal/http/multipart/PartSource;

    invoke-interface {v3}, Lcom/android/internal/http/multipart/PartSource;->createInputStream()Ljava/io/InputStream;

    move-result-object v0

    .line 224
    .local v0, instream:Ljava/io/InputStream;
    :goto_1
    :try_start_0
    invoke-virtual {v0, v2}, Ljava/io/InputStream;->read([B)I

    move-result v1

    .local v1, len:I
    if-ltz v1, :cond_1

    .line 225
    const/4 v3, 0x0

    invoke-virtual {p1, v2, v3, v1}, Ljava/io/OutputStream;->write([BII)V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_1

    .line 229
    .end local v1           #len:I
    :catchall_0
    move-exception v3

    invoke-virtual {v0}, Ljava/io/InputStream;->close()V

    throw v3

    .restart local v1       #len:I
    :cond_1
    invoke-virtual {v0}, Ljava/io/InputStream;->close()V

    goto :goto_0
.end method

.method protected sendDispositionHeader(Ljava/io/OutputStream;)V
    .locals 3
    .parameter "out"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 191
    sget-object v1, Lcom/android/internal/http/multipart/FilePart;->LOG:Lorg/apache/commons/logging/Log;

    const-string v2, "enter sendDispositionHeader(OutputStream out)"

    invoke-interface {v1, v2}, Lorg/apache/commons/logging/Log;->trace(Ljava/lang/Object;)V

    .line 192
    invoke-super {p0, p1}, Lcom/android/internal/http/multipart/Part;->sendDispositionHeader(Ljava/io/OutputStream;)V

    .line 193
    iget-object v1, p0, Lcom/android/internal/http/multipart/FilePart;->source:Lcom/android/internal/http/multipart/PartSource;

    invoke-interface {v1}, Lcom/android/internal/http/multipart/PartSource;->getFileName()Ljava/lang/String;

    move-result-object v0

    .line 194
    .local v0, filename:Ljava/lang/String;
    if-eqz v0, :cond_0

    .line 195
    sget-object v1, Lcom/android/internal/http/multipart/FilePart;->FILE_NAME_BYTES:[B

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 196
    sget-object v1, Lcom/android/internal/http/multipart/FilePart;->QUOTE_BYTES:[B

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 197
    invoke-static {v0}, Lorg/apache/http/util/EncodingUtils;->getAsciiBytes(Ljava/lang/String;)[B

    move-result-object v1

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 198
    sget-object v1, Lcom/android/internal/http/multipart/FilePart;->QUOTE_BYTES:[B

    invoke-virtual {p1, v1}, Ljava/io/OutputStream;->write([B)V

    .line 200
    :cond_0
    return-void
.end method


text:
<?php

use \JsonRpc\Base\Rpc;

class RequestMethodTest extends RequestTests\Base
{

  public function testValidRequestMethod()
  {
    $data = '{"jsonrpc": "2.0", "method": "foobar", "params": [6], "id": 1}';
    $expects = '';
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodMissing()
  {
    $data = '{"jsonrpc": "2.0", "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method', false);
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithStringEmpty()
  {
    $data = '{"jsonrpc": "2.0", "method": "", "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithInteger()
  {
    $data = '{"jsonrpc": "2.0", "method": 1, "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithFloat()
  {
    $data = '{"jsonrpc": "2.0", "method": 2.46, "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithTrue()
  {
    $data = '{"jsonrpc": "2.0", "method": true, "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithFalse()
  {
    $data = '{"jsonrpc": "2.0", "method": false, "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithNull()
  {
    $data = '{"jsonrpc": "2.0", "method": null, "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithArray()
  {
    $data = '{"jsonrpc": "2.0", "method": [1,2,3], "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

  public function testInvalidRequestMethodWithObject()
  {
    $data = '{"jsonrpc": "2.0", "method": {"name": 2}, "params": [6], "id": 1}';
    $expects = Rpc::getErrorMsg('method');
    $fault = $this->getRequestFault($data);
    $this->assertEquals($expects, $fault);
  }

}