text:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
            android:id="@+id/action_search"
            android:icon="@drawable/ic_search"
            android:title="@string/menu_search_title"
            android:actionViewClass="android.widget.SearchView"
            android:showAsAction="ifRoom|collapseActionView"/>
</menu>

redpajama_set_name: RedPajamaGithub


text:
s3_testing_bucket=br-tmp
# Set this to 1 to use local file repo; otherwise use S3.
run_local=1

repo_prefix=zinc-testing/repo
file_root=/tmp/$repo_prefix
s3_root=s3://$s3_testing_bucket/$repo_prefix
work=/tmp/zinc-testing/work
zinc_path=$(cd `dirname $0`; pwd)/zinc.py

# Tests can be done either way, but run faster on local filesystem.
if [[ "$run_local" == "1" ]]; then
  root_uri="file://$file_root"
else
  root_uri="$s3_root"
fi

#debug=--debug
#debug=-v
debug=$1

mkdir -p $work
work=$(cd $work; pwd)

# We turn on exit on error, so that any status code changes cause a test failure.
set -e
set -o pipefail

mkdir -p $file_root $work

zinc() {
  "$zinc_path" $debug "$@"
}

delete_work() {
  rm -rf $work/work_dir*
  rm -rf $work/copies
  rm -rf $work/forbidden
  rm -rf $work/logs
}

delete_repo() {
  if echo $root_uri | grep s3; then
    s3cmd del -r $root_uri >/dev/null
  else
    rm -rf $file_root
  fi
}

create_file() {
  echo "$2" > $1
}

create_file_of_size() {
  dd if=/dev/zero bs=1000000 count=$1 of=$2 status=noxfer
}

ls_pretty() {
  # Ensure deterministic ordering of revision paths.
  find $1 -type f -printf "%12s %p\n" | sed -r 's/\b[a-z0-9]{13}\b/_REV_/g' | sort -k2
}

ls_pretty_nosize() {
  # Ensure deterministic ordering of revision paths.
  find $1 -type f -printf "%p\n" | sed -r 's/\b[a-z0-9]{13}\b/_REV_/g' | sort -k2
}

# A trick to test for error conditions
expect_error() {
  echo "(got expected error: status $?)"
}

cd $work

delete_repo
delete_work

echo Running test against repository: $root_uri
echo Work directory: $work

# This will echo all commands as they are read. Bash commands plus their
# outputs will be used for validating regression tests pass (set -x is similar
# but less readable and sometimes not deterministic).
set -v

# Record Python version.
python -V

### Setup
zinc init $root_uri

zinc newscope -R $root_uri -u user0 test_scope
zinc checkout -s test_scope $root_uri work_dir

zinc newscope -R $root_uri -u user0 another_scope --date '2010-01-01'
zinc checkout -s another_scope $root_uri work_dir

cd work_dir

### First working dir
mkdir test_scope/subdir1
create_file test_scope/file1 "contents of file1"
create_file test_scope/subdir1/file2 "contents of file2"
# S3 has a minimum filesize of 5MB for part size in multipart
create_file_of_size 50 test_scope/subdir1/bigfile
zinc status -s test_scope
cd test_scope
zinc status
cd subdir1
zinc status
cd ../..
zinc commit -s test_scope -u user1 -m "first commit" --date '2010-01-01 9:00am'

sleep 1

mkdir test_scope/subdir2
create_file test_scope/subdir1/file3 "more contents"
create_file test_scope/subdir2/file4 "contents of file4, a different size"
rm test_scope/file1
create_file test_scope/file5 "more contents"
zinc status -s test_scope
zinc commit -s test_scope -u user2 -m "second commit"

zinc tags -s test_scope
zinc tag -s test_scope my-first-tag

sleep 1

create_file test_scope/subdir1/file2 "new contents"
create_file test_scope/file6 "file6 contents"
rm test_scope/file5
zinc status -s test_scope
zinc commit -s test_scope -u user3 -m "another commit!
with multiple lines"
sleep 2

