text:
package org.necros.data.h4;

import static org.junit.Assert.*;

import java.util.List;

import javax.annotation.Resource;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

import org.necros.data.MetaClass;
import org.necros.data.MetaClassManager;
import org.necros.data.MetaPackageManager;
import org.necros.data.MetaPackage;
import org.necros.data.MetaProperty;
import org.necros.data.MetaDataAccessException;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath*:META-INF/*-beans.xml")
@TransactionConfiguration(defaultRollback=true)
public class MetaClassManagerH4Test {
	private static final Logger logger = LoggerFactory.getLogger(MetaClassManagerH4Test.class);

	@Resource
	private MetaClassManager manager;
	@Resource
	private MetaPackageManager pkgMgr;

	private String globalId, arrId, arrPropId;

	private void initPackages() throws MetaDataAccessException {
		MetaPackage pkg;
		pkg = new MetaPackage();
		pkg.setPath("net.sf.jsonlib");
		pkgMgr.add(pkg);
		pkg = new MetaPackage();
		pkg.setPath("net.21cn");
		pkgMgr.add(pkg);
		pkg = new MetaPackage();
		pkg.setPath("com.microsoft.web");
		pkgMgr.add(pkg);
	}

	private void initClasses() throws MetaDataAccessException {
		MetaClass cls;
		MetaProperty prop;
		prop = new MetaProperty();
		prop.setName("name");
		prop.setColumnName("arr_name");
		cls = new MetaClass();
		cls.setMetaPackage("net.sf.jsonlib");
		cls.setName("JsonArray");
		cls.setTableName("clazz_json_array");
		cls.getProperties().add(prop);
		cls = manager.add(cls);
		arrId = cls.getId();
		arrPropId = cls.getProperties().iterator().next().getId();
		cls = new MetaClass();
		cls.setName("Global");
		cls.setTableName("clazz_global");
		cls = manager.add(cls);
		globalId = cls.getId();
	}

	@Before
	public void setUp() throws Exception {
		initPackages();
		initClasses();
	}

	@After
	public void tearDown() throws Exception {

	}

	@Test @Transactional
	public void testGet() {
		MetaClass cls;
		cls = manager.get(globalId);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(0, cls.getProperties().size());
		cls = manager.get(arrId);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(1, cls.getProperties().size());
		cls = manager.get("none");
		assertNull(cls);
	}

	@Test @Transactional
	public void testGetWithName() {
		MetaClass cls;
		String pkg, name;
		pkg = null; name = "Global";
		logger.debug("Retrieving with name: [{}].[{}]", pkg, name);
		cls = manager.getWithName(pkg, name);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(0, cls.getProperties().size());
		pkg = ""; name = "Global";
		logger.debug("Retrieving with name: [{}].[{}]", pkg, name);
		cls = manager.getWithName(pkg, name);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(0, cls.getProperties().size());
		pkg = "net.sf.jsonlib"; name = "JsonArray";
		logger.debug("Retrieving with name: [{}].[{}]", pkg, name);
		cls = manager.getWithName(pkg, name);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(1, cls.getProperties().size());
		pkg = "net.sf.jsonlib"; name = "Global";
		logger.debug("Retrieving with name: [{}].[{}]", pkg, name);
		cls = manager.getWithName(pkg, name);
		assertNull(cls);
		pkg = "none"; name = "Global";
		logger.debug("Retrieving with name: [{}].[{}]", pkg, name);
		cls = manager.getWithName(pkg, name);
		assertNull(cls);
		pkg = null; name = "JsonArray";
		logger.debug("Retrieving with name: [{}].[{}]", pkg, name);
		cls = manager.getWithName(pkg, name);
		assertNull(cls);
		pkg = null; name = null;
		logger.debug("Retrieving with name: [{}].[{}]", pkg, name);
		cls = manager.getWithName(pkg, name);
		assertNull(cls);
	}

	@Test @Transactional
	public void testAdd() throws MetaDataAccessException {
		MetaClass cls;
		logger.debug("Testing adding global MetaClass...");
		cls = new MetaClass();
		cls.setName("Golbal2");
		cls.setTableName("clazz_global_2");
		cls = manager.add(cls);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(0, cls.getProperties().size());
		assertNotNull(cls.getId());
		logger.debug("Testing adding packaged MetaClass...");
		cls = new MetaClass();
		cls.setMetaPackage("net.sf.jsonlib");
		cls.setName("JsonObject");
		cls.setTableName("clazz_json_object");
		cls = manager.add(cls);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(0, cls.getProperties().size());
		assertNotNull(cls.getId());
		logger.debug("Testing adding packaged MetaClass...");
		cls = new MetaClass();
		cls.setMetaPackage("net.sf.jsonlib");
		cls.setName("Global");
		cls.setTableName("clazz_global");
		cls = manager.add(cls);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(0, cls.getProperties().size());
		assertNotNull(cls.getId());
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testAddInvalidPackage() throws MetaDataAccessException {
		MetaClass cls;
		logger.debug("Testing adding duplicated global MetaClass...");
		cls = new MetaClass();
		cls.setMetaPackage("Global");
		cls.setName("Global");
		cls = manager.add(cls);
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testAddInvalidName() throws MetaDataAccessException {
		MetaClass cls;
		logger.debug("Testing adding duplicated global MetaClass...");
		cls = new MetaClass();
		cls.setName("Global.1");
		cls = manager.add(cls);
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testAddDuplicatedGlobal() throws MetaDataAccessException {
		MetaClass cls;
		logger.debug("Testing adding duplicated global MetaClass...");
		cls = new MetaClass();
		cls.setName("Global");
		cls = manager.add(cls);
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testAddDuplicatedPackaged() throws MetaDataAccessException {
		MetaClass cls;
		logger.debug("Testing adding duplicated packaged MetaClass...");
		cls = new MetaClass();
		cls.setMetaPackage("net.sf.jsonlib");
		cls.setName("JsonArray");
		cls.setTableName("clazz_json_array");
		cls = manager.add(cls);
	}

	@Test @Transactional
	public void testUpdateInfo() throws MetaDataAccessException {
		MetaClass cls;
		cls = new MetaClass();
		cls.setId(arrId);
		cls.setMetaPackage("none");
		cls.setName("invalid..");
		cls.setDisplayName("displayName");
		cls.setDescription("description");
		cls = manager.updateInfo(cls);
		assertNotNull(cls);
		assertTrue(arrId.equals(cls.getId()));
		assertTrue("displayName".equals(cls.getDisplayName()));
		assertTrue("description".equals(cls.getDescription()));
		assertFalse("none".equals(cls.getMetaPackage()));
		assertFalse("invalid..".equals(cls.getName()));
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testUpdateInfoInvalidId() throws MetaDataAccessException {
		MetaClass cls;
		cls = new MetaClass();
		cls.setId(arrId + "abc");
		cls = manager.updateInfo(cls);
	}

	@Test @Transactional
	public void testRemove() throws MetaDataAccessException {
		MetaClass cls;
		logger.debug("Removing existing MetaClass...");
		cls = manager.remove(arrId);
		assertNotNull(cls);
		assertNull(manager.get(arrId));
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testRemoveInvalid() throws MetaDataAccessException {
		logger.debug("Removing non-existing MetaClass...");
		manager.remove(arrId + "abc");
	}

	@Test @Transactional
	public void testMoveTo() throws MetaDataAccessException {
		MetaClass cls;
		String pkg;
		pkg = null;
		cls = manager.moveTo(arrId, pkg);
		assertNotNull(cls);
		assertNull(cls.getMetaPackage());
		pkg = "net.sf";
		cls = manager.moveTo(arrId, pkg);
		assertNotNull(cls);
		assertNotNull(cls.getMetaPackage());
		assertTrue("net.sf".equals(cls.getMetaPackage()));
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testMoveToInvalid() throws MetaDataAccessException {
		String pkg;
		pkg = "org.necros";
		manager.moveTo(arrId, pkg);
	}

	@Test @Transactional
	public void testAddProperty() throws MetaDataAccessException {
		MetaProperty prop;
		prop = new MetaProperty();
		prop.setName("prop");
		prop = manager.addProperty(arrId, prop);
		assertNotNull(prop);
		assertNotNull(prop.getId());
		assertNotNull(prop.getMetaClass());
		assertNotNull(prop.getMetaClass().getId());
		assertTrue(arrId.equals(prop.getMetaClass().getId()));
		assertNotNull(prop.getMetaClass().getProperties());
		assertEquals(2, prop.getMetaClass().getProperties().size());
		//Duplicated name
		prop = new MetaProperty();
		prop.setName("prop");
		prop = manager.addProperty(arrId, prop);
		assertNotNull(prop);
		assertNotNull(prop.getId());
		assertNotNull(prop.getMetaClass());
		assertNotNull(prop.getMetaClass().getId());
		assertTrue(arrId.equals(prop.getMetaClass().getId()));
		assertNotNull(prop.getMetaClass().getProperties());
		assertEquals(2, prop.getMetaClass().getProperties().size());
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testAddPropertyInvalidClass() throws MetaDataAccessException {
		MetaProperty prop;
		prop = new MetaProperty();
		prop.setName("prop");
		prop = manager.addProperty(arrId + "abc", prop);
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testAddPropertyInvalidName() throws MetaDataAccessException {
		MetaProperty prop;
		prop = new MetaProperty();
		prop.setName("prop.abc");
		prop = manager.addProperty(arrId, prop);
	}

	@Test @Transactional
	public void testRemoveProperty() throws MetaDataAccessException {
		MetaProperty prop;
		MetaClass cls;
		String clsId, propId;
		cls = manager.get(arrId);
		prop = cls.getProperties().iterator().next();
		assertNotNull(prop);
		assertNotNull(prop.getMetaClass());
		clsId = cls.getId();
		propId = prop.getId();
		prop = manager.removeProperty(clsId, propId);
		assertNotNull(prop);
		cls = manager.get(arrId);
		assertNotNull(cls);
		assertNotNull(cls.getProperties());
		assertEquals(0, cls.getProperties().size());
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testRemovePropertyInvalidProp() throws MetaDataAccessException {
		MetaProperty prop;
		MetaClass cls;
		String clsId, propId;
		cls = manager.get(arrId);
		prop = cls.getProperties().iterator().next();
		clsId = cls.getId();
		propId = prop.getId() + "abc";
		prop = manager.removeProperty(clsId, propId);
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testRemovePropertyInvalidClazz() throws MetaDataAccessException {
		MetaProperty prop;
		MetaClass cls;
		String clsId, propId;
		cls = manager.get(arrId);
		prop = cls.getProperties().iterator().next();
		clsId = globalId;
		propId = prop.getId();
		prop = manager.removeProperty(clsId, propId);
	}

	@Test @Transactional
	public void testUpdateProperty() throws MetaDataAccessException {
		MetaProperty prop;
		prop = new MetaProperty();
		prop.setId(arrPropId);
		prop.setName("another");
		prop.setDisplayName("dispName");
		prop = manager.updateProperty(prop);
		assertNotNull(prop);
		assertTrue(arrPropId.equals(prop.getId()));
		assertFalse("another".equals(prop.getName()));
		assertTrue("dispName".equals(prop.getDisplayName()));
	}

	@Test(expected=MetaDataAccessException.class) @Transactional
	public void testUpdatePropertyInvalid() throws MetaDataAccessException {
		MetaProperty prop;
		prop = new MetaProperty();
		prop.setId(arrPropId + "abc");
		manager.updateProperty(prop);
	}

	@Test @Transactional
	public void testAll() {
		List<MetaClass> lst;
		lst = manager.all(null);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		lst = manager.all("");
		assertNotNull(lst);
		assertEquals(1, lst.size());
		lst = manager.all("com");
		assertNotNull(lst);
		assertEquals(0, lst.size());
		lst = manager.all("net.sf");
		assertNotNull(lst);
		assertEquals(0, lst.size());
		lst = manager.all("net.sf.jsonlib");
		assertNotNull(lst);
		assertEquals(1, lst.size());
		lst = manager.all("none");
		assertNotNull(lst);
		assertEquals(0, lst.size());
	}

	@Test @Transactional
	public void testSearch() {
		List<MetaClass> lst;
		String filterText;
		filterText = null;
		logger.debug("Searching MetaClass: [{}]", filterText);
		lst = manager.search(filterText);
		assertNotNull(lst);
		assertEquals(2, lst.size());
		filterText = "";
		logger.debug("Searching MetaClass: [{}]", filterText);
		lst = manager.search(filterText);
		assertNotNull(lst);
		assertEquals(2, lst.size());
		filterText = "net";
		logger.debug("Searching MetaClass: [{}]", filterText);
		lst = manager.search(filterText);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		filterText = "l";
		logger.debug("Searching MetaClass: [{}]", filterText);
		lst = manager.search(filterText);
		assertNotNull(lst);
		assertEquals(2, lst.size());
		filterText = "f3209";
		logger.debug("Searching MetaClass: [{}]", filterText);
		lst = manager.search(filterText);
		assertNotNull(lst);
		assertEquals(0, lst.size());
	}

	@Test @Transactional
	public void testSearchInPackage() {
		List<MetaClass> lst;
		String pkg, filterText;
		pkg = null; filterText = null;
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		pkg = ""; filterText = "";
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		pkg = null; filterText = "none";
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(0, lst.size());
		pkg = null; filterText = "o";
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		pkg = "net"; filterText = null;
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(0, lst.size());
		pkg = "net.sf.jsonlib"; filterText = null;
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		pkg = "net.sf.jsonlib"; filterText = "";
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		pkg = "net.sf.jsonlib"; filterText = "nA";
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(1, lst.size());
		pkg = "net.sf.jsonlib"; filterText = "none";
		logger.debug("Searching MetaClass in package [{}]: [{}]", pkg, filterText);
		lst = manager.searchInPackage(pkg, filterText);
		assertNotNull(lst);
		assertEquals(0, lst.size());
	}
}


text:
=========================================
Frequently Asked/Answered Questions (FAQ)
=========================================

These are some of the most commonly encountered problems or frequently asked
questions which we receive from users. They aren't intended as a substitute for
reading the rest of the documentation, so please make sure you check it out if
your question is not answered here.

.. note::
    Most API examples and links are for version 2 and up; FAQs specific to
    version 1 will typically be marked as such.

.. warning::
    Many questions about shell command execution and task behavior are answered
    on `Invoke's FAQ page <http://www.pyinvoke.org/faq.html>`_ - please check
    there also!

.. _remote-env-vars-dont-work:

Explicitly set env variables are not being set correctly on the remote end!
===========================================================================

If your attempts to set environment variables for things like `Connection.run
<fabric.connection.Connection.run>` appear to silently fail, you're almost
certainly talking to an SSH server which is setting a highly restrictive
`AcceptEnv <https://man.openbsd.org/sshd_config#AcceptEnv>`_.

To fix, you can either modify the server's configuration to allow the env vars
you're setting, or use the ``inline_ssh_env`` `~fabric.connection.Connection`
parameter (or the :ref:`global config option <default-values>` of the same
name) to force Fabric to send env vars prefixed before your command strings
instead.

The remote shell environment doesn't match interactive shells!
==============================================================

You may find environment variables (or the behavior they trigger) differ
interactively vs scripted via Fabric. For example, a program that's on your
``$PATH`` when you manually ``ssh`` in might not be visible when using
`Connection.run <fabric.connection.Connection.run>`; or special per-program env
vars such as those for Python, pip, Java etc are not taking effect; etc.

The root cause of this is typically because the SSH server runs non-interactive
commands via a very limited shell call: ``/path/to/shell -c "command"`` (for
example, `OpenSSH
<https://github.com/fabric/fabric/issues/1519#issuecomment-411247228>`_). Most
shells, when run this way, are not considered to be either **interactive** or
**login** shells; and this then impacts which startup files get loaded.

Users typically only modify shell files related to interactive operation (such
as ``~/.bash_profile`` or ``/etc/zshrc``); such changes do not take effect when
the SSH server is running one-off commands.

To work around this, consult your shell's documentation to see if it offers any
non-login, non-interactive config files; for example, ``zsh`` lets you
configure ``/etc/zshrc`` or ``~/.zshenv`` for this purpose.

.. note::
    ``bash`` does not appear to offer standard non-login/non-interactive
    startup files, even in version 4. However, it may attempt to determine if
    it's being run by a remote-execution daemon and will apparently source
    ``~/.bashrc`` if so; check to see if this is the case on your target
    systems.

.. note::
    Another workaround for ``bash`` users is to reply on its ``$BASH_ENV``
    functionality, which names a file path as the startup file to load:

    - configure your SSH server to ``AcceptEnv BASH_ENV``, so that you can
      actually set that env var for the remote session at the top level (most
      SSH servers disallow this method by default).
    - decide which file this should be, though if you're already modifying
      files like ``~/.bash_profile`` or ``~/.bashrc``, you may want to just
      point at that exact path.
    - set the Fabric configuration value ``run.env`` to aim at the above path,
      e.g. ``{"BASH_ENV": "~/.bash_profile"}``.

.. _one-shell-per-command:

My (``cd``/``workon``/``export``/etc) calls don't seem to work!
===============================================================

While Fabric can be used for many shell-script-like tasks, there's a slightly
unintuitive catch: each `~fabric.connection.Connection.run` or
`~fabric.connection.Connection.sudo` call (or the ``run``/``sudo`` functions in
v1) has its own distinct shell session. This is required in order for Fabric to
reliably figure out, after your command has run, what its standard out/error
and return codes were.

Unfortunately, it means that code like the following doesn't behave as you
might assume::

    @task
    def deploy(c):
        c.run("cd /path/to/application")
        c.run("./update.sh")

If that were a shell script, the second `~fabric.connection.Connection.run`
call would have executed with a current working directory of
``/path/to/application/`` -- but because both commands are run in their own
distinct session over SSH, it actually tries to execute ``$HOME/update.sh``
instead (since your remote home directory is the default working directory).

A simple workaround is to make use of shell logic operations such as ``&&``,
which link multiple expressions together (provided the left hand side executed
without error) like so::

    def deploy(c):
        c.run("cd /path/to/application && ./update.sh")

.. TODO: reinsert mention of 'with cd():' if that is reimplemented

.. note::
    You might also get away with an absolute path and skip directory changing
    altogether::

        def deploy(c):
            c.run("/path/to/application/update.sh")

    However, this requires that the command in question makes no assumptions
    about your current working directory!

.. TODO:
    reinstate FAQ about 'su' / running as another user, when sudo grows that
    back. (Probably in Invoke tho.)

Why do I sometimes see ``err: stdin: is not a tty``?
====================================================

See :ref:`Invoke's FAQ <stdin-not-tty>` for this; even for Fabric v1,
which is not based on Invoke, the answer is the same.

.. _faq-daemonize:

Why can't I run programs in the background with ``&``? It makes Fabric hang.
============================================================================

Because SSH executes a new shell session on the remote end for each invocation
of ``run`` or ``sudo`` (:ref:`see also <one-shell-per-command>`), backgrounded
processes may prevent the calling shell from exiting until the processes stop
running, which in turn prevents Fabric from continuing on with its own
execution.

The key to fixing this is to ensure that your process' standard pipes are all
disassociated from the calling shell, which may be done in a number of ways
(listed in order of robustness):

* Use a pre-existing daemonization technique if one exists for the program at
  hand -- for example, calling an init script instead of directly invoking a
  server binary.

    * Or leverage a process manager such as ``supervisord``, ``upstart`` or
      ``systemd`` - such tools let you define what it means to "run" one of
      your background processes, then issue init-script-like
      start/stop/restart/status commands. They offer many advantages over
      classic init scripts as well.

* Use ``tmux``, ``screen`` or ``dtach`` to fully detach the process from the
  running shell; these tools have the benefit of allowing you to reattach to
  the process later on if needed (though they are more ad-hoc than
  ``supervisord``-like tools).
* Run the program under ``nohup`` or similar "in-shell" tools - note that this
  approach has seen limited success for most users.

I'm sometimes incorrectly asked for a passphrase instead of a password.
=======================================================================

Due to a bug of sorts in our SSH layer, it's not currently possible for Fabric
to always accurately detect the type of authentication needed. We have to try
and guess whether we're being asked for a private key passphrase or a remote
server password, and in some cases our guess ends up being wrong.

The most common such situation is where you, the local user, appear to have an
SSH keychain agent running, but the remote server is not able to honor your SSH
key, e.g. you haven't yet transferred the public key over or are using an
incorrect username. In this situation, Fabric will prompt you with "Please
enter passphrase for private key", but the text you enter is actually being
sent to the remote end's password authentication.

We hope to address this in future releases by contributing to the
aforementioned SSH library.

redpajama_set_name: RedPajamaGithub


text:
package com.littlesparkle.growler.library.activity;

import android.support.v7.widget.AppCompatImageView;
import android.view.View;
import android.widget.TextView;

import com.littlesparkle.growler.library.R;

public abstract class BaseTitleBarActivity extends BaseActivity {
    protected AppCompatImageView mBack;
    protected TextView mTitle;

    @Override
    protected void initView() {
        mBack = (AppCompatImageView) findViewById(R.id.base_title_bar_back);
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        mTitle = (TextView) findViewById(R.id.base_title_bar_text);
        mTitle.setText(getTitleResourceId());
    }

    protected abstract int getTitleResourceId();
}


text:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;

namespace FluidDbClient
{
    public abstract partial class ManagedDbQuery : ManagedDbControl, IManagedDbQuery
    {
        private readonly bool _usingExternalResources;
        private DbDataReader _reader;

        // --- Connection and transaction managed internally ---
        protected ManagedDbQuery(Database database, object parameters)
            : base(database, parameters)
        { }

        // --- Connection and transaction managed externally via DbSessionBase ---
        protected ManagedDbQuery(Database database, DbSessionBase session, object parameters)
            : base(database, session, parameters)
        {
            _usingExternalResources = session != null;
        }

        // --- Connection managed externally ---
        protected ManagedDbQuery(Database database, DbConnection connection, object parameters)
            : base(database, connection, parameters)
        {
            _usingExternalResources = connection != null;
        }

        // --- Connection and transaction managed externally ---
        protected ManagedDbQuery(Database database, DbTransaction transaction, object parameters)
            : base(database, transaction, parameters)
        {
            _usingExternalResources = transaction != null;
        }

        public T GetScalar<T>(T dbNullSubstitute = default(T))
        {
            try
            {
                EstablishCommonResources();

                var val = Command.ExecuteScalar();

                return val.DbCast(dbNullSubstitute);
            }
            finally
            {
                ReleaseResources();
            }
        }

        public IDataRecord GetRecord()
        {
            return GetResultSet(CommandBehavior.SingleRow, dr => dr.Copy()).FirstOrDefault();
        }

        public IEnumerable<IDataRecord> GetResultSet()
        {
            return GetResultSet(CommandBehavior.SingleResult, dr => dr);
        }

        public void ProcessResultSets(params Action<IEnumerable<IDataRecord>>[] processes)
        {
            if (processes.Length == 0) return;

            var isSingleProcess = processes.Length == 1;

            try
            {
                EstablishReaderResources(processes.Length == 1 ? CommandBehavior.SingleResult : CommandBehavior.Default);

                for (var i = 0; i != processes.Length; i++)
                {
                    processes[i](YieldRecords());

                    if (!isSingleProcess)
                    {
                        _reader.NextResult();
                    }
                }
            }
            finally
            {
                ReleaseResources();
            }
        }

        public DataTable GetDataTable(string tableName = null)
        {
            try
            {
                EstablishReaderResources(CommandBehavior.SingleResult);

                var dt = new DataTable(tableName);

                dt.Load(_reader);

                return dt;
            }
            finally
            {
                ReleaseResources();
            }
        }

        public DataSet GetDataSet(params string[] tableNames)
        {
            var dataSet = new DataSet();

            if (tableNames.Length == 0) return dataSet;

            try
            {
                EstablishReaderResources(CommandBehavior.Default);

                dataSet.Load(_reader, LoadOption.Upsert, tableNames);

                return dataSet;
            }
            finally
            {
                ReleaseResources();
            }
        }

        public void UseDataReader(Action<DbDataReader> doThis)
        {
            try
            {
                EstablishReaderResources(CommandBehavior.Default);

                doThis(_reader);
            }
            finally
            {
                ReleaseResources();
            }
        }

        private IEnumerable<IDataRecord> GetResultSet(CommandBehavior readBehavior, Func<IDataRecord, IDataRecord> yieldRecord)
        {
            try
            {
                EstablishReaderResources(readBehavior);

                while (_reader.Read())
                {
                    yield return yieldRecord(_reader);
                }
            }
            finally
            {
                ReleaseResources();
            }
        }

        private void EstablishCommonResources()
        {
            OnOperationStarted();

            EstablishConnection();
            CreateCommand();
        }

        private void EstablishReaderResources(CommandBehavior readBehavior)
        {
            EstablishCommonResources();
            CreateReader(readBehavior);
        }

        private void ReleaseResources()
        {
            DisposeReader();
            DisposeCommand();
            ReleaseConnection(_usingExternalResources);
        }

        private void CreateReader(CommandBehavior readBehavior)
        {
            _reader = Command.ExecuteReader(readBehavior);

            Log("Created DbReader");
        }

        private void DisposeReader()
        {
            if (_reader == null) return;

            _reader.Dispose();
            _reader = null;

            Log("Disposed DbReader");
        }

        private IEnumerable<IDataRecord> YieldRecords()
        {
            while (_reader.Read())
            {
                yield return _reader;
            }
        }
    }
}


text:
package org.apache.hyracks.storage.am.btree;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.data.marshalling.IntegerSerializerDeserializer;
import org.apache.hyracks.dataflow.common.data.marshalling.UTF8StringSerializerDeserializer;
import org.apache.hyracks.dataflow.common.utils.SerdeUtils;
import org.apache.hyracks.storage.am.common.IIndexTestWorkerFactory;
import org.apache.hyracks.storage.am.common.IndexMultiThreadTestDriver;
import org.apache.hyracks.storage.am.common.TestWorkloadConf;
import org.apache.hyracks.storage.am.config.AccessMethodTestsConfig;
import org.apache.hyracks.storage.common.IIndex;
import org.junit.Test;

@SuppressWarnings("rawtypes")
public abstract class OrderedIndexMultiThreadTest {

    protected final Logger LOGGER = Logger.getLogger(OrderedIndexMultiThreadTest.class.getName());

    // Machine-specific number of threads to use for testing.
    protected final int REGULAR_NUM_THREADS = Runtime.getRuntime().availableProcessors();
    // Excessive number of threads for testing.
    protected final int EXCESSIVE_NUM_THREADS = Runtime.getRuntime().availableProcessors() * 4;
    protected final int NUM_OPERATIONS = AccessMethodTestsConfig.BTREE_MULTITHREAD_NUM_OPERATIONS;

    protected ArrayList<TestWorkloadConf> workloadConfs = getTestWorkloadConf();

    protected abstract void setUp() throws HyracksDataException;

    protected abstract void tearDown() throws HyracksDataException;

    protected abstract IIndex createIndex(ITypeTraits[] typeTraits, IBinaryComparatorFactory[] cmpFactories,
            int[] bloomFilterKeyFields) throws HyracksDataException;

    protected abstract IIndexTestWorkerFactory getWorkerFactory();

    protected abstract ArrayList<TestWorkloadConf> getTestWorkloadConf();

    protected abstract String getIndexTypeName();

    protected void runTest(ISerializerDeserializer[] fieldSerdes, int numKeys, int numThreads, TestWorkloadConf conf,
            String dataMsg) throws InterruptedException, HyracksDataException {
        setUp();

        if (LOGGER.isLoggable(Level.INFO)) {
            String indexTypeName = getIndexTypeName();
            LOGGER.info(indexTypeName + " MultiThread Test:\nData: " + dataMsg + "; Threads: " + numThreads
                    + "; Workload: " + conf.toString() + ".");
        }

        ITypeTraits[] typeTraits = SerdeUtils.serdesToTypeTraits(fieldSerdes);
        IBinaryComparatorFactory[] cmpFactories = SerdeUtils.serdesToComparatorFactories(fieldSerdes, numKeys);

        // This is only used for the LSM-BTree.
        int[] bloomFilterKeyFields = new int[numKeys];
        for (int i = 0; i < numKeys; ++i) {
            bloomFilterKeyFields[i] = i;
        }

        IIndex index = createIndex(typeTraits, cmpFactories, bloomFilterKeyFields);
        IIndexTestWorkerFactory workerFactory = getWorkerFactory();

        // 4 batches per thread.
        int batchSize = (NUM_OPERATIONS / numThreads) / 4;
        IndexMultiThreadTestDriver driver =
                new IndexMultiThreadTestDriver(index, workerFactory, fieldSerdes, conf.ops, conf.opProbs);
        driver.init();
        long[] times = driver.run(numThreads, 1, NUM_OPERATIONS, batchSize);
        index.validate();
        driver.deinit();

        if (LOGGER.isLoggable(Level.INFO)) {
            LOGGER.info("BTree MultiThread Test Time: " + times[0] + "ms");
        }

        tearDown();
    }

    @Test
    public void oneIntKeyAndValue() throws InterruptedException, HyracksDataException {
        ISerializerDeserializer[] fieldSerdes = new ISerializerDeserializer[] { IntegerSerializerDeserializer.INSTANCE,
                IntegerSerializerDeserializer.INSTANCE };
        int numKeys = 1;
        String dataMsg = "One Int Key And Value";

        for (TestWorkloadConf conf : workloadConfs) {
            runTest(fieldSerdes, numKeys, REGULAR_NUM_THREADS, conf, dataMsg);
            runTest(fieldSerdes, numKeys, EXCESSIVE_NUM_THREADS, conf, dataMsg);
        }
    }

    @Test
    public void oneStringKeyAndValue() throws InterruptedException, HyracksDataException {
        ISerializerDeserializer[] fieldSerdes = new ISerializerDeserializer[] { new UTF8StringSerializerDeserializer(),
                new UTF8StringSerializerDeserializer() };
        int numKeys = 1;
        String dataMsg = "One String Key And Value";

        for (TestWorkloadConf conf : workloadConfs) {
            runTest(fieldSerdes, numKeys, REGULAR_NUM_THREADS, conf, dataMsg);
            runTest(fieldSerdes, numKeys, EXCESSIVE_NUM_THREADS, conf, dataMsg);
        }
    }
}


text:
"""Tests for web_app.backend.models.tag_model_py23_migration."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import mock
from loaner.web_app.backend.models import tag_model
from absl.testing import absltest

class TagModelPy23MigrationTest(absltest.TestCase):

  def setUp(self):
    super(TagModelPy23MigrationTest, self).setUp()
    self.tag = tag_model.Tag(
        name='TestTag1',
        hidden=False,
        protect=True,
        color='blue',
        description='Description 1.')

  @mock.patch.object(tag_model.ndb.Model, 'put')
  @mock.patch.object(tag_model.base_model.BaseModel, 'stream_to_bq')
  def testCreate(self, stream_to_bq_mock, model_put_mock):
    user_email = 'test@google.com'
    name = 'name'
    hidden = False
    protect = True
    color = 'grey'
    tag = tag_model.Tag.create(
        user_email, name, hidden, protect, color, description=None)
    stream_to_bq_mock.assert_called_once_with(
        'test@google.com', "Created a new tag with name 'name'.")
    model_put_mock.assert_called_once_with()
    self.assertEqual('grey', tag.color)
    self.assertEqual(False, tag.hidden)
    self.assertEqual(True, tag.protect)

  @mock.patch.object(tag_model.ndb.Model, 'put')
  @mock.patch.object(tag_model.base_model.BaseModel, 'stream_to_bq')
  @mock.patch.object(tag_model.Tag, 'key')
  def testUpdate(self, key_mock, stream_to_bq_mock, model_put_mock):
    self.tag.update(
        user_email='test@google.com',
        hidden=False,
        protect=False,
        color='blue',
        description='A new description.',
        name='TestTag2')
    stream_to_bq_mock.assert_called_once_with(
        'test@google.com', "Updated a tag with name 'TestTag2'.")
    model_put_mock.assert_called_once_with()
    key_mock.urlsafe.assert_called_once_with()

  @mock.patch.object(tag_model.Tag, 'query')
  def testPrePutHook(self, query_mock):
    self.tag = tag_model.Tag(
        name='TestTag3',
        hidden=False,
        protect=False,
        color='red',
        description='Description 2.')
    query_mock.return_value.get.return_value = False
    self.tag.name = 'test123'
    self.tag._pre_put_hook()
    query_mock.return_value.get.assert_called_once_with(keys_only=True)

  @mock.patch.object(tag_model.ndb, 'Key')
  @mock.patch.object(tag_model.logging, 'info')
  def testPreDeleteHook(self, info_mock, key_mock):
    self.tag = tag_model.Tag(
        name='TestTag3',
        hidden=False,
        protect=False,
        color='red',
        description='Description 2.')
    key_mock.urlsafe.return_value = 'test'
    key_mock.get.return_value.name = 'test_name'
    self.tag._pre_delete_hook(key_mock)
    info_mock.assert_called_once_with(
        'Destroying the tag with urlsafe key %r and name %r.', 'test',
        'test_name')
    key_mock.urlsafe.assert_called_once_with()

  @mock.patch.object(tag_model.Tag, 'query')
  def testList(self, query_mock):
    query_mock.return_value.fetch_page.return_value = 1
    tag_model.Tag.list(page_size=1, include_hidden_tags=True)
    query_mock.return_value.fetch_page.assert_called_once_with(
        offset=0, page_size=1, start_cursor=None)

  @mock.patch.object(tag_model.logging, 'info')
  @mock.patch.object(tag_model.deferred, 'defer')
  @mock.patch.object(tag_model.ndb, 'put_multi')
  def testDeleteTags(self, mock_ndb, mock_defer, mock_info):
    tag_mock = mock.Mock()
    tag_mock.key.urlsafe.return_value = 'http://test.com'
    model_tag_mock = mock.Mock(tags='test')
    entity_mock = mock.Mock()
    entity_mock.tags = [model_tag_mock]
    model_mock = mock.Mock()
    model_mock.query.return_value.fetch_page.return_value = ([entity_mock],
                                                             'test', True)
    tag_model._delete_tags(model_mock, tag=tag_mock, batch_size=2)
    mock_defer.assert_called_once_with(
        tag_model._delete_tags,
        model_mock,
        tag_mock,
        batch_size=2,
        cursor='test',
        num_updated=1)
    model_mock.query.return_value.fetch_page.assert_called_once_with(
        2, start_cursor=None)
    mock_ndb.assert_called_once_with([entity_mock])
    mock_info.assert_called_once_with(
        'Destroyed %d occurrence(s) of the tag with URL safe key %r', 1,
        'http://test.com')

class TestTagData(absltest.TestCase):

  def testTagDate(self):

    tag_model_object = tag_model.Tag(
        name='TestTag1', hidden=False, protect=True,
        color='blue', description='Description 1.')

    tag = tag_model.TagData(tag=tag_model_object, more_info='test_data')
    self.assertEqual('test_data', tag.more_info)
    self.assertEqual(tag_model_object, tag.tag)

if __name__ == '__main__':
  absltest.main()


text:
package com.snm.dao;

import com.snm.domain.Douban;
import org.springframework.stereotype.Repository;

@Repository
public class DoubanDao extends BaseDao<Douban, Integer> {
}


text:
PLEASE NOTE: This document applies to the HEAD of the source tree

If you are using a released version of Kubernetes, you should
refer to the docs that go with that version.

Documentation for other releases can be found at
[releases.k8s.io](http://releases.k8s.io).

--

## kubectl create secret docker-registry

Create a secret for use with a Docker registry.

### Synopsis

Create a new secret for use with Docker registries.

Dockercfg secrets are used to authenticate against Docker registries.

When using the Docker command line to push images, you can authenticate to a given registry by running
  'docker login DOCKER_REGISTRY_SERVER --username=DOCKER_USER --password=DOCKER_PASSWORD --email=DOCKER_EMAIL'.
That produces a ~/.dockercfg file that is used by subsequent 'docker push' and 'docker pull' commands to
authenticate to the registry.

When creating applications, you may have a Docker registry that requires authentication.  In order for the
nodes to pull images on your behalf, they have to have the credentials.  You can provide this information
by creating a dockercfg secret and attaching it to your service account.

```
kubectl create secret docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run]
```

### Examples

```
  # If you don't already have a .dockercfg file, you can create a dockercfg secret directly by using:
  $ kubectl create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
```

### Options

```
      --docker-email="": Email for Docker registry
      --docker-password="": Password for Docker registry authentication
      --docker-server="https://index.docker.io/v1/": Server location for Docker registry
      --docker-username="": Username for Docker registry authentication
      --dry-run[=false]: If true, only print the object that would be sent, without sending it.
      --generator="secret-for-docker-registry/v1": The name of the API generator to use.
  -o, --output="": Output format. One of: json|yaml|wide|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md].
      --output-version="": Output the formatted object with the given version (default api-version).
      --save-config[=false]: If true, the configuration of current object will be saved in its annotation. This is useful when you want to perform kubectl apply on this object in the future.
      --schema-cache-dir="~/.kube/schema": If non-empty, load/store cached API schemas in this directory, default is '$HOME/.kube/schema'
      --validate[=true]: If true, use a schema to validate the input before sending it
```

### Options inherited from parent commands

```
      --alsologtostderr[=false]: log to standard error as well as files
      --api-version="": The API version to use when talking to the server
      --certificate-authority="": Path to a cert. file for the certificate authority.
      --client-certificate="": Path to a client certificate file for TLS.
      --client-key="": Path to a client key file for TLS.
      --cluster="": The name of the kubeconfig cluster to use
      --context="": The name of the kubeconfig context to use
      --insecure-skip-tls-verify[=false]: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
      --kubeconfig="": Path to the kubeconfig file to use for CLI requests.
      --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace
      --log-dir="": If non-empty, write log files in this directory
      --log-flush-frequency=5s: Maximum number of seconds between log flushes
      --logtostderr[=true]: log to standard error instead of files
      --match-server-version[=false]: Require server version to match client version
      --namespace="": If present, the namespace scope for this CLI request.
      --password="": Password for basic authentication to the API server.
  -s, --server="": The address and port of the Kubernetes API server
      --stderrthreshold=2: logs at or above this threshold go to stderr
      --token="": Bearer token for authentication to the API server.
      --user="": The name of the kubeconfig user to use
      --username="": Username for basic authentication to the API server.
      --v=0: log level for V logs
      --vmodule=: comma-separated list of pattern=N settings for file-filtered logging
```

### SEE ALSO

* [kubectl create secret](kubectl_create_secret.md)	 - Create a secret using specified subcommand.

###### Auto generated by spf13/cobra on 14-Dec-2015

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_create_secret_docker-registry.md?pixel)]()


text:
package org.xito.dialog.layout;

import java.awt.*;
import javax.swing.*;

import org.xito.dialog.TablePanel;

public class ColspanLayout1 {

   static int currentColorNum = 50;
   static int colorStep = 10;

   public static void main(String args[]) {

      JFrame f = new JFrame("Col Span Layout");
      f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      f.setSize(400,400);

      TablePanel contentPane = new TablePanel(ColspanLayout1.class.getResource("colspan_layout1.html"));
      contentPane.setPaintBorderLines(true);

      f.setContentPane(contentPane);
      contentPane.add("a1", new CellPanel("a1", nextColor()));
      contentPane.add("b1", new CellPanel("b1", nextColor()));
      contentPane.add("c1", new CellPanel("c1", nextColor()));
      contentPane.add("d1", new CellPanel("d1", nextColor()));
      contentPane.add("e1", new CellPanel("e1", nextColor()));
      contentPane.add("f1", new CellPanel("f1", nextColor()));

      contentPane.add("a2", new CellPanel("a2", nextColor()));
      contentPane.add("b2", new CellPanel("b2", nextColor()));
      contentPane.add("d2", new CellPanel("d2", nextColor()));
      contentPane.add("f2", new CellPanel("f2", nextColor()));

      contentPane.add("a3", new CellPanel("a3", nextColor()));
      contentPane.add("d3", new CellPanel("d3", nextColor()));

      contentPane.add("a4", new CellPanel("a4", nextColor()));
      contentPane.add("data", new CellPanel("data", nextColor()));
      contentPane.add("f4", new CellPanel("f4", nextColor()));

      f.setVisible(true);
   }

   public static Color nextColor() {
       currentColorNum+=colorStep;
       return new Color(currentColorNum, currentColorNum, currentColorNum);
   }

   public static class CellPanel extends JPanel {

       public CellPanel(String name, Color bgColor) {
           setLayout(new BorderLayout());
           setName(name);
           add(new JLabel(name, JLabel.CENTER), BorderLayout.CENTER);
           setOpaque(true);
           setBackground(bgColor);
       }

   }

}