text:
//////////////////////////////////////////////////////////////////////////////
// CONSTANTS AND DATA TYPES
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// LOCAL FUNCTION PROTOTYPES
//////////////////////////////////////////////////////////////////////////////
static void test_create_destroy(CuTest* tc);
static void test_connectors_connect_disconnect_node_with_only_require_ports(CuTest* tc);
static void test_connectors_connect_disconnect_node_with_only_provide_ports(CuTest* tc);
static void test_connectors_node_with_require_port_is_connected_after_node_with_provide_port(CuTest* tc);
static void test_connectors_node_with_provide_port_is_connected_when_multiple_nodes_with_require_ports_are_waiting(CuTest* tc);

//////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
// LOCAL VARIABLES
//////////////////////////////////////////////////////////////////////////////
static const char* m_provider1_definition = "APX/1.2\n"
"N\"Provider1\"\n"
"P\"VehicleSpeed\"S:=65535\n"
"\n";

static const char* m_requester1_definition = "APX/1.2\n"
"N\"Requester1\"\n"
"R\"VehicleSpeed\"S:=65535\n"
"\n";

static const char* m_requester2_definition = "APX/1.2\n"
"N\"Requester2\"\n"
"R\"EngineSpeed\"S:=65535\n"
"R\"VehicleSpeed\"S:=65535\n"
"\n";

//////////////////////////////////////////////////////////////////////////////
// GLOBAL FUNCTIONS
//////////////////////////////////////////////////////////////////////////////

CuSuite* testSuite_apx_server(void)
{
   CuSuite* suite = CuSuiteNew();

   SUITE_ADD_TEST(suite, test_create_destroy);
   SUITE_ADD_TEST(suite, test_connectors_connect_disconnect_node_with_only_require_ports);
   SUITE_ADD_TEST(suite, test_connectors_connect_disconnect_node_with_only_provide_ports);
   SUITE_ADD_TEST(suite, test_connectors_node_with_require_port_is_connected_after_node_with_provide_port);
   SUITE_ADD_TEST(suite, test_connectors_node_with_provide_port_is_connected_when_multiple_nodes_with_require_ports_are_waiting);

   return suite;
}

//////////////////////////////////////////////////////////////////////////////
// LOCAL FUNCTIONS
//////////////////////////////////////////////////////////////////////////////
static void test_create_destroy(CuTest* tc)
{
   apx_server_t* server;
   server = apx_server_new();
   CuAssertPtrNotNull(tc, server);
   apx_server_delete(server);
}

static void test_connectors_connect_disconnect_node_with_only_require_ports(CuTest* tc)
{
   apx_server_t* server;
   apx_serverTestConnection_t* connection;
   adt_bytearray_t* packet = NULL;
   apx_nodeManager_t* node_manager;
   apx_portSignatureMap_t *port_signature_map = NULL;
   int const acknowledge_size = 9;
   int const open_request_size = 13;
   int const file_info_publish_size = 66;
   int const data_write_size = 4;
   char const* apx_text =
      "APX/1.2\n"
      "N\"TestNode1\"\n"
      "R\"BreakAlertStatus\"C(0,3):=3\n";

   apx_size_t const definition_size = (apx_size_t)strlen(apx_text);
   server = apx_server_new();
   CuAssertPtrNotNull(tc, server);
   port_signature_map = apx_server_get_port_signature_map(server);
   CuAssertPtrNotNull(tc, port_signature_map);
   connection = apx_serverTestConnection_new();
   CuAssertPtrNotNull(tc, connection);
   apx_server_accept_connection(server, (apx_serverConnection_t*)connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertUIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_send_greeting_header(connection));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(connection));
   packet = apx_serverTestConnection_get_log_packet(connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, acknowledge_size, adt_bytearray_length(packet)); //This is the acknowledge message
   apx_serverTestConnection_clear_log(connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(connection, APX_DEFINITION_ADDRESS_START, "TestNode1.apx", definition_size));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(connection));
   packet = apx_serverTestConnection_get_log_packet(connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message
   apx_serverTestConnection_clear_log(connection);
   node_manager = apx_serverTestConnection_get_node_manager(connection);
   CuAssertPtrNotNull(tc, node_manager);
   apx_nodeInstance_t* node_instance = apx_nodeManager_find(node_manager, "TestNode1");
   apx_nodeData_t const* node_data = apx_nodeInstance_get_const_node_data(node_instance);
   CuAssertPtrNotNull(tc, node_data);
   CuAssertUIntEquals(tc, definition_size, apx_nodeData_definition_data_size(node_data));
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_definition_data_state(node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(connection, APX_DEFINITION_ADDRESS_START, (uint8_t const*)apx_text, definition_size));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_definition_data_state(node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(connection));
   packet = apx_serverTestConnection_get_log_packet(connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, file_info_publish_size, adt_bytearray_length(packet)); //Should be a file info struct
   apx_serverTestConnection_clear_log(connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_OPEN_REQUEST, apx_nodeInstance_get_require_port_data_state(node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_request_open_local_file(connection, "TestNode1.in"));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, 1, apx_portSignatureMap_length(port_signature_map));
   apx_portSignatureMapEntry_t* map_entry = apx_portSignatureMap_find(port_signature_map, "\"BreakAlertStatus\"C(0,3)");
   CuAssertPtrNotNull(tc, map_entry);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_require_port_data_state(node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(connection));
   packet = apx_serverTestConnection_get_log_packet(connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, data_write_size, adt_bytearray_length(packet)); //port data
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_server_detach_connection(server, (apx_serverConnection_t*)connection));
   CuAssertIntEquals(tc, 0, apx_portSignatureMap_length(port_signature_map));
   apx_server_delete(server);
}

static void test_connectors_connect_disconnect_node_with_only_provide_ports(CuTest* tc)
{
   apx_server_t* server;
   apx_serverTestConnection_t* connection;
   adt_bytearray_t* packet = NULL;
   apx_nodeManager_t* node_manager;
   apx_portSignatureMap_t* port_signature_map = NULL;
   int const provide_port_data_size = 1;
   int const acknowledge_size = 9;
   int const open_request_size = 13;
   uint8_t provide_port_data[1] = { 0u };
   char const* apx_text =
      "APX/1.2\n"
      "N\"TestNode1\"\n"
      "P\"BreakAlertStatus\"C(0,3):=3\n";

   apx_size_t const definition_size = (apx_size_t)strlen(apx_text);
   server = apx_server_new();
   CuAssertPtrNotNull(tc, server);
   port_signature_map = apx_server_get_port_signature_map(server);
   CuAssertPtrNotNull(tc, port_signature_map);
   connection = apx_serverTestConnection_new();
   CuAssertPtrNotNull(tc, connection);
   apx_server_accept_connection(server, (apx_serverConnection_t*)connection);
   port_signature_map = apx_server_get_port_signature_map(server);
   CuAssertPtrNotNull(tc, port_signature_map);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertUIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_send_greeting_header(connection));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(connection));
   packet = apx_serverTestConnection_get_log_packet(connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, acknowledge_size, adt_bytearray_length(packet)); //This is the acknowledge message
   apx_serverTestConnection_clear_log(connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(connection, APX_PORT_DATA_ADDRESS_START, "TestNode1.out", provide_port_data_size));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(connection, APX_DEFINITION_ADDRESS_START, "TestNode1.apx", definition_size));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(connection));
   packet = apx_serverTestConnection_get_log_packet(connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message (TestNode1.apx)
   apx_serverTestConnection_clear_log(connection);
   node_manager = apx_serverTestConnection_get_node_manager(connection);
   CuAssertPtrNotNull(tc, node_manager);
   apx_nodeInstance_t* node_instance = apx_nodeManager_find(node_manager, "TestNode1");
   apx_nodeData_t const* node_data = apx_nodeInstance_get_const_node_data(node_instance);
   CuAssertPtrNotNull(tc, node_data);
   CuAssertUIntEquals(tc, definition_size, apx_nodeData_definition_data_size(node_data));
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_definition_data_state(node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(connection, APX_DEFINITION_ADDRESS_START, (uint8_t const*)apx_text, definition_size));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_definition_data_state(node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(connection));
   packet = apx_serverTestConnection_get_log_packet(connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message (TestNode1.out)
   apx_serverTestConnection_clear_log(connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_provide_port_data_state(node_instance));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(connection, APX_PORT_DATA_ADDRESS_START, provide_port_data, provide_port_data_size));
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_provide_port_data_state(node_instance));
   apx_serverTestConnection_run(connection);
   CuAssertIntEquals(tc, 1, apx_portSignatureMap_length(port_signature_map));
   apx_portSignatureMapEntry_t* map_entry = apx_portSignatureMap_find(port_signature_map, "\"BreakAlertStatus\"C(0,3)");
   CuAssertPtrNotNull(tc, map_entry);
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_server_detach_connection(server, (apx_serverConnection_t*)connection));
   CuAssertIntEquals(tc, 0, apx_portSignatureMap_length(port_signature_map));
   apx_server_delete(server);
}