# Try MD5 checks for file of unchanged size
touch test_scope/file6
zinc status -s test_scope
create_file test_scope/file6 "file6 contentX"
touch -d 2000-01-01 test_scope/file6
zinc status -s test_scope
create_file test_scope/file6 "file6 contents"
touch -d 2000-01-01 test_scope/file6
zinc status -s test_scope

sleep 1

zinc tag -s test_scope my-second-tag
zinc tag -s test_scope my-second-tag-duplicate

# Testing reverts
rm test_scope/subdir1/file2
create_file test_scope/file6 "modified contents"
create_file test_scope/file7 "new file7"
create_file test_scope/file8 "new file8"
zinc revert -s test_scope file6
zinc status -s test_scope
ls -1 test_scope
zinc revert -s test_scope subdir1/file2
zinc revert -s test_scope bad_filename || expect_error
zinc status -s test_scope
zinc revert -s test_scope
zinc status -s test_scope
ls -1 test_scope
zinc commit -s test_scope -u user3 -m "empty commit, will fail" || expect_error
zinc commit --suppress -s test_scope -u user3 -m "empty commit, will be ignored"

create_file test_scope/file7 "new file7, take 2"
zinc commit -s test_scope -u user3 -m "another commit"
test_scope_rev=$(zinc id -s test_scope)
zinc tag -s test_scope -r $test_scope_rev my-third-tag

zinc status -s test_scope
zinc log -s test_scope
zinc tags -s test_scope
zinc id -s test_scope
zinc ids
zinc scopes

### Second working dir
cd $work
zinc checkout -s test_scope -r my-first-tag $root_uri work_dir_alt
cd work_dir_alt
zinc ids
zinc update -s test_scope -r my-second-tag
zinc update -s test_scope
create_file test_scope/added_file "an added file"
zinc commit -s test_scope -u user4 -m "commit from a different working dir"
zinc ids

diff -r --brief test_scope/subdir1 $work/work_dir/test_scope/subdir1

### Third working dir
cd $work
zinc checkout --all $root_uri work_dir_all
cd work_dir_all
zinc tag --work tagging-things-at-once
zinc update --work
zinc update --all

### First working dir again
cd $work
cd work_dir
create_file test_scope/new_file_from_another_work_dir "contents"
zinc update -s test_scope
zinc commit -s test_scope -u user5 -m "committing from original working dir"
create_file test_scope/non_conflicting_file "modifying this file should be fine since it is new"
zinc update -s test_scope -r my-first-tag
create_file test_scope/file6 "modifying this file locally so next update will have conflicts"
zinc update -s test_scope -r tagging-things-at-once || expect_error
cat .zinc/checkout-state

### Third working dir again
cd $work
cd work_dir_all
zinc newscope -u user5 -R $root_uri new_scope
zinc update --all
rm test_scope/file6
create_file test_scope/file7 "modifying file7"
create_file test_scope/file8 "creating a new file"
create_file new_scope/file_in_new_scope "creating a new file in second scope"
zinc status --work
zinc commit --work -u user6 -m "committing multiple scopes at once"
cat .zinc/checkout-state

# Test error suppression
zinc newscope -u user5 -R $root_uri new_scope || expect_error
zinc newscope -u user5 -R $root_uri --suppress new_scope

### Compression
create_file test_scope/file9 "another file for compression"
zinc commit --work --compression=lzo -u user6 -m "committing with compression on"
create_file test_scope/file10 "another file no compression"
zinc commit --work --compression=raw -u user6 -m "committing with compression off"
zinc tag --work mixed-compression
zinc status --work --mod-all
zinc status -s test_scope --mod-all
zinc commit --work --mod-all --compression=lzo -u user7 -m "recommitting with compression on for all files"

### Ignore files
create_file test_scope/junk1.orig "this file should be ignored"
create_file test_scope/junk2.bak "this file should be ignored"
create_file test_scope/.junk3 "this file should be ignored"
create_file test_scope/.tmp.junk4 "this file should be ignored"
mkdir -p test_scope/.tmp-copy.e8q4rtgsjvkoy/some-path
create_file test_scope/.tmp-copy.e8q4rtgsjvkoy/some-path/junk5 "this whole directory should be ignored"
zinc status --work

