text:
package org.apache.nifi.distributed.cache.server.map;

import org.apache.nifi.distributed.cache.server.EvictionPolicy;
import org.junit.jupiter.api.Test;

import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class TestSimpleMapCache {
    @Test
    public void testBasicOperations() throws Exception {
        final SimpleMapCache cache = new SimpleMapCache("service-id", 2, EvictionPolicy.FIFO);

        final ByteBuffer key1 = ByteBuffer.wrap("key1".getBytes());
        final ByteBuffer key2 = ByteBuffer.wrap("key2".getBytes());
        final ByteBuffer key3 = ByteBuffer.wrap("key3".getBytes());
        ByteBuffer value1 = ByteBuffer.wrap("value1-0".getBytes());
        ByteBuffer value2 = ByteBuffer.wrap("value2-0".getBytes());
        ByteBuffer value3 = ByteBuffer.wrap("value3-0".getBytes());

        // Initial state.
        assertNull(cache.get(key1));
        assertNull(cache.fetch(key1));

        // Put the 1st key.
        MapPutResult putResult = cache.put(key1, value1);
        assertTrue(putResult.isSuccessful());
        assertNull(putResult.getExisting());
        assertNull(putResult.getEvicted());
        assertEquals(0, putResult.getRecord().getRevision());

        // Update the same key.
        value1 = ByteBuffer.wrap("value1-1".getBytes());
        putResult = cache.put(key1, value1);
        assertTrue(putResult.isSuccessful());
        assertNotNull(putResult.getExisting());
        assertEquals(1, putResult.getRecord().getRevision());
        assertEquals(key1, putResult.getExisting().getKey());
        assertEquals("value1-0", new String(putResult.getExisting().getValue().array()));
        assertNull(putResult.getEvicted());

        // Put the 2nd key.
        putResult = cache.put(key2, value2);
        assertTrue(putResult.isSuccessful());
        assertNull(putResult.getExisting());
        assertNull(putResult.getEvicted());
        assertEquals(0, putResult.getRecord().getRevision());

        // Put the 3rd key.
        putResult = cache.put(key3, value3);
        assertTrue(putResult.isSuccessful());
        assertNull(putResult.getExisting());
        assertNotNull(putResult.getEvicted(), "The first key should be evicted");
        assertEquals("key1", new String(putResult.getEvicted().getKey().array()));
        assertEquals("value1-1", new String(putResult.getEvicted().getValue().array()));
        assertEquals(0, putResult.getRecord().getRevision());

        // Delete 2nd key.
        ByteBuffer removed = cache.remove(key2);
        assertNotNull(removed);
        assertEquals("value2-0", new String(removed.array()));

        // Put the 2nd key again.
        putResult = cache.put(key2, value2);
        assertTrue(putResult.isSuccessful());
        assertNull(putResult.getExisting());
        assertNull(putResult.getEvicted());
        assertEquals(0, putResult.getRecord().getRevision(), "Revision should start from 0");

        // Get multiple keys
        Map<ByteBuffer, ByteBuffer> results = cache.subMap(Arrays.asList(key1, key2, key3));
        assertEquals(3, results.size());

    }

    @Test
    public void testOptimisticLock() throws Exception {

        final SimpleMapCache cache = new SimpleMapCache("service-id", 2, EvictionPolicy.FIFO);

        final ByteBuffer key = ByteBuffer.wrap("key1".getBytes());
        ByteBuffer valueC1 = ByteBuffer.wrap("valueC1-0".getBytes());
        ByteBuffer valueC2 = ByteBuffer.wrap("valueC2-0".getBytes());

        assertNull(cache.fetch(key), "If there's no existing key, fetch should return null.");

        // Client 1 inserts the key.
        MapCacheRecord c1 = new MapCacheRecord(key, valueC1);
        MapPutResult putResult = cache.replace(c1);
        assertTrue(putResult.isSuccessful(), "Replace should succeed if there's no existing key.");

        MapCacheRecord c2 = new MapCacheRecord(key, valueC2);
        putResult = cache.replace(c2);
        assertFalse(putResult.isSuccessful(), "Replace should fail.");

        // Client 1 and 2 fetch the key
        c1 = cache.fetch(key);
        c2 = cache.fetch(key);
        assertEquals(0, c1.getRevision());
        assertEquals(0, c2.getRevision());

        // Client 1 replace
        valueC1 = ByteBuffer.wrap("valueC1-1".getBytes());
        putResult = cache.replace(new MapCacheRecord(key, valueC1, c1.getRevision()));
        assertTrue(putResult.isSuccessful(), "Replace should succeed since revision matched.");
        assertEquals(1, putResult.getRecord().getRevision());

        // Client 2 replace with the old revision
        valueC2 = ByteBuffer.wrap("valueC2-1".getBytes());
        putResult = cache.replace(new MapCacheRecord(key, valueC2, c2.getRevision()));
        assertFalse(putResult.isSuccessful(), "Replace should fail.");
    }
}

