text:
package com.azure.spring.cloud.autoconfigure.implementation.jdbc;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;

import java.util.HashMap;
import java.util.Map;

import static com.azure.spring.cloud.autoconfigure.implementation.jdbc.JdbcConnectionStringTest.PATH_WITHOUT_QUERY_PATTERN;
import static com.azure.spring.cloud.autoconfigure.implementation.jdbc.JdbcConnectionStringTest.PATH_WITH_QUERY_PATTERN;
import static com.azure.spring.cloud.autoconfigure.implementation.jdbc.JdbcConnectionStringUtils.enhanceJdbcUrl;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

class JdbcConnectionStringEnhancerTest {

    @ParameterizedTest
    @EnumSource(value = DatabaseType.class, names = { "MYSQL", "POSTGRESQL" })
    void inconsistentPropertiesShouldThrow(DatabaseType databaseType) {
        Map<String, String> defaultEnhancedProperties = databaseType.getDefaultEnhancedProperties();
        Map.Entry<String, String> randomDefaultEnhancedProperty = defaultEnhancedProperties.entrySet().iterator().next();

        String queries = randomDefaultEnhancedProperty.getKey() + "=randomValue";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionString jdbcConnectionString = JdbcConnectionString.resolve(connectionString);
        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(jdbcConnectionString);
        Map<String, String> configMap = new HashMap<>();
        configMap.putAll(defaultEnhancedProperties);

        assertEquals(databaseType, jdbcConnectionString.getDatabaseType());
        assertThrows(IllegalArgumentException.class, () -> jdbcConnectionStringEnhancer.enhanceProperties(configMap));
    }

    @ParameterizedTest
    @EnumSource(value = DatabaseType.class, names = { "MYSQL", "POSTGRESQL" })
    void consistentPropertiesShouldNotThrow(DatabaseType databaseType) {
        Map<String, String> defaultEnhancedProperties = databaseType.getDefaultEnhancedProperties();
        Map.Entry<String, String> randomDefaultEnhancedProperty = defaultEnhancedProperties.entrySet().iterator().next();

        String queries = randomDefaultEnhancedProperty.getKey() + "=" + randomDefaultEnhancedProperty.getValue();
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(JdbcConnectionString.resolve(connectionString));

        Map<String, String> configMap = new HashMap<>();
        configMap.put(randomDefaultEnhancedProperty.getKey(), randomDefaultEnhancedProperty.getValue());
        jdbcConnectionStringEnhancer.enhanceProperties(configMap);

        assertEquals(databaseType, jdbcConnectionStringEnhancer.getDatabaseType());
        assertNotNull(jdbcConnectionStringEnhancer.getJdbcUrl());
        assertNull(jdbcConnectionStringEnhancer.getEnhancedProperty(randomDefaultEnhancedProperty.getKey()));
        assertEquals(randomDefaultEnhancedProperty.getValue(), jdbcConnectionStringEnhancer.getOriginalProperty(randomDefaultEnhancedProperty.getKey()));
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhanceConnectionStringWithoutProperties(DatabaseType databaseType) {
        String connectionString = String.format(PATH_WITHOUT_QUERY_PATTERN, databaseType.getSchema());

        JdbcConnectionString jdbcConnectionString = JdbcConnectionString.resolve(connectionString);
        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(jdbcConnectionString);

        jdbcConnectionStringEnhancer.enhanceProperties(databaseType.getDefaultEnhancedProperties());

        String actualJdbcUrl = jdbcConnectionStringEnhancer.getJdbcUrl();
        String expectedUrl = enhanceJdbcUrl(databaseType, false, connectionString);

        Assertions.assertEquals(databaseType, jdbcConnectionString.getDatabaseType());
        Assertions.assertEquals(expectedUrl, actualJdbcUrl);
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhanceConnectionStringWithProperties(DatabaseType databaseType) {
        String queries = "someProperty=someValue";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionString jdbcConnectionString = JdbcConnectionString.resolve(connectionString);
        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(jdbcConnectionString);

        jdbcConnectionStringEnhancer.enhanceProperties(databaseType.getDefaultEnhancedProperties());

        String actualJdbcUrl = jdbcConnectionStringEnhancer.getJdbcUrl();
        String expectedUrl = enhanceJdbcUrl(databaseType, connectionString);

        Assertions.assertEquals(databaseType, jdbcConnectionString.getDatabaseType());
        Assertions.assertEquals(expectedUrl, actualJdbcUrl);
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhancePropertyWithExistingValueShouldThrowException(DatabaseType databaseType) {
        String queries = "applicationName=defaultApp";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionString jdbcConnectionString = JdbcConnectionString.resolve(connectionString);
        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(jdbcConnectionString);

        Map<String, String> enhancedProperties = new HashMap<>();
        enhancedProperties.put("applicationName", "newApp");

        Assertions.assertThrows(IllegalArgumentException.class, () -> jdbcConnectionStringEnhancer.enhanceProperties(enhancedProperties));
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhancePropertyWithExistingValueShouldBeSilent(DatabaseType databaseType) {
        String queries = "applicationName=defaultApp";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionString jdbcConnectionString = JdbcConnectionString.resolve(connectionString);
        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(jdbcConnectionString);

        Map<String, String> enhancedProperties = new HashMap<>();
        enhancedProperties.put("applicationName", "newApp");

        Assertions.assertDoesNotThrow(() -> jdbcConnectionStringEnhancer.enhanceProperties(enhancedProperties, true));
        Assertions.assertNull(jdbcConnectionStringEnhancer.getEnhancedProperty("applicationName"));
        Assertions.assertEquals("defaultApp", jdbcConnectionString.getProperty("applicationName"));
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhancePropertyWithoutExistingValueShouldSet(DatabaseType databaseType) {
        String queries = "someProperty=someValue";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(JdbcConnectionString.resolve(connectionString));

        Map<String, String> enhancedProperties = new HashMap<>();
        enhancedProperties.put("applicationName", "newApp");
        jdbcConnectionStringEnhancer.enhanceProperties(enhancedProperties);

        Assertions.assertEquals(databaseType, jdbcConnectionStringEnhancer.getDatabaseType());
        Assertions.assertEquals("newApp", jdbcConnectionStringEnhancer.getEnhancedProperty("applicationName"));
        Assertions.assertEquals(connectionString + databaseType.getQueryDelimiter() + "applicationName=newApp", jdbcConnectionStringEnhancer.getJdbcUrl());
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhanceNotExistingAttributePropertyShouldSet(DatabaseType databaseType) {
        String queries = "someProperty=someValue";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(JdbcConnectionString.resolve(connectionString));

        Map<String, String> attributes = new HashMap<>();
        attributes.put("attr1", "val1");
        attributes.put("attr2", "val2");
        jdbcConnectionStringEnhancer.enhancePropertyAttributes("attributeProperty", attributes, ",", ":");

        Assertions.assertEquals("attr1:val1,attr2:val2", jdbcConnectionStringEnhancer.getEnhancedProperty("attributeProperty"));
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhanceNotExistingAttributePropertyShouldSetByOrder(DatabaseType databaseType) {
        String queries = "someProperty=someValue";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(JdbcConnectionString.resolve(connectionString));

        Map<String, String> attributes = new HashMap<>();
        attributes.put("attr5", "val5");
        attributes.put("attr1", "val1");
        attributes.put("attr4", "val4");
        attributes.put("attr2", "val2");
        jdbcConnectionStringEnhancer.enhancePropertyAttributes("attributeProperty", attributes, ",", ":");

        Assertions.assertEquals("attr1:val1,attr2:val2,attr4:val4,attr5:val5", jdbcConnectionStringEnhancer.getEnhancedProperty("attributeProperty"));
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhanceExistingAttributePropertyShouldMerge(DatabaseType databaseType) {
        String queries = "someProperty=someValue" + databaseType.getQueryDelimiter() + "attributeProperty=attr3:val3";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(JdbcConnectionString.resolve(connectionString));

        Map<String, String> attributes = new HashMap<>();
        attributes.put("attr1", "val1");
        attributes.put("attr2", "val2");
        jdbcConnectionStringEnhancer.enhancePropertyAttributes("attributeProperty", attributes, ",", ":");

        Assertions.assertEquals("attr3:val3,attr1:val1,attr2:val2", jdbcConnectionStringEnhancer.getEnhancedProperty("attributeProperty"));
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhanceExistingAttributePropertySameAttributeDifferentValueShouldNotSet(DatabaseType databaseType) {
        String queries = "someProperty=someValue" + databaseType.getQueryDelimiter() + "attributeProperty=attr3:val3";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(JdbcConnectionString.resolve(connectionString));

        Map<String, String> attributes = new HashMap<>();
        attributes.put("attr1", "val1");
        attributes.put("attr2", "val2");
        attributes.put("attr3", "anotherVal3");
        jdbcConnectionStringEnhancer.enhancePropertyAttributes("attributeProperty", attributes, ",", ":");

        Assertions.assertEquals("attr3:val3,attr1:val1,attr2:val2", jdbcConnectionStringEnhancer.getEnhancedProperty("attributeProperty"));
    }

    @ParameterizedTest
    @EnumSource(DatabaseType.class)
    void enhanceExistingAttributePropertyEnhancedShouldOrder(DatabaseType databaseType) {
        String queries = "someProperty=someValue" + databaseType.getQueryDelimiter() + "attributeProperty=attr3:val3";
        String connectionString = String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), queries);

        JdbcConnectionStringEnhancer jdbcConnectionStringEnhancer = new JdbcConnectionStringEnhancer(JdbcConnectionString.resolve(connectionString));

        Map<String, String> attributes = new HashMap<>();
        attributes.put("attr2", "val2");
        attributes.put("attr1", "val1");
        attributes.put("attr5", "val5");
        attributes.put("attr4", "val4");
        jdbcConnectionStringEnhancer.enhancePropertyAttributes("attributeProperty", attributes, ",", ":");
        String actualJdbcUrl = jdbcConnectionStringEnhancer.getJdbcUrl();

        String expectedAttributeValue = "attr3:val3,attr1:val1,attr2:val2,attr4:val4,attr5:val5";
        Assertions.assertEquals(expectedAttributeValue, jdbcConnectionStringEnhancer.getEnhancedProperty("attributeProperty"));
        String newQueries = queries + ",attr1:val1,attr2:val2,attr4:val4,attr5:val5";
        Assertions.assertEquals(String.format(PATH_WITH_QUERY_PATTERN, databaseType.getSchema(), databaseType.getPathQueryDelimiter(), newQueries), actualJdbcUrl);
    }

}


text:
__THIS PROJECT IS NO LONGER MAINTAINED. Please seek other alternatives.__

* the project cannot be updated on npm due to camelCased title
* i no longer do Windows
* both iojs and node.js v0.12 have execSync function
* older node users can try sync-exec from npm (suggested by one of the commentors)

# execSync

Executes shell commands synchronously.

__WARNING__ For dev machine shell scripting only. **DO NOT USE** for
production servers.

## Install

__Windows__ requires Python and Visual Studio 2012 (Express) installed for
node to build. See [node-gyp installation](https://github.com/TooTallNate/node-gyp#installation).
Pre-built binaries for node v0.8 and node v0.10 are packaged. They should work and if not try manually
building.

    npm install execSync

Sometimes a manual build is necessary on Windows even with all the tools in place, replace Visual Studio version
with '2010' or '2012' based on the version installed.

    npm install node-gyp -g
    node-gyp rebuild --msvs_version=2012

## Usage

Require it

    var sh = require('execSync');

`Run` does not capture output.

    var code = sh.run('echo $USER; echo some_err 1>&2; exit 1');
    console.log('return code ' + code);

Use the less efficient `exec` if you need output. `exec` is just redirection
trickery around `run`.

    var result = sh.exec('echo $USER; echo some_err 1>&2; exit 1');
    console.log('return code ' + result.code);
    console.log('stdout + stderr ' + result.stdout);

## Notes

In *nix and OSX version commands are run via `sh -c YOUR_COMMAND`

In __Windows__ commands are run via `cmd /C YOUR_COMMAND`

## License

Copyright (c) 2012, 2013 Mario Gutierrez mario@mgutz.com

See the file LICENSE for copying permission.

redpajama_set_name: RedPajamaGithub


text:
typedef enum {
    SAPISilenceShareLoginMode = 2,
    SAPIChoiceShareLoginMode
} SAPILoginShareMode;

typedef enum {
    SAPIShareImplicitBindMode = 1,
    SAPIShareExplicitBindMode,
    SAPIShareOptionalBindMode
} SAPIShareBindMode;

// 快速登录选项
typedef enum {
    SAPILoginOptionTSina = 0,
    SAPILoginOptionTSinaSSO,
    SAPILoginOptionTQQ,
    SAPILoginOptionQzone,
    SAPILoginOptionQRCode,
    SAPILoginOptionDeviceLogin,
    SAPILoginOptionRenRen,
    SAPILoginOptionNuoMi,
    SAPILoginOptionVoicePrint,
    SAPILoginOptionWeiXinSSO,
} SAPILoginOptionType;

// 环境配置
typedef enum ESapiEnvironmentType
{
    SapiEnvironment_Online = 1,
    SapiEnvironment_RD,
    SapiEnvironment_QA
} SapiEnvironmentType;

//第3方登录相关操作返回errorcode信息
typedef enum
{
    //登录返回errorcode
    Oauth_TypeNotAvailable = 10,
    Oauth_InvalidOsuid = 17,
    Oauth_InvalidAct = 18,
    Oauth_InvalidAccessToken = 19,
    Oauth_AccessCancel = 501,
    Oauth_NoUserInfo = 502,
    Oauth_PassLoginFail = 401,
    Oauth_BindError = 901,
    Oauth_OtherError = -1,

    //帐号正常化返回errorcode
    Oauth_UserNoLogin = 119990
}TOauthErrorCode;

typedef NS_ENUM(NSInteger, SAPILoginType) {
    SAPILoginTypeDefault, // 普通登录
    SAPILoginTypeSMS, // 短信登录
};

typedef NS_ENUM(NSInteger, SAPILoginAccountType) {
    SAPILoginAccountTypeDefault = 0, // 默认情况
    SAPILoginAccountTypeMobile = 1, // 登录帐号类型为手机号码格式
    SAPILoginAccountTypeUsername = 2, // 登录帐号类型为用户名格式
};

//Service方法回调
typedef void (^SAPIRequestCompletionBlock)(NSDictionary *info);
typedef void (^SAPIRequestErrorBlock)(NSDictionary *errorInfo);

//登录相关Notification
// SAPI中相关行为所产生的Notification
//登陆成功消息 notification中的userInfo中会有登录成功后的json字典
#define kLoginSucceedNotification        @"kLoginSucceedNotification"

#define kUnsharedLoginSucceedNotification @"kUnsharedLoginSucceedNotification"

//登陆失败消息
#define kLoginFailNotification           @"kLoginFailNotification"

//注册验证成功消息 notification中的userInfo中会有注册成功后的json字典
#define kRegistVerifiedNotification      @"kRegistVerifiedNotification"

//补填用户名成功消息 notification中的userInfo中会有注册成功后的json字典
//返回json数据包含
#define kFillUnameSucceedNotification    @"kFillUnameSucceedNotification"

//第3方页面登录返回信息
#define kOauthLoginNotification          @"kOauthLoginNotification"

//帐号完整化返回信息
#define kFillAccountNotification         @"kFillAccountNotification"

//退出返回信息
#define kLogOutNotification              @"kLogOutNotification"

#endif


text:
import java.io.*;
import java.util.*;
import java.text.*;

import com.vmware.vim.*;
import com.vmware.apputils.*;
import com.vmware.apputils.vim.*;

/************************************
 * Manages VMware VMs               *
 * through the VI API               *
 ************************************/
class OneVmmVmware extends Thread
{
    private String[]     arguments;
    OperationsOverVM     oVM;
    DeployVM             dVM;

    boolean              debug;

    PrintStream          stdout;
    PrintStream          stderr;

    public static void main(String[] args)
    {
        boolean debug_flag;

        if (System.getProperty("debug").equals("1"))
        {
            debug_flag=true;
        }
        else
        {
            debug_flag=false;
        }

        OneVmmVmware omv = new OneVmmVmware(args, debug_flag);
        omv.loop();
    }

    // Constructor
    OneVmmVmware(String[] args, boolean _debug)
    {
        debug     = _debug;
        arguments = args;

        // Get out and err descriptors
        stdout    = System.out;
        stderr    = System.err;

        // No VMware library output to standard out
        // or err. This will be activated when needed
        disable_standard_output();
        disable_standard_error();
    }

    // Main loop
    void loop()
    {
        String  str     = null;
        String  action  = null;
        String  vid_str = null;
		String  hostName;
		String  fileName;
        boolean end     = false;

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        while (!end)
	    {
            action   = null;
            vid_str  = null;
            hostName = null;
            fileName = null;

            // Read a line and parse it
            try
            {
                str = in.readLine();
            }
            catch (IOException e)
            {
                String message = e.getMessage().replace('\n', ' ');

                send_message(action + " FAILURE " + vid_str + " " + message);
                send_error  (action + " FAILURE " + vid_str +
                             " Action malformed. Reason: " + message);
            }

            String str_split[] = str.split(" ", 5);

            action    = str_split[0].toUpperCase();

            // Perform the action
            if (action.equals("INIT"))
            {
                init();
            }
            else if (action.equals("FINALIZE"))
            {
                finalize_mad();
                end = true;
            }
            else
            {
                if (action.equals("DEPLOY"))
                {
                    if (str_split.length != 5)
                    {
                       send_message(action + " FAILURE " + vid_str);
                       send_error("FAILURE Wrong number of arguments for DEPLOY action. Number args = [" +
                                              str_split.length + "].");
                       continue;
                    }
                    else
                    {
                        vid_str        = str_split[1];
                        hostName       = str_split[2];
                        fileName       = str_split[3];

                        try
                        {
                            fileName = fileName.replace("/images", "");

                            // let's read the XML file and extract needed info
                            ParseXML pXML = new ParseXML(fileName);

                            // First, register the VM
                            dVM = new DeployVM(arguments,
                                                        hostName,
                                                        vid_str,
                                                        pXML,
                                                        System.getProperty("datastore"),
                                                        System.getProperty("datacenter"));

                            if(!dVM.connect())
                            {
                                throw new Exception("DeployVM: Failed connection to host " + hostName);
                            }

                            if(!dVM.registerVirtualMachine())
                            {
                                // We will skip this error, it may be pre-registered
                            }

                            // Now, proceed with the reconfiguration

                            if(!dVM.shapeVM())
                            {
                                // Will try and deregister VM
                                try
                                {
                                    oVM = new OperationsOverVM(arguments,hostName);
                                    String vmName = pXML.getName() + "-" + vid_str;
                                    oVM.deregisterVM(vmName);
                                }
                                catch(Exception e){}

                                throw new Exception("Error reconfiguring VM (" + pXML.getName() + ").");
                            }

                            dVM.disconnect();

                            try
                            {
                                oVM = new OperationsOverVM(arguments,hostName);

                                if(!oVM.connect())
                                {
                                    throw new Exception("Failed connection to host " + hostName);
                                }

                            }
                            catch(Exception e)
                            {
                                oVM.disconnect();
                                send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
                                if (!debug)
                                    send_error  (action + " FAILURE " + vid_str + " " + e.getMessage());
                                continue;
                            }

                            if(!oVM.powerOn(pXML.getName() + "-" + vid_str))
                            {
                                // Will try and deregister VM
                                try
                                {
                                    String vmName = pXML.getName() + "-" + vid_str;
                                    oVM.deregisterVM(vmName);
                                }
                                catch(Exception e)
                                {
                                    oVM.disconnect();
                                }
                                throw new Exception("Error powering on VM(" + pXML.getName() + ").");
                            }

                            send_message("DEPLOY SUCCESS " + vid_str + " " + pXML.getName() + "-" + vid_str);
                            oVM.disconnect();

                            continue;

                         }
                         catch(Exception e)
                         {
                             send_message("DEPLOY FAILURE " + vid_str + " Failed deploying VM in host " +
                                                hostName + ".");

                             if(debug)
                             {
                                 send_error("Failed deploying VM " + vid_str + " into " + hostName +
                                             ".Reason: "+ e.getMessage() +
                                             "\n---- Debug stack trace ----");
                                 enable_standard_error();
                                 e.printStackTrace();
                                 disable_standard_error();
                                 send_error("---------------------------");
                             }
                             else
                             {   // If debug activated, this will be replicated in send_message
                                 send_error("Failed deploying VM " + vid_str + " into " + hostName +
                                                  ".Reason:" + e.getMessage());
                             }
                         } // catch
           		    } // else if (str_split.length != 4)
                 } // if (action.equals("DEPLOY"))

                 if (action.equals("SHUTDOWN") || action.equals("CANCEL"))
                 {
                     if (str_split.length < 3 )
                     {
                         send_message(action + " FAILURE " + vid_str);
                         send_error("FAILURE Wrong number of arguments for " + action +
                                           " action. Number args = [" +
                                           str_split.length + "].");
                     }
                     else
                     {

                         vid_str        = str_split[1];
                         hostName       = str_split[2];
                         String vmName  = str_split[3];

                         try
                         {
                             oVM = new OperationsOverVM(arguments,hostName);
                             if(!oVM.connect())
                             {
                                 throw new Exception("Failed connection to host " + hostName);
                             }
                         }
                         catch(Exception e)
                         {
                             send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
                             if(!debug)
                                 send_error(action + " FAILURE " + vid_str + " " + e.getMessage());
                             oVM.disconnect();
                             continue;
                         }

                         if(!oVM.powerOff(vmName))
                         {
                             send_message(action + " FAILURE " + vid_str + " Failed shutdown VM in host " +
                                                    hostName);
                             oVM.disconnect();
                             continue;
                         }

                         if(!oVM.deregisterVM(vmName))
                         {
                             send_message(action + " FAILURE " + vid_str + " Failed deregistering of " +vmName
                                                    + " in host " + hostName +".");
                             oVM.disconnect();
                             continue;
                         }
                         else
                         {
                             send_message(action + " SUCCESS " + vid_str);
                         }
                      }
                      oVM.disconnect();
                      continue;
                 } // if (action.equals("SHUTDOWN or CANCEL"))

                 if (action.equals("SAVE"))
                 {
                     if (str_split.length < 5)
                     {
                        send_message(action + " FAILURE " + vid_str);
                        send_error("FAILURE Wrong number of arguments for SAVE action. Number args = [" +
                                           str_split.length + "].");
                        continue;
                     }
                     else
                     {
                         vid_str               = str_split[1];
                         hostName              = str_split[2];
                         String vmName         = str_split[3];
                         String checkpointName = str_split[4];

                         try
                         {
                             oVM = new OperationsOverVM(arguments,hostName);
                             if(!oVM.connect())
                             {
                                 throw new Exception("Failed connection to host " + hostName);
                             }
                         }
                         catch(Exception e)
                         {
                             send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
                             if(!debug)
                                send_error(action + " FAILURE " + vid_str + " " + e.getMessage());
                             oVM.disconnect();
                             continue;
                         }

                         if(!oVM.save(vmName))
                         {
                             send_message(action + " FAILURE " + vid_str + " Failed suspending VM in host " +
                                                    hostName);
                             oVM.disconnect();
                             continue;
                         }

                         if(!oVM.deregisterVM(vmName))
                         {
                             send_message(action + " FAILURE " + vid_str + " Failed deregistering of " +vmName
                                                    + " in host " + hostName +".");
                             oVM.disconnect();
                             continue;
                         }
                         else
                         {
                             send_message(action + " SUCCESS " + vid_str);
                         }
                         oVM.disconnect();
                         continue;
                      }
                 } // if (action.equals("SAVE"))

                 if (action.equals("CHECKPOINT"))
                 {
                     if (str_split.length < 4)
                     {
                        send_message(action + " FAILURE " + vid_str);
                        send_error("FAILURE Wrong number of arguments for CHECKPOINT action. Number args = [" +
                                           str_split.length + "].");
                        continue;
                     }
                     else
                     {
                         vid_str               = str_split[1];
                         hostName              = str_split[2];
                         String vmName         = str_split[3];
                         String checkpointName = str_split[4];

                         try
                         {
                             oVM = new OperationsOverVM(arguments,hostName);
                             if(!oVM.connect())
                             {
                                 throw new Exception("Failed connection to host " + hostName);
                             }
                         }
                         catch(Exception e)
                         {
                             send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
                             oVM.disconnect();
                             continue;
                         }

                         if(!oVM.createCheckpoint(vmName))
                         {
                             send_message(action + " FAILURE " + vid_str + " Failed suspending VM in host " +
                                                    hostName);
                             oVM.disconnect();
                             continue;
                         }
                         else
                         {
                             send_message(action + " SUCCESS " + vid_str);
                         }
                         oVM.disconnect();
                         continue;
                      }
                 } // if (action.equals("CHECKPOINT"))

                 if (action.equals("RESTORE"))
                 {
                     if (str_split.length < 4)
                     {
                        send_message(action + " FAILURE " + vid_str);
                        send_error("FAILURE Wrong number of arguments for RESTORE " +
                                           "action. Number args = [" + str_split.length + "].");
                        continue;
                     }
                     else
                     {
                         vid_str               = str_split[1];
                         hostName              = str_split[2];
                         String vmName         = str_split[3];
                         boolean result;

                         try
                         {
                             oVM = new OperationsOverVM(arguments,hostName);

                             dVM = new DeployVM(arguments,
                                                hostName,
                                                vmName,
                                                vid_str,
                                                System.getProperty("datastore"),
                                                System.getProperty("datacenter"));
                             if(!oVM.connect())
                             {
                                 throw new Exception("Failed connection to host " + hostName);
                             }

                             if(!dVM.connect())
                             {
                                 throw new Exception("Failed connection to host " + hostName);
                             }
                             if(!dVM.registerVirtualMachine())
                             {
                                 // We will skip this error, it may be pre-registered
                             }
                         }
                         catch(Exception e)
                         {
                             send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
                             if(!debug)
                                send_error(action + " FAILURE " + vid_str + " " + e.getMessage());
                             oVM.disconnect();
                             dVM.disconnect();
                             continue;
                         }

                         if(!oVM.restoreCheckpoint(vmName))
                         {
                             send_message(action + " FAILURE " + vid_str + " Failed restoring VM in host " +
                                                    hostName);
                             oVM.disconnect();
                             dVM.disconnect();
                             continue;
                         }
                         else
                         {
                             try
                             {
                                 if(!oVM.powerOn(vmName))
                                 {
                                      send_message(action + " FAILURE " + vid_str + " Failed restoring VM in host " +
                                                        hostName);
                                 }
                                 else
                                 {
                                     send_message(action + " SUCCESS " + vid_str);
                                     oVM.disconnect();
                                     dVM.disconnect();
                                     continue;
                                 }
                             }
                             catch(Exception e)
                             {
                                 send_message(action + " FAILURE " + vid_str + " Failed connection to host " +
                                                        hostName +". Reason: " + e.getMessage());
                                 oVM.disconnect();
                                 dVM.disconnect();
                                 continue;
                              }

                         }
                         oVM.disconnect();
                         dVM.disconnect();
                         continue;
                     }
                 } // if (action.equals("RESTORE"))

                 if (action.equals("MIGRATE"))
                 {
                     send_message(action + " FAILURE " + vid_str + " Action not implemented.");
                     if(!debug)
                        send_error(action + " FAILURE " + vid_str + " Action not implemented.");
                     continue;
                 } // if (action.equals("MIGRATE"))

                 if (action.equals("POLL"))
                 {
                     if (str_split.length < 4)
                     {
                         send_message(action + " FAILURE " + vid_str);
                         send_error("FAILURE Wrong number of arguments for POLL " +
                                            "action. Number args = [" + str_split.length + "].");
                         continue;
                     }
                     else
                     {
                         vid_str               = str_split[1];
                         hostName              = str_split[2];
                         String vmName         = str_split[3];

                         String                pollInfo;

                         try
                         {

                             String[] argsWithHost = new String[arguments.length+2];

                             for(int i=0;i<arguments.length;i++)
                             {
                                 argsWithHost[i] = arguments[i];
                             }

                             argsWithHost[arguments.length]      = "--url";
                             argsWithHost[arguments.length + 1 ] = "https://" + hostName + ":443/sdk";

                             GetProperty gPHost = new GetProperty(argsWithHost, "HostSystem", hostName);
                             GetProperty gPVM   = new GetProperty(argsWithHost, "VirtualMachine", vmName);

                             if(!gPHost.connect())
                             {
                                throw new Exception();
                             }

                             String hostCPUMhz = gPHost.getObjectProperty("summary.hardware.cpuMhz").toString();

                             gPHost.disconnect();

                             if(!gPVM.connect())
                             {
                                throw new Exception();
                             }

                             String powerState =
                                   gPVM.getObjectProperty("runtime.powerState").toString();

                            if (powerState.equals("poweredOn"))
                            {

                                 String vmCPUMhz =
                                      gPVM.getObjectProperty("summary.quickStats.overallCpuUsage").toString();

                                 String vmMEMMb  =
                                      gPVM.getObjectProperty("summary.quickStats.guestMemoryUsage").toString();

                                 gPVM.disconnect();

                                 int hostCPUMhz_i = Integer.parseInt(hostCPUMhz);
                                 int vmCPUMhz_i   = Integer.parseInt(vmCPUMhz);
                                 int vmCPUperc    = (vmCPUMhz_i / hostCPUMhz_i) * 100;

                                 pollInfo = "STATE=a USEDMEMORY=" + vmMEMMb + " USEDCPU=" + vmCPUperc;
                             }
                             else
                             {
                                 if (powerState.equals("suspended"))
                                 {
                                     pollInfo = "STATE=p";
                                 }
                                 else // Machine poweredOff
                                 {
                                     pollInfo = "STATE=d";
                                 }
                             }

                         }
                         catch(Exception e)
                         {
                             pollInfo = "STATE=-";
                         }

                         send_message(action + " SUCCESS " + vid_str + " " + pollInfo);
                         continue;
                     }
                 } // if (action.equals("POLL"))
             } //  else if (action.equals("FINALIZE"))
        } // while(!fin)
    } // loop

    void init()
    {
        // Nothing to do here
        send_message("INIT SUCCESS");
    }

    void finalize_mad()
    {
        send_message("FINALIZE SUCCESS");
    }

    void enable_standard_output()
    {
        System.setOut(stdout);
    }

    void enable_standard_error()
    {
        System.setErr(stderr);
    }

    void disable_standard_output()
    {
        try
        {
            System.setOut(new PrintStream(new FileOutputStream("/dev/null")));
        }
        catch(Exception e)
        {}
    }

    void disable_standard_error()
    {
        try
        {
            System.setErr(new PrintStream(new FileOutputStream("/dev/null")));
        }
        catch(Exception e)
        {}
    }

    void send_message(String str)
    {
        synchronized (System.out)
        {
            enable_standard_output();
            System.out.println(str);
            disable_standard_output();
        }

        if(debug){ send_error(str);}
    }

    void send_error(String str)
    {
        Date date = new Date();
        Format formatter;
        formatter = new SimpleDateFormat("[dd.MM.yyyy HH:mm:ss] ");
        synchronized (System.err)
        {
            enable_standard_error();
            System.err.println(formatter.format(date)+str);
            disable_standard_error();
        }
    }
}


text:
require 'spec_helper_integration'

describe Doorkeeper, "configuration" do
  subject { Doorkeeper.configuration }

  describe "resource_owner_authenticator" do
    it "sets the block that is accessible via authenticate_resource_owner" do
      block = proc do end
      Doorkeeper.configure do
        orm DOORKEEPER_ORM
        resource_owner_authenticator &block
      end
      expect(subject.authenticate_resource_owner).to eq(block)
    end
  end

  describe "admin_authenticator" do
    it "sets the block that is accessible via authenticate_admin" do
      block = proc do end
      Doorkeeper.configure do
        orm DOORKEEPER_ORM
        admin_authenticator &block
      end
      expect(subject.authenticate_admin).to eq(block)
    end
  end

  describe "access_token_expires_in" do
    it "has 2 hours by default" do
      expect(subject.access_token_expires_in).to eq(2.hours)
    end

    it "can change the value" do
      Doorkeeper.configure do
        orm DOORKEEPER_ORM
        access_token_expires_in 4.hours
      end
      expect(subject.access_token_expires_in).to eq(4.hours)
    end

    it "can be set to nil" do
      Doorkeeper.configure do
        orm DOORKEEPER_ORM
        access_token_expires_in nil
      end
      expect(subject.access_token_expires_in).to be_nil
    end
  end

  describe "scopes" do
    it "has default scopes" do
      Doorkeeper.configure {
        orm DOORKEEPER_ORM
        default_scopes :public
      }
      expect(subject.default_scopes).to include('public')
    end

    it 'has optional scopes' do
      Doorkeeper.configure {
        orm DOORKEEPER_ORM
        optional_scopes :write, :update
      }
      expect(subject.optional_scopes).to include('write', 'update')
    end

    it 'has all scopes' do
      Doorkeeper.configure do
        orm DOORKEEPER_ORM
        default_scopes  :normal
        optional_scopes :admin
      end
      expect(subject.scopes).to include('normal', 'admin')
    end
  end

  describe "use_refresh_token" do
    it "is false by default" do
      expect(subject.refresh_token_enabled?).to be_false
    end

    it "can change the value" do
      Doorkeeper.configure {
        orm DOORKEEPER_ORM
        use_refresh_token
      }
      expect(subject.refresh_token_enabled?).to be_true
    end
  end

  describe 'client_credentials' do
    it 'has defaults order' do
      expect(subject.client_credentials_methods).to eq([:from_basic, :from_params])
    end

    it "can change the value" do
      Doorkeeper.configure {
        orm DOORKEEPER_ORM
        client_credentials :from_digest, :from_params
      }
      expect(subject.client_credentials_methods).to eq([:from_digest, :from_params])
    end
  end

  describe 'access_token_credentials' do
    it 'has defaults order' do
      expect(subject.access_token_methods).to eq([:from_bearer_authorization, :from_access_token_param, :from_bearer_param])
    end

    it "can change the value" do
      Doorkeeper.configure {
        orm DOORKEEPER_ORM
        access_token_methods :from_access_token_param, :from_bearer_param
      }
      expect(subject.access_token_methods).to eq([:from_access_token_param, :from_bearer_param])
    end
  end

  describe "enable_application_owner" do
    it "is disabled by default" do
      expect(Doorkeeper.configuration.enable_application_owner?).not_to be_true
    end

    context "when enabled without confirmation" do
      before do
        Doorkeeper.configure do
          orm DOORKEEPER_ORM
          enable_application_owner
        end
      end
      it "adds support for application owner" do
        expect(Doorkeeper::Application.new).to respond_to :owner
      end
      it "Doorkeeper.configuration.confirm_application_owner? returns false" do
        expect(Doorkeeper.configuration.confirm_application_owner?).not_to be_true
      end
    end

    context "when enabled with confirmation set to true" do
      before do
        Doorkeeper.configure do
          orm DOORKEEPER_ORM
          enable_application_owner :confirmation => true
        end
      end
      it "adds support for application owner" do
        expect(Doorkeeper::Application.new).to respond_to :owner
      end
      it "Doorkeeper.configuration.confirm_application_owner? returns true" do
        expect(Doorkeeper.configuration.confirm_application_owner?).to be_true
      end
    end
  end

  describe "wildcard_redirect_uri" do
    it "is disabled by default" do
      Doorkeeper.configuration.wildcard_redirect_uri.should be_false
    end
  end

  describe "realm" do
    it "is \"Doorkeeper\" by default" do
      expect(Doorkeeper.configuration.realm).to eq("Doorkeeper")
    end

    it "can change the value" do
      Doorkeeper.configure {
        orm DOORKEEPER_ORM
        realm "Example"
      }
      expect(subject.realm).to eq("Example")
    end
  end

  it 'raises an exception when configuration is not set' do
    old_config = Doorkeeper.configuration
    Doorkeeper.module_eval do
      @config = nil
    end

    expect do
      Doorkeeper.configuration
    end.to raise_error Doorkeeper::MissingConfiguration

    Doorkeeper.module_eval do
      @config = old_config
    end
  end
end


text:
<!DOCTYPE HTML>

<title>ChangeLogFilter (ebean api 13.6.0 API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2022-05-03">
<meta name="description" content="declaration: module: io.ebean.api, package: io.ebean.event.changelog, interface: ChangeLogFilter">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../script-dir/jquery-ui.min.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../jquery-ui.overrides.css" title="Style">

JavaScript is disabled on your browser.

Skip navigation links

Module

Package

Class

Use

Tree

Deprecated

Index

Help

Summary:

Nested |

Field |

Constr |

Method

Detail:

Field |

Constr |

Method

SEARCH:
<input type="text" id="search-input" value="search" disabled="disabled">
<input type="reset" id="reset-button" value="reset" disabled="disabled">

Module io.ebean.api

Package io.ebean.event.changelog

Interface ChangeLogFilter

public interface ChangeLogFilter

Used to provide fine grained control over what persist requests are included in the change log.

Method Summary

<button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button>

Modifier and Type

Method

Description

boolean

includeDelete<wbr>(BeanPersistRequest<?> deleteRequest)

Return true if this delete request should be included in the change log.

boolean

includeInsert<wbr>(BeanPersistRequest<?> insertRequest)

Return true if this insert request should be included in the change log.

boolean

includeUpdate<wbr>(BeanPersistRequest<?> updateRequest)

Return true if this update request should be included in the change log.

Method Details

includeInsert

boolean includeInsert<wbr>(BeanPersistRequest<?> insertRequest)

Return true if this insert request should be included in the change log.

includeUpdate

boolean includeUpdate<wbr>(BeanPersistRequest<?> updateRequest)

Return true if this update request should be included in the change log.

includeDelete

boolean includeDelete<wbr>(BeanPersistRequest<?> deleteRequest)

Return true if this delete request should be included in the change log.

Copyright © 2022. All rights reserved.


text:
<?php

namespace Fridge\DBAL\Type;

use Fridge\DBAL\Platform\PlatformInterface;

/**
 * Text type.
 *
 * @author GeLo <geloen.eric@gmail.com>
 */
class TextType implements TypeInterface
{
    /**
     * {@inheritdoc}
     */
    public function getSQLDeclaration(PlatformInterface $platform, array $options = array())
    {
        return $platform->getClobSQLDeclaration($options);
    }

    /**
     * {@inheritdoc}
     */
    public function convertToDatabaseValue($value, PlatformInterface $platform)
    {
        return ($value === null) ? null : (string) $value;
    }

    /**
     * {@inheritdoc}
     */
    public function convertToPHPValue($value, PlatformInterface $platform)
    {
        return ($value === null) ? null : (string) $value;
    }

    /**
     * {@inheritdoc}
     */
    public function getBindingType()
    {
        return \PDO::PARAM_STR;
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return Type::TEXT;
    }
}


text:
Welcome to Angular 2 Starter

                <button md-raised-button color="primary" fxFlex routerLink="/login">Login</button>


text:
require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')

describe Twitter::Client, "#friend" do
  before(:each) do
    @twitter = client_context
    @id = 1234567
    @screen_name = 'dummylogin'
    @friend = Twitter::User.new(:id => @id, :screen_name => @screen_name)
    @uris = Twitter::Client.class_eval("@@FRIENDSHIP_URIS")
    @request = mas_net_http_post(:basic_auth => nil)
    @response = mas_net_http_response(:success)
    @connection = mas_net_http(@response)
    Net::HTTP.stub!(:new).and_return(@connection)
    Twitter::User.stub!(:unmarshal).and_return(@friend)
  end

  def create_uri(action, id)
  	"#{@uris[action]}/#{id}.json"
  end

  it "should create expected HTTP GET request for :add case using integer user ID" do
  	# the integer user ID scenario...
    @twitter.should_receive(:create_http_post_request).with(create_uri(:add, @id)).and_return(@request)
    @twitter.friend(:add, @id)
  end

  it "should create expected HTTP GET request for :add case using screen name" do
  	# the screen name scenario...
    @twitter.should_receive(:create_http_post_request).with(create_uri(:add, @screen_name)).and_return(@request)
    @twitter.friend(:add, @screen_name)
  end

	it "should create expected HTTP GET request for :add case using Twitter::User object" do
  	# the Twitter::User object scenario...
    @twitter.should_receive(:create_http_post_request).with(create_uri(:add, @friend.to_i)).and_return(@request)
    @twitter.friend(:add, @friend)
  end

  it "should create expected HTTP GET request for :remove case using integer user ID" do
  	# the integer user ID scenario...
    @twitter.should_receive(:create_http_post_request).with(create_uri(:remove, @id)).and_return(@request)
    @twitter.friend(:remove, @id)
  end

	it "should create expected HTTP GET request for :remove case using screen name" do
  	# the screen name scenario...
    @twitter.should_receive(:create_http_post_request).with(create_uri(:remove, @screen_name)).and_return(@request)
    @twitter.friend(:remove, @screen_name)
  end

  it "should create expected HTTP GET request for :remove case using Twitter::User object" do
  	# the Twitter::User object scenario...
    @twitter.should_receive(:create_http_post_request).with(create_uri(:remove, @friend.to_i)).and_return(@request)
    @twitter.friend(:remove, @friend)
  end

  it "should bless user model returned for :add case" do
    @twitter.should_receive(:bless_model).with(@friend)
    @twitter.friend(:add, @friend)
  end

  it "should bless user model returned for :remove case" do
    @twitter.should_receive(:bless_model).with(@friend)
    @twitter.friend(:remove, @friend)
  end

  it "should raise ArgumentError if action given is not valid" do
    lambda {
      @twitter.friend(:crap, @friend)
    }.should raise_error(ArgumentError)
  end

  after(:each) do
    nilize(@twitter, @id, @uris, @request, @response, @connection)
  end
end


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

namespace DomainModel.Repository
{
    interface IBookingRepository
    {
        void AddBooking(Room room, DateTime CheckIn, DateTime CheckOut);
    }
}


text:
@interface CMSSpeakerAvatar : NSManagedObject

@property (nonatomic, strong) NSData *imageData;
@property (nonatomic, strong) UIImage *image;

+ (NSString *)entityName;
+ (instancetype)insertInContext:(NSManagedObjectContext *)context;

@end


text:
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using Kirkin.Threading;

using NUnit.Framework;

namespace Kirkin.Tests.Threading
{
    public class AsyncLockTests
    {
        [Test]
        public void MutexTests()
        {
            AsyncLock l = new AsyncLock();
            int badInt = int.MaxValue - 1;
            Task[] tasks = new Task[10];

            for (int i = 0; i < tasks.Length; i++)
            {
                tasks[i] = Task.Run(async () =>
                {
                    using (AsyncLockReleaser releaser = await l.EnterAsync().ConfigureAwait(false))
                    {
                        checked
                        {
                            badInt++;
                            Thread.Sleep(100);
                            badInt--;
                        }
                    }
                });
            }

            Task.WaitAll(tasks);

            Assert.AreEqual(int.MaxValue - 1, badInt);
        }

        [Test]
        public void SequentialCompletionTests()
        {
            AsyncLock l = new AsyncLock();
            Task[] tasks = new Task[10];
            List<int> ints = new List<int>();

            for (int i = 0; i < tasks.Length; i++)
            {
                int _i = i;
                Task<AsyncLockReleaser> releaserTask = l.EnterAsync();

                tasks[i] = Task.Run(async () =>
                {
                    using (AsyncLockReleaser releaser = await releaserTask.ConfigureAwait(false))
                    {
                        Thread.Sleep(100);
                        ints.Add(_i);
                    }
                });
            }

            Task.WaitAll(tasks);

            Assert.True(ints.SequenceEqual(ints.OrderBy(i => i)));
        }
    }
}


text:
/*
 * ARIA Menu Button example
 * @function onload
 * @desc
 */

window.addEventListener('load', function() {

  var menuButtons = document.querySelectorAll('[aria-haspopup][aria-controls]');

  [].forEach.call(menuButtons, function (menuButton) {
      if (menuButton &&
          (menuButton.tagName.toLowerCase() === 'button') || (menuButton.getAttribute('role').toLowerCase() === 'button')) {
      var mb = new aria.widget.MenuButton(menuButton);
      mb.initMenuButton();
    }
  });
});

/**
 * @namespace aria
 */

  var aria = aria || {};

/* ---------------------------------------------------------------- */
/*                  ARIA Utils Namespace                        */
/* ---------------------------------------------------------------- */

/**
 * @constructor Menu
 *
 * @memberOf aria.Utils

 * @desc  Computes absolute position of an element
 *
 * @param  element    DOM node  -  DOM node object
 *
 * @retruns  Object  Object contains left and top position
 */

aria.Utils = aria.Utils || {};

aria.Utils.findPos = function(element) {
    var xPosition = 0;
    var yPosition = 0;

    while(element) {
        xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
        yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
        element = element.offsetParent;
    }
    return { x: xPosition, y: yPosition };
};

/* ---------------------------------------------------------------- */
/*                  ARIA Widget Namespace                           */
/* ---------------------------------------------------------------- */

aria.widget = aria.widget || {};

/* ---------------------------------------------------------------- */
/*                  Menu Object                                     */
/* ---------------------------------------------------------------- */

/**
 * @constructor Menu
 *
 * @memberOf aria.widget
 *
 * @desc  Creates a Menu Button widget using ARIA
 *
 * @param  node    DOM node  -  DOM node object
 *
 * @property  keyCode      Object    -  Object containing the keyCodes used by the slider widget
 *
 * @property  node               Object    -  JQuery node object
 */

aria.widget.Menu = function(node, menuButton) {

   this.keyCode = Object.freeze({
     "TAB"      : 9,
     "RETURN"   : 13,
     "ESC"    : 27,
     "SPACE"    : 32,
     "PAGEUP"    : 33,
     "PAGEDOWN" : 34,
     "END"      : 35,
     "HOME"     : 36,
     "LEFT"  : 37,
     "UP"    : 38,
     "RIGHT" : 39,
     "DOWN"  : 40
  });

  // Check fo DOM element node
  if (typeof node !== 'object' || !node.getElementsByClassName) return false;

  this.menuNode   = node;
  node.tabIndex = -1;

  this.menuButton = menuButton;

  this.firstMenuItem = false;
  this.lastMenuItem = false;

};

/**
 * @method initMenu
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  Creates the HTML for the slider
 */

aria.widget.Menu.prototype.initMenu = function() {

    var menu = this;

    var cn = this.menuNode.firstChild;

    while (cn) {
      if (cn.nodeType === Node.ELEMENT_NODE) {
        if (cn.getAttribute('role')  === 'menuitem') {
          cn.tabIndex = -1;
          if (!this.firstMenuItem) this.firstMenuItem = cn;
          this.lastMenuItem = cn;

          var eventKeyDown = function (event) {
            menu.eventKeyDown(event, menu);
          };
          cn.addEventListener('keydown', eventKeyDown);

          var eventMouseClick = function (event) {
            menu.eventMouseClick(event, menu);
          };
          cn.addEventListener('click', eventMouseClick);

          var eventBlur = function (event) {
            menu.eventBlur(event, menu);
          };
          cn.addEventListener('blur', eventBlur);

          var eventFocus = function (event) {
            menu.eventFocus(event, menu);
          };
          cn.addEventListener('focus', eventFocus);

        }
      }
      cn = cn.nextSibling;
    }
};

/**
 * @method nextMenuItem
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  Moves focus to next menuItem
 */

aria.widget.Menu.prototype.nextMenuItem = function(currentMenuItem) {

  var mi = currentMenuItem.nextSibling;

  while (mi) {
    if ((mi.nodeType === Node.ELEMENT_NODE) &&
      (mi.getAttribute('role')  === 'menuitem')) {
      mi.focus();
      break;
    }
    mi = mi.nextSibling;
  }

  if (!mi && this.firstMenuItem) {
    this.firstMenuItem.focus();
  }
};

/**
 * @method previousMenuItem
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  Moves focus to next menuItem
 */

aria.widget.Menu.prototype.previousMenuItem = function(currentMenuItem) {

  var mi = currentMenuItem.previousSibling;

  while (mi) {
    if (mi.nodeType === Node.ELEMENT_NODE && mi.getAttribute('role')  === 'menuitem') {
      mi.focus();
      break;
    }
    mi = mi.previousSibling;
  }

  if (!mi && this.lastMenuItem) {
    this.lastMenuItem.focus();
  }
};

/**
 * @method eventKeyDown
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  Keydown event handler for Menu Object
 *        NOTE: The menu parameter is needed to provide a reference to the specific
 *               menu
 */

aria.widget.Menu.prototype.eventKeyDown = function(event, menu) {

  var ct = event.currentTarget;
  var flag = false;

  switch(event.keyCode) {

  case menu.keyCode.SPACE:
  case menu.keyCode.RETURN:
      var click_event = new MouseEvent('click', {
        'view': window,
        'bubbles': true,
        'cancelable': true
      });
      ct.dispatchEvent(click_event);
    menu.menuButton.closeMenu(true);
    flag = true;
    break;

  case menu.keyCode.ESC:
    menu.menuButton.closeMenu(true);
    menu.menuButton.buttonNode.focus();
    flag = true;
    break;

  case menu.keyCode.UP:
  case menu.keyCode.LEFT:
    menu.previousMenuItem(ct);
    flag = true;
    break;

  case menu.keyCode.DOWN:
  case menu.keyCode.RIGHT:
    menu.nextMenuItem(ct);
    flag = true;
    break;

  case menu.keyCode.TAB:
    menu.menuButton.closeMenu(true, false);
    break;

  default:
    break;
  }

  if (flag) {
    event.stopPropagation();
    event.preventDefault();
  }

};

/**
 * @method eventMouseClick
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  onclick event handler for Menu Object
 *        NOTE: The menu parameter is needed to provide a reference to the specific
 *               menu
 */

aria.widget.Menu.prototype.eventMouseClick = function(event, menu) {

  menu.menuButton.closeMenu(true);

};

/**
 * @method eventMouseOver
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  Mouse over event handler for Menu Object
 *        NOTE: The menu parameter is needed to provide a reference to the specific
 *               menu
 */

aria.widget.Menu.prototype.eventMouseOver = function(event, menu) {

  menu.mouseInMenu = true;
  menu.menuButton.openMenu();

};

/**
 * @method eventMouseOut
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  eventMouseOut event handler for Menu Object
 *        NOTE: The menu parameter is needed to provide a reference to the specific
 *               menu
 */
aria.widget.Menu.prototype.eventMouseOut = function(event, menu) {

  menu.mouseInMenu = false;
  setTimeout(function(){ menu.menuButton.closeMenu() }, 500);

};

/**
 * @method eventBlur
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  eventBlur event handler for Menu Object
 *        NOTE: The menu parameter is needed to provide a reference to the specific
 *               menu
 */
aria.widget.Menu.prototype.eventBlur = function(event, menu) {
  menu.menuHasFocus = false;
  setTimeout(function(){ menu.menuButton.closeMenu(false, false) }, 500);
};

/**
 * @method eventFocus
 *
 * @memberOf aria.widget.Menu
 *
 * @desc  eventBlur event handler for Menu Object
 *        NOTE: The menu parameter is needed to provide a reference to the specific
 *               menu
 */
aria.widget.Menu.prototype.eventFocus = function(event, menu) {
  menu.menuHasFocus = true;
};

/* ---------------------------------------------------------------- */
/*                  Menu Button Widget                           */
/* ---------------------------------------------------------------- */

/**
 * @constructor Menu Button
 *
 * @memberOf aria.Widget
 *
 * @desc  Creates a Menu Button widget using ARIA
 *
 * @param  node    DOM node  -  DOM node object
 *
 * @property  keyCode      Object    -  Object containing the keyCodes used by the slider widget
 *
 * @property  node               Object    -  JQuery node object
 * @property  mouseInMenuButton  Boolean   - Flag indicating the mouse is in menu button, so menu should stay open
 * @property  mouseInMenu        Boolean   - Flag indicating the mouse is in menu, so menu should stay open
 */

aria.widget.MenuButton = function(node) {

  this.keyCode = Object.freeze({
     "TAB"    : 9,
     "RETURN" : 13,
     "ESC"    : 27,
     "SPACE"  : 32,
     "UP"    : 38,
     "DOWN"  : 40
  });

  // Check fo DOM element node
  if (typeof node !== 'object' || !node.getElementsByClassName) return false;

  this.done = true;
  this.mouseInMouseButton = false;
  this.menuHasFocus = false;
  this.buttonNode = node;
  this.isLink = false;

  if (node.tagName.toLowerCase() === 'a') {
    var url = node.getAttribute('href');
    if (url && url.length && (url.length > 0)) {
      this.isLink = true;
    }
  }

};

/**
 * @method initMenuButton
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Adds event handlers to button element
 */

aria.widget.MenuButton.prototype.initMenuButton = function() {

  var id = this.buttonNode.getAttribute('aria-controls');

  if (id) {
    this.menuNode = document.getElementById(id);

    if (this.menuNode) {
      this.menu = new aria.widget.Menu(this.menuNode, this);
        this.menu.initMenu();
    }
  }

  this.closeMenu();

    var menuButton = this;

    var eventKeyDown = function (event) {
      menuButton.eventKeyDown(event, menuButton);
    };
    this.buttonNode.addEventListener('keydown',   eventKeyDown);

   var eventMouseClick = function (event) {
      menuButton.eventMouseClick(event, menuButton);
    };
    this.buttonNode.addEventListener('click', eventMouseClick);

};

/**
 * @method openMenu
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Opens the menu
 */

aria.widget.MenuButton.prototype.openMenu = function() {

  if (this.menuNode) {
    var pos = aria.Utils.findPos(this.buttonNode);
    var br = this.buttonNode.getBoundingClientRect();

    this.menuNode.style.display = 'block';
    this.menuNode.style.position = 'absolute';
    this.menuNode.style.top  = (pos.y + br.height) + "px";
    this.menuNode.style.left = pos.x + "px"; ;
  }
};

/**
 * @method closeMenu
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Close the menu
 */

aria.widget.MenuButton.prototype.closeMenu = function(force, focus_menu_button) {

  if (typeof force !== 'boolean') force = false;
  if (typeof focus_menu_button !== 'boolean') focus_menu_button = true;

  if (force || (!this.mouseInMenuButton &&
    !this.menu.mouseInMenu &&
    !this.menu.menuHasFocus &&
    this.menuNode)) {
      this.menuNode.style.display = 'none';
      if (focus_menu_button) this.buttonNode.focus();
  }

};

/**
 * @method toggleMenu
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Close or open the menu depending on current state
 */

aria.widget.MenuButton.prototype.toggleMenu = function() {

  if (this.menuNode) {
    if (this.menuNode.style.display === 'block') this.menuNode.style.display = 'none';
    else this.menuNode.style.display = 'block';
  }

};

/**
 * @method moveFocusToFirstMenuItem
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Move keyboard focus to first menu item
 */

aria.widget.MenuButton.prototype.moveFocusToFirstMenuItem = function() {

  if (this.menu.firstMenuItem) {
    this.openMenu();
    this.menu.firstMenuItem.focus();
  }

};

/**
 * @method moveFocusToLastMenuItem
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Move keyboard focus to first menu item
 */

aria.widget.MenuButton.prototype.moveFocusToLastMenuItem = function() {

  if (this.menu.lastMenuItem) {
    this.openMenu();
    this.menu.lastMenuItem.focus();
  }

};

/**
 * @method eventKeyDown
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Keydown event handler for MenuButton Object
 *        NOTE: The menuButton parameter is needed to provide a reference to the specific
 *               menuButton
 */

aria.widget.MenuButton.prototype.eventKeyDown = function(event, menuButton) {

  var flag = false;

  switch(event.keyCode) {

  case menuButton.keyCode.SPACE:
    menuButton.moveFocusToFirstMenuItem();
    flag = true;
    break;

  case menuButton.keyCode.RETURN:
    menuButton.moveFocusToFirstMenuItem();
      flag = true;
    break;

  case menuButton.keyCode.UP:
    menuButton.moveFocusToLastMenuItem();
    flag = true;
    break;

  case menuButton.keyCode.DOWN:
    menuButton.moveFocusToFirstMenuItem();
    flag = true;
    break;

  case menuButton.keyCode.TAB:
    menuButton.closeMenu(true, false);
    break;

  default:
      break;
    }

  if (flag) {
    event.stopPropagation();
    event.preventDefault();
  }

};

/**
 * @method eventMouseClick
 *
 * @memberOf aria.widget.MenuButton
 *
 * @desc  Click event handler for MenuButton Object
 *        NOTE: The menuButton parameter is needed to provide a reference to the specific
 *               menuButton
 */
aria.widget.MenuButton.prototype.eventMouseClick= function(event, menuButton) {
 menuButton.moveFocusToFirstMenuItem();
};


text:
from msrest.serialization import Model

class FirstParameterGroup(Model):
    """
    Additional parameters for the postMultipleParameterGroups operation.
    """

    _required = []

    def __init__(self, *args, **kwargs):
        """FirstParameterGroup

        :param str header_one
        :param int query_one: Query parameter with default. Default value: 30 .
        """
        self.header_one = None
        self.query_one = None

        super(FirstParameterGroup, self).__init__(*args, **kwargs)


text:
package org.jaxen.expr;

/**
 * Represents the XPath node-test text().
 *
 */
public interface TextNodeStep extends Step
{
}


text:
require "test_helper"

class PdfDeliveryTest < ActionDispatch::IntegrationTest

  test "pdf requests is send a pdf file" do
    get home_path(format: :pdf)

    assert_match "PDF", response.body
    assert_match "binary", headers["Content-Transfer-Encoding"]

    assert_equal "attachment; filename=\"contents.pdf\"", headers["Content-Disposition"]
    assert_equal "application/pdf", headers["Content-Type"]
  end

  test "pdf renderes a required template" do
    get templated_path(format: :pdf)

    assert_match "PDF", response.body
    assert_match "binary", headers["Content-Transfer-Encoding"]

    assert_equal "attachment; filename=\"contents.pdf\"", headers["Content-Disposition"]
    assert_equal "application/pdf", headers["Content-Type"]
  end
end


text:
#include "post_auction_runner.h"
#include "post_auction_service.h"
#include "rtbkit/core/banker/slave_banker.h"
#include "soa/service/service_utils.h"
#include "soa/service/process_stats.h"
#include "soa/utils/print_utils.h"
#include "jml/utils/file_functions.h"

#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>

using namespace std;
using namespace boost::program_options;
using namespace Datacratic;
using namespace RTBKIT;

static Json::Value loadJsonFromFile(const std::string & filename)
{
    ML::File_Read_Buffer buf(filename);
    return Json::parse(std::string(buf.start(), buf.end()));
}

/************************************************************************/
/* POST AUCTION LOOP RUNNER                                             */
/************************************************************************/
PostAuctionRunner::
PostAuctionRunner() :
    shard(0),
    auctionTimeout(EventMatcher::DefaultAuctionTimeout),
    winTimeout(EventMatcher::DefaultWinTimeout),
    bidderConfigurationFile("rtbkit/examples/bidder-config.json"),
    winLossPipeTimeout(PostAuctionService::DefaultWinLossPipeTimeout),
    campaignEventPipeTimeout(PostAuctionService::DefaultCampaignEventPipeTimeout),
    useHttpBanker(false)
{
}

void
PostAuctionRunner::
doOptions(int argc, char ** argv,
        const boost::program_options::options_description & opts)
{
    using namespace boost::program_options;

    options_description postAuctionLoop_options("Post Auction Loop options");
    postAuctionLoop_options.add_options()
        ("bidder,b", value<string>(&bidderConfigurationFile),
         "configuration file with bidder interface data")
        ("use-http-banker", bool_switch(&useHttpBanker),
         "Communicate with the MasterBanker over http")
        ("shard,s", value<size_t>(&shard),
         "Shard index starting at 0 for this post auction loop")
        ("win-seconds", value<float>(&winTimeout),
         "Timeout for storing win auction")
        ("auction-seconds", value<float>(&auctionTimeout),
         "Timeout to get late win auction")
        ("winlossPipe-seconds", value<int>(&winLossPipeTimeout),
         "Timeout before sending error on WinLoss pipe")
        ("campaignEventPipe-seconds", value<int>(&campaignEventPipeTimeout),
         "Timeout before sending error on CampaignEvent pipe");

    options_description all_opt = opts;
    all_opt
        .add(serviceArgs.makeProgramOptions())
        .add(postAuctionLoop_options);

    all_opt.add_options()
        ("help,h","print this message");

    variables_map vm;
    store(command_line_parser(argc, argv)
            .options(all_opt)
            .run(),
            vm);
    notify(vm);

    if (vm.count("help")) {
        cerr << all_opt << endl;
        exit(1);
    }
}

void
PostAuctionRunner::
init()
{
    auto proxies = serviceArgs.makeServiceProxies();
    auto serviceName = serviceArgs.serviceName("PostAuctionLoop");

    auto bidderConfig = loadJsonFromFile(bidderConfigurationFile);

    postAuctionLoop = std::make_shared<PostAuctionService>(proxies, serviceName);
    postAuctionLoop->initBidderInterface(bidderConfig);
    postAuctionLoop->init(shard);

    postAuctionLoop->setWinTimeout(winTimeout);
    postAuctionLoop->setAuctionTimeout(auctionTimeout);
    postAuctionLoop->setWinLossPipeTimeout(winLossPipeTimeout);
    postAuctionLoop->setCampaignEventPipeTimeout(campaignEventPipeTimeout);

    LOG(PostAuctionService::print) << "win timeout is " << winTimeout << std::endl;
    LOG(PostAuctionService::print) << "auction timeout is " << auctionTimeout << std::endl;
    LOG(PostAuctionService::print) << "winLoss pipe timeout is " << winLossPipeTimeout << std::endl;
    LOG(PostAuctionService::print) << "campaignEvent pipe timeout is " << campaignEventPipeTimeout << std::endl;

    banker = std::make_shared<SlaveBanker>(postAuctionLoop->serviceName() + ".slaveBanker");
    std::shared_ptr<ApplicationLayer> layer;
    if (useHttpBanker) {
        auto bankerUri = proxies->bankerUri;
        ExcCheck(!bankerUri.empty(),
                "the banker-uri must be specified in the bootstrap.json");
        LOG(PostAuctionService::print) << "using http interface for the MasterBanker" << std::endl;
        layer = make_application_layer<HttpLayer>(bankerUri);
    }
    else {
        layer = make_application_layer<ZmqLayer>(proxies);
        LOG(PostAuctionService::print) << "using zmq interface for the MasterBanker" << std::endl;
    }
    banker->setApplicationLayer(layer);

    postAuctionLoop->addSource("slave-banker", *banker);
    postAuctionLoop->setBanker(banker);
    postAuctionLoop->bindTcp();

}

void
PostAuctionRunner::
start()
{
    postAuctionLoop->start();
}

void
PostAuctionRunner::
shutdown()
{
    postAuctionLoop->shutdown();
    banker->shutdown();
}

PostAuctionService::Stats
report( const PostAuctionService& service,
        double delta,
        const PostAuctionService::Stats& last = PostAuctionService::Stats())
{
    auto current = service.stats;

    auto diff = current;
    diff -= last;

    double bidsThroughput = diff.auctions / delta;
    double eventsThroughput = diff.events / delta;
    double winsThroughput = diff.matchedWins / delta;
    double lossThroughput = diff.matchedLosses / delta;

    std::stringstream ss;
    ss << std::endl
        << printValue(bidsThroughput) << " bids/sec\n"
        << printValue(eventsThroughput) << " events/sec\n"
        << printValue(winsThroughput) << " wins/sec\n"
        << printValue(lossThroughput) << " loss/sec\n"
        << printValue(current.unmatchedEvents) << " unmatched\n"
        << printValue(current.errors) << " errors\n";
    LOG(PostAuctionService::print) << ss.str();

    return current;
}

void setMemoryLimit()
{
    rlimit64 currentLimit;
    int status = getrlimit64(RLIMIT_AS, &currentLimit);
    if(status != 0)
        throw ML::Exception("Failed to get the current system limits");

    currentLimit.rlim_cur = 1UL << 36;// 64G
    if(setrlimit64(RLIMIT_AS, &currentLimit) != 0)
        throw ML::Exception("Failed to set the current system limits to 512G");
}

int main(int argc, char ** argv)
{
    setMemoryLimit();

    PostAuctionRunner runner;

    runner.doOptions(argc, argv);
    runner.init();
    runner.start();

    auto stats = report(*runner.postAuctionLoop, 0.1);
    ProcessStats lastStats;

    auto onStat = [&] (std::string key, double val) {
        runner.postAuctionLoop->recordStableLevel(val, key);
    };

    for (size_t i = 0;; ++i) {
        ML::sleep(1.0);

        ProcessStats curStats;
        ProcessStats::logToCallback(onStat, lastStats, curStats, "process");
        lastStats = curStats;

        if (i % 10 == 0)
            stats = report(*runner.postAuctionLoop, 10.0, stats);
    }

}