### Another working dir, but no caching
cd $work
zinc checkout --no-cache -s test_scope -r my-first-tag $root_uri work_dir_no_cache

### Check internal .zinc state
ls_pretty work_dir_all/.zinc
ls_pretty work_dir_no_cache/.zinc

### Repo-only commands
cd $work
zinc list -R $root_uri -s test_scope
zinc list -R $root_uri -s test_scope subdir1
zinc list -R $root_uri -s test_scope --short-paths subdir1
zinc list -R $root_uri -s test_scope -a
zinc list -R $root_uri -s test_scope -a --short-paths
zinc copy -R $root_uri -s test_scope subdir1/file2 copies/file2-copy
cd copies
zinc copy -R $root_uri -s test_scope subdir1/file2 file2-copy2
cd ..
zinc copy -R $root_uri -s test_scope -r my-second-tag subdir1/file3 copies/file3-copy
zinc copy -R $root_uri -s test_scope -r my-second-tag -a subdir1 copies/subdir1-copy
zinc log -R $root_uri -s test_scope -r :tip --date '> 2010-01-02'
zinc tags -R $root_uri -s test_scope -r :tip --date '>2010-01-02'
zinc locate -R $root_uri -s test_scope -r my-second-tag subdir1/file2
zinc locate -R $root_uri -s test_scope file9
zinc locate -R $root_uri -s test_scope file10
zinc _manifest -R $root_uri -s test_scope -r my-third-tag
zinc _manifest -R $root_uri -s test_scope -r mixed-compression
zinc _manifest -R $root_uri -s test_scope

### Error situations

# Nested checkouts.
cd $work/work_dir/test_scope
echo blah
zinc checkout -s test_scope $root_uri work_dir || expect_error
ls_pretty .

# Disk I/O error.
mkdir $work/forbidden
chmod a-wx $work/forbidden
zinc copy -R $root_uri -s test_scope subdir1/file2 $work/forbidden/file2-copy || expect_error
chmod +wx $work/forbidden

# Set up a big file so we can interrupt operations.
cd $work/work_dir_all
create_file_of_size 100 test_scope/subdir1/bigfile-uncompressed
zinc commit -s test_scope -u user1 -m "another commit (big file, no compression)" --compression=raw

# Broken pipe on output.
# Output here is ugly in Python 2.7: http://bugs.python.org/issue11380
zinc log -R $root_uri -s test_scope | head -5
zinc log -R $root_uri -s test_scope | true

# Interruptions.
cd $work
mkdir -p $work/logs
zinc copy -R $root_uri -s test_scope subdir1/bigfile-uncompressed copies/bigfile-copy1 > logs/copy1.log 2>&1 &
sleep 0.2
jobs
kill -KILL %1
sleep 0.2
jobs
ls_pretty_nosize copies
wait

# SIGPIPE is important to test since S3 connections can sometimes get this
# (especially for big files).  It's not clear this accurately simulates a
# socket pipe failure, but including in any case for basic testing.
zinc copy -R $root_uri -s test_scope subdir1/bigfile-uncompressed copies/bigfile-copy2 > logs/copy2.log 2>&1 &
sleep 0.2
jobs
kill -PIPE %1
sleep 0.2
jobs
ls_pretty_nosize copies
wait