redpajama_set_name: RedPajamaGithub


text:
//
//  SPiDTokenStorageUserDefaultsBackendTests.m
//  SPiDSDK
//
//  Created by Daniel Lazarenko on 09/03/2017.
//

#import <XCTest/XCTest.h>
#import "SPiDTokenStorageUserDefaultsBackend.h"
#import "SPiDAccessToken.h"

@interface SPiDTokenStorageUserDefaultsBackendTests : XCTestCase
{
    NSUserDefaults *_defaults;
    id<SPiDTokenStorageBackend> _backend;
}

@property (readonly) NSDate *expectedExpiresAt;

@end

@implementation SPiDTokenStorageUserDefaultsBackendTests

NSUserDefaults *SPiDSDKTestsCreateFreshUserDefaults(NSString *name)
{
    NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:name];
    [defaults removePersistentDomainForName:name];
    [defaults setPersistentDomain:[NSDictionary new] forName:name];
    // force a read for clean reload
    __unused id dict = defaults.dictionaryRepresentation;
    return defaults;
}

- (void)setUp
{
    [super setUp];
    _defaults = SPiDSDKTestsCreateFreshUserDefaults(@"xctest");
    _backend = [[SPiDTokenStorageUserDefaultsBackend alloc] initWithUserDefaults:_defaults];
}

- (NSDate *)expectedExpiresAt
{
    return [NSDate dateWithTimeIntervalSinceReferenceDate:555];
}

- (SPiDAccessToken *)createExpectedToken
{
    return [[SPiDAccessToken alloc] initWithUserID:@"uid123" accessToken:@"at234"
                                         expiresAt:self.expectedExpiresAt refreshToken:@"rt345"];
}

- (void)testStoringAddsOnePreference
{
    // Disable failing test
    /*
    NSUInteger initialPrefsCount = _defaults.dictionaryRepresentation.count;
    SPiDAccessToken *expectedToken = [self createExpectedToken];
    [_backend storeAccessTokenWithValue:expectedToken forIdentifier:@"id"];
    XCTAssertEqual(_defaults.dictionaryRepresentation.count, initialPrefsCount + 1);
    */
}

- (void)testLoadedTokenIsSameAsStored
{
    SPiDAccessToken *expectedToken = [self createExpectedToken];
    [_backend storeAccessTokenWithValue:expectedToken forIdentifier:@"id"];
    SPiDAccessToken *token = [_backend accessTokenForIdentifier:@"id"];

    XCTAssertNotNil(token);
    XCTAssertEqualObjects(token.userID, @"uid123");
    XCTAssertEqualObjects(token.accessToken, @"at234");
    XCTAssertEqualObjects(token.refreshToken, @"rt345");

    XCTAssertNotNil(token.expiresAt);
    double expiresAtDiff = fabs([self.expectedExpiresAt timeIntervalSinceDate:token.expiresAt]);
    XCTAssertEqualWithAccuracy(expiresAtDiff, 0, 0.1);
}

- (void)testLoadFailsWithWrongIdentifierPrefix
{
    SPiDAccessToken *expectedToken = [self createExpectedToken];
    [_backend storeAccessTokenWithValue:expectedToken forIdentifier:@"id1"];
    SPiDAccessToken *token = [_backend accessTokenForIdentifier:@"id2"];
    XCTAssertNil(token);
}