static void test_connectors_node_with_require_port_is_connected_after_node_with_provide_port(CuTest* tc)
{
   apx_server_t* server;
   apx_serverTestConnection_t* provider_connection = NULL;
   apx_serverTestConnection_t* requester_connection = NULL;
   adt_bytearray_t* packet = NULL;
   apx_nodeManager_t* node_manager;
   apx_portSignatureMap_t* port_signature_map = NULL;
   int const provide_port_data_size = UINT16_SIZE;
   int const acknowledge_size = 9;
   int const open_request_size = 13;
   int const file_info_publish_size = 67;
   int const requester1_data_size = 5;
   uint8_t provide_port_data[UINT16_SIZE] = { 0x34u, 0x12u };
   uint8_t data_message[5];
   apx_size_t const provider_definition_size = (apx_size_t)strlen(m_provider1_definition);
   apx_size_t const requester_definition_size = (apx_size_t)strlen(m_requester1_definition);

   memset(data_message, 0, sizeof(data_message));
   server = apx_server_new();
   CuAssertPtrNotNull(tc, server);
   port_signature_map = apx_server_get_port_signature_map(server);
   CuAssertPtrNotNull(tc, port_signature_map);
   provider_connection = apx_serverTestConnection_new();
   CuAssertPtrNotNull(tc, provider_connection);
   apx_server_accept_connection(server, (apx_serverConnection_t*)provider_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertUIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_send_greeting_header(provider_connection));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(provider_connection));
   packet = apx_serverTestConnection_get_log_packet(provider_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, acknowledge_size, adt_bytearray_length(packet)); //This is the acknowledge message
   apx_serverTestConnection_clear_log(provider_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(provider_connection, APX_PORT_DATA_ADDRESS_START, "Provider1.out", provide_port_data_size));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(provider_connection, APX_DEFINITION_ADDRESS_START, "Provider1.apx", provider_definition_size));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(provider_connection));
   packet = apx_serverTestConnection_get_log_packet(provider_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message (TestNode1.apx)
   apx_serverTestConnection_clear_log(provider_connection);
   node_manager = apx_serverTestConnection_get_node_manager(provider_connection);
   CuAssertPtrNotNull(tc, node_manager);
   apx_nodeInstance_t* provider_node_instance = apx_nodeManager_find(node_manager, "Provider1");
   apx_nodeData_t* provider_node_data = apx_nodeInstance_get_node_data(provider_node_instance);
   CuAssertPtrNotNull(tc, provider_node_data);
   CuAssertUIntEquals(tc, provider_definition_size, apx_nodeData_definition_data_size(provider_node_data));
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_definition_data_state(provider_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(provider_connection, APX_DEFINITION_ADDRESS_START, (uint8_t const*)m_provider1_definition, provider_definition_size));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_definition_data_state(provider_node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(provider_connection));
   packet = apx_serverTestConnection_get_log_packet(provider_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message (TestNode1.out)
   apx_serverTestConnection_clear_log(provider_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_provide_port_data_state(provider_node_instance));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(provider_connection, APX_PORT_DATA_ADDRESS_START, provide_port_data, provide_port_data_size));
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_provide_port_data_state(provider_node_instance));
   apx_serverTestConnection_run(provider_connection);
   apx_portSignatureMapEntry_t* map_entry = apx_portSignatureMap_find(port_signature_map, "\"VehicleSpeed\"S");
   CuAssertPtrNotNull(tc, map_entry);
   uint8_t* snapshot = apx_nodeData_take_provide_port_data_snapshot(provider_node_data);
   CuAssertPtrNotNull(tc, snapshot);
   CuAssertUIntEquals(tc, 0x34, snapshot[0]);
   CuAssertUIntEquals(tc, 0x12, snapshot[1]);
   free(snapshot);

   requester_connection = apx_serverTestConnection_new();
   CuAssertPtrNotNull(tc, requester_connection);
   apx_server_accept_connection(server, (apx_serverConnection_t*)requester_connection);
   port_signature_map = apx_server_get_port_signature_map(server);
   CuAssertPtrNotNull(tc, port_signature_map);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester_connection));
   CuAssertUIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_send_greeting_header(requester_connection));
   apx_serverTestConnection_run(requester_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester_connection));
   packet = apx_serverTestConnection_get_log_packet(requester_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, acknowledge_size, adt_bytearray_length(packet)); //This is the acknowledge message
   apx_serverTestConnection_clear_log(requester_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(requester_connection, APX_DEFINITION_ADDRESS_START, "Requester1.apx", requester_definition_size));
   apx_serverTestConnection_run(requester_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester_connection));
   packet = apx_serverTestConnection_get_log_packet(requester_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message
   apx_serverTestConnection_clear_log(requester_connection);
   node_manager = apx_serverTestConnection_get_node_manager(requester_connection);
   CuAssertPtrNotNull(tc, node_manager);
   apx_nodeInstance_t* requester_node_instance = apx_nodeManager_find(node_manager, "Requester1");
   apx_nodeData_t* requester_node_data = apx_nodeInstance_get_node_data(requester_node_instance);
   CuAssertPtrNotNull(tc, requester_node_data);
   CuAssertUIntEquals(tc, requester_definition_size, apx_nodeData_definition_data_size(requester_node_data));
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_definition_data_state(requester_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(requester_connection, APX_DEFINITION_ADDRESS_START, (uint8_t const*)m_requester1_definition, requester_definition_size));
   apx_serverTestConnection_run(requester_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_definition_data_state(requester_node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester_connection));
   packet = apx_serverTestConnection_get_log_packet(requester_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, file_info_publish_size, adt_bytearray_length(packet)); //Should be a file info struct
   apx_serverTestConnection_clear_log(requester_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_OPEN_REQUEST, apx_nodeInstance_get_require_port_data_state(requester_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_request_open_local_file(requester_connection, "Requester1.in"));
   apx_serverTestConnection_run(requester_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_require_port_data_state(requester_node_instance));
   snapshot = apx_nodeData_take_require_port_data_snapshot(requester_node_data);
   CuAssertPtrNotNull(tc, snapshot);
   CuAssertUIntEquals(tc, 0x34, snapshot[0]);
   CuAssertUIntEquals(tc, 0x12, snapshot[1]);
   free(snapshot);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester_connection));
   packet = apx_serverTestConnection_get_log_packet(requester_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, requester1_data_size, adt_bytearray_length(packet)); //Should be contents of "Requester1.in"
   memcpy(data_message, adt_bytearray_data(packet), requester1_data_size);
   CuAssertUIntEquals(tc, 4u, data_message[0]);
   CuAssertUIntEquals(tc, 0u, data_message[1]);
   CuAssertUIntEquals(tc, 0u, data_message[2]);
   CuAssertUIntEquals(tc, 0x34, data_message[3]);
   CuAssertUIntEquals(tc, 0x12, data_message[4]);
   CuAssertIntEquals(tc, 1, apx_portSignatureMap_length(port_signature_map));
   map_entry = apx_portSignatureMap_find(port_signature_map, "\"VehicleSpeed\"S");
   CuAssertPtrNotNull(tc, map_entry);
   CuAssertIntEquals(tc, 1, apx_portSignatureMapEntry_get_num_providers(map_entry));
   CuAssertIntEquals(tc, 1, apx_portSignatureMapEntry_get_num_requesters(map_entry));
   apx_server_delete(server);
}

static void test_connectors_node_with_provide_port_is_connected_when_multiple_nodes_with_require_ports_are_waiting(CuTest* tc)
{
   apx_server_t* server;
   apx_serverTestConnection_t* provider_connection = NULL;
   apx_serverTestConnection_t* requester1_connection = NULL;
   apx_serverTestConnection_t* requester2_connection = NULL;
   adt_bytearray_t* packet = NULL;
   apx_nodeManager_t* node_manager;
   apx_portSignatureMap_t* port_signature_map = NULL;
   apx_portSignatureMapEntry_t* map_entry = NULL;
   int const provide_port_data_size = UINT16_SIZE;
   int const acknowledge_size = 9;
   int const open_request_size = 13;
   int const file_info_publish_size = 67;
   int const requester1_data_size = 5;
   int const requester2_data_size = 7;
   int const single_port_update_size = 5;
   uint8_t provide_port_data[UINT16_SIZE] = { 0x34u, 0x12u };
   uint8_t data_message[7];
   uint8_t* snapshot;
   apx_size_t const provider_definition_size = (apx_size_t)strlen(m_provider1_definition);
   apx_size_t const requester1_definition_size = (apx_size_t)strlen(m_requester1_definition);
   apx_size_t const requester2_definition_size = (apx_size_t)strlen(m_requester2_definition);

   server = apx_server_new();
   CuAssertPtrNotNull(tc, server);
   port_signature_map = apx_server_get_port_signature_map(server);
   CuAssertPtrNotNull(tc, port_signature_map);
   //First connection
   requester1_connection = apx_serverTestConnection_new();
   CuAssertPtrNotNull(tc, requester1_connection);
   apx_server_accept_connection(server, (apx_serverConnection_t*)requester1_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester1_connection));
   CuAssertUIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_send_greeting_header(requester1_connection));
   apx_serverTestConnection_run(requester1_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester1_connection));
   packet = apx_serverTestConnection_get_log_packet(requester1_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, acknowledge_size, adt_bytearray_length(packet)); //This is the acknowledge message
   apx_serverTestConnection_clear_log(requester1_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester1_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(requester1_connection, APX_DEFINITION_ADDRESS_START, "Requester1.apx", requester1_definition_size));
   apx_serverTestConnection_run(requester1_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester1_connection));
   packet = apx_serverTestConnection_get_log_packet(requester1_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message
   apx_serverTestConnection_clear_log(requester1_connection);
   node_manager = apx_serverTestConnection_get_node_manager(requester1_connection);
   CuAssertPtrNotNull(tc, node_manager);
   apx_nodeInstance_t* requester1_node_instance = apx_nodeManager_find(node_manager, "Requester1");
   apx_nodeData_t* requester1_node_data = apx_nodeInstance_get_node_data(requester1_node_instance);
   CuAssertPtrNotNull(tc, requester1_node_data);
   CuAssertUIntEquals(tc, requester1_definition_size, apx_nodeData_definition_data_size(requester1_node_data));
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_definition_data_state(requester1_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester1_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(requester1_connection, APX_DEFINITION_ADDRESS_START, (uint8_t const*)m_requester1_definition, requester1_definition_size));
   apx_serverTestConnection_run(requester1_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_definition_data_state(requester1_node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester1_connection));
   packet = apx_serverTestConnection_get_log_packet(requester1_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, file_info_publish_size, adt_bytearray_length(packet)); //Should be a file info struct
   apx_serverTestConnection_clear_log(requester1_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_OPEN_REQUEST, apx_nodeInstance_get_require_port_data_state(requester1_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester1_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_request_open_local_file(requester1_connection, "Requester1.in"));
   apx_serverTestConnection_run(requester1_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_require_port_data_state(requester1_node_instance));
   //Verify that Requester1.in has default init values since no provider is available yet
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester1_connection));
   packet = apx_serverTestConnection_get_log_packet(requester1_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, requester1_data_size, adt_bytearray_length(packet)); //Should be contents of "Requester1.in"
   memcpy(data_message, adt_bytearray_data(packet), requester1_data_size);
   CuAssertUIntEquals(tc, 4u, data_message[0]);
   CuAssertUIntEquals(tc, 0u, data_message[1]);
   CuAssertUIntEquals(tc, 0u, data_message[2]);
   CuAssertUIntEquals(tc, 0xFF, data_message[3]);
   CuAssertUIntEquals(tc, 0xFF, data_message[4]);
   apx_serverTestConnection_clear_log(requester1_connection);
   //Analyze port map changes
   CuAssertIntEquals(tc, 1, apx_portSignatureMap_length(port_signature_map));
   map_entry = apx_portSignatureMap_find(port_signature_map, "\"VehicleSpeed\"S");
   CuAssertPtrNotNull(tc, map_entry);
   CuAssertIntEquals(tc, 0, apx_portSignatureMapEntry_get_num_providers(map_entry));
   CuAssertIntEquals(tc, 1, apx_portSignatureMapEntry_get_num_requesters(map_entry));

   //Second connection
   requester2_connection = apx_serverTestConnection_new();
   CuAssertPtrNotNull(tc, requester2_connection);
   apx_server_accept_connection(server, (apx_serverConnection_t*)requester2_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester2_connection));
   CuAssertUIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_send_greeting_header(requester2_connection));
   apx_serverTestConnection_run(requester2_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester2_connection));
   packet = apx_serverTestConnection_get_log_packet(requester2_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, acknowledge_size, adt_bytearray_length(packet)); //This is the acknowledge message
   apx_serverTestConnection_clear_log(requester2_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester2_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(requester2_connection, APX_DEFINITION_ADDRESS_START, "Requester2.apx", requester2_definition_size));
   apx_serverTestConnection_run(requester2_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester2_connection));
   packet = apx_serverTestConnection_get_log_packet(requester2_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message
   apx_serverTestConnection_clear_log(requester2_connection);
   node_manager = apx_serverTestConnection_get_node_manager(requester2_connection);
   CuAssertPtrNotNull(tc, node_manager);
   apx_nodeInstance_t* requester2_node_instance = apx_nodeManager_find(node_manager, "Requester2");
   apx_nodeData_t* requester2_node_data = apx_nodeInstance_get_node_data(requester2_node_instance);
   CuAssertPtrNotNull(tc, requester2_node_data);
   CuAssertUIntEquals(tc, requester2_definition_size, apx_nodeData_definition_data_size(requester2_node_data));
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_definition_data_state(requester2_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester2_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(requester2_connection, APX_DEFINITION_ADDRESS_START, (uint8_t const*)m_requester2_definition, requester2_definition_size));
   apx_serverTestConnection_run(requester2_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_definition_data_state(requester2_node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester2_connection));
   packet = apx_serverTestConnection_get_log_packet(requester2_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, file_info_publish_size, adt_bytearray_length(packet)); //Should be a file info struct
   apx_serverTestConnection_clear_log(requester2_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_OPEN_REQUEST, apx_nodeInstance_get_require_port_data_state(requester2_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(requester2_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_request_open_local_file(requester2_connection, "Requester2.in"));
   apx_serverTestConnection_run(requester2_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_require_port_data_state(requester1_node_instance));
   //Verify that Requester1.in has default init values since no provider is available yet
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester2_connection));
   packet = apx_serverTestConnection_get_log_packet(requester2_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, requester2_data_size, adt_bytearray_length(packet)); //Should be contents of "Requester2.in"
   memcpy(data_message, adt_bytearray_data(packet), requester2_data_size);
   CuAssertUIntEquals(tc, 6u, data_message[0]);
   CuAssertUIntEquals(tc, 0u, data_message[1]);
   CuAssertUIntEquals(tc, 0u, data_message[2]);
   CuAssertUIntEquals(tc, 0xFF, data_message[3]);
   CuAssertUIntEquals(tc, 0xFF, data_message[4]);
   CuAssertUIntEquals(tc, 0xFF, data_message[5]);
   CuAssertUIntEquals(tc, 0xFF, data_message[6]);
   apx_serverTestConnection_clear_log(requester2_connection);
   //Analyze port map changes
   CuAssertIntEquals(tc, 2, apx_portSignatureMap_length(port_signature_map));
   map_entry = apx_portSignatureMap_find(port_signature_map, "\"VehicleSpeed\"S");
   CuAssertPtrNotNull(tc, map_entry);
   CuAssertIntEquals(tc, 0, apx_portSignatureMapEntry_get_num_providers(map_entry));
   CuAssertIntEquals(tc, 2, apx_portSignatureMapEntry_get_num_requesters(map_entry));

   //Third connection
   provider_connection = apx_serverTestConnection_new();
   CuAssertPtrNotNull(tc, provider_connection);
   apx_server_accept_connection(server, (apx_serverConnection_t*)provider_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertUIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_send_greeting_header(provider_connection));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(provider_connection));
   packet = apx_serverTestConnection_get_log_packet(provider_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, acknowledge_size, adt_bytearray_length(packet)); //This is the acknowledge message
   apx_serverTestConnection_clear_log(provider_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(provider_connection, APX_PORT_DATA_ADDRESS_START, "Provider1.out", provide_port_data_size));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_publish_remote_file(provider_connection, APX_DEFINITION_ADDRESS_START, "Provider1.apx", provider_definition_size));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(provider_connection));
   packet = apx_serverTestConnection_get_log_packet(provider_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message (TestNode1.apx)
   apx_serverTestConnection_clear_log(provider_connection);
   node_manager = apx_serverTestConnection_get_node_manager(provider_connection);
   CuAssertPtrNotNull(tc, node_manager);
   apx_nodeInstance_t* provider_node_instance = apx_nodeManager_find(node_manager, "Provider1");
   apx_nodeData_t* provider_node_data = apx_nodeInstance_get_node_data(provider_node_instance);
   CuAssertPtrNotNull(tc, provider_node_data);
   CuAssertUIntEquals(tc, provider_definition_size, apx_nodeData_definition_data_size(provider_node_data));
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_definition_data_state(provider_node_instance));
   CuAssertIntEquals(tc, 0u, apx_serverTestConnection_log_length(provider_connection));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(provider_connection, APX_DEFINITION_ADDRESS_START, (uint8_t const*)m_provider1_definition, provider_definition_size));
   apx_serverTestConnection_run(provider_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_definition_data_state(provider_node_instance));
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(provider_connection));
   packet = apx_serverTestConnection_get_log_packet(provider_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, open_request_size, adt_bytearray_length(packet)); //Should be a file open request message (TestNode1.out)
   apx_serverTestConnection_clear_log(provider_connection);
   CuAssertIntEquals(tc, APX_DATA_STATE_WAITING_FOR_FILE_DATA, apx_nodeInstance_get_provide_port_data_state(provider_node_instance));
   CuAssertIntEquals(tc, APX_NO_ERROR, apx_serverTestConnection_write_remote_data(provider_connection, APX_PORT_DATA_ADDRESS_START, provide_port_data, provide_port_data_size));
   CuAssertIntEquals(tc, APX_DATA_STATE_CONNECTED, apx_nodeInstance_get_provide_port_data_state(provider_node_instance));
   apx_serverTestConnection_run(provider_connection);

   //Analyze port map changes
   CuAssertIntEquals(tc, 2, apx_portSignatureMap_length(port_signature_map));
   map_entry = apx_portSignatureMap_find(port_signature_map, "\"VehicleSpeed\"S");
   CuAssertPtrNotNull(tc, map_entry);
   CuAssertIntEquals(tc, 1, apx_portSignatureMapEntry_get_num_providers(map_entry));
   CuAssertIntEquals(tc, 2, apx_portSignatureMapEntry_get_num_requesters(map_entry));

   //Verify that require ports have been locally updated in server
   snapshot = apx_nodeData_take_require_port_data_snapshot(requester1_node_data);
   CuAssertPtrNotNull(tc, snapshot);
   CuAssertUIntEquals(tc, 0x34, snapshot[0]);
   CuAssertUIntEquals(tc, 0x12, snapshot[1]);
   free(snapshot);
   snapshot = apx_nodeData_take_require_port_data_snapshot(requester2_node_data);
   CuAssertPtrNotNull(tc, snapshot);
   CuAssertUIntEquals(tc, 0xff, snapshot[0]);
   CuAssertUIntEquals(tc, 0xff, snapshot[1]);
   CuAssertUIntEquals(tc, 0x34, snapshot[2]);
   CuAssertUIntEquals(tc, 0x12, snapshot[3]);
   free(snapshot);

   //Check for data updates in each connections
   apx_serverTestConnection_run(provider_connection);
   apx_serverTestConnection_run(requester1_connection);
   apx_serverTestConnection_run(requester2_connection);
   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester1_connection));
   packet = apx_serverTestConnection_get_log_packet(requester1_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, single_port_update_size, adt_bytearray_length(packet));
   memcpy(data_message, adt_bytearray_data(packet), single_port_update_size);
   CuAssertUIntEquals(tc, 4u, data_message[0]);
   CuAssertUIntEquals(tc, 0u, data_message[1]);
   CuAssertUIntEquals(tc, 0u, data_message[2]); //offset: 0
   CuAssertUIntEquals(tc, 0x34, data_message[3]);
   CuAssertUIntEquals(tc, 0x12, data_message[4]);
   apx_serverTestConnection_clear_log(requester1_connection);

   CuAssertIntEquals(tc, 1u, apx_serverTestConnection_log_length(requester2_connection));
   packet = apx_serverTestConnection_get_log_packet(requester2_connection, 0);
   CuAssertPtrNotNull(tc, packet);
   CuAssertIntEquals(tc, single_port_update_size, adt_bytearray_length(packet));
   memcpy(data_message, adt_bytearray_data(packet), single_port_update_size);
   CuAssertUIntEquals(tc, 4u, data_message[0]);
   CuAssertUIntEquals(tc, 0u, data_message[1]);
   CuAssertUIntEquals(tc, 2u, data_message[2]); //offset: 2
   CuAssertUIntEquals(tc, 0x34, data_message[3]);
   CuAssertUIntEquals(tc, 0x12, data_message[4]);
   apx_serverTestConnection_clear_log(requester2_connection);

   apx_server_delete(server);
}


text:
Maintenance version

## Improvements

 * made the `runAsync` methods more generic by accepting any stack which can be translated to `Fx1[M]`
 * added a convenience method to shutdown the execution services on a future completion

## Fixes

 * fixed a possible deadlock when shutting down `ExecutorServices`

redpajama_set_name: RedPajamaGithub


text:
package com.msi.tough.core;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.transaction.TransactionConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/test-toughcore-context.xml" })
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = false)
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class })
public class CommaObjectTest {

    @Test
    public void testToArray() throws Exception {
        CommaObject commas = new CommaObject("One,Two,Three,Four");
        String[] vals = commas.toArray();
        assertEquals("Expect parsed value.", "Three", vals[2]);
    }

    @Test
    public void testToArrayEmpty() throws Exception {
        CommaObject commas = new CommaObject("");
        String[] vals = commas.toArray();
        assertEquals("Expect no length.", vals.length, 0);
    }
}


text:
import { browser } from "webextension-polyfill-ts";
import { FunctionRegistry } from "registry/FunctionRegistry";
import { RemoteFunctionBrowserExtensionRegistry } from "registry/RemoteFunctionBrowserExtensionRegistry";

export const extensionFunctionRegistry: FunctionRegistry = new RemoteFunctionBrowserExtensionRegistry(browser);


text:
package net.rubygrapefruit.platform.file;

import javax.annotation.Nullable;

public interface FileWatchEvent {

    void handleEvent(Handler handler);

    interface Handler {
        void handleChangeEvent(ChangeType type, String absolutePath);

        void handleUnknownEvent(String absolutePath);

        void handleOverflow(OverflowType type, @Nullable String absolutePath);

        void handleFailure(Throwable failure);

        void handleTerminated();
    }

    enum ChangeType {
        /**
         * An item with the given path has been created.
         */
        CREATED,

        /**
         * An item with the given path has been removed.
         */
        REMOVED,

        /**
         * An item with the given path has been modified.
         */
        MODIFIED,

        /**
         * Some undisclosed changes happened under the given path,
         * all information about descendants must be discarded.
         */
        INVALIDATED
    }

    enum OverflowType {
        /**
         * The overflow happened in the operating system's routines.
         */
        OPERATING_SYSTEM,

        /**
         * The overflow happened because the Java event queue has filled up.
         */
        EVENT_QUEUE
    }
}


text:
package com.github.DNAProject.crypto.bip32;

import com.github.DNAProject.crypto.bip32.derivation.CkdFunction;

public interface Derivation<Path> {

    /**
     * Traverse the nodes from the root key node to find the node referenced by the path.
     *
     * @param rootKey     The root of the path
     * @param path        The path to follow
     * @param ckdFunction Allows you to follow one link
     * @param <Key>       The type of node we are visiting
     * @return The final node found at the end of the path
     */
    <Key> Key derive(final Key rootKey, final Path path, final CkdFunction<Key> ckdFunction);
}


text:
package io.sweers.barber.sample;

import android.app.AlertDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        switch (id) {
            case R.id.action_about:
                new AlertDialog.Builder(this)
                        .setTitle("Barber")
                        .setMessage(Html.fromHtml(getString(R.string.about_body)))
                        .setPositiveButton("Done", null)
                        .create().show();
                return true;
            case R.id.action_repo:
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("https://github.com/hzsweers/barber"));
                startActivity(intent);
                return true;
        }

        return super.onOptionsItemSelected(item);
    }
}


text:
<?xml version="1.0" encoding="utf-8"?>
<resources>

    <dimen name="font_size_tiny">12sp</dimen>
    <dimen name="font_size_small">15sp</dimen>
    <dimen name="font_size_normal">18sp</dimen>
    <dimen name="font_size_large">24sp</dimen>
    <dimen name="font_size_xlarge">28sp</dimen>
    <dimen name="font_size_huge">34sp</dimen>
    <dimen name="symbol_size_normal">15sp</dimen>
    <dimen name="list_entry_padding_horizontal_cram">6dp</dimen>
    <dimen name="list_entry_padding_horizontal">12dp</dimen>
    <dimen name="list_entry_padding_horizontal_lax">20dp</dimen>
    <dimen name="list_entry_padding_vertical_cram">3dp</dimen>
    <dimen name="list_entry_padding_vertical">6dp</dimen>
    <dimen name="list_entry_padding_vertical_lax">10dp</dimen>
    <dimen name="card_padding_horizontal">6dp</dimen>
    <dimen name="card_padding_vertical">2dp</dimen>
    <dimen name="exchange_rate_pane_width">352sp</dimen>
    <dimen name="divider_currency_padding">0dp</dimen>
    <dimen name="wallet_address_qr_size">80dp</dimen>
    <dimen name="request_coins_qr_size">128dp</dimen>
    <dimen name="bitmap_dialog_qr_size">224dp</dimen>
    <dimen name="scan_laser_width">4dp</dimen>
    <dimen name="scan_dot_size">8dp</dimen>
    <dimen name="shortcut_padding">2dp</dimen>
    <dimen name="shortcut_size">48dp</dimen>
    <dimen name="shortcut_icon_size">32dp</dimen>

</resources>


text:
require 'chronic'

require 'masamune/actions/date_parse'

module Masamune::Actions
  module DataFlow
    extend ActiveSupport::Concern

    include Masamune::Actions::DateParse

    def engine
      self.class.engine
    end

    def targets
      engine.targets(current_command_name)
    end

    def sources
      engine.sources(current_command_name)
    end

    def target
      targets.first
    end

    def source
      sources.first
    end

    def reset_module!
      ClassMethods.reset_module!
    end
    module_function :reset_module!

    private

    # TODO: sources from file or input array
    def parse_file_type(key)
      return Set.new unless key
      (value = options[key]) || (return Set.new)
      File.exist?(value) || raise(Thor::MalformattedArgumentError, "Expected file value for '--#{key}'; got #{value}")
      Set.new File.read(value).split(/\s+/)
    end

    def prepare_and_execute(options = {})
      raise Thor::RequiredArgumentMissingError, "No value provided for required options '--start' or '--at'" unless options[:start] || options[:at] || options[:sources] || options[:targets]
      raise Thor::MalformattedArgumentError, "Cannot specify both option '--sources' and option '--targets'" if options[:sources] && options[:targets]

      desired_sources = Masamune::DataPlan::Set.new current_command_name, parse_file_type(:sources)
      desired_targets = Masamune::DataPlan::Set.new current_command_name, parse_file_type(:targets)

      if start_time && stop_time
        desired_targets.merge engine.targets_for_date_range(current_command_name, start_time, stop_time)
      end

      engine.prepare(current_command_name, options.merge(sources: desired_sources, targets: desired_targets))
      engine.execute(current_command_name, options)
    end

    included do |base|
      base.extend ClassMethods
      base.class_eval do
        class_option :sources, desc: 'File of data sources to process'
        class_option :targets, desc: 'File of data targets to process'
        class_option :resolve, type: :boolean, desc: 'Recursively resolve data dependencies', default: true
      end

      if defined?(base.after_initialize)
        base.after_initialize(:final) do |thor, options|
          thor.engine.environment = thor.environment
          thor.engine.filesystem.environment = thor.environment
          thor.environment.with_process_lock(:data_flow_after_initialize) do
            thor.send(:prepare_and_execute, options)
          end
          exit 0 if thor.top_level?
        end
      end
    end

    # rubocop:disable Style/ClassVars
    module ClassMethods
      def skip
        initialize_module!
        @@namespaces << namespace
        @@sources << { skip: true }
        @@targets << { skip: true }
      end

      def source(source_options = {})
        initialize_module!
        @@namespaces << namespace
        @@sources << source_options
      end

      def target(target_options = {})
        initialize_module!
        @@targets << target_options
      end

      def create_command(*a)
        initialize_module!
        super.tap do
          @@commands += a
        end
      end

      def engine
        @@engine ||= Masamune::DataPlan::Builder.instance.build(@@namespaces, @@commands, @@sources, @@targets)
      end

      private

      def reset_module!
        @@namespaces = []
        @@targets = []
        @@sources = []
        @@commands = []
        @@engine = nil
      end
      module_function :reset_module!

      def initialize_module!
        @@namespaces ||= []
        @@targets ||= []
        @@sources ||= []
        @@commands ||= []
      end

      # If internal call to Thor::Base.start fails, exit
      def exit_on_failure?
        true
      end
    end
    # rubocop:enable Style/ClassVars
  end
end


text:
@InterfaceAudience.Private
package org.apache.hadoop.yarn.api.records.impl.pb;
import org.apache.hadoop.classification.InterfaceAudience;


text:
namespace blink {

class Scheduler;
class WebTraceLocation;

// This class is used to submit tasks to Blink's main thread scheduler.
class WebSchedulerProxy {
public:
    BLINK_PLATFORM_EXPORT ~WebSchedulerProxy();

    BLINK_PLATFORM_EXPORT static WebSchedulerProxy create();

    // Schedule an input processing task to be run on the Blink main thread.
    // Takes ownership of |Task|. Can be called from any thread.
    BLINK_PLATFORM_EXPORT void postInputTask(const WebTraceLocation&, WebThread::Task*);

    // Schedule a compositor task to run on the Blink main thread. Takes
    // ownership of |Task|. Can be called from any thread.
    BLINK_PLATFORM_EXPORT void postCompositorTask(const WebTraceLocation&, WebThread::Task*);

private:
    WebSchedulerProxy();

    Scheduler* m_scheduler;
};

} // namespace blink

#endif // WebSchedulerProxy_h


text:
import org.jetbrains.annotations.NotNull;

class Test {
  Object o;

  void field() {
    o.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
  }

  void parameter(Object o) {
    o.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
  }

  void callUnknownMethod() {
    unknownObject().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>();
  }

  void callNotNullMethod() {
    knownObject().hashCode();
  }

  native Object unknownObject();

  @NotNull
  native Object knownObject();
}


text:
<?php

namespace WebLoader\Filter;

/**
 * Scss CSS filter
 *
 * @author Roman Matěna
 * @license MIT
 */
class ScssFilter
{

	/**
	 * @var \Leafo\ScssPhp\Compiler
	 */
	private $sc;

	public function __construct(\Leafo\ScssPhp\Compiler $sc = NULL)
	{
		$this->sc = $sc;
	}

	/**
	 * @return \Leafo\ScssPhp\Compiler|\scssc
	 */
	private function getScssC()
	{
		// lazy loading
		if (empty($this->sc)) {
			$this->sc = new \Leafo\ScssPhp\Compiler();
		}

		return $this->sc;
	}

	/**
	 * Invoke filter
	 * @param string $code
	 * @param \WebLoader\Compiler $loader
	 * @param string $file
	 * @return string
	 */
	public function __invoke($code, \WebLoader\Compiler $loader, $file)
	{
		if (pathinfo($file, PATHINFO_EXTENSION) === 'scss') {
			$this->getScssC()->setImportPaths(pathinfo($file, PATHINFO_DIRNAME) . '/');
			return $this->getScssC()->compile($code);
		}

		return $code;
	}

}


text:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class CreateTemp
{

    // socket for connection to SISServer
    static Socket universal;
    private static int port = 53217;
    // message writer
    static MsgEncoder encoder;
    // message reader
    static MsgDecoder decoder;
    // scope of this component
    private static final String SCOPE = "SIS.Scope1";
	// name of this component
    private static final String NAME = "Temp";
    // messages types that can be handled by this component
    private static final List<String> TYPES = new ArrayList<String>(
        Arrays.asList(new String[] { "Setting", "Confirm" }));

    private static int refreshRate = 500, max = 40, min = 15;
    private static Date startDate = new Date(), endDate = new Date();

    private static Timer timer = new Timer();

    // shared by all kinds of records that can be generated by this component
    private static KeyValueList record = new KeyValueList();
    // shared by all kinds of alerts that can be generated by this component
    private static KeyValueList alert = new KeyValueList();

    private static TempReading reading = new TempReading();

    private static SimpleDateFormat format = new SimpleDateFormat(
        "yyyy-MM-dd HH:mm:ss");

    /*
     * Main program
     */
    public static void main(String[] args)
    {
        while (true)
        {
            try
            {

                // try to establish a connection to SISServer
                universal = connect();

                // bind the message reader to inputstream of the socket
                decoder = new MsgDecoder(universal.getInputStream());
                // bind the message writer to outputstream of the socket
                encoder = new MsgEncoder(universal.getOutputStream());

                /*
                 * construct a Connect message to establish the connection
                 */
                KeyValueList conn = new KeyValueList();
                conn.putPair("Scope", SCOPE);
                conn.putPair("MessageType", "Connect");
				conn.putPair("Role", "Basic");
                conn.putPair("Name", NAME);
                encoder.sendMsg(conn);

                initRecord();

                // KeyValueList for inward messages, see KeyValueList for
                // details
                KeyValueList kvList;

                while (true)
                {
                    // attempt to read and decode a message, see MsgDecoder for
                    // details
                    kvList = decoder.getMsg();

                    // process that message
                    ProcessMsg(kvList);
                }

            }
            catch (Exception e)
            {
                // if anything goes wrong, try to re-establish the connection
                e.printStackTrace();
                try
                {
                    // wait for 1 second to retry
                    Thread.sleep(1000);
                }
                catch (InterruptedException e2)
                {
                }
                System.out.println("Try to reconnect");
                try
                {
                    universal = connect();
                }
                catch (IOException e1)
                {
                }
            }
        }
    }

    /*
     * used for connect(reconnect) to SISServer
     */
    static Socket connect() throws IOException
    {
        Socket socket = new Socket("127.0.0.1", port);
        return socket;
    }

    private static void initRecord()
    {
        record.putPair("Scope", SCOPE);
        record.putPair("MessageType", "Reading");
        record.putPair("Sender", NAME);

        // Receiver may be different for each message, so it doesn't make sense
        // to set here
        // record.putPair("Receiver", "");

        alert.putPair("Scope", SCOPE);
        alert.putPair("MessageType", "Alert");
        alert.putPair("Sender", NAME);
        alert.putPair("Purpose", "TempAlert");

        // Receiver may be different for each message, so it doesn't make sense
        // to set here
        // alert.putPair("Receiver", "");
    }

    private static void componentTask()
    {
        try
        {
            collect();

			if (reading.temp > min && reading.temp < max) {//normal
				//reading
				reading.date = System.currentTimeMillis();
				record.putPair("Temp", reading.temp + "");
				record.putPair("Date", reading.date + "");
				//send reading message to GUI, uploader
				encoder.sendMsg(record);
				//send reading message to controller
				record.putPair("Receiver", "DiController");
				encoder.sendMsg(record);
				record.removePair("Receiver");
			} else { //alert
				reading.date = System.currentTimeMillis(); //[Duncan Add Nov 16]
				alert.putPair("Temp", reading.temp + "");
				alert.putPair("Date", reading.date + "");
				//send alert message to GUI, uploader
				alert.removePair("Receiver");//[Duncan Add Nov 16]
				alert.putPair("Receiver", "DiUploader");//[Duncan Add Nov 16]
                		encoder.sendMsg(alert);
				//send alert message to controller
				alert.removePair("Receiver");
				alert.putPair("Receiver", "DiController");
                encoder.sendMsg(alert);
			}
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    private static void ProcessMsg(KeyValueList kvList) throws Exception
    {

        String scope = kvList.getValue("Scope");
        if (!SCOPE.startsWith(scope))
        {
            return;
        }

        String messageType = kvList.getValue("MessageType");
        if (!TYPES.contains(messageType))
        {
            return;
        }

        String sender = kvList.getValue("Sender");

        String receiver = kvList.getValue("Receiver");

        String purpose = kvList.getValue("Purpose");

        switch (messageType)
        {
        case "Confirm":
            System.out.println("Connect to SISServer successful.");
            break;
        case "Setting":
            if (receiver.equals(NAME))
            {
                System.out.println("Message from " + sender);
                System.out.println("Message type: " + messageType);
                System.out.println("Message Purpose: " + purpose);
                switch (purpose)
                {

                case "Activate":
                    String rRate = kvList.getValue("RefreshRate");
                    String sDate = kvList.getValue("StartDate");
                    String eDate = kvList.getValue("EndDate");
                    String maxx = kvList.getValue("Max");
                    String minn = kvList.getValue("Min");

                    if (rRate != null && !rRate.equals(""))
                    {

                        refreshRate = Integer.parseInt(rRate);

                    }

                    if (sDate != null && !sDate.equals("") && eDate != null
                            && !eDate.equals(""))
                    {
                        startDate.setTime(Long.parseLong(sDate));
                        endDate.setTime(Long.parseLong(eDate));
                    }

                    if (maxx != null && !maxx.equals("") && minn != null
                            && !minn.equals(""))
                    {
                        max = Integer.parseInt(maxx);
                        min = Integer.parseInt(minn);
                    }

                    try
                    {
                        timer.cancel();
                        timer = new Timer();
                    }
                    catch (Exception e)
                    {
                        // TODO: handle exception
                    }
                    timer.schedule(new TimerTask()
                    {

                        @Override
                        public void run()
                        {
                            // TODO Auto-generated method stub
                            if (System.currentTimeMillis() - endDate.getTime() > 0)
                            {
                                cancel();
                            }
                            else
                            {
                                componentTask();
                            }
                        }
                    }, startDate, refreshRate);
                    System.out.println("Algorithm Activated");
                    break;

                case "Kill":
                    try
                    {
                        timer.cancel();
                    }
                    catch (Exception e)
                    {
                        // TODO: handle exception
                    }
                    System.exit(0);
                    break;

                case "Deactivate":
                    try
                    {
                        timer.cancel();
                    }
                    catch (Exception e)
                    {
                        // TODO: handle exception
                    }
                    System.out.println("Algorithm Deactivated");
                    break;
                }
            }
            break;
        }
    }

    private static void collect() throws Exception
    {
        Runtime rt = Runtime.getRuntime();
        String comm = "tempered.exe";
        Process proc = rt.exec(comm);

        BufferedReader std = new BufferedReader(new InputStreamReader(proc.getInputStream()));
        //BufferedReader err = new BufferedReader(new InputStreamReader(proc.getErrorStream()));

        String s = null;
        //int count = 0;
        while((s = std.readLine()) != null)
        {
            try
            {
				//System.out.println(s);
                reading.temp = Double.parseDouble(s);
				//System.out.println(reading.temp);
                //++count;
            }
            catch(Exception e) {}
        }
        //reading.temp /= count;
		System.out.println(reading.temp);
    }

}

class TempReading
{
    double temp;
    long date;
}


text:
module EventMachine
  module IRC
    # Client commands
    # @see http://tools.ietf.org/html/rfc2812 RFC 2812
    module Commands
      # Set connection password
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.1 3.1.1 Password message
      def pass(password)
        send_data("PASS #{password}")
      end

      # Set/get user nick
      # @return [String] nick if no param
      # @return nil otherwise
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.2 3.1.2 Nick Message
      def nick(nick = nil)
        if nick
          send_data("NICK #{nick}")
        else
          @nick
        end
      end

      # Set username, hostname, and realname
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.3 3.1.3 User Message
      def user(username, mode, realname)
        send_data("USER #{username} #{mode} * :#{realname}")
      end

      # Gain operator privledges
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.4 3.1.4 Oper Message
      def oper(name, password)
        send_data("OPER #{name} #{password}")
      end

      # Set user mode
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.5 3.1.5 Mode Message
      def mode(nickname, setting)
        raise NotImplementedError.new
      end

      # Register a new service
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.6 3.1.6 Service Message
      def service(nickname, reserved, distribution, type)
      end

      # Terminate connection
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.7 3.1.7 Quit
      def quit(message = 'leaving')
        send_data("QUIT :#{message}")
      end

      # Disconnect server links
      # @see http://tools.ietf.org/html/rfc2812#section-3.1.8 3.1.8 Squit
      def squit(server, message = "quiting")
        raise NotImplementedError.new
      end

      # Join a channel
      # @see http://tools.ietf.org/html/rfc2812#section-3.2.1 3.2.1 Join message
      # @example
      #   client.join("#general")
      #   client.join("#general", "fubar")  # join #general with fubar key
      #   client.join(['#general', 'fubar'], "#foo")  # join multiple channels
      def join(*args)
        raise ArgumentError.new("Not enough arguments") unless args.size > 0
        channels, keys = [], []
        args.map!  {|arg| arg.is_a?(Array) ? arg : [arg, '']}
        args.sort! {|a,b| b[1].length <=> a[1].length}  # key channels first
        args.each  {|arg|
          channels << arg[0]
          keys     << arg[1] if arg[1].length > 0
        }
        send_data("JOIN #{channels.join(',')} #{keys.join(',')}".strip)
      end

      # Part all channels
      def part_all
        join('0')
      end

      # Leave a channel
      # @see http://tools.ietf.org/html/rfc2812#section-3.2.2 3.2.2 Part message
      # @example
      #   client.part('#general')
      #   client.part('#general', '#foo')
      #   client.part('#general', 'Bye all!')
      #   client.part('#general', '#foo', 'Bye all!')
      def part(*args)
        raise ArgumentError.new("Not enough arguments") unless args.size > 0
        message = channel?(args.last) ? "Leaving..." : args.pop
        send_data("PART #{args.join(',')} :#{message}")
      end

      # Set channel mode
      # @todo name conflict with user MODE message
      def channel_mode
        raise NotImplementedError.new
      end

      # Set/get topic
      # @param topic [Mixed] String, nil
      #   non-blank string sets the topic
      #   blank string unsets the topic
      #   nil returns the current topic (default)
      # @see http://tools.ietf.org/html/rfc2812#section-3.2.4 3.2.4 Topic message
      def topic(channel, message = nil)
        message = message.nil? ? "" : ":#{message}"
        send_data("TOPIC #{channel} #{message}".strip)
      end

      # List all nicknames visible to user
      # @param args [Multiple] list of channels to list nicks
      #   if last argument is a hash, then :target can request
      #   which server generates response
      # @see http://tools.ietf.org/html/rfc2812#section-3.2.5 3.2.5 Names message
      def names(*args)
        options = args.extract_options!
        send_data("NAMES #{args.join(',')} #{options[:target]}".strip)
      end

      # List channels and topics
      # @param args [Multiple] list of channels
      #   if last argument is a hash, then :target can request
      #   which server generates response
      # @see http://tools.ietf.org/html/rfc2812#section-3.2.6 3.2.6 List message
      def list(*args)
        options = args.extract_options!
        send_data("LIST #{args.join(',')} #{options[:target]}".strip)
      end

      # Invite a user to a channel
      # @param nickname [String] to invite
      # @param channel  [String] to invite to
      # @see http://tools.ietf.org/html/rfc2812#section-3.2.7 3.2.7 Invite message
      def invite(nickname, channel)
        send_data("INVITE #{nickname} #{channel}")
      end

      # Kick a user from a channel
      # @param args [Multiple]
      # @example
      #   client.kick('#general', 'jch')
      #   client.kick('#general', '&bar', 'jch', 'wcc')
      # @see http://tools.ietf.org/html/rfc2812#section-3.2.8 3.2.8 Kick message
      def kick(*args)
        channels = args.select {|arg| channel?(arg)}
        nicks    = args.select {|arg| !channel?(arg)}
        raise ArgumentError.new("Missing channels") if channels.empty?
        send_data("KICK #{channels.join(',')} #{nicks.join(',')}".strip)
      end

      # Send message to user or channel
      # @param target [String] nick or channel name
      # @param message [String]
      # @see http://tools.ietf.org/html/rfc2812#section-3.3.1 3.3.1 Private message
      def privmsg(target, message)
        send_data("PRIVMSG #{target} :#{message}")
      end
      alias_method :message, :privmsg

      # Send message to user or channel
      # @param target [String] nick or channel name
      # @param message [String]
      # @see http://tools.ietf.org/html/rfc2812#section-3.3.2 3.3.2 Notice message
      def notice(target, message)
        send_data("NOTICE #{target} :#{message}")
      end

      # Get message of the day for a server or current server
      # @param target [String] server name or current server if nil
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.1 3.4.1 Motd message
      def motd(target = nil)
        send_data("MOTD #{target}".strip)
      end

      # List users
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.2 3.4.2 Lusers message
      def lusers(mask = nil, target = nil)
        send_data("LUSERS #{mask} #{target}".strip)
      end

      # Get server version
      # @param target [String] server or current server if nil
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.3 3.4.3 Version message
      def version(target = nil)
        send_data("VERSION #{target}".strip)
      end

      # Get stats for a server
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.4 3.4.4 Stats message
      def stats(query = nil, target = nil)
        send_data("STATS #{query} #{target}".strip)
      end

      # List all servernames
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.5 3.4.5 Links message
      def links(remote_server = nil, server_mask = nil)
        send_data("LINKS #{remote_server} #{server_mask}".strip)
      end

      # Get server local time
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.6 3.4.6 Time message
      def time(target = nil)
        send_data("TIME #{target}".strip)
      end

      # Connect to another server
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.7 3.4.7 Connect message
      def server_connect(target, port, remote = nil)
        send_data("CONNECT #{target} #{port} #{remote}".strip)
      end

      # Find the route to a specific server
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.8 3.4.8 Trace message
      def trace(target = nil)
        send_data("TRACE #{target}".strip)
      end

      # Find info about admin of a given server
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.9 3.4.9 Admin message
      def admin(target = nil)
        send_data("ADMIN #{target}".strip)
      end

      # Describe server information
      # @see http://tools.ietf.org/html/rfc2812#section-3.4.10 3.4.10 Info message
      def info(target = nil)
        send_data("INFO #{target}".strip)
      end

      # List services connected to network
      # @see http://tools.ietf.org/html/rfc2812#section-3.5.1 3.5.1 Servlist message
      def servlist(mask = nil, type = nil)
        send_data("SERVLIST #{mask} #{type}".strip)
      end
      alias_method :server_list, :servlist

      # Send a message to a service
      # @see http://tools.ietf.org/html/rfc2812#section-3.5.2 3.5.2 Squery message
      def squery(service, text)
        send_data("SQUERY #{service} :#{text}")
      end

      # Get info about a user
      # @see http://tools.ietf.org/html/rfc2812#section-3.6.1 3.6.1 Who message
      def who(mask, mode = 'o')
        send_data("WHO #{mask} #{mode}")
      end

      # Get user information about a list of users
      # @param args [Multiple]
      #   if last arg is a hash, :target specifies which server to query
      # @see http://tools.ietf.org/html/rfc2812#section-3.6.2 3.6.2 Whois message
      def whois(*args)
        options = args.extract_options!
        target = options[:target] ? "#{options[:target]} " : ''
        send_data("WHOIS #{target}#{args.join(',')}")
      end

      # Get user information that no longer exists (nick changed, etc)
      # @param args [Multiple] list of nicknames
      # @param options [Hash]
      # @option options [Integer] :count number of history entries to list
      # @option options [Integer] :target
      # @example
      #   client.whowas('jch')
      #   client.whowas('jch', 'foo')
      #   client.whowas('jch', 'foo', :count => 5, :target => 'irc.net')
      # @see http://tools.ietf.org/html/rfc2812#section-3.6.3 3.6.3 Whowas message
      def whowas(*args)
        options = args.extract_options!
        send_data("WHOWAS #{args.join(',')} #{options[:count]} #{options[:target]}".strip)
      end

      # Terminate a connection by nickname
      # @see http://tools.ietf.org/html/rfc2812#section-3.7.1 3.7.1 Kill message
      def kill(nickname, comment = "Connection killed")
        send_data("KILL #{nickname} :#{comment}".strip)
      end

      # Test connection is alive
      # @see http://tools.ietf.org/html/rfc2812#section-3.7.2 3.7.2 Ping message
      def ping(server, target = '')
        send_data("PING #{server} #{target}".strip)
      end

      # Respond to a server ping
      # @see http://tools.ietf.org/html/rfc2812#section-3.7.3 3.7.3 Pong message
      def pong(*servers)
        send_data("PONG #{servers.join(' ')}")
      end

      # Server serious or fatal error, or to terminate a connection on quit
      # @see http://tools.ietf.org/html/rfc2812#section-3.7.4 3.7.4 Error message
      def error(message)
        send_data("ERROR :#{message}")
      end

      # Set user as away with optional message
      # @see http://tools.ietf.org/html/rfc2812#section-4.1 4.1 Away
      def away(message = nil)
        send_data("AWAY " + (message ? ":#{message}" : ""))
      end

      # Force user to re-read config
      # @see http://tools.ietf.org/html/rfc2812#section-4.2 4.2 Rehash message
      def rehash
        send_data("REHASH")
      end

      # Shutdown server
      # @see http://tools.ietf.org/html/rfc2812#section-4.3 4.3 Die message
      def die
        send_data("DIE")
      end

      # Restart server
      # @see http://tools.ietf.org/html/rfc2812#section-4.4 4.4 Restart
      def restart
        send_data("RESTART")
      end

      # Ask user to join IRC
      # @see http://tools.ietf.org/html/rfc2812#section-4.5 4.5 Summon
      def summon(user, target = nil, channel = nil)
        send_data("SUMMON #{user} #{target} #{channel}".strip)
      end

      # List logged in users
      # @see http://tools.ietf.org/html/rfc2812#section-4.6 4.6 Users
      def users(target = nil)
        send_data("USERS #{target}".strip)
      end

      # Broadcast to all logged in users
      # @see http://tools.ietf.org/html/rfc2812#section-4.7 4.7 Operwall
      def wallops(message)
        send_data("WALLOPS :#{message}")
      end
      alias_method :broadcast, :wallops

      # Returns information about up to 5 nicknames
      # @see http://tools.ietf.org/html/rfc2812#section-4.9 4.9 Userhost
      def userhost(*nicks)
        raise ArgumentError.new("Wrong number of arguments") unless nicks.size > 0 && nicks.size <= 5
        send_data("USERHOST #{nicks.join(' ')}")
      end

      # Efficient way to check if nicks are currently on
      # @see http://tools.ietf.org/html/rfc2812#section-4.9 4.9 Ison
      def ison(*nicks)
        send_data("ISON #{nicks.join(' ')}")
      end
    end
  end
end


text:
PERSONAL INFORMATION

			<?php
				echo form_open('login/create_member');
				echo form_input('fname',set_value('fname',''),'class="col-12" placeholder="First Name" type="text"');
				echo form_error('fname');
				echo form_input('lname',set_value('lname',''),'class="col-12" placeholder="Last Name" type="text"');
				echo form_error('lname');
				echo form_input('contact_no',set_value('contact_no',''),'class="col-12" placeholder="Contact No." type="text"');
				echo form_error('contact_no');
				echo form_input('email_address',set_value('email_address',''),'class="col-12" placeholder="Email Address" type="text"');
				echo form_error('email_address');
				echo form_input('home_address',set_value('home_address',''),'class="col-12" placeholder="Home Address" type="text"');
				echo form_error('home_address');

				$school_name = 1;
				$extra_attributes1='class="col-12" id="dropy" style="background-color:#f4ab25; color:white; height:50px"';
				echo form_dropdown('school', $school_list, set_value('school', $school_name), $extra_attributes1);
				echo form_error('school');
				echo '
';

				echo '
';
		echo "
";
	echo "
";
	echo '
';
		echo '
';
			echo '
LOGIN CREDENTIALS
';
			echo '<form>';
				echo form_input('stud_id',set_value('stud_id',''),'class="col-12" placeholder="ID Number" type="text"');
				echo form_error('stud_id');
				echo form_input('username',set_value('username',''),'class="col-12" placeholder="Username" type="text"');
				echo form_error('username');
				echo form_password('password','','class="col-12" placeholder="Password" type="password"');
				echo form_error('password');
				echo form_password('password_confirm','','class="col-12" placeholder="Confirm Password" type="password"');
				echo form_error('password_confirm');
				echo '
';
				echo '';
				echo '
';
				echo form_submit('submit','Submit Information','onclick="javascript:return confirm(\'Are you sure you want to save this?\')"');
				echo form_close();
				echo '
';
				echo '
';
				echo '<button class="btn-dflt btn-red">Cancel</button>';
				echo '';
				echo '
';

			?>


text:
package me.jccr.selectionwithjavascriptandwebview;

import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

public class MainActivity extends ActionBarActivity {
    private static final String TAG = MainActivity.class.getSimpleName();
    WebView mWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mWebView = (WebView) findViewById(R.id.webView);
        mWebView.addJavascriptInterface(this, "ActivityInterface");
        mWebView.loadUrl("file:///android_asset/main.html");
        mWebView.getSettings().setJavaScriptEnabled(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            WebView.setWebContentsDebuggingEnabled(true);
        }
    }

    @JavascriptInterface
    public void selectionChange(String infoJson){
        Log.d(TAG, infoJson);
        /*
        Example output:
            {
              "boundingRect": {
                "height": 40,
                "width": 235,
                "left": 8,
                "bottom": 48,
                "right": 243,
                "top": 8
              },
              "rectList": [
                {
                  "height": 19,
                  "width": 190,
                  "left": 53,
                  "bottom": 27,
                  "right": 243,
                  "top": 8
                },
                {
                  "height": 21,
                  "width": 234,
                  "left": 8,
                  "bottom": 48,
                  "right": 242,
                  "top": 27
                },
                {
                  "height": 19,
                  "width": 200,
                  "left": 9,
                  "bottom": 47,
                  "right": 209,
                  "top": 28
                }
              ],
              "selectionText": "random text and elements Some random text and elem",
              "isEmpty": false
            }
         */
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}


text:
/* @depends ../abstract/item.class.js */
const Weapon = class Weapon extends Item{
	//todo: basespeed (weight?), special properties (cleave, reach)
	//stuff
	constructor(name, damage, speed) {
		super(null);
		this.slot = "weapon";
		this.damage = damage || 1;
		this.speed = speed || 10;
		this.name = name;

		this.glyph = "(";
		this.color = "red";
		this.bgColor = TILE_COLOR;
		this.flavorName = this.name;
	}

	toString(){
		return `${this.name} (${this.damage}, ${this.speed})`;
	}
};


text:
// OutputWindow.cs
//
// Copyright (C) 2001 Mike Krueger
//
// This file was translated from java, it was part of the GNU Classpath
// Copyright (C) 2001 Free Software Foundation, Inc.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
// Linking this library statically or dynamically with other modules is
// making a combined work based on this library.  Thus, the terms and
// conditions of the GNU General Public License cover the whole
// combination.
//
// As a special exception, the copyright holders of this library give you
// permission to link this library with independent modules to produce an
// executable, regardless of the license terms of these independent
// modules, and to copy and distribute the resulting executable under
// terms of your choice, provided that you also meet, for each linked
// independent module, the terms and conditions of the license of that
// module.  An independent module is a module which is not derived from
// or based on this library.  If you modify this library, you may extend
// this exception to your version of the library, but you are not
// obligated to do so.  If you do not wish to do so, delete this
// exception statement from your version.

using System;

namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams
{

	/// <summary>
	/// Contains the output from the Inflation process.
	/// We need to have a window so that we can refer backwards into the output stream
	/// to repeat stuff.
	///
	/// author of the original java version : John Leuner
	/// </summary>
	public class OutputWindow
	{
		private static int WINDOW_SIZE = 1 << 15;
		private static int WINDOW_MASK = WINDOW_SIZE - 1;

		private byte[] window = new byte[WINDOW_SIZE]; //The window is 2^15 bytes
		private int windowEnd  = 0;
		private int windowFilled = 0;

		/// <summary>
		/// write a byte to this output window
		/// </summary>
		/// <param name="abyte">value to write</param>
		/// <exception cref="InvalidOperationException">
		/// if window is full
		/// </exception>
		public void Write(int abyte)
		{
			if (windowFilled++ == WINDOW_SIZE) {
				throw new InvalidOperationException("Window full");
			}
			window[windowEnd++] = (byte) abyte;
			windowEnd &= WINDOW_MASK;
		}

		private void SlowRepeat(int repStart, int len, int dist)
		{
			while (len-- > 0) {
				window[windowEnd++] = window[repStart++];
				windowEnd &= WINDOW_MASK;
				repStart &= WINDOW_MASK;
			}
		}

		/// <summary>
		/// Append a byte pattern already in the window itself
		/// </summary>
		/// <param name="len">length of pattern to copy</param>
		/// <param name="dist">distance from end of window pattern occurs</param>
		/// <exception cref="InvalidOperationException">
		/// If the repeated data overflows the window
		/// </exception>
		public void Repeat(int len, int dist)
		{
			if ((windowFilled += len) > WINDOW_SIZE) {
				throw new InvalidOperationException("Window full");
			}

			int rep_start = (windowEnd - dist) & WINDOW_MASK;
			int border = WINDOW_SIZE - len;
			if (rep_start <= border && windowEnd < border) {
				if (len <= dist) {
					System.Array.Copy(window, rep_start, window, windowEnd, len);
					windowEnd += len;
				} else {
					/* We have to copy manually, since the repeat pattern overlaps. */
					while (len-- > 0) {
						window[windowEnd++] = window[rep_start++];
					}
				}
			} else {
				SlowRepeat(rep_start, len, dist);
			}
		}

		/// <summary>
		/// Copy from input manipulator to internal window
		/// </summary>
		/// <param name="input">source of data</param>
		/// <param name="len">length of data to copy</param>
		/// <returns>the number of bytes copied</returns>
		public int CopyStored(StreamManipulator input, int len)
		{
			len = Math.Min(Math.Min(len, WINDOW_SIZE - windowFilled), input.AvailableBytes);
			int copied;

			int tailLen = WINDOW_SIZE - windowEnd;
			if (len > tailLen) {
				copied = input.CopyBytes(window, windowEnd, tailLen);
				if (copied == tailLen) {
					copied += input.CopyBytes(window, 0, len - tailLen);
				}
			} else {
				copied = input.CopyBytes(window, windowEnd, len);
			}

			windowEnd = (windowEnd + copied) & WINDOW_MASK;
			windowFilled += copied;
			return copied;
		}

		/// <summary>
		/// Copy dictionary to window
		/// </summary>
		/// <param name="dict">source dictionary</param>
		/// <param name="offset">offset of start in source dictionary</param>
		/// <param name="len">length of dictionary</param>
		/// <exception cref="InvalidOperationException">
		/// If window isnt empty
		/// </exception>
		public void CopyDict(byte[] dict, int offset, int len)
		{
			if (windowFilled > 0) {
				throw new InvalidOperationException();
			}

			if (len > WINDOW_SIZE) {
				offset += len - WINDOW_SIZE;
				len = WINDOW_SIZE;
			}
			System.Array.Copy(dict, offset, window, 0, len);
			windowEnd = len & WINDOW_MASK;
		}

		/// <summary>
		/// Get remaining unfilled space in window
		/// </summary>
		/// <returns>Number of bytes left in window</returns>
		public int GetFreeSpace()
		{
			return WINDOW_SIZE - windowFilled;
		}

		/// <summary>
		/// Get bytes available for output in window
		/// </summary>
		/// <returns>Number of bytes filled</returns>
		public int GetAvailable()
		{
			return windowFilled;
		}

		/// <summary>
		/// Copy contents of window to output
		/// </summary>
		/// <param name="output">buffer to copy to</param>
		/// <param name="offset">offset to start at</param>
		/// <param name="len">number of bytes to count</param>
		/// <returns>The number of bytes copied</returns>
		/// <exception cref="InvalidOperationException">
		/// If a window underflow occurs
		/// </exception>
		public int CopyOutput(byte[] output, int offset, int len)
		{
			int copy_end = windowEnd;
			if (len > windowFilled) {
				len = windowFilled;
			} else {
				copy_end = (windowEnd - windowFilled + len) & WINDOW_MASK;
			}

			int copied = len;
			int tailLen = len - copy_end;

			if (tailLen > 0) {
				System.Array.Copy(window, WINDOW_SIZE - tailLen, output, offset, tailLen);
				offset += tailLen;
				len = copy_end;
			}
			System.Array.Copy(window, copy_end - len, output, offset, len);
			windowFilled -= copied;
			if (windowFilled < 0) {
				throw new InvalidOperationException();
			}
			return copied;
		}

		/// <summary>
		/// Reset by clearing window so <see cref="GetAvailable">GetAvailable</see> returns 0
		/// </summary>
		public void Reset()
		{
			windowFilled = windowEnd = 0;
		}
	}
}


text:
'use strict';

var path = require('path'),
    thing = require('core-util-is');

var CRAZY_SLASHES = new RegExp('\\\\', 'g');
var ROOT_DIR = new RegExp('^[^\\' + path.sep + ']*\\' + path.sep);
var ALL_SEPARATORS = new RegExp('\\' + path.sep, 'g');
var LEADING_SEPARATOR = new RegExp('^\\' + path.sep);
var REGEX_SPECIAL_CHARACTERS = /[-[\]{}()*+?.^$|]/g;

exports.isAbsolutePath = function isAbsolutePath(file) {
    return path.resolve(file) === file;
};

exports.nameify = function nameify(file, views, ext) {
    // Windows. Ugh.
    views = views && views.replace(CRAZY_SLASHES, '\\\\');

    // Escape special characters in path
    views = views && views.replace(REGEX_SPECIAL_CHARACTERS, "\\$&");

    // Remove absolute path (if necessary)
    file = file.replace(new RegExp('^' + views), '');

    // Remove file extension
    file = file.replace(ext, '');

    // Remove leading slash or drive (platform-dependent, e.g. `c:\\` or '/');
    file = exports.isAbsolutePath(file) ? file.replace(ROOT_DIR, '') : file;

    // Remove remaining leading slashes (if not abs path).
    file = file.replace(LEADING_SEPARATOR, '');

    // Ensure path separators in name are all forward-slashes.
    file = file.replace(ALL_SEPARATORS, '/');

    return file;
};

exports.resolveViewDir = function resolveViewDir(context, fallback) {
    var views;

    views = context.views || fallback || '.';
    if (context.settings) {
        views = context.settings.views || views;
    }

    return views;
};

exports.deepClone = exports.deepCopy = function deepClone(src) {
    var dest = src;

    if (thing.isObject(src)) {
        dest = Array.isArray(src) ? [] : Object.create(Object.getPrototypeOf(src));
        Object.getOwnPropertyNames(src).forEach(function (prop) {
            var descriptor = Object.getOwnPropertyDescriptor(src, prop);
            descriptor.value = deepClone(descriptor.value);
            Object.defineProperty(dest, prop, descriptor);
        });
    }

    return dest;
};


text:
module.exports = {
  NODE_ENV: '"production"',
  mongodb: 'mongodb://localhost:27017/project'
};


text:
<?php

    /**
     * Created by PhpStorm.
     * User: social13
     * Date: 11.06.2017
     * Time: 20:09
     */

    namespace Locrian\Tests\Bus;

    use Locrian\Bus\Event;
    use Locrian\Bus\EventBus;
    use Locrian\Bus\Subscriber;
    use Locrian\Collections\Queue;
    use PHPUnit_Framework_TestCase;

    class BusTest extends PHPUnit_Framework_TestCase implements Subscriber{

        /**
         * @var EventBus
         */
        private $bus;

        /**
         * @var Queue
         */
        private $queue;

        const EVENT_TYPE = "test_event_type";
        const EVENT_TYPE2 = "test_event_type2";

        protected function setUp(){
            $this->queue = new Queue();
            $this->bus = new EventBus(false);
            $this->bus->subscribe(self::EVENT_TYPE, $this);
            $this->bus->subscribe(self::EVENT_TYPE2, $this);
        }

        public function testEvent(){
            $e1 = new Event(self::EVENT_TYPE, "New Event1");
            $e2 = new Event(self::EVENT_TYPE2, "New Event2");
            $this->queue->push($e1);
            $this->queue->push($e2);
            $this->bus->publish($e1);
            $this->bus->publish($e2);
        }

        public function testEventChannels(){
            $ch = $this->bus->getEventChannels();
            self::assertEquals(self::EVENT_TYPE, $ch->get(0));
            self::assertEquals(self::EVENT_TYPE2, $ch->get(1));
        }

        /**
         * @param Event $event
         * Subscribers will receive Events which are subscribed before
         */
        public function receive(Event $event){
            $e = $this->queue->pop();
            self::assertEquals($e->getEventType(), $event->getEventType());
            self::assertEquals($e->getEvent(), $event->getEvent());
        }

    }