head -1000 logs/*.log

# Other test cases to consider adding:
# - actual S3 socket or other error (simulate S3 exceptions/errors?)
# - use https://github.com/jubos/fake-s3 for more extensive testing
# - keyboard interupt
# - kill of process group vs individual process?


text:
@interface SBSettingsTests : SBTestCase
@property (nonatomic, strong) SBSettings *target;
@property (nonatomic, strong) XCTestExpectation *expectation;
@property (nonatomic, strong) SBSettingEvent *responseEvent;
@end

@implementation SBSettingsTests

- (void)setUp
{
    [super setUp];
    self.expectation = nil;
    self.responseEvent = nil;
    self.target = [SBSettings new];
}

- (void)tearDown
{
    self.expectation = nil;
    self.responseEvent = nil;
    self.target = nil;
    [super tearDown];
}

SUBSCRIBE(SBSettingEvent) {
    self.responseEvent = event;
    [self.expectation fulfill];
    self.expectation = nil;
}

- (void)test002SettingsWithCachedDictionary
{
    SBMSettings *newSettings = self.target.settings;

    SBSettings *newTarget = [SBSettings new];
    XCTAssert([[newSettings toDictionary] isEqualToDictionary:[[newTarget settings] toDictionary]]);
}

- (void)test003SharedInstance {
    SBSettings *testTarget = [SBSettings sharedManager];
    XCTAssert(testTarget);
}

- (void)test04DefaultBeaconRegions {
    SBSettings *testTarget = [SBSettings sharedManager];

    XCTAssert([testTarget.settings.defaultBeaconRegions isEqualToDictionary:[SensorbergSDK defaultBeaconRegions]]);
}

@end


text:
#include "honeycomb.h"

/*
 * Honeycomb application entry point.
 */
int
main(int args, char **argv)
{
}


text:
package org.sana.net.http.handler;

import java.io.IOException;
import java.lang.reflect.Type;

import java.util.Collection;

import org.sana.api.task.EncounterTask;
import org.sana.net.Response;

import com.google.gson.reflect.TypeToken;

public class EncounterTaskResponseHandler extends ApiResponseHandler<Response<Collection<EncounterTask>>>{

	public Type getType() {
		Type typeOf = new TypeToken<Response<Collection<EncounterTask>>>(){}.getType();
		return typeOf;
	}
}


text:
require 'rubybvc'
require 'yaml'

delay = 5

puts "Loading configuration..."
config = YAML.load_file('config.yml')

puts "\nStarting Demo 16: Setting OpenFlow flow on the Controller: "\
  "send to controller traffic with a particular ipv6 source and destination"

puts "\nCreating controller instance"
controller = Controller.new(ip_addr: config['controller']['ip_addr'],
  admin_name: config['controller']['username'],
  admin_password: config['controller']['password'])
puts "Controller: #{JSON.pretty_generate controller.to_hash}"

name = config['node']['name']
of_switch = OFSwitch.new(controller: controller, name: name)
eth_type = 34525 # IPv6 Protocol
ipv6_src = "fe08::2acf:e9ff:fe21:6431/128"
ipv6_dst = "aabb:1234:2acf:e9ff::fe21:6431/64"

output_port = "CONTROLLER"

puts "\nMatch: Ethernet Type 0x#{eth_type.to_s(16)}, IPv6 Source #{ipv6_src}, "\
  "IPv6 Destination #{ipv6_dst}"
puts "Action: Output (controller)"

sleep(delay)
flow_id = 23
table_id = 0
flow_entry = FlowEntry.new(flow_priority: 1014, flow_table_id: table_id,
  flow_id: flow_id, cookie: 408, cookie_mask: 255, hard_timeout: 3400,
  idle_timeout: 3400)
# Instruction: 'Apply-action'
#     Actions: 'Output'
instruction = Instruction.new(instruction_order: 0)
action = OutputAction.new(order: 0, port: output_port)
instruction.add_apply_action(action)
flow_entry.add_instruction(instruction)

# Match Fields: Ethernet Type
#               IPv6 Source Addres
#               IPv6 Destination Address
match = Match.new(eth_type: eth_type, ipv6_source: ipv6_src,
  ipv6_destination: ipv6_dst)
flow_entry.add_match(match)

puts"\nFlow to send: #{JSON.pretty_generate flow_entry.to_hash}"

sleep(delay)
response = of_switch.add_modify_flow(flow_entry)
if response.status == NetconfResponseStatus::OK
  puts "\nFlow successfully added to the controller"
else
  puts "\nDemo terminated: #{response.message}"
  exit
end

puts "\n Get configured flow from the Controller"
response = of_switch.get_configured_flow(table_id: table_id, flow_id: flow_id)
if response.status == NetconfResponseStatus::OK
  puts "Flow successfully read from the controller"
  puts "Flow info: #{JSON.pretty_generate response.body}"
else
  puts "\nDemo terminated: #{response.message}"
  exit
end

puts "\nDelete flow with ID #{flow_id} from Controller's cache and from table "\
  "#{table_id} on #{name} node"
sleep(delay)
response = of_switch.delete_flow(flow_id: flow_id, table_id: table_id)
if response.status == NetconfResponseStatus::OK
  puts "Flow successfully removed from the controller"
else
  puts "\nDemo terminated: #{response.message}"
  exit
end

puts "\nEnd of Demo 16"


text:
package org.apache.sis.xml;

import java.util.Map;
import java.util.List;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
import java.lang.reflect.Proxy;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import org.opengis.metadata.Identifier;
import org.apache.sis.util.Classes;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.LenientComparable;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.util.Strings;
import org.apache.sis.internal.jaxb.IdentifierMapAdapter;
import org.apache.sis.internal.jaxb.ModifiableIdentifierMap;

/**
 * The handler for an object where all methods returns null or empty collections, except
 * a few methods related to object identity. This handler is used only when no concrete
 * definition were found for a XML element identified by {@code xlink} or {@code uuidref}
 * attributes.
 *
 *
Implementation note:
 * The same handler could be used for every proxy having the same XLink.
 * For now, it doesn't seem worth to cache the handlers.

 *
 * @author  Martin Desruisseaux (Geomatys)
 * @version 0.3
 * @since   0.3
 * @module
 */
final class NilObjectHandler implements InvocationHandler {
    /**
     * The identifiers as an {@link IdentifierMapAdapter} object, or the {@code nilReason}
     * attribute as a {@link NilReason} object. We don't use separated fields because
     * those attributes are exclusive, and some operations like {@code toString()},
     * {@code hashCode()} and {@code equals(Object)} are the same for both types.
     */
    private final Object attribute;

    /**
     * Creates a new handler for an object identified by the given identifiers.
     * The identifiers are wrapped in a mutable list, so users can add, remove
     * or modify identifiers.
     */
    NilObjectHandler(final Identifier[] identifiers) {
        final List<Identifier> asList = new ArrayList<>(identifiers.length);
        for (final Identifier identifier : identifiers) {
            if (identifier != null) {
                asList.add(identifier);
            }
        }
        attribute = new ModifiableIdentifierMap(asList);
    }

    /**
     * Creates a new handler for an object which is nil for the given reason.
     */
    NilObjectHandler(final NilReason nilReason) {
        attribute = nilReason;
    }

    /**
     * Returns {@code true} if the given type is one of the interfaces ignored by
     * {@link #getInterface(Object)}.
     */
    static boolean isIgnoredInterface(final Class<?> type) {
        return IdentifiedObject.class.isAssignableFrom(type) ||
               NilObject.class.isAssignableFrom(type) ||
               LenientComparable.class.isAssignableFrom(type);
    }

    /**
     * Returns the interface implemented by the given proxy.
     */
    private static Class<?> getInterface(final Object proxy) {
        for (final Class<?> type : proxy.getClass().getInterfaces()) {
            if (!isIgnoredInterface(type)) {
                return type;
            }
        }
        throw new AssertionError(proxy);                                // Should not happen.
    }

    /**
     * Processes a method invocation. For any invocation of a getter method, there is a choice:
     *
     *

     *
If the invoked method is {@code getIdentifiers()}, returns the identifiers given at
     *       construction time.

     *
If the invoked method is {@code getIdentifierMap()}, returns a view over the
     *       identifiers given at construction time.

     *
If the invoked method is any other kind of getter, returns null except if:

     *
the return type is a collection, in which case an empty collection is returned;

     *
the return type is a primitive, in which case the nil value for that primitive
     *           type is returned.

     *
If the invoked method is a setter method, throw a {@link UnsupportedOperationException}
     *       since the proxy instance is assumed unmodifiable.

     *
If the invoked method is one of the {@link Object} method, delegate to the {@link #attribute}.

     *

     */
    @Override
    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
        final String name = method.getName();
        if (args == null) {
            switch (name) {
                case "getNilReason": {
                    return (attribute instanceof NilReason) ? (NilReason) attribute : null;
                }
                case "getIdentifierMap": {
                    return (attribute instanceof IdentifierMap) ? (IdentifierMap) attribute : null;
                }
                case "getIdentifiers": {
                    return (attribute instanceof IdentifierMapAdapter) ?
                            ((IdentifierMapAdapter) attribute).getIdentifiers(method.getReturnType()) : null;
                }
                case "toString": {
                    return Strings.bracket(getInterface(proxy), attribute);
                }
                case "hashCode": {
                    return ~attribute.hashCode();
                }
            }
            if (name.startsWith("get") || name.startsWith("is")) {
                return Numbers.valueOfNil(method.getReturnType());
            }
        } else switch (args.length) {
            case 1: {
                if (name.equals("equals")) {
                    return equals(proxy, args[0], ComparisonMode.STRICT);
                }
                if (name.startsWith("set")) {
                    throw new UnsupportedOperationException(Errors.format(
                            Errors.Keys.UnmodifiableObject_1, getInterface(proxy)));
                }
                break;
            }
            case 2: {
                if (name.equals("equals")) {
                    return equals(proxy, args[0], (ComparisonMode) args[1]);
                }
                break;
            }
        }
        throw new UnsupportedOperationException(Errors.format(Errors.Keys.UnsupportedOperation_1,
                getInterface(proxy).getSimpleName() + '.' + name));
    }

    /**
     * Compares the given objects to the given level of strictness. The first object shall
     * be the proxy, and the second object an arbitrary implementation. This method returns
     * {@code true} if the given arbitrary implementation contains only null or empty attributes.
     */
    private boolean equals(final Object proxy, final Object other, final ComparisonMode mode) throws Throwable {
        if (other == proxy) return true;
        if (other == null) return false;
        if (proxy.getClass() == other.getClass()) {
            if (mode.isIgnoringMetadata()) {
                return true;
            }
            final NilObjectHandler h = (NilObjectHandler) Proxy.getInvocationHandler(other);
            return attribute.equals(h.attribute);
        }
        switch (mode) {
            case STRICT: return false;              // The above test is the only relevant one for this mode.
            case BY_CONTRACT: {
                Object tx = attribute, ox = null;
                if (tx instanceof IdentifierMapAdapter) {
                    tx = ((IdentifierMapAdapter) tx).identifiers;
                    if (other instanceof IdentifiedObject) {
                        ox = ((IdentifiedObject) other).getIdentifiers();
                    }
                } else {
                    if (other instanceof NilObject) {
                        ox = ((NilObject) other).getNilReason();
                    }
                }
                if (!Objects.equals(tx, ox)) {
                    return false;
                }
                break;
            }
        }
        /*
         * Having two objects declaring the same identifiers and implementing the same interface,
         * ensures that all properties in the other objects are null or empty collections.
         */
        final Class<?> type = getInterface(proxy);
        if (!type.isInstance(other)) {
            return false;
        }
        for (final Method getter : type.getMethods()) {
            if (Classes.isPossibleGetter(getter)) {
                final Object value;
                try {
                    value = getter.invoke(other, (Object[]) null);
                } catch (InvocationTargetException e) {
                    throw e.getTargetException();
                }
                if (value != null) {
                    if ((value instanceof Collection<?>) && ((Collection<?>) value).isEmpty()) {
                        continue;           // Empty collection, which is consistent with this proxy behavior.
                    }
                    if ((value instanceof Map<?,?>) && ((Map<?,?>) value).isEmpty()) {
                        continue;           // Empty collection, which is consistent with this proxy behavior.
                    }
                    return false;
                }
            }
        }
        return true;
    }
}