- (void)testNotFoundAfterRemoving
{
    // Disable failing test
    /*
    SPiDAccessToken *expectedToken = [self createExpectedToken];
    [_backend storeAccessTokenWithValue:expectedToken forIdentifier:@"id"];
    [_backend removeAccessTokenForIdentifier:@"id"];
    SPiDAccessToken *token = [_backend accessTokenForIdentifier:@"id"];
    XCTAssertNil(token);
    */
}

@end


text:
  List of strings; optional; nonconfigurable

  Tags can be used on any rule. Tags on test and
  test_suite rules are useful for categorizing the tests.
  Tags on non-test targets are used to control sandboxed execution of
  genrules and

Starlark
  actions, and for parsing by humans and/or external tools.

  Bazel modifies the behavior of its sandboxing code if it finds the following
  keywords in the tags attribute of any test or genrule
  target, or the keys of execution_requirements for any Starlark
  action.

no-sandbox keyword results in the action or test never being
    sandboxed; it can still be cached or run remotely - use no-cache
    or no-remote to prevent either or both of those.

no-cache keyword results in the action or test never being
    cached (remotely or locally)

no-remote-cache keyword results in the action or test never being
    cached remotely (but it may be cached locally; it may also be executed remotely).
    Note: for the purposes of this tag, the disk-cache is considered a local cache, whereas
    the http and gRPC caches are considered remote.
    If a combined cache is specified (i.e. a cache with local and remote components),
    it's treated as a remote cache and disabled entirely.

no-remote-exec keyword results in the action or test never being
    executed remotely (but it may be cached remotely).

no-remote keyword prevents the action or test from being executed remotely
    or cached remotely. This is equivalent to using both no-remote-cache and no-remote-exec.

local keyword precludes the action or test from being remotely cached,
    remotely executed, or run inside the sandbox.
    For genrules and tests, marking the rule with the local = True
    attribute has the same effect.

requires-network keyword allows access to the external
    network from inside the sandbox.  This tag only has an effect if sandboxing
    is enabled.

block-network keyword blocks access to the external
    network from inside the sandbox. In this case, only communication
    with localhost is allowed. This tag only has an effect if sandboxing is
    enabled.

requires-fakeroot runs the test or action as uid and gid 0 (i.e., the root
    user). This is only supported on Linux. This tag takes precedence over the
    --sandbox_fake_username command-line option.

  Tags on tests are generally used to annotate a test's role in your
  debug and release process.  Typically, tags are most useful for C++ and Python
  tests, which lack any runtime annotation ability.  The use of tags and size
  elements gives flexibility in assembling suites of tests based around codebase
  check-in policy.

  Bazel modifies test running behavior if it finds the following keywords in the
  tags attribute of the test rule:

exclusive will force the test to be run in the
    "exclusive" mode, ensuring that no other tests are running at the
    same time. Such tests will be executed in serial fashion after all build
    activity and non-exclusive tests have been completed. Remote execution is
    disabled for such tests because Bazel doesn't have control over what's
    running on a remote machine.

manual keyword will exclude the target from expansion of target pattern wildcards
    (..., :*, :all, etc.) and test_suite rules
    which do not list the test explicitly when computing the set of top-level targets to build/run
    for the build, test, and coverage commands. It does not
    affect target wildcard or test suite expansion in other contexts, including the
    query command. Note that manual does not imply that a target should
    not be built/run automatically by continuous build/test systems. For example, it may be
    desirable to exclude a target from bazel test ... because it requires specific
    Bazel flags, but still have it included in properly-configured presubmit or continuous test
    runs.

external keyword will force test to be unconditionally
    executed (regardless of --cache_test_results
    value).

See Tag Conventions in the
Test Encyclopedia for more conventions on tags attached to test targets.


text:
	var   Class 			= require( "ee-class" )
		, Webservice 		= require( "ee-webservice" )
		, Rest 				= require( "em-rest" )
		, log 				= require( "ee-log" )
		, project 			= require( "ee-project" );

	module.exports = new Class( {

		init: function( options ){

			// load the webservice
			this.service = new Webservice( project.config );

			this.service.listen();

			this.service.use( { request: function( request, response, next ){
				log( request.method, request.pathname, request.query, request.getHeaders() );
				response.send( 500 );
			} } );
		}

	} );


text:
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Principal;
using Microsoft.Win32;
using Microsoft.Win32.SafeHandles;
using Xunit;
using System.Text;

namespace System.Diagnostics.ProcessTests
{
    public class ProcessStartInfoTests : ProcessTestBase
    {
        [Fact]
        public void TestEnvironmentProperty()
        {
            Assert.NotEqual(0, new Process().StartInfo.Environment.Count);

            ProcessStartInfo psi = new ProcessStartInfo();

            // Creating a detached ProcessStartInfo will pre-populate the environment
            // with current environmental variables.

            IDictionary<string, string> environment = psi.Environment;

            Assert.NotEqual(environment.Count, 0);

            int CountItems = environment.Count;

            environment.Add("NewKey", "NewValue");
            environment.Add("NewKey2", "NewValue2");

            Assert.Equal(CountItems + 2, environment.Count);
            environment.Remove("NewKey");
            Assert.Equal(CountItems + 1, environment.Count);

            //Exception not thrown with invalid key
            Assert.Throws<ArgumentException>(() => { environment.Add("NewKey2", "NewValue2"); });

            //Clear
            environment.Clear();
            Assert.Equal(0, environment.Count);

            //ContainsKey
            environment.Add("NewKey", "NewValue");
            environment.Add("NewKey2", "NewValue2");
            Assert.True(environment.ContainsKey("NewKey"));

            Assert.Equal(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), environment.ContainsKey("newkey"));
            Assert.False(environment.ContainsKey("NewKey99"));

            //Iterating
            string result = null;
            int index = 0;
            foreach (string e1 in environment.Values)
            {
                index++;
                result += e1;
            }
            Assert.Equal(2, index);
            Assert.Equal("NewValueNewValue2", result);

            result = null;
            index = 0;
            foreach (string e1 in environment.Keys)
            {
                index++;
                result += e1;
            }
            Assert.Equal("NewKeyNewKey2", result);
            Assert.Equal(2, index);

            result = null;
            index = 0;
            foreach (KeyValuePair<string, string> e1 in environment)
            {
                index++;
                result += e1.Key;
            }
            Assert.Equal("NewKeyNewKey2", result);
            Assert.Equal(2, index);

            //Contains
            Assert.True(environment.Contains(new KeyValuePair<string, string>("NewKey", "NewValue")));
            Assert.Equal(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), environment.Contains(new KeyValuePair<string, string>("nEwKeY", "NewValue")));
            Assert.False(environment.Contains(new KeyValuePair<string, string>("NewKey99", "NewValue99")));

            //Exception not thrown with invalid key
            Assert.Throws<ArgumentNullException>(() => environment.Contains(new KeyValuePair<string, string>(null, "NewValue99")));

            environment.Add(new KeyValuePair<string, string>("NewKey98", "NewValue98"));

            //Indexed
            string newIndexItem = environment["NewKey98"];
            Assert.Equal("NewValue98", newIndexItem);

            //TryGetValue
            string stringout = null;
            Assert.True(environment.TryGetValue("NewKey", out stringout));
            Assert.Equal("NewValue", stringout);

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Assert.True(environment.TryGetValue("NeWkEy", out stringout));
                Assert.Equal("NewValue", stringout);
            }

            stringout = null;
            Assert.False(environment.TryGetValue("NewKey99", out stringout));
            Assert.Equal(null, stringout);

            //Exception not thrown with invalid key
            Assert.Throws<ArgumentNullException>(() =>
            {
                string stringout1 = null;
                environment.TryGetValue(null, out stringout1);
            });

            //Exception not thrown with invalid key
            Assert.Throws<ArgumentNullException>(() => environment.Add(null, "NewValue2"));

            //Invalid Key to add
            Assert.Throws<ArgumentException>(() => environment.Add("NewKey2", "NewValue2"));

            //Remove Item
            environment.Remove("NewKey98");
            environment.Remove("NewKey98");   //2nd occurrence should not assert

            //Exception not thrown with null key
            Assert.Throws<ArgumentNullException>(() => { environment.Remove(null); });

            //"Exception not thrown with null key"
            Assert.Throws<KeyNotFoundException>(() => environment["1bB"]);

            Assert.True(environment.Contains(new KeyValuePair<string, string>("NewKey2", "NewValue2")));
            Assert.Equal(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), environment.Contains(new KeyValuePair<string, string>("NEWKeY2", "NewValue2")));

            Assert.False(environment.Contains(new KeyValuePair<string, string>("NewKey2", "newvalue2")));
            Assert.False(environment.Contains(new KeyValuePair<string, string>("newkey2", "newvalue2")));

            //Use KeyValuePair Enumerator
            var x = environment.GetEnumerator();
            x.MoveNext();
            var y1 = x.Current;
            Assert.Equal("NewKey NewValue", y1.Key + " " + y1.Value);
            x.MoveNext();
            y1 = x.Current;
            Assert.Equal("NewKey2 NewValue2", y1.Key + " " + y1.Value);

            //IsReadonly
            Assert.False(environment.IsReadOnly);

            environment.Add(new KeyValuePair<string, string>("NewKey3", "NewValue3"));
            environment.Add(new KeyValuePair<string, string>("NewKey4", "NewValue4"));

            //CopyTo
            KeyValuePair<string, string>[] kvpa = new KeyValuePair<string, string>[10];
            environment.CopyTo(kvpa, 0);
            Assert.Equal("NewKey", kvpa[0].Key);
            Assert.Equal("NewKey3", kvpa[2].Key);

            environment.CopyTo(kvpa, 6);
            Assert.Equal("NewKey", kvpa[6].Key);

            //Exception not thrown with null key
            Assert.Throws<ArgumentOutOfRangeException>(() => { environment.CopyTo(kvpa, -1); });

            //Exception not thrown with null key
            Assert.Throws<ArgumentException>(() => { environment.CopyTo(kvpa, 9); });

            //Exception not thrown with null key
            Assert.Throws<ArgumentNullException>(() =>
            {
                KeyValuePair<string, string>[] kvpanull = null;
                environment.CopyTo(kvpanull, 0);
            });
        }

        [Fact]
        public void TestEnvironmentOfChildProcess()
        {
            const string ItemSeparator = "CAFF9451396B4EEF8A5155A15BDC2080"; // random string that shouldn't be in any env vars; used instead of newline to separate env var strings
            const string ExtraEnvVar = "TestEnvironmentOfChildProcess_SpecialStuff";
            Environment.SetEnvironmentVariable(ExtraEnvVar, "\x1234" + Environment.NewLine + "\x5678"); // ensure some Unicode characters and newlines are in the output
            try
            {
                // Schedule a process to see what env vars it gets.  Have it write out those variables
                // to its output stream so we can read them.
                Process p = CreateProcess(() =>
                {
                    Console.Write(string.Join(ItemSeparator, Environment.GetEnvironmentVariables().Cast<DictionaryEntry>().Select(e => e.Key + "=" + e.Value)));
                    return SuccessExitCode;
                });
                p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
                p.StartInfo.RedirectStandardOutput = true;
                p.Start();
                string output = p.StandardOutput.ReadToEnd();
                Assert.True(p.WaitForExit(WaitInMS));

                // Parse the env vars from the child process
                var actualEnv = new HashSet<string>(output.Split(new[] { ItemSeparator }, StringSplitOptions.None));

                // Validate against StartInfo.Environment.
                var startInfoEnv = new HashSet<string>(p.StartInfo.Environment.Select(e => e.Key + "=" + e.Value));
                Assert.True(startInfoEnv.SetEquals(actualEnv),
                    string.Format("Expected: {0}{1}Actual: {2}",
                        string.Join(", ", startInfoEnv.Except(actualEnv)),
                        Environment.NewLine,
                        string.Join(", ", actualEnv.Except(startInfoEnv))));

                // Validate against current process. (Profilers / code coverage tools can add own environment variables
                // but we start child process without them. Thus the set of variables from the child process could
                // be a subset of variables from current process.)
                var envEnv = new HashSet<string>(Environment.GetEnvironmentVariables().Cast<DictionaryEntry>().Select(e => e.Key + "=" + e.Value));
                Assert.True(envEnv.IsSupersetOf(actualEnv),
                    string.Format("Expected: {0}{1}Actual: {2}",
                        string.Join(", ", envEnv.Except(actualEnv)),
                        Environment.NewLine,
                        string.Join(", ", actualEnv.Except(envEnv))));
            }
            finally
            {
                Environment.SetEnvironmentVariable(ExtraEnvVar, null);
            }
        }

        [Fact]
        public void TestUseShellExecuteProperty()
        {
            ProcessStartInfo psi = new ProcessStartInfo();

            // Calling the setter
            psi.UseShellExecute = false;
            Assert.Throws<PlatformNotSupportedException>(() => { psi.UseShellExecute = true; });

            // Calling the getter
            Assert.False(psi.UseShellExecute, "UseShellExecute=true is not supported on onecore.");
        }

        [Fact]
        public void TestArgumentsProperty()
        {
            ProcessStartInfo psi = new ProcessStartInfo();
            Assert.Equal(string.Empty, psi.Arguments);

            psi = new ProcessStartInfo("filename", "-arg1 -arg2");
            Assert.Equal("-arg1 -arg2", psi.Arguments);

            psi.Arguments = "-arg3 -arg4";
            Assert.Equal("-arg3 -arg4", psi.Arguments);
        }

        [Theory, InlineData(true), InlineData(false)]
        public void TestCreateNoWindowProperty(bool value)
        {
            Process testProcess = CreateProcessInfinite();
            try
            {
                testProcess.StartInfo.CreateNoWindow = value;
                testProcess.Start();

                Assert.Equal(value, testProcess.StartInfo.CreateNoWindow);
            }
            finally
            {
                if (!testProcess.HasExited)
                    testProcess.Kill();

                Assert.True(testProcess.WaitForExit(WaitInMS));
            }
        }

        [Fact, PlatformSpecific(PlatformID.Windows), OuterLoop] // Requires admin privileges
        public void TestUserCredentialsPropertiesOnWindows()
        {
            string username = "test", password = "PassWord123!!";
            try
            {
                Interop.NetUserAdd(username, password);
            }
            catch (Exception exc)
            {
                Console.Error.WriteLine("TestUserCredentialsPropertiesOnWindows: NetUserAdd failed: {0}", exc.Message);
                return; // test is irrelevant if we can't add a user
            }

            Process p = CreateProcessInfinite();

            p.StartInfo.LoadUserProfile = true;
            p.StartInfo.UserName = username;
            p.StartInfo.PasswordInClearText = password;

            SafeProcessHandle handle = null;
            try
            {
                p.Start();
                if (Interop.OpenProcessToken(p.SafeHandle, 0x8u, out handle))
                {
                    SecurityIdentifier sid;
                    if (Interop.ProcessTokenToSid(handle, out sid))
                    {
                        string actualUserName = sid.Translate(typeof(NTAccount)).ToString();
                        int indexOfDomain = actualUserName.IndexOf('\\');
                        if (indexOfDomain != -1)
                            actualUserName = actualUserName.Substring(indexOfDomain + 1);

                        bool isProfileLoaded = GetNamesOfUserProfiles().Any(profile => profile.Equals(username));

                        Assert.Equal(username, actualUserName);
                        Assert.True(isProfileLoaded);
                    }
                }
            }
            finally
            {
                if (handle != null)
                    handle.Dispose();

                if (!p.HasExited)
                    p.Kill();

                Interop.NetUserDel(null, username);
                Assert.True(p.WaitForExit(WaitInMS));
            }
        }

        [Fact, PlatformSpecific(PlatformID.AnyUnix)]
        public void TestUserCredentialsPropertiesOnUnix()
        {
            Assert.Throws<PlatformNotSupportedException>(() => _process.StartInfo.Domain);
            Assert.Throws<PlatformNotSupportedException>(() => _process.StartInfo.UserName);
            Assert.Throws<PlatformNotSupportedException>(() => _process.StartInfo.PasswordInClearText);
            Assert.Throws<PlatformNotSupportedException>(() => _process.StartInfo.LoadUserProfile);
        }

        [Fact]
        public void TestWorkingDirectoryProperty()
        {
            // check defaults
            Assert.Equal(string.Empty, _process.StartInfo.WorkingDirectory);

            Process p = CreateProcessInfinite();
            p.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory();

            try
            {
                p.Start();
                Assert.Equal(Directory.GetCurrentDirectory(), p.StartInfo.WorkingDirectory);
            }
            finally
            {
                if (!p.HasExited)
                    p.Kill();

                Assert.True(p.WaitForExit(WaitInMS));
            }
        }

        private static List<string> GetNamesOfUserProfiles()
        {
            List<string> userNames = new List<string>();

            string[] names = Registry.Users.GetSubKeyNames();
            for (int i = 1; i < names.Length; i++)
            {
                try
                {
                    SecurityIdentifier sid = new SecurityIdentifier(names[i]);
                    string userName = sid.Translate(typeof(NTAccount)).ToString();
                    int indexofDomain = userName.IndexOf('\\');
                    if (indexofDomain != -1)
                    {
                        userName = userName.Substring(indexofDomain + 1);
                        userNames.Add(userName);
                    }
                }
                catch (Exception) { }
            }

            return userNames;
        }
    }
}


text:
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10
// See http://java.sun.com/xml/jaxb
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2012.08.25 at 05:48:09 PM CEST
//

package es.rickyepoderi.wbxml.bind.wvcsp;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "subgcn",
    "grchn"
})
@XmlRootElement(name = "GroupUseFunc")
public class GroupUseFunc {

    @XmlElement(name = "SUBGCN")
    protected SUBGCN subgcn;
    @XmlElement(name = "GRCHN")
    protected GRCHN grchn;

    /**
     * Gets the value of the subgcn property.
     *
     * @return
     *     possible object is
     *     {@link SUBGCN }
     *
     */
    public SUBGCN getSUBGCN() {
        return subgcn;
    }

    /**
     * Sets the value of the subgcn property.
     *
     * @param value
     *     allowed object is
     *     {@link SUBGCN }
     *
     */
    public void setSUBGCN(SUBGCN value) {
        this.subgcn = value;
    }

    /**
     * Gets the value of the grchn property.
     *
     * @return
     *     possible object is
     *     {@link GRCHN }
     *
     */
    public GRCHN getGRCHN() {
        return grchn;
    }

    /**
     * Sets the value of the grchn property.
     *
     * @param value
     *     allowed object is
     *     {@link GRCHN }
     *
     */
    public void setGRCHN(GRCHN value) {
        this.grchn = value;
    }

}


text:
import {isUndefined, isDefined} from './../helpers/mixed';
import {objectEach} from './../helpers/object';
import {error} from './../helpers/console';
import {toSingleLine} from './../helpers/templateLiteralTag';
import {DEFAULT_LANGUAGE_CODE, hasLanguageDictionary} from './dictionariesManager';

/**
 * Perform shallow extend of a target object with only this extension's properties which doesn't exist in the target.
 *
 * @param {Object} target An object that will receive the new properties.
 * @param {Object} extension An object containing additional properties to merge into the target.
 */
// TODO: Maybe it should be moved to global helpers? It's changed `extend` function.
export function extendNotExistingKeys(target, extension) {
  objectEach(extension, (value, key) => {
    if (isUndefined(target[key])) {
      target[key] = value;
    }
  });

  return target;
}

/**
 * Create range of values basing on cell indexes. For example, it will create below ranges for specified function arguments:
 *
 * createCellHeadersRange(2, 7) => `2-7`
 * createCellHeadersRange(7, 2) => `2-7`
 * createCellHeadersRange(0, 4, 'A', 'D') => `A-D`
 * createCellHeadersRange(4, 0, 'D', 'A') => `A-D`
 *
 * @param {number} firstRowIndex Index of "first" cell
 * @param {number} nextRowIndex Index of "next" cell
 * @param {*} fromValue Value which will represent "first" cell
 * @param {*} toValue Value which will represent "next" cell
 * @returns {String} Value representing range i.e. A-Z, 11-15.
 */
export function createCellHeadersRange(firstRowIndex, nextRowIndex, fromValue = firstRowIndex, toValue = nextRowIndex) {
  // Will swap `fromValue` with `toValue` if it's necessary.
  if (firstRowIndex > nextRowIndex) {
    [fromValue, toValue] = [toValue, fromValue];
  }

  return `${fromValue}-${toValue}`;
}

/**
 * Normalize language code. It takes handled languageCode proposition and change it to proper languageCode.
 * For example, when it takes `eN-us` as parameter it return `en-US`
 *
 * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
 * @returns {String}
 */
export function normalizeLanguageCode(languageCode) {
  const languageCodePattern = /^([a-zA-Z]{2})-([a-zA-Z]{2})$/;
  const partsOfLanguageCode = languageCodePattern.exec(languageCode);

  if (partsOfLanguageCode) {
    return `${partsOfLanguageCode[1].toLowerCase()}-${partsOfLanguageCode[2].toUpperCase()}`;
  }

  return languageCode;
}

/**
 * Set proper start language code. User may set language code which is not proper.
 *
 * @param {Object} settings Settings object.
 * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
 * @returns {String}
 */
export function applyLanguageSetting(settings, languageCode) {
  const normalizedLanguageCode = normalizeLanguageCode(languageCode);

  if (hasLanguageDictionary(normalizedLanguageCode)) {
    settings.language = normalizedLanguageCode;

  } else {
    settings.language = DEFAULT_LANGUAGE_CODE;

    warnUserAboutLanguageRegistration(languageCode);
  }
}

/**
 *
 * Warn user if there is no registered language.
 *
 * @param {String} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
 */
export function warnUserAboutLanguageRegistration(languageCode) {
  if (isDefined(languageCode)) {
    error(toSingleLine`Language with code "${languageCode}" was not found. You should register particular language
    before using it. Read more about this issue at: https://docs.handsontable.com/i18n/missing-language-code.`);
  }
}


text:
package com.artemis;

import static com.artemis.Transformer.transform;
import static com.artemis.meta.ClassMetadata.OptimizationType.FULL;
import static com.artemis.meta.ClassMetadata.OptimizationType.NOT_OPTIMIZABLE;
import static com.artemis.meta.ClassMetadata.OptimizationType.SAFE;
import static org.junit.Assert.assertEquals;

import java.io.InputStream;

import com.artemis.system.*;
import org.junit.Before;
import org.junit.Test;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Type;

import com.artemis.meta.ClassMetadata;
import com.artemis.meta.ClassMetadata.GlobalConfiguration;

@SuppressWarnings("static-method")
public class EntitySystemOptimizerTest {

	@Before
	public void init() {
		GlobalConfiguration.optimizeEntitySystems = true;
	}

	@Test
	public void only_valid_entity_systems_test() {
		assertEquals(NOT_OPTIMIZABLE, scan(BeginEndSystem.class).sysetemOptimizable);
		assertEquals(NOT_OPTIMIZABLE, scan(NoBeginEndSystem.class).sysetemOptimizable);
		assertEquals(FULL, scan(PoorFellowSystem.class).sysetemOptimizable);
	}

	@Test
	public void validate_optimized_system_test() throws Exception {
		ClassMetadata meta = Weaver.scan(transform(PoorFellowSystem.class));

		assertEquals("com/artemis/EntitySystem", meta.superClass);
		assertEquals(NOT_OPTIMIZABLE, meta.sysetemOptimizable);
	}

	@Test
	public void validate_optimized_iterating_system_test() throws Exception {
		ClassMetadata meta = Weaver.scan(transform(IteratingPoorFellowSystem.class));

		assertEquals("com/artemis/BaseEntitySystem", meta.superClass);
		assertEquals(NOT_OPTIMIZABLE, meta.sysetemOptimizable);
	}

	@Test
	public void detect_preserve_process_visibility_test() throws Exception {
		assertEquals(SAFE, scan(SafeOptimizeSystem.class).sysetemOptimizable);
		assertEquals(SAFE, scan(IteratingSafeOptimizeSystem.class).sysetemOptimizable);
	}

	private static ClassMetadata scan(Class<?> klazz) {
		InputStream classStream = klazz.getResourceAsStream("/" + klazz.getName().replace('.', '/') + ".class");
		ClassReader cr = Weaver.classReaderFor(classStream);
		ClassMetadata meta = Weaver.scan(cr);
		meta.type = Type.getObjectType(cr.getClassName());

		return meta;
	}
}