text:
<?php
class PO_Ajax {
	var $PO;
	function __construct($PO) {
		$this->PO = $PO;
	}

	function save_order() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}
		$returnStatus = "";
		if ( current_user_can( 'activate_plugins' ) ) {
			$plugins = $this->PO->get_active_plugins();
			if (preg_match("/^(([0-9])+[,]*)*$/", implode(",", $_POST['orderList'])) && preg_match("/^(([0-9])+[,]*)*$/", implode(",", $_POST['startOrder']))) {
				$newPlugArray = $_POST['orderList'];
				$startOrderArray = $_POST['startOrder'];
				if (sizeof(array_unique($newPlugArray)) == sizeof($plugins) && sizeof(array_unique($startOrderArray)) == sizeof($plugins)) {
					array_multisort($startOrderArray, $newPlugArray);
					array_multisort($newPlugArray, $plugins);
					update_option("active_plugins", $plugins);
					update_option("PO_plugin_order", $plugins);
					$returnStatus = "The plugin load order has been changed.";
				} else {
					$returnStatus = "The order values were not unique so no changes were made.";
				}
			} else {
				$returnStatus = "Did not recieve the proper variables.  No changes made.";
			}
		} else {
			$returnStatus = "You dont have permissions to access this page.";
		}
		print $returnStatus;
		die();
	}

	function create_group() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce']) || !current_user_can('activate_plugins')) {
			print "You dont have permissions to access this page.";
			die();
		}
		$returnStatus = "";
		$plugins = $this->PO->get_active_plugins();
		if (is_array($_POST['PO_group_list']) && $this->PO->validate_field('PO_group_name')) {
			$groupID = wp_insert_post(array('post_title'=>$_POST['PO_group_name'], 'post_type'=>'plugin_group', 'post_status'=>'publish'));
			if (!is_wp_error($groupID)) {
				update_post_meta($groupID, '_PO_group_members', $_POST['PO_group_list']);
				$returnStatus = "The " . get_the_title($groupID) . " group was created and the selected plugins have been added to it.
";
			} else {
				$returnStatus = "There was a problem creating the group.
";
			}

		} else {
			$returnStatus = "Did not recieve the proper variables.  No changes made.
";
		}
		print $returnStatus;
		die();
	}

	function delete_group() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce']) || !current_user_can('activate_plugins')) {
			print "You dont have permissions to access this page.";
			die();
		}
		$returnStatus = "";
		if (is_array($_POST['PO_group_ids'])) {
			foreach($_POST['PO_group_ids'] as $groupID) {
				if (is_numeric($groupID)) {
					$groupName = get_the_title($groupID);
					$result = wp_delete_post($groupID, true);
					if ($result) {
						$returnStatus .= "The " . $groupName . " plugin group has been deleted.
";
					} else {
						$returnStatus .= "There was a problem deleting the " . $groupName . " plugin group.
";
					}
				}
			}
		}
		print $returnStatus;
		die();
	}

	function remove_plugins_from_group() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce']) || !current_user_can('activate_plugins')) {
			print "You dont have permissions to access this page.";
			die();
		}
		$returnStatus = "";
		if (is_array($_POST['PO_group_ids']) && is_array($_POST['PO_group_list'])) {
			foreach($_POST['PO_group_ids'] as $groupID) {
				if (is_numeric($groupID)) {
					$members = get_post_meta($groupID, '_PO_group_members', $single=true);
					if (!is_array($members)) {
						$members = array();
					}
					foreach($_POST['PO_group_list'] as $key=>$pluginToRemove) {
						if (array_search($pluginToRemove, $members) !== FALSE) {
							unset($members[array_search($pluginToRemove, $members)]);
						}
					}
					$members = array_values($members);
					if ($members === get_post_meta($groupID, '_PO_group_members', $single=true)) {
						$returnStatus .= "The selected plugins were not found in the " . get_the_title($groupID) . " group.
";
					} else {
						$result = update_post_meta($groupID, "_PO_group_members", $members);
						if ($result) {
							$returnStatus .= "The selected plugins were removed from the " . get_the_title($groupID) . " group.
";
						} else {
							$returnStatus .= "There was a problem removing the plugins from the " . get_the_title($groupID) . " group.
";
						}
					}
				}
			}
		}
		print $returnStatus;
		die();

	}

	function add_to_group() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce']) || !current_user_can('activate_plugins')) {
			print "You dont have permissions to access this page.";
			die();
		}
		$returnStatus = "";
		$plugins = $this->PO->get_active_plugins();
		if (is_array($_POST['PO_group_list']) && is_array($_POST['PO_group_ids'])) {
			foreach($_POST['PO_group_ids'] as $groupID) {
				if (is_numeric($groupID)) {
					$members = get_post_meta($groupID, '_PO_group_members', $single=true);
					$members = stripslashes_deep($members);
					if (!is_array($members)) {
						$members = array();
					}

					foreach($_POST['PO_group_list'] as $newGroupMember) {
						#print $newGroupMember . " - " . array_search($newGroupMember, $members) . "\n";
						if (array_search($newGroupMember, $members) === FALSE) {
							$members[]=$newGroupMember;
						}
					}
					if ($members === get_post_meta($groupID, '_PO_group_members', $single=true)) {
						$returnStatus .= "The selected plugins were not added to the " . get_the_title($groupID) . " group because they already belong to it.
";
					} else {
						update_post_meta($groupID, "_PO_group_members", $members);
						$returnStatus .= "The selected plugins were added to the " . get_the_title($groupID) . " group.
";
					}
				}
			}
		} else {
			$returnStatus = "Did not recieve the proper variables.  No changes made.";
		}
		print $returnStatus;
		die();
	}

	function edit_plugin_group_name() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce']) || !current_user_can( 'activate_plugins' ) ) {
			print "You dont have permissions to access this page.";
			die();
		}
		$returnStatus = "";
		if (is_numeric($_POST['PO_group_id']) && $this->PO->validate_field('PO_group_name')) {
			$oldGroupTitle = get_the_title($_POST['PO_group_id']);
			$post_id = wp_update_post(array('ID'=>$_POST['PO_group_id'], 'post_title'=>$_POST['PO_group_name']));
			if ($post_id > 0) {
				$newGroupTitle = get_the_title($_POST['PO_group_id']);
				$returnStatus = "The " . $oldGroupTitle . " group was successfully changed to " . $newGroupTitle . ".
";
			} else {
				$returnStatus = "There was an error and the " . $oldGroupTitle . " group was not changed.
";
			}
		} else {
			$returnStatus = "No changes were made because the correct variables were not received.
";
		}
		print $returnStatus;
		die();
	}

	function save_global_plugins() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}
		$returnStatus = "";
		if ( current_user_can( 'activate_plugins' ) ) {
			if (isset($_POST['PO_disabled_std_plugin_list']) && is_array($_POST['PO_disabled_std_plugin_list']) && $_POST['PO_disabled_std_plugin_list'][0] != 'EMPTY') {
				$disabledPlugins = $_POST['PO_disabled_std_plugin_list'];
				update_option("PO_disabled_plugins", $disabledPlugins);
				$returnStatus .= "Global plugin list has been saved.
";
			} else {
				update_option("PO_disabled_plugins", array());
				$returnStatus .= "Global plugin list has been saved.
";
			}

			if (isset($_POST['PO_disabled_std_group_list']) && is_array($_POST['PO_disabled_std_group_list']) && $_POST['PO_disabled_std_group_list'][0] != 'EMPTY') {
				$disabledGroups = $_POST['PO_disabled_std_group_list'];
				update_option("PO_disabled_groups", $disabledGroups);
				$returnStatus .= "Global group list has been saved.
";
			} else {
				update_option("PO_disabled_groups", array());
				$returnStatus .= "Global group list has been saved.
";
			}

			if (get_option('PO_disable_mobile_plugins') == 1) {
				if (isset($_POST['PO_disabled_mobile_plugin_list']) && is_array($_POST['PO_disabled_mobile_plugin_list']) && $_POST['PO_disabled_mobile_plugin_list'][0] != 'EMPTY') {
					$disabledMobilePlugins = $_POST['PO_disabled_mobile_plugin_list'];
					update_option("PO_disabled_mobile_plugins", $disabledMobilePlugins);
					$returnStatus .= "Global mobile plugin list has been saved.
";
				} else {
					update_option("PO_disabled_mobile_plugins", array());
					$returnStatus .= "Global mobile plugin list has been saved.
";
				}

				if (isset($_POST['PO_disabled_mobile_group_list']) && is_array($_POST['PO_disabled_mobile_group_list']) && $_POST['PO_disabled_mobile_group_list'][0] != 'EMPTY') {
					$disabledMobileGroups = $_POST['PO_disabled_mobile_group_list'];
					update_option("PO_disabled_mobile_groups", $disabledMobileGroups);
					$returnStatus .= "Global mobile group list has been saved.
";
				} else {
					update_option("PO_disabled_mobile_groups", array());
					$returnStatus .= "Global mobile group list has been saved.
";
				}
			}
		} else {
			$returnStatus .= "You dont have permissions to access this page.
";
		}
		print $returnStatus;
		die();
	}

	function save_search_plugins() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}

		$submittedPlugins = $this->PO->get_submitted_plugin_lists();

		update_option('PO_disabled_search_plugins', $submittedPlugins[0]);
		update_option('PO_enabled_search_plugins', $submittedPlugins[1]);
		update_option('PO_disabled_mobile_search_plugins', $submittedPlugins[2]);
		update_option('PO_enabled_mobile_search_plugins', $submittedPlugins[3]);
		update_option('PO_disabled_search_groups', $submittedPlugins[4]);
		update_option('PO_enabled_search_groups', $submittedPlugins[5]);
		update_option('PO_disabled_mobile_search_groups', $submittedPlugins[6]);
		update_option('PO_enabled_mobile_search_groups', $submittedPlugins[7]);

		print "Search plugins updated!";
		die();
	}

	function save_pt_plugins() {
		global $wpdb;
		$returnVals = array('success'=>0, 'msg'=>'', 'total'=>0, 'offset'=>0);
		if ( !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			$returnVals['msg'] = "You dont have permissions to access this page.";
			print json_encode($returnVals);
			die();
		}

		if (isset($_POST['selectedPostType']) && $_POST['selectedPostType'] != '') {
			$postType = $_POST['selectedPostType'];
		} else {
			$returnVals['msg'] = "Plugins were not updated because no post type was recieved!";
			print json_encode($returnVals);
			die();
		}

		$supportedPostTypes = get_option("PO_custom_post_type_support");
		if (!is_array($supportedPostTypes)) {
			$supportedPostTypes = array();
		}

		if (is_numeric($_POST['PO_post_offset'])) {
			$returnVals['offset'] = $_POST['PO_post_offset'];
		} else {
			$returnVals['msg'] = "Plugins were not updated because there was a problem calculating the number of posts to update.";
			print json_encode($returnVals);
			die();
		}

		if (!in_array($postType, $supportedPostTypes)) {
			$returnVals['msg'] = "Plugins were not updated because you have not selected this post type on the settings page.";
			print json_encode($returnVals);
			die();
		}

		$submittedPlugins = $this->PO->get_submitted_plugin_lists();
		update_option('PO_disabled_pt_plugins_'.$postType, $submittedPlugins[0]);
		update_option('PO_enabled_pt_plugins_'.$postType, $submittedPlugins[1]);
		update_option('PO_disabled_mobile_pt_plugins_'.$postType, $submittedPlugins[2]);
		update_option('PO_enabled_mobile_pt_plugins_'.$postType, $submittedPlugins[3]);
		update_option('PO_disabled_pt_groups_'.$postType, $submittedPlugins[4]);
		update_option('PO_enabled_pt_groups_'.$postType, $submittedPlugins[5]);
		update_option('PO_disabled_mobile_pt_groups_'.$postType, $submittedPlugins[6]);
		update_option('PO_enabled_mobile_pt_groups_'.$postType, $submittedPlugins[7]);

		$ptStored = get_option('PO_pt_stored');
		if (!is_array($ptStored)) {
			$ptStored = array();
		}

		if (!in_array($postType, $ptStored)) {
			$ptStored[] = $postType;
			update_option('PO_pt_stored', $ptStored);
		}

		if (!is_numeric($_POST['PO_total_post_count']) || $_POST['PO_total_post_count'] == 0) {
			$query = "SELECT COUNT(*) AS num_posts FROM ".$wpdb->posts." WHERE post_type = %s";
			$returnVals['total'] = $wpdb->get_var($wpdb->prepare($query, $postType));
		} else {
			$returnVals['total'] = $_POST['PO_total_post_count'];
		}

		$allPosts = get_posts(array('post_type'=>$postType, 'posts_per_page'=>100, 'offset'=>$returnVals['offset'], 'orderby'=>'post_id'));
		foreach($allPosts as $post) {
			$postStatus = get_post_status($post->ID);
			if (!$postStatus) {
				$postStatus = 'publish';
			}

			$ptOverride = $wpdb->get_var($wpdb->prepare("SELECT pt_override FROM ".$wpdb->prefix."po_plugins WHERE post_id=%d", $post->ID));

			$secure=0;
			if (preg_match('/^.{1,5}:\/\//', get_permalink($post->ID), $matches)) {
				switch ($matches[0]) {
					case "https://":
						$secure=1;
						break;
					default:
						$secure=0;
				}
			}
			$permalink = preg_replace('/^.{1,5}:\/\//', '', get_permalink($post->ID));

			$permalinkNoArgs = preg_replace('/\?.*$/', '', $permalink);

			$dirCount = substr_count($permalink, "/");
			if ($ptOverride == '0') {
				$wpdb->update($wpdb->prefix."po_plugins", array("permalink"=>$permalink, "permalink_hash"=>md5($permalinkNoArgs), "permalink_hash_args"=>md5($permalink), "enabled_plugins"=>serialize($submittedPlugins[1]), "disabled_plugins"=>serialize($submittedPlugins[0]), "enabled_mobile_plugins"=>serialize($submittedPlugins[3]), "disabled_mobile_plugins"=>serialize($submittedPlugins[2]), "enabled_groups"=>serialize($submittedPlugins[5]), "disabled_groups"=>serialize($submittedPlugins[4]), "enabled_mobile_groups"=>serialize($submittedPlugins[7]), "disabled_mobile_groups"=>serialize($submittedPlugins[6]), "secure"=>$secure, "post_type"=>get_post_type($post->ID), "status"=>$postStatus, "dir_count"=>$dirCount), array("post_id"=>$post->ID));
			} else if ($ptOverride == '') {
				$wpdb->insert($wpdb->prefix."po_plugins", array("post_id"=>$post->ID, "permalink"=>$permalink, "permalink_hash"=>md5($permalinkNoArgs), "permalink_hash_args"=>md5($permalink), "enabled_plugins"=>serialize($submittedPlugins[1]), "disabled_plugins"=>serialize($submittedPlugins[0]), "enabled_mobile_plugins"=>serialize($submittedPlugins[3]), "disabled_mobile_plugins"=>serialize($submittedPlugins[2]), "enabled_groups"=>serialize($submittedPlugins[5]), "disabled_groups"=>serialize($submittedPlugins[4]), "enabled_mobile_groups"=>serialize($submittedPlugins[7]), "disabled_mobile_groups"=>serialize($submittedPlugins[6]), "secure"=>$secure, "post_type"=>get_post_type($post->ID), "status"=>$postStatus, "dir_count"=>$dirCount));
			}
		}

		$returnVals['success'] = 1;
		$returnVals['msg'] = "Plugins updated for " . $_POST['selectedPostType'] . ".";
		print json_encode($returnVals);
		die();
	}

	function get_pt_plugins() {
		if ( !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}
		if (!isset($_POST['selectedPostType']) || !in_array($_POST['selectedPostType'], get_option('PO_custom_post_type_support'))) {
			print "post_type_not_supported";
			die();
		} else {
			$postType=$_POST['selectedPostType'];
		}

		$pluginLists = array();
		$pluginLists[] = get_option('PO_disabled_pt_plugins_'.$postType);
		$pluginLists[] = get_option('PO_enabled_pt_plugins_'.$postType);
		$pluginLists[] = get_option('PO_disabled_mobile_pt_plugins_'.$postType);
		$pluginLists[] = get_option('PO_enabled_mobile_pt_plugins_'.$postType);
		$pluginLists[] = get_option('PO_disabled_pt_groups_'.$postType);
		$pluginLists[] = get_option('PO_enabled_pt_groups_'.$postType);
		$pluginLists[] = get_option('PO_disabled_mobile_pt_groups_'.$postType);
		$pluginLists[] = get_option('PO_enabled_mobile_pt_groups_'.$postType);
		print json_encode($pluginLists);
		die();
	}

	function reset_pt_settings() {
		global $wpdb;
		if ( !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}
		if (!isset($_POST['selectedPostType']) || !in_array($_POST['selectedPostType'], get_option('PO_custom_post_type_support'))) {
			print "post_type_not_supported";
			die();
		} else {
			$postType=$_POST['selectedPostType'];
		}

		delete_option('PO_disabled_pt_plugins_'.$postType);
		delete_option('PO_enabled_pt_plugins_'.$postType);
		delete_option('PO_disabled_mobile_pt_plugins_'.$postType);
		delete_option('PO_enabled_mobile_pt_plugins_'.$postType);
		delete_option('PO_disabled_pt_groups_'.$postType);
		delete_option('PO_enabled_pt_groups_'.$postType);
		delete_option('PO_disabled_mobile_pt_groups_'.$postType);
		delete_option('PO_enabled_mobile_pt_groups_'.$postType);

		$ptStored = get_option('PO_pt_stored');
		if (!is_array($ptStored)) {
			$ptStored = array();
		}

		if (in_array($postType, $ptStored)) {
			unset($ptStored[array_search($postType, $ptStored)]);
			update_option('PO_pt_stored', array_values($ptStored));
		}

		print "Plugin settings have been reset to default for the " . $postType . " post type.
";
		if (isset($_POST['PO_reset_all_pt']) && $_POST['PO_reset_all_pt'] == "1") {
			$allPosts = get_posts(array('post_type'=>$postType, 'posts_per_page'=>-1));
			foreach($allPosts as $post) {
				$ptOverride = $wpdb->get_var($wpdb->prepare("SELECT pt_override FROM ".$wpdb->prefix."po_plugins WHERE post_id=%d", $post->ID));
				if ($ptOverride == '0') {
					$wpdb->delete($wpdb->prefix."po_plugins", array("post_id"=>$post->ID));
				}
			}
			print "
Plugin settings were also reset on each " . $postType . ".
";
		}

		die();
	}

	function redo_permalinks() {
		global $wpdb;
		if (!empty($_POST['old_site_address'])) {
			$oldSiteAddress = preg_quote($this->PO->fix_trailng_slash($_POST['old_site_address']), "/");
		} else {
			$oldSiteAddress = "";
		}

		if (!empty($_POST['new_site_address'])) {
			$newSiteAddress = $this->PO->fix_trailng_slash($_POST['new_site_address']);
		} else {
			$newSiteAddress = "";
		}

		$failedCount = 0;
		$updatedCount = 0;
		$noUpdateCount = 0;
		if ( !current_user_can( 'activate_plugins' ) || !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}
		$postIDsQuery = "SELECT post_id FROM ".$wpdb->prefix."po_plugins WHERE post_type != 'plugin_filter'";
		$postIDs = $wpdb->get_results($postIDsQuery, ARRAY_A);
		foreach ($postIDs as $postID) {
			$post = get_post($postID['post_id']);
			if (!is_null($post)) {
				$secure=0;
				if (preg_match('/^.{1,5}:\/\//', get_permalink($post->ID), $matches)) {
					switch ($matches[0]) {
						case "https://":
							$secure=1;
							break;
						default:
							$secure=0;
					}
				}
				$permalink = preg_replace('/^.{1,5}:\/\//', '', get_permalink($post->ID));

				$dirCount = substr_count($permalink, "/");
				if ($permalink != $wpdb->get_var("SELECT permalink FROM ".$wpdb->prefix."po_plugins WHERE post_id=".$post->ID)) {

					if ($wpdb->get_var("SELECT count(*) FROM ".$wpdb->prefix."po_plugins WHERE post_id=".$post->ID) > 0) {
						if($wpdb->update($wpdb->prefix."po_plugins", array('permalink'=>$permalink, 'permalink_hash'=>md5($permalink), 'permalink_hash_args'=>md5($permalink), 'secure'=>$secure, "dir_count"=>$dirCount), array("post_id"=>$post->ID))) {
							$updatedCount++;
						} else {
							$failedCount++;
						}
					} else {
						if ($wpdb->insert($wpdb->prefix."po_plugins", array("enabled_mobile_plugins"=>serialize(array()), "disabled_mobile_plugins"=>serialize(array()), "enabled_plugins"=>serialize(array()), "disabled_plugins"=>serialize(array()), "post_type"=>get_post_type($post->ID), "permalink"=>$permalink, "permalink_hash"=>md5($permalink), "permalink_hash_args"=>md5($permalink), "children"=>0, "secure"=>$secure, "post_id"=>$post->ID, "dir_count"=>$dirCount))) {
							$updatedCount++;
						} else {
							$failedCount++;
						}
					}
				} else {
					$noUpdateCount++;
				}
			} else {
				$failedCount++;
			}
		}

		if ($oldSiteAddress != "" && $newSiteAddress != "") {
			$filterQuery = "SELECT * FROM ".$wpdb->prefix."po_plugins WHERE post_type = 'plugin_filter'";
			$filters = $wpdb->get_results($filterQuery, ARRAY_A);
			foreach ($filters as $filter) {
				$filterObject = get_post($filter['post_id']);
				if (!is_null($filterObject)) {
					if (preg_match('/^'.$oldSiteAddress.'/', $filter['permalink'])) {
						$permalink = preg_replace("/^".$oldSiteAddress."/", "".$newSiteAddress."", $filter['permalink']);
						$dirCount = substr_count($permalink, "/");
						if ($wpdb->update($wpdb->prefix."po_plugins", array('permalink'=>$permalink, 'permalink_hash'=>md5($permalink), 'permalink_hash_args'=>md5($permalink), "dir_count"=>$dirCount), array("post_id"=>$filter['post_id']))) {
							$updatedCount++;
						} else {
							$failedCount++;
						}
					} else {
						$noUpdateCount++;
					}
				}
			}
		} else {
			print "Plugin Filters were not updated since the new or old address was blank.
";
		}

		if ($failedCount > 0) {
			print $failedCount . " permalinks failed to update!
";
			print $updatedCount . " permalinks were updated successfully.
";
			print $noUpdateCount . " permalinks were already up to date.
";
		} else {
			print $updatedCount . " permalinks were updated successfully.
";
			print $noUpdateCount . " permalinks were already up to date.
";
		}
		die();
	}

	function manage_mu_plugin() {
		if ( !current_user_can( 'activate_plugins' ) || !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}
		$result = "";
		if ($_POST['selected_action'] == 'delete') {
			if (file_exists(WPMU_PLUGIN_DIR . "/PluginOrganizerMU.class.php")) {
				if (@unlink(WPMU_PLUGIN_DIR . "/PluginOrganizerMU.class.php")) {
					$result = "The MU plugin component has been removed.";
				} else {
					$result = "There was an issue removing the MU plugin component!";
				}
			} else {
				$result = "There was an issue removing the MU plugin component!";
			}
		} else if ($_POST['selected_action'] == 'move') {
			if (!file_exists(WPMU_PLUGIN_DIR)) {
				@mkdir(WPMU_PLUGIN_DIR);
			}
			if (file_exists($this->PO->pluginDirPath . "/" . plugin_basename(dirname(__FILE__)) . "/PluginOrganizerMU.class.php")) {
				@unlink(WPMU_PLUGIN_DIR . "/PluginOrganizerMU.class.php");
				@copy($this->PO->pluginDirPath . "/" . plugin_basename(dirname(__FILE__)) . "/PluginOrganizerMU.class.php", WPMU_PLUGIN_DIR . "/PluginOrganizerMU.class.php");
			}
			if (file_exists(WPMU_PLUGIN_DIR . "/PluginOrganizerMU.class.php")) {
				$result = "The MU plugin component has been moved to the mu-plugins folder.";
			} else {
				$result = "There was an issue moving the MU plugin component!";
			}
		}
		print $result;
		die();
	}

	function reset_plugin_order() {
		$activePlugins = $this->PO->get_active_plugins();
		usort($activePlugins, array($this, 'custom_sort_plugins'));
		$sortedPlugins = array();
		foreach ($activePlugins as $plugin) {
			if (is_plugin_active_for_network($plugin)) {
				$sortedPlugins[] = $plugin;
			}
		}

		foreach ($activePlugins as $plugin) {
			if (!is_plugin_active_for_network($plugin)) {
				$sortedPlugins[] = $plugin;
			}
		}
		update_option("active_plugins", $sortedPlugins);
		update_option("PO_plugin_order", $sortedPlugins);
		print "The order has been reset.";
		die();
	}

	function save_mobile_user_agents() {
		if ( !current_user_can( 'activate_plugins' ) || !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}

		$userAgents = preg_replace("/\\r\\n/", "\n", $_POST['PO_mobile_user_agents']);
		$userAgents = explode("\n", $userAgents);
		if (!is_array($userAgents)) {
			$userAgents = array();
		}
		foreach ($userAgents as $key=>$agent) {
			if ($agent == '') {
				unset($userAgents[$key]);
			}
		}

		if (get_option('PO_mobile_user_agents') == $userAgents) {
			print "The user agent list matches the database.";
		} else if (update_option('PO_mobile_user_agents', $userAgents)) {
			print "The user agents were saved.";
		} else {
			print "There was a problem saving the user agents.";
		}
		die();
	}

	function disable_admin_notices() {
		update_option('PO_disable_admin_notices', 1);
		die();
	}

	function submit_admin_css_settings() {
		if ( !current_user_can( 'activate_plugins' ) || !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}

		$result = '';
		$POAdminStyles = get_option('PO_admin_styles');
		if (!is_array($POAdminStyles)) {
			$POAdminStyles = array();
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_network_plugins_bg_color'])) {
			$POAdminStyles['network_plugins_bg_color'] = $_POST['PO_network_plugins_bg_color'];
		} else {
			$result .= "The text submitted for Network Plugin Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_network_plugins_font_color'])) {
			$POAdminStyles['network_plugins_font_color'] = $_POST['PO_network_plugins_font_color'];
		} else {
			$result .= "The text submitted for Network Plugin Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_active_plugins_bg_color'])) {
			$POAdminStyles['active_plugins_bg_color'] = $_POST['PO_active_plugins_bg_color'];
		} else {
			$result .= "The text submitted for Active Plugin Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_active_plugins_font_color'])) {
			$POAdminStyles['active_plugins_font_color'] = $_POST['PO_active_plugins_font_color'];
		} else {
			$result .= "The text submitted for Active Plugin Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_active_plugins_border_color'])) {
			$POAdminStyles['active_plugins_border_color'] = $_POST['PO_active_plugins_border_color'];
		} else {
			$result .= "The text submitted for Active Plugin Border is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_inactive_plugins_bg_color'])) {
			$POAdminStyles['inactive_plugins_bg_color'] = $_POST['PO_inactive_plugins_bg_color'];
		} else {
			$result .= "The text submitted for Inactive Plugin Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_inactive_plugins_font_color'])) {
			$POAdminStyles['inactive_plugins_font_color'] = $_POST['PO_inactive_plugins_font_color'];
		} else {
			$result .= "The text submitted for Inactive Plugin Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_inactive_plugins_border_color'])) {
			$POAdminStyles['inactive_plugins_border_color'] = $_POST['PO_inactive_plugins_border_color'];
		} else {
			$result .= "The text submitted for Inactive Plugin Border is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_plugin_groups_bg_color'])) {
			$POAdminStyles['plugin_groups_bg_color'] = $_POST['PO_plugin_groups_bg_color'];
		} else {
			$result .= "The text submitted for Plugin Group Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_plugin_groups_font_color'])) {
			$POAdminStyles['plugin_groups_font_color'] = $_POST['PO_plugin_groups_font_color'];
		} else {
			$result .= "The text submitted for Plugin Group Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_plugin_groups_border_color'])) {
			$POAdminStyles['plugin_groups_border_color'] = $_POST['PO_plugin_groups_border_color'];
		} else {
			$result .= "The text submitted for Plugin Group Border is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_global_plugins_bg_color'])) {
			$POAdminStyles['global_plugins_bg_color'] = $_POST['PO_global_plugins_bg_color'];
		} else {
			$result .= "The text submitted for Global Plugin Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_global_plugins_font_color'])) {
			$POAdminStyles['global_plugins_font_color'] = $_POST['PO_global_plugins_font_color'];
		} else {
			$result .= "The text submitted for Global Plugin Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_global_plugins_border_color'])) {
			$POAdminStyles['global_plugins_border_color'] = $_POST['PO_global_plugins_border_color'];
		} else {
			$result .= "The text submitted for Global Plugin Border is not a valid css hex color.
";
		}

		##Buttons

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_on_btn_bg_color'])) {
			$POAdminStyles['on_btn_bg_color'] = $_POST['PO_on_btn_bg_color'];
		} else {
			$result .= "The text submitted for On Button Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_on_btn_font_color'])) {
			$POAdminStyles['on_btn_font_color'] = $_POST['PO_on_btn_font_color'];
		} else {
			$result .= "The text submitted for On Button Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_off_btn_bg_color'])) {
			$POAdminStyles['off_btn_bg_color'] = $_POST['PO_off_btn_bg_color'];
		} else {
			$result .= "The text submitted for Off Button Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_off_btn_font_color'])) {
			$POAdminStyles['off_btn_font_color'] = $_POST['PO_off_btn_font_color'];
		} else {
			$result .= "The text submitted for Off Button Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_yes_btn_bg_color'])) {
			$POAdminStyles['yes_btn_bg_color'] = $_POST['PO_yes_btn_bg_color'];
		} else {
			$result .= "The text submitted for Yes Button Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_yes_btn_font_color'])) {
			$POAdminStyles['yes_btn_font_color'] = $_POST['PO_yes_btn_font_color'];
		} else {
			$result .= "The text submitted for Yes Button Font is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_no_btn_bg_color'])) {
			$POAdminStyles['no_btn_bg_color'] = $_POST['PO_no_btn_bg_color'];
		} else {
			$result .= "The text submitted for No Button Background is not a valid css hex color.
";
		}

		if (preg_match("/^(#[0-9A-Za-z]{0,6}|)$/", $_POST['PO_no_btn_font_color'])) {
			$POAdminStyles['no_btn_font_color'] = $_POST['PO_no_btn_font_color'];
		} else {
			$result .= "The text submitted for No Button Font is not a valid css hex color.
";
		}

		update_option('PO_admin_styles', $POAdminStyles);

		if ($result == '') {
			print "All settings saved successfully!";
		} else {
			print $result;
		}
		die();
	}

	function reset_post_settings() {
		global $wpdb;
		if ( !current_user_can( 'activate_plugins' ) || !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}

		if (is_numeric($_POST['postID'])) {
			if ($wpdb->get_var($wpdb->prepare("SELECT count(*) FROM ".$wpdb->prefix."po_plugins WHERE post_id=%d", $_POST['postID'])) > 0) {
				$deletePluginQuery = "DELETE FROM ".$wpdb->prefix."po_plugins WHERE post_id = %d";
				print $wpdb->query($wpdb->prepare($deletePluginQuery, $_POST['postID']));
			} else {
				print -1;
			}
		}
		die();
	}

	function save_gen_settings() {
		if ( !current_user_can( 'activate_plugins' ) || !$this->PO->verify_nonce($_POST['PO_nonce'])) {
			print "You dont have permissions to access this page.";
			die();
		}
		$result = "";

		##Fuzzy URL matching
		if ($_POST['PO_fuzzy_url_matching'] == "1") {
			update_option("PO_fuzzy_url_matching", 1);
			$result .= "Fuzzy URL matching is enabled.

";
		} else {
			update_option("PO_fuzzy_url_matching", 0);
			$result .= "Fuzzy URL matching is disabled.

";
		}

		##Ignore protocol
		if ($_POST['PO_ignore_protocol'] == "1") {
			update_option("PO_ignore_protocol", 1);
			$result .= "URL Protocol will be ignored.  http:// will be treated the same as https://

";
		} else {
			update_option("PO_ignore_protocol", 0);
			$result .= "URL Protocol will NOT be ignored.  http:// will NOT be treated the same as https://

";
		}

		##Ignore arguments
		if ($_POST['PO_ignore_arguments'] == "1") {
			update_option("PO_ignore_arguments", 1);
			$result .= "URL Arguments will be ignored.  " . home_url() . "?test=test will be treated the same as " . home_url() . "

";
		} else {
			update_option("PO_ignore_arguments", 0);
			$result .= "URL Arguments will NOT be ignored.  " . home_url() . "?test=test will NOT be treated the same as " . home_url() . "

";
		}

		##Network admin access
		if ($_POST['PO_order_access_net_admin'] == "1") {
			update_option('PO_order_access_net_admin', 1);
			$result .= "Only network admins will be able to change the plugin load order.

";
		} else {
			update_option('PO_order_access_net_admin', 0);
			$result .= "Any admin will be able to change the plugin load order.

";
		}

		##Auto trailing slash
		if ($_POST['PO_auto_trailing_slash'] == "1") {
			update_option("PO_auto_trailing_slash", 1);
			$result .= "Trailing slashes will automatically be removed or added based on your premalink structure.

";
		} else {
			update_option("PO_auto_trailing_slash", 0);
			$result .= "Trailing slashes will NOT automatically be removed or added.

";
		}

		##Custom post type support
		if (isset($_POST['PO_cutom_post_type']) && is_array($_POST['PO_cutom_post_type'])) {
			$submittedPostTypes = $_POST['PO_cutom_post_type'];
		} else {
			$submittedPostTypes = array();
		}

		update_option("PO_custom_post_type_support", $submittedPostTypes);
		if (sizeof(array_diff(get_option("PO_custom_post_type_support"), $submittedPostTypes)) == 0) {
			$result .= "Post types saved.

";
		} else {
			$result .= "Saving post types failed!

";
		}

		##Selective Plugin Loading
		if ($_POST['PO_disable_plugins'] == "1") {
			update_option("PO_disable_plugins", 1);
			$result .= "Selective Plugin Loading is enabled.
";
		} else {
			update_option("PO_disable_plugins", 0);
			$result .= "Selective Plugin Loading is disabled.
";
		}

		##Selective Mobile Plugin Loading
		if ($_POST['PO_disable_mobile_plugins'] == "1") {
			update_option("PO_disable_mobile_plugins", 1);
			$result .= "Selective Mobile Plugin loading is enabled.
";
		} else {
			update_option("PO_disable_mobile_plugins", 0);
			$result .= "Selective Mobile Plugin loading is disabled.
";
		}

		##Selective Admin Plugin Loading
		if ($_POST['PO_admin_disable_plugins'] == "1") {
			update_option("PO_admin_disable_plugins", 1);
			$result .= "Selective Admin Plugin Loading is enabled.
";
		} else {
			update_option("PO_admin_disable_plugins", 0);
			$result .= "Selective Admin Plugin Loading is disabled.
";
		}

		print $result;
		die();
	}

	function get_plugin_group_container() {
		$groups = get_posts(array('post_type'=>'plugin_group', 'posts_per_page'=>-1));
		$assignedGroups = "";
		foreach($groups as $group) {
			$members = $this->PO->get_group_members($group->ID);
			$members = stripslashes_deep($members);
			if (is_array($members) && array_search($_POST['PO_plugin_path'], $members) !== FALSE) {
				$assignedGroups .= 'ID.'">'.$group->post_title.'

';
			}
		}
		print $assignedGroups;
		die();
	}

	function get_group_list() {
		$groups = get_posts(array('post_type'=>'plugin_group', 'posts_per_page'=>-1));
		$groupNames = array();
		foreach($groups as $group) {
			$groupNames[] = array($group->ID, $group->post_title);
		}
		print json_encode($groupNames);
		die();
	}

	function custom_sort_plugins($a, $b) {
		$aData = get_plugin_data($this->PO->pluginDirPath.'/'.$a);
		$bData = get_plugin_data($this->PO->pluginDirPath.'/'.$b);
		return strcasecmp($aData['Name'], $bData['Name']);
	}
}
?>


text:
import unittest
from datetime import date

from infi.clickhouse_orm.database import Database
from infi.clickhouse_orm.models import Model
from infi.clickhouse_orm.fields import *
from infi.clickhouse_orm.engines import *

class ArrayFieldsTest(unittest.TestCase):

    def setUp(self):
        self.database = Database('test-db', log_statements=True)
        self.database.create_table(ModelWithArrays)

    def tearDown(self):
        self.database.drop_database()

    def test_insert_and_select(self):
        instance = ModelWithArrays(
            date_field='2016-08-30',
            arr_str=['goodbye,', 'cruel', 'world', 'special chars: ,"\\\'` \n\t\\[]'],
            arr_date=['2010-01-01'],
        )
        self.database.insert([instance])
        query = 'SELECT * from $db.modelwitharrays ORDER BY date_field'
        for model_cls in (ModelWithArrays, None):
            results = list(self.database.select(query, model_cls))
            self.assertEqual(len(results), 1)
            self.assertEqual(results[0].arr_str, instance.arr_str)
            self.assertEqual(results[0].arr_int, instance.arr_int)
            self.assertEqual(results[0].arr_date, instance.arr_date)

    def test_conversion(self):
        instance = ModelWithArrays(
            arr_int=('1', '2', '3'),
            arr_date=['2010-01-01']
        )
        self.assertEqual(instance.arr_str, [])
        self.assertEqual(instance.arr_int, [1, 2, 3])
        self.assertEqual(instance.arr_date, [date(2010, 1, 1)])

    def test_assignment_error(self):
        instance = ModelWithArrays()
        for value in (7, 'x', [date.today()], ['aaa'], [None]):
            with self.assertRaises(ValueError):
                instance.arr_int = value

    def test_parse_array(self):
        from infi.clickhouse_orm.utils import parse_array, unescape
        self.assertEqual(parse_array("[]"), [])
        self.assertEqual(parse_array("[1, 2, 395, -44]"), ["1", "2", "395", "-44"])
        self.assertEqual(parse_array("['big','mouse','','!']"), ["big", "mouse", "", "!"])
        self.assertEqual(parse_array(unescape("['\\r\\n\\0\\t\\b']")), ["\r\n\0\t\b"])
        for s in ("",
                  "[",
                  "]",
                  "[1, 2",
                  "3, 4]",
                  "['aaa', 'aaa]"):
            with self.assertRaises(ValueError):
                parse_array(s)

    def test_invalid_inner_field(self):
        for x in (DateField, None, "", ArrayField(Int32Field())):
            with self.assertRaises(AssertionError):
                ArrayField(x)

class ModelWithArrays(Model):

    date_field = DateField()
    arr_str = ArrayField(StringField())
    arr_int = ArrayField(Int32Field())
    arr_date = ArrayField(DateField())

    engine = MergeTree('date_field', ('date_field',))

redpajama_set_name: RedPajamaGithub


text:
namespace crashpad {
namespace internal {

bool ReinterpretBytesImpl(const char* data,
                          size_t data_size,
                          char* dest,
                          size_t dest_size) {
  // Verify that any unused bytes from data are zero.
  // The unused bytes are at the start of the data buffer for big-endian and the
  // end of the buffer for little-endian.
  if (dest_size < data_size) {
    auto extra_bytes = data;
#if defined(ARCH_CPU_LITTLE_ENDIAN)
    extra_bytes += dest_size;
#endif  // ARCH_CPU_LITTLE_ENDIAN

    uint64_t zero = 0;
    size_t extra_bytes_size = data_size - dest_size;
    while (extra_bytes_size > 0) {
      size_t to_check = std::min(extra_bytes_size, sizeof(zero));
      if (memcmp(extra_bytes, &zero, to_check) != 0) {
        LOG(ERROR) << "information loss";
        return false;
      }
      extra_bytes += to_check;
      extra_bytes_size -= to_check;
    }
  }

  // Zero out the destination, in case it is larger than data.
  memset(dest, 0, dest_size);

#if defined(ARCH_CPU_LITTLE_ENDIAN)
  // Copy a prefix of data to a prefix of dest for little-endian
  memcpy(dest, data, std::min(dest_size, data_size));
#else
  // or the suffix of data to the suffix of dest for big-endian
  if (data_size >= dest_size) {
    memcpy(dest, data + data_size - dest_size, dest_size);
  } else {
    memcpy(dest + dest_size - data_size, data, data_size);
  }
#endif  // ARCH_CPU_LITTLE_ENDIAN
  return true;
}

}  // namespace internal
}  // namespace crashpad


text:
**Namespace:** [OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.V201508](OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.V201508.md)
**Assembly:** OfficeDevPnP.Core.dll
## Syntax
```C#
public XmlElement SearchSettings { get; set; }
```

### Property Value
Type: System.Xml.XmlElement

## See also
- [ProvisioningTemplate](OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.V201508.ProvisioningTemplate.md)
- [OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.V201508](OfficeDevPnP.Core.Framework.Provisioning.Providers.Xml.V201508.md)


text:
#ifndef _LOG4CXX_PATTERN_CLASSNAME_PATTERN_CONVERTER_H
#define _LOG4CXX_PATTERN_CLASSNAME_PATTERN_CONVERTER_H

#include <log4cxx/pattern/namepatternconverter.h>

namespace log4cxx {
 namespace pattern {

/**
 * Formats the class name of the site of the logging request.
 *
 *
 *
 */
class LOG4CXX_EXPORT ClassNamePatternConverter : public NamePatternConverter {
  /**
   * Private constructor.
   * @param options options, may be null.
   * @param logger logger for diagnostic messages, may be null.
   */
  ClassNamePatternConverter(
    const std::vector<LogString>& options);

public:
   DECLARE_LOG4CXX_PATTERN(ClassNamePatternConverter)
   BEGIN_LOG4CXX_CAST_MAP()
        LOG4CXX_CAST_ENTRY(ClassNamePatternConverter)
        LOG4CXX_CAST_ENTRY_CHAIN(NamePatternConverter)
   END_LOG4CXX_CAST_MAP()

  /**
   * Gets an instance of ClassNamePatternConverter.
   * @param options options, may be null.
   * @return instance of pattern converter.
   */
  static PatternConverterPtr newInstance(
    const std::vector<LogString>& options);

  using NamePatternConverter::format;

  void format(const log4cxx::spi::LoggingEventPtr&event,
     LogString& toAppendTo,
     log4cxx::helpers::Pool& p) const;
};

 }
}
#endif


text:
//
//  SCPopupMenu.h
//  C2CallPhone
//
//  Created by Michael Knecht on 07.04.13.
//  Copyright 2013 C2Call GmbH. All rights reserved.
//
//

#import <UIKit/UIKit.h>

/** Presents a standard C2Call SDK Popup Menu.

 SCPopupMenu is a convenient PopMenu Control to show menu choices in any ViewController.

 Example Code:
     SCPopupMenu *cv = [SCPopupMenu popupMenu:self];

    [cv addChoiceWithName:NSLocalizedString(@"Forward", @"MenuItem") andSubTitle:NSLocalizedString(@"Forward to another FriendCaller user", @"Button") andIcon:[UIImage imageNamed:@"ico_forward"] andCompletion:^{
        [self forwardMessage:nil];
    }];

    [cv addCancelWithName:NSLocalizedString(@"Cancel", @"Button") andCompletion:^{

    }];
    [cv showMenu];

 */

@interface SCPopupMenu : UIViewController

/** Shows a Cancel Button as part of the PopupMenu.

 @param name - Name of the Button (e.g. @"Cancel")
 @param completion - The Block executed on Button Click

 */
-(void) addCancelWithName:(NSString *)name andCompletion:(void (^)())completion;

/** Shows a Menu Choice with Name, Subtitle and Icon as part of the PopupMenu.

 @param name - The Choice Name
 @param subTitle - Sub Title to the Choice Name (optional)
 @param icon - The Choice Icon (optional)
 @param completion - The Block executed on Button Click

 */
-(void) addChoiceWithName:(NSString *) name andSubTitle:(NSString *) subTitle andIcon:(UIImage *) icon andCompletion:(void (^)())_completion;

/** Shows PopupMenu.
 */
-(void) showMenu;

/** Hides PopupMenu with completion handler.

 For internal use...

 @param completion - The Block executed on hide
 */
-(void) hideMenu:(void (^)())_completion;

/** @name Static Methods */
/** Creates an Instance of SCPopupMenu.

 @param parent - Presenting ViewController
 */
+(SCPopupMenu *) popupMenu:(UIViewController *) parent;

@end


text:
package org.jbpm.designer.web.plugin.impl;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import javax.servlet.ServletContext;

/**
 * @author Antoine Toulme
 * A default implementation of a plugin for plugins defined inside the Process Designer web application
 */
public class LocalResource {

    private String _path;
    private String _name;

    public LocalResource(String name, String path, ServletContext context) {
        this._name = name;
        StringBuilder localPath = new StringBuilder();
        localPath.append("js").append("/").append("Plugins").append("/").append(path);
        this._path = context.getRealPath(localPath.toString());
    }

    public LocalResource(String name, String path) {
        this._name = name;
        this._path = path;
    }

    public String getName() {
        return _name;
    }

    public InputStream getContents() {
        try {
            return new FileInputStream(_path);
        } catch (FileNotFoundException e) {
            throw new IllegalArgumentException(e);
        }
    }
}


text:
MINIGAME.Base = "base"
MINIGAME.Unique = "jumpfive"

MINIGAME.Name = "Jump Five"
MINIGAME.Description = "Be the first to jump 5 times!"
MINIGAME.Author = "Chewgum"


text:
describe('Core_updateSettings', function () {
  var id = 'testContainer';

  beforeEach(function () {
    this.$container = $('

').appendTo('body');
  });

  afterEach(function () {
    if (this.$container) {
      destroy();
      this.$container.remove();
    }
  });

  it('should inherit cell type', function () {

    handsontable({
      data : [[1,2]],
      columns : [
        { },
        { type : 'checkbox' }
      ],
      cells : function (row, col, prop) {
        if (row === 0 && col === 0) {
          return {
            type : 'numeric'
          }
        }
      }
    });

    expect(getCellMeta(0, 0).type).toEqual('numeric');
    expect(getCellMeta(0, 1).type).toEqual('checkbox');

  });

  it('should not reset columns types to text', function () {
    handsontable({
      data : [[1, true]],
      columns : [
        { type : 'numeric' },
        { type : 'checkbox' }
      ]
    });

    var td = this.$container.find('td');

    expect(td.eq(0).text()).toEqual('1');
    expect(td.eq(1).text()).toEqual('');

    updateSettings({});

    expect(td.eq(0).text()).toEqual('1');
    expect(td.eq(1).text()).toEqual('');

  });

  it('should update readOnly global setting', function(){
    handsontable({
      readOnly: true,
      data : [['foo', 'bar']],
      columns : [
        { },
        { }
      ]
    });

    expect(getCellMeta(0, 0).readOnly).toBe(true);
    expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);

    expect(getCellMeta(0, 1).readOnly).toBe(true);
    expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(true);

    updateSettings({
      readOnly: false
    });

    expect(getCellMeta(0, 0).readOnly).toBe(false);
    expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);

    expect(getCellMeta(0, 1).readOnly).toBe(false);
    expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
  });

  it('should update readOnly columns setting', function(){
    handsontable({
      data : [['foo', true]],
      columns : [
        { type : 'text',
          readOnly: true
        },
        { type : 'checkbox' }
      ]
    });

    expect(getCellMeta(0, 0).readOnly).toBe(true);
    expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);

    expect(getCellMeta(0, 1).readOnly).toBe(false);
    expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);

    updateSettings({
      columns: [
        { type : 'text',
          readOnly: false
        },
        { type : 'checkbox' }
      ]
    });

    expect(getCellMeta(0, 0).readOnly).toBe(false);
    expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);

    expect(getCellMeta(0, 1).readOnly).toBe(false);
    expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
  });

  it('should update readOnly columns setting and override global setting', function(){
    handsontable({
      readOnly: true,
      data : [['foo', true]],
      columns : [
        { type : 'text'
        },
        { type : 'checkbox' }
      ]
    });

    expect(getCellMeta(0, 0).readOnly).toBe(true);
    expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(true);

    expect(getCellMeta(0, 1).readOnly).toBe(true);
    expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);

    updateSettings({
      columns: [
        { type : 'text',
          readOnly: false
        },
        { type : 'checkbox' }
      ]
    });

    expect(getCellMeta(0, 0).readOnly).toBe(false);
    expect($(getCell(0, 0)).hasClass('htDimmed')).toBe(false);

    expect(getCellMeta(0, 1).readOnly).toBe(true);
    expect($(getCell(0, 1)).hasClass('htDimmed')).toBe(false);
  });

  it("should not alter the columns object during init", function () {

    var columns = [
      {
        type: 'text'
      }
    ];

    var columnsCopy = JSON.parse(JSON.stringify(columns));

    handsontable({
      columns: columns
    });

    expect(columns).toEqual(columnsCopy);

  });

  it("should update column type", function () {

    var columns = [
      {
        type: 'text'
      }
    ];

    handsontable({
      columns: columns
    });

    expect(getCellMeta(0, 0).type).toEqual('text');
    expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.TextRenderer);
    expect(getCellEditor(0, 0)).toBe(Handsontable.TextCell.editor);

    columns[0].type = 'date';

    updateSettings({
      columns: columns
    });

    expect(getCellMeta(0, 0).type).toEqual('date');
    expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.AutocompleteRenderer);
    expect(getCellEditor(0, 0)).toEqual(Handsontable.DateCell.editor);

});

  it("should update cell type functions, even if new type does not implement all of those functions", function () {

    var columns = [
      {
        type: 'numeric'
      }
    ];

    handsontable({
      columns: columns
    });

    expect(getCellMeta(0, 0).type).toEqual('numeric');
    expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.NumericRenderer);
    expect(getCellEditor(0, 0)).toBe(Handsontable.NumericCell.editor);
    expect(getCellValidator(0, 0)).toBe(Handsontable.NumericCell.validator);

    columns[0].type = 'text';

    updateSettings({
      columns: columns
    });

    expect(getCellMeta(0, 0).type).toEqual('text');
    expect(getCellRenderer(0, 0)).toBe(Handsontable.renderers.TextRenderer);
    expect(getCellEditor(0, 0)).toEqual(Handsontable.TextCell.editor);
    expect(Handsontable.TextCell.validator).toBeUndefined();
    expect(getCellValidator(0, 0)).toBeUndefined();
  });

});


text:
using UnityEngine;
using System.Collections;

public class BuildingManager : MonoBehaviour
{

    public GameObject[] buildings;

    private BuildingPlacement buildingPlacement;

    [HideInInspector]
    public int[] buildingAmount = new int[5];

    // Use this for initialization
    void Start()
    {

        buildingPlacement = GetComponent<BuildingPlacement>();

        for (int i = 0; i < buildings.Length; i++)
        {
            buildingAmount[i] = 0;
        }
    }

    void Update()
    {

        /*  if (Input.GetKey(KeyCode.A)){
              buildingPlacement.SetItem(buildings[0]);
          }*/
    }
    public void ConstruirEdificio(int n)
    {
        buildingPlacement.SetItem(buildings[n]);
    }
    /* void OnGUI()
     {
         for (int i = 0; i < buildings.Length; i++){
             if (GUI.Button(new Rect(Screen.width / 20, Screen.height / 15 + Screen.height / 12 * i,100,30), buildings[i].name))
             {
                 buildingPlacement.SetItem(buildings[i]);
             }
         }
     }*/
}


text:
import pytest
import testinfra
import time

def assert_service_starts(Start_Service, Stop_Service, Service, name):
    rc = Start_Service(name)
    assert rc == 0

    print('sleeping to make sure service has a chance to startup')
    time.sleep(5)

    svc = Service(name)
    assert svc.is_running

    rc = Stop_Service(name)
    assert rc == 0

    svc = Service(name)
    assert svc.is_running == False

@pytest.mark.parametrize('name', [
    'storm-nimbus',
    'storm-drpc',
    'storm-logviewer',
    'storm-supervisor',
    'storm-ui',
])
def test_service_starts_up(Start_Service, Stop_Service, Service, name):
    assert_service_starts(Start_Service, Stop_Service, Service, name)


text:
var tiers = [];
var defaultDatasource = "_default";

var ruleTypes = [
  "loadByInterval",
  "loadByPeriod",
  "dropByInterval",
  "dropByPeriod",
  "dropBeforeByPeriod",
  "loadForever",
  "dropForever",
  "JSON"
];

function makeRuleDiv(rule) {
  var retVal = "
";

  if (rule === null || typeof rule === "undefined") {
    retVal += makeRuleComponents("") + makeRuleBody();
  } else {
    retVal += makeRuleComponents(rule.type) + makeRuleBody(rule);
  }

  retVal += "
";
  return retVal;
}

function makeRuleComponents(type) {
  var components = "<button type='button' class='delete_rule'>X</button>";
  components +=
  "" +
    "type" +
      "<select class='rule_dropdown_types'>" +
        "<option></option>";

  $.each(ruleTypes, function(index, ruleType) {
    if (ruleType === type) {
      components += "<option selected='selected' value='" + ruleType + "'>" + ruleType + "</option>";
    } else {
      components += "<option value='" + ruleType + "'>" + ruleType + "</option>";
    }
  });

  components +=
    "</select>" +
  "";

  return components;
}

function makeRuleBody(rule) {
  var retVal = "";
  if (rule !== null && typeof rule !== "undefined") {
    switch (rule.type) {
      case "loadByInterval":
        retVal += makeLoadByInterval(rule);
        break;
      case "loadByPeriod":
        retVal += makeLoadByPeriod(rule);
        break;
      case "loadForever":
        retVal += makeLoadForever(rule);
        break;
      case "dropByInterval":
        retVal += makeDropByInterval(rule);
        break;
      case "dropByPeriod":
        retVal += makeDropByPeriod(rule);
        break;
      case "dropBeforeByPeriod":
        retVal += makeDropBeforeByPeriod(rule);
        break;
      case "dropForever":
        retVal += "";
        break;
      case "JSON":
        retVal += makeJSON();
        break;
      default:
        break;
    }
  }
  retVal += "";
  return retVal;
}

function makeLoadByInterval(rule) {
  var retVal = "";
  retVal += "interval<input type='text' class='long_text' name='interval' " + "value='" + rule.interval + "'/>";
  retVal += "<button type='button' class='add_tier'>Add Another Tier</button>";
  if (rule.tieredReplicants === undefined) {
    retVal += makeTierLoad(null, 0);
  }
  for (var tier in rule.tieredReplicants) {
    retVal += makeTierLoad(tier, rule.tieredReplicants[tier]);
  }
  return retVal;
}

function makeLoadByPeriod(rule) {
  var retVal = "";
  retVal += "period<input type='text' name='period' " + "value='" + rule.period + "'/>";
  retVal += "includeFuture<input type='text' name='includeFuture' " + "value='" + true + "'/>";
  retVal += "<button type='button' class='add_tier'>Add Another Tier</button>";
  if (rule.tieredReplicants === undefined) {
    retVal += makeTierLoad(null, 0);
  }
  for (var tier in rule.tieredReplicants) {
    retVal += makeTierLoad(tier, rule.tieredReplicants[tier]);
  }
  return retVal;
}

function makeLoadForever(rule) {
  var retVal = "";
  retVal += "<button type='button' class='add_tier'>Add Another Tier</button>";
  if (rule.tieredReplicants === undefined) {
    retVal += makeTierLoad(null, 0);
  }
  for (var tier in rule.tieredReplicants) {
    retVal += makeTierLoad(tier, rule.tieredReplicants[tier]);
  }
  return retVal;
}

function makeTierLoad(tier, val) {
  return "
" +
         "replicants<input type='text' class='short_text' name='replicants' " + "value='" + val + "'/>" +
                      makeTiersDropdown(tier) +
         "
";
}

function makeDropByInterval(rule) {
  return "interval<input type='text' name='interval' " + "value='" + rule.interval + "'/>";
}

function makeDropByPeriod(rule) {
  var retVal = "";
  retVal += "period<input type='text' name='period' " + "value='" + rule.period + "'/>";
  retVal += "includeFuture<input type='text' name='includeFuture' " + "value='" + true + "'/>";
  return retVal;
}

function makeDropBeforeByPeriod(rule) {
  return "period<input type='text' name='period' " + "value='" + rule.period + "'/>";
}

function makeJSON() {
  return "JSON<input type='text' class='very_long_text' name='JSON'/>";
}

function makeTiersDropdown(selTier) {
  var retVal = "tier<select class='tiers' name='tier'>"

  if ($.inArray(selTier, tiers) == -1) {
    tiers.push(selTier);
  }

  $.each(tiers, function(index, tier) {
    if (selTier === tier) {
      retVal += "<option selected='selected' value='" + tier + "'>" + tier + "</option>";
    } else {
      retVal += "<option value='" + tier + "'>" + tier + "</option>";
    }
  });

  retVal += "</select>";
  return retVal;
}

function getRules() {
  var selected = $('#datasources option:selected').text();
  if (selected !== "") {
    $.getJSON("/druid/coordinator/v1/rules/" + selected, function(data) {
      $('#rules_list').empty();
      if (!$.isEmptyObject(data)) {
        $.each(data, function(index, rule) {
          $('#rules_list').append(makeRuleDiv(rule));
        });
      }
    });
  }
}

function domToRule(domRule) {
  var ruleType = $($(domRule).find(".rule_dropdown_types:first")).val();
  var inputs = $($(domRule).find(".rule_body:first")).children("input");

  // Special case for free form JSON
  if (ruleType === "JSON") {
    return $.parseJSON($(inputs.children("input:first")).val());
  }

  var rule = {};
  rule.type = ruleType;
  $.each(inputs, function(index, input) {
    var name = $(input).attr("name");
    rule[name] = $(input).val();
  });

  var theTiers = $($(domRule).find(".rule_body:first")).children(".rule_tier");

  var tieredReplicants = {};
  $.each(theTiers, function(index, theTier) {
    var tierName = $(theTier).find("select").val();
    var replicants = $(theTier).find("[name=replicants]").val();
    tieredReplicants[tierName] = replicants;
  });
  rule.tieredReplicants = tieredReplicants;

  return rule;
}

$(document).ready(function() {
  $("button").button();

  $("#rules_list").sortable();

  $("#error_dialog").dialog({
      autoOpen: false,
      modal:true,
      resizeable: false,
      buttons: {
        Ok : function() {
          $(this).dialog("close");
        }
      }
  });

  $("#cancel_dialog").dialog({
      autoOpen: false,
      modal:true,
      resizeable: false,
      buttons: {
        Yes : function() {
          getRules();
          $(this).dialog("close");
        },
        No: function() {
          $(this).dialog("close");
        }
      }
  });

  $("#update_dialog").dialog({
    autoOpen: false,
    modal:true,
    resizeable: false,
    buttons: {
      Yes : function() {
        var rules = [];
        $.each($("#rules_list").children(), function(index, domRule) {
          rules.push(domToRule(domRule));
        });

        var selected = $('#datasources option:selected').text();
        $.ajax({
          type: 'POST',
          url:'/druid/coordinator/v1/rules/' + selected,
          data: JSON.stringify(rules),
          contentType:"application/json; charset=utf-8",
          dataType:"text",
          error: function(xhr, status, error) {
            $("#update_dialog").dialog("close");
            $("#error_dialog").html(xhr.responseText);
            $("#error_dialog").dialog("open");
          },
          success: function(data, status, xhr) {
            $("#update_dialog").dialog("close");
          }
        });
      },
      Cancel: function() {
        $(this).dialog("close");
      }
    }
  });

  $.getJSON("/druid/coordinator/v1/tiers", function(theTiers) {
      tiers = theTiers;
  });

  $.getJSON("/druid/coordinator/v1/metadata/datasources", function(data) {
    $.each(data, function(index, datasource) {
      $('#datasources').append($('<option></option>').val(datasource).text(datasource));
    });
    $('#datasources').append($('<option></option>').val(defaultDatasource).text(defaultDatasource));
  });

  $("#datasources").change(function(event) {
    getRules();
    $("#rules").show();
  });

  $(document).on("change", '.rule_dropdown_types', null, function(event) {
    var newRule = {
      "type" : $(event.target).val()
    };
    var ruleBody = $(event.target).parent('.rule_dropdown').next('.rule_body');
    ruleBody.replaceWith(makeRuleBody(newRule));
  });

  $(document).on("click", '.delete_rule', null, function(event) {
    $(event.target).parent(".rule").remove();
  });

  $(document).on("click", '.add_tier', null, function(event) {
    $(event.target).parent().append(makeTierLoad(null, 0));
  });

  $("#create_new_rule").click(function (event) {
    $('#rules_list').prepend(makeRuleDiv());
  });

  $("#cancel").click(function() {
    $("#cancel_dialog").dialog("open");
  });

  $('#update').click(function (){
    $("#update_dialog").dialog("open")
  });
});


text:
enum PointTotal  { Pn1 = 1, Pn4 = 4, Pn5 = 5, Pn9=9, Pn13=13, Pn21=21, Pn25=25, Pn49=49, PnGamma = 256, NoPn = 999};
enum ColorType   { NoColor = 0, White, Red, Green, Blue, Dark, Nits, CrsTlk, CrsTlkW, CrsTlkD, JNDX, JND};
enum ParaOfPara  { PA_FEover = 0, PA_FElength, PA_D25RectSide, PA_NitsLv, PA_NitsDir, PA_JndGrayLv, PA_GmaBegin, PA_GmaEnd, PA_GmaAvg, PA_Max};
enum FEtype      { FT_1overN = 0, FT_Ncm };

class Nucleotide
{
//«Ø¸Ñºc¤l
public:
    Nucleotide(const ColorType& _C = NoColor, const PointTotal& _P = NoPn, const int& _N1 = -1, const int& _N2 = -1, const int& _N3 = -1);
    ~Nucleotide();

//¸Ó¶µ¥Ø¦@´XÂI
private:
    PointTotal  m_MsrPointTotal;
public:
                void SetMsrPointTotal(const PointTotal& pn);
    const PointTotal GetMsrPointTotal()    const;
    const    CString GetStrMsrPointTotal() const;

//I´ºÃC¦â
private:
    ColorType m_BkColor;
public:
               void SetBackColor(const ColorType& clr);
    const ColorType GetBackColor()    const;
    const   CString GetStrBackColor() const;

//°Ñ¼Æ¦ê
private:
             CString m_paraStr;
    std::vector<int> m_Parameters;
public:
             void SetPara(const ParaOfPara&, const int&);
    const     int GetPara(const ParaOfPara&) const;
    const CString GetStrPara() const;

//¹Bºâ¤l
    const BOOL operator==(const Nucleotide& vNucl) const;
          void operator= (const Nucleotide& vNucl);
    const BOOL equalMsrPtTotal(const Nucleotide& vCar) const;
	const BOOL equalBackColor(const Nucleotide& vCar) const;
	const BOOL equalParameter(const Nucleotide& vCar) const;

    const CString ShowMe() const;
};

inline const BOOL Nucleotide::equalMsrPtTotal(const Nucleotide& vCar) const
{
	return (GetMsrPointTotal() == vCar.GetMsrPointTotal())? TRUE : FALSE;
}

inline const BOOL Nucleotide::equalBackColor(const Nucleotide& vCar) const
{
	return (GetBackColor()  == vCar.GetBackColor() )? TRUE : FALSE;
}

inline const BOOL Nucleotide::equalParameter(const Nucleotide& vCar) const
{
	BOOL b(TRUE);
	if (vCar.m_Parameters.size() == m_Parameters.size())
	{
		for ( int i = 0; i < PA_Max; ++i)
		{
//			int b;
// 			int a, b, c;
// 			a = vCar.m_Parameters[i];
// 			b = m_Parameters[i];
// 			c = i;
			if (vCar.m_Parameters[i] != m_Parameters[i])
				b = FALSE;
		}
	}
	else
		ASSERT(0);

	return b;
}

#endif


text:
package jsonrpc

import "encoding/json"

// JSON-RPC 2.0 message types. Version field is ommited for brevity.

// Request is a JSON-RPC request object.
type Request struct {
	ID     string      `json:"id"`
	Method string      `json:"method"`
	Params interface{} `json:"params,omitempty"`
}

// Notification is a JSON-RPC notification object.
type Notification struct {
	Method string      `json:"method"`
	Params interface{} `json:"params,omitempty"`
}

// Response is a JSON-RPC response object.
type Response struct {
	ID     string      `json:"id"`
	Result interface{} `json:"result,omitempty"`
	Error  *ResError   `json:"error,omitempty"`
}

// ResError is a JSON-RPC response error object.
type ResError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

// message is a JSON-RPC request, response, or notification message.
// This is used internally only to manage incoming messages.
// We don't need this for outgoing messages as we always know their specific types.
type message struct {
	ID     string          `json:"id,omitempty"`
	Method string          `json:"method,omitempty"`
	Params json.RawMessage `json:"params,omitempty"` // request params
	Result json.RawMessage `json:"result,omitempty"` // response result
	Error  *resError       `json:"error,omitempty"`  // response error
}

type resError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}


text:
"""Module for testing network device discovery."""

import unittest

if __name__ == "__main__":
    import utils
    utils.import_depends()

from brokertest import TestBrokerCommand
from netdevtest import VerifyNetworkDeviceMixin

class TestDiscoverNetworkDevice(TestBrokerCommand, VerifyNetworkDeviceMixin):

    def test_100_add_swsync(self):
        ip = self.net["switch_sync"].usable[0]
        self.dsdb_expect_add("swsync.aqd-unittest.ms.com", ip,
                             interface="mgmt0", mac=ip.mac)
        self.noouttest(["add", "network_device", "--type", "misc",
                        "--network_device", "swsync.aqd-unittest.ms.com",
                        "--interface", "mgmt0", "--iftype", "physical",
                        "--ip", ip, "--mac", ip.mac,
                        "--rack", "ut3", "--model", "temp_switch"])
        self.dsdb_verify()

    def test_110_add_swsync_ifaces(self):
        self.noouttest(["add", "interface", "--network_device", "swsync",
                        "--interface", "vlan100", "--iftype", "virtual"])
        self.noouttest(["add", "interface", "--network_device", "swsync",
                        "--interface", "vlan200", "--iftype", "virtual"])
        self.noouttest(["add", "interface", "--network_device", "swsync",
                        "--interface", "vlan300", "--iftype", "virtual"])
        self.noouttest(["add", "interface", "--network_device", "swsync",
                        "--interface", "vlan400", "--iftype", "virtual"])

    def test_120_add_swsync_addrs(self):
        ip1 = self.net["switch_sync"].usable[1]
        ip2 = self.net["switch_sync"].usable[2]
        ip3 = self.net["switch_sync"].usable[3]
        self.dsdb_expect_add("swsync-vlan100.aqd-unittest.ms.com",
                             ip1, "vlan100",
                             primary="swsync.aqd-unittest.ms.com")
        self.dsdb_expect_add("swsync-nomatch.aqd-unittest.ms.com",
                             ip2, "vlan200",
                             primary="swsync.aqd-unittest.ms.com")
        self.dsdb_expect_add("swsync-vlan300.aqd-unittest.ms.com",
                             ip3, "vlan300",
                             primary="swsync.aqd-unittest.ms.com")
        self.noouttest(["add", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan100", "--ip", ip1,
                        "--fqdn", "swsync-vlan100.aqd-unittest.ms.com"])
        self.noouttest(["add", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan200", "--ip", ip2,
                        "--fqdn", "swsync-nomatch.aqd-unittest.ms.com"])
        self.noouttest(["add", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan300", "--ip", ip3,
                        "--fqdn", "swsync-vlan300.aqd-unittest.ms.com"])
        self.dsdb_verify()

    def test_200_show(self):
        ip1 = self.net["switch_sync"].usable[1]
        ip2 = self.net["switch_sync"].usable[2]
        ip3 = self.net["switch_sync"].usable[3]
        ip4 = self.net["switch_sync"].usable[4]
        ip5 = self.net["switch_sync"].usable[5]
        command = ["show", "network_device", "--network_device", "swsync", "--discover"]
        out = self.commandtest(command)
        self.matchoutput(out,
                         "aq update_network_device --network_device swsync.aqd-unittest.ms.com "
                         "--model ws-c2960-48tt-l --vendor cisco "
                         "--comments 'T1 T2'",
                         command)
        self.matchoutput(out, "aq del_interface_address "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan100 --ip %s" % ip1, command)
        self.matchoutput(out, "aq del_interface "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan400", command)
        self.matchoutput(out, "aq update_interface "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan200 --rename_to vlan210", command)
        self.matchoutput(out, "aq update_interface "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan300 --rename_to vlan310", command)
        self.matchoutput(out, "aq add_interface_address "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan100 --ip %s --label hsrp" % ip1,
                         command)
        self.matchoutput(out, "aq add_interface_address "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan100 --ip %s" % ip4, command)
        self.matchoutput(out, "aq add_interface "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan500 --iftype virtual", command)
        self.matchoutput(out, "aq add_interface_address "
                         "--network_device swsync.aqd-unittest.ms.com "
                         "--interface vlan500 --ip %s" % ip5, command)
        self.matchoutput(out, "qip-set-router %s" % ip1, command)

    def test_210_update(self):
        ip1 = self.net["switch_sync"].usable[1]
        ip4 = self.net["switch_sync"].usable[4]
        ip5 = self.net["switch_sync"].usable[5]
        self.dsdb_expect_update("swsync.aqd-unittest.ms.com",
                                "mgmt0", comments="T1 T2")
        self.dsdb_expect_update("swsync-vlan100.aqd-unittest.ms.com",
                                "vlan100", ip4, comments="T1 T2")
        self.dsdb_expect_add("swsync-vlan100-hsrp.aqd-unittest.ms.com", ip1,
                             "vlan100_hsrp", comments="T1 T2",
                             primary="swsync.aqd-unittest.ms.com")
        self.dsdb_expect_update("swsync-nomatch.aqd-unittest.ms.com",
                                "vlan200", comments="T1 T2")
        self.dsdb_expect_update("swsync-vlan300.aqd-unittest.ms.com",
                                "vlan300", comments="T1 T2")
        self.dsdb_expect_rename("swsync-nomatch.aqd-unittest.ms.com",
                                iface="vlan200", new_iface="vlan210")
        self.dsdb_expect_rename("swsync-vlan300.aqd-unittest.ms.com",
                                "swsync-vlan310.aqd-unittest.ms.com",
                                "vlan300", "vlan310")
        self.dsdb_expect_add("swsync-vlan500.aqd-unittest.ms.com", ip5,
                             "vlan500", comments="T1 T2",
                             primary="swsync.aqd-unittest.ms.com")
        command = ["update", "network_device", "--network_device", "swsync", "--discover"]
        out, err = self.successtest(command)
        self.matchoutput(err,
                         "Using jump host nyaqd1.ms.com from service instance "
                         "poll_helper/unittest to run discovery for switch "
                         "swsync.aqd-unittest.ms.com.",
                         command)
        self.matchoutput(err, "You should run 'qip-set-router %s'." % ip1,
                         command)
        self.dsdb_verify()

    def test_300_verify(self):
        ip = self.net["switch_sync"].usable[0]
        ip1 = self.net["switch_sync"].usable[1]
        ip2 = self.net["switch_sync"].usable[2]
        ip3 = self.net["switch_sync"].usable[3]
        ip4 = self.net["switch_sync"].usable[4]
        ip5 = self.net["switch_sync"].usable[5]
        out, command = self.verifynetdev("swsync.aqd-unittest.ms.com",
                                         "cisco", "ws-c2960-48tt-l", "ut3", "a",
                                         "3", switch_type="misc",
                                         ip=ip, mac=ip.mac,
                                         interface="mgmt0",
                                         comments="T1 T2")
        # TODO: the interface type is not updated, it's not clear if it should
        self.searchoutput(out,
                          r"Interface: mgmt0 %s\s*"
                          r"Type: physical\s*"
                          r"Network Environment: internal\s*"
                          r"Provides: swsync.aqd-unittest.ms.com \[%s\]"
                          % (ip.mac, ip), command)
        self.searchoutput(out,
                          r"Interface: vlan100 \(no MAC addr\)\s*"
                          r"Type: virtual\s*"
                          r"Network Environment: internal\s*"
                          r"Provides: swsync-vlan100.aqd-unittest.ms.com \[%s\]\s*"
                          r"Provides: swsync-vlan100-hsrp.aqd-unittest.ms.com \[%s\] \(label: hsrp\)"
                          % (ip4, ip1), command)
        self.searchoutput(out,
                          r"Interface: vlan210 \(no MAC addr\)\s*"
                          r"Type: virtual\s*"
                          r"Network Environment: internal\s*"
                          r"Provides: swsync-nomatch.aqd-unittest.ms.com \[%s\]"
                          % ip2, command)
        self.searchoutput(out,
                          r"Interface: vlan310 \(no MAC addr\)\s*"
                          r"Type: virtual\s*"
                          r"Network Environment: internal\s*"
                          r"Provides: swsync-vlan310.aqd-unittest.ms.com \[%s\]"
                          % ip3, command)
        self.searchoutput(out,
                          r"Interface: vlan500 \(no MAC addr\)\s*"
                          r"Type: virtual\s*"
                          r"Network Environment: internal\s*"
                          r"Provides: swsync-vlan500.aqd-unittest.ms.com \[%s\]"
                          % ip5, command)

    def test_400_del_swsync_addrs(self):
        ip1 = self.net["switch_sync"].usable[1]
        ip2 = self.net["switch_sync"].usable[2]
        ip3 = self.net["switch_sync"].usable[3]
        ip4 = self.net["switch_sync"].usable[4]
        ip5 = self.net["switch_sync"].usable[5]
        self.dsdb_expect_delete(ip1)
        self.dsdb_expect_delete(ip2)
        self.dsdb_expect_delete(ip3)
        self.dsdb_expect_delete(ip4)
        self.dsdb_expect_delete(ip5)
        self.noouttest(["del", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan100", "--ip", ip1])
        self.noouttest(["del", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan100", "--ip", ip4])
        self.noouttest(["del", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan210", "--ip", ip2])
        self.noouttest(["del", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan310", "--ip", ip3])
        self.noouttest(["del", "interface", "address", "--network_device", "swsync",
                        "--interface", "vlan500", "--ip", ip5])
        self.dsdb_verify()

    def test_410_del_swsync(self):
        self.dsdb_expect_delete(self.net["switch_sync"].usable[0])
        self.noouttest(["del", "network_device", "--network_device", "swsync"])
        self.dsdb_verify()

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestDiscoverNetworkDevice)
    unittest.TextTestRunner(verbosity=2).run(suite)


text:
package vip.xuanhao.integration.model.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Xuanhao on 2016/9/27.
 */

public class HomeData extends BaseModel{

    private List<FoceImages> strikeCarList = new ArrayList<>(); //焦点图片
    private List<Note> hotNoteList = new ArrayList<>();

}


text:
import sys
print(sys.stdin.read().replace('\\n', '\n').replace('\\t', '\t'))


text:
namespace Envoy {
namespace Quic {

class EnvoyQuicAlarmFactory : public quic::QuicAlarmFactory, NonCopyable {
public:
  EnvoyQuicAlarmFactory(Event::Dispatcher& dispatcher, const quic::QuicClock& clock)
      : dispatcher_(dispatcher), clock_(clock) {}

  ~EnvoyQuicAlarmFactory() override = default;

  // QuicAlarmFactory
  quic::QuicAlarm* CreateAlarm(quic::QuicAlarm::Delegate* delegate) override;
  quic::QuicArenaScopedPtr<quic::QuicAlarm>
  CreateAlarm(quic::QuicArenaScopedPtr<quic::QuicAlarm::Delegate> delegate,
              quic::QuicConnectionArena* arena) override;

private:
  Event::Dispatcher& dispatcher_;
  const quic::QuicClock& clock_;
};

} // namespace Quic
} // namespace Envoy


text:
<?php

namespace RedUNIT\Base;

use RedUNIT\Base as Base;
use RedBeanPHP\Facade as R;
use RedBeanPHP\Logger\RDefault as RDefault;
use RedBeanPHP\Logger as Logger;
use RedBeanPHP\OODBBean as OODBBean;
use RedBeanPHP\OODB as OODB;
use RedBeanPHP\Adapter as Adapter;
use RedBeanPHP\QueryWriter as QueryWriter;
use RedBeanPHP\RedException as RedException;
use RedBeanPHP\RedException\SQL as SQL;
use RedBeanPHP\Driver\RPDO as RPDO;
use RedBeanPHP\SimpleModel as SimpleModel;

/**
 * Misc
 *
 * @file    RedUNIT/Base/Misc.php
 * @desc    Various tests.
 * @author  Gabor de Mooij and the RedBeanPHP Community
 * @license New BSD/GPLv2
 *
 * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
 * This source file is subject to the New BSD/GPLv2 License that is bundled
 * with this source code in the file license.txt.
 */
class Misc extends Base
{
	/**
	 * Test whether we can set the 'auto clear'
	 * option in OODB.
	 *
	 * @return void
	 */
	public function testAutoClearHistory()
	{
		testpack( 'Auto clear history' );
		$book = R::dispense( 'book' );
		$book->pages = 100;
		$book->title = 'book';
		R::store( $book );
		$book = R::findOne( 'book' );
		asrt( $book->hasChanged( 'title' ), FALSE );
		$book->title = 'yes';
		R::store( $book );
		asrt( $book->hasChanged( 'title' ), TRUE );
		OODB::autoClearHistoryAfterStore( TRUE );
		$book = R::findOne( 'book' );
		asrt( $book->hasChanged( 'title' ), FALSE );
		$book->title = 'yes2';
		R::store( $book );
		asrt( $book->hasChanged( 'title' ), FALSE );
		OODB::autoClearHistoryAfterStore( FALSE );
		$book = R::findOne( 'book' );
		asrt( $book->hasChanged( 'title' ), FALSE );
		$book->title = 'yes';
		R::store( $book );
		asrt( $book->hasChanged( 'title' ), TRUE );
	}

	/**
	* Tests the R::inspect() method on the Facade.
	*
	* @return void
	*/
	public function testInspect() {

		testpack( 'Test R::inspect() ' );
		R::nuke();
		R::store( R::dispense( 'book' )->setAttr( 'title', 'book' ) );
		$info = R::inspect();
		asrt( count( $info ), 1 );
		asrt( strtolower( $info[0] ), 'book' );
		$info = R::inspect( 'book' );
		asrt( count( $info ), 2 );
		$keys = array_keys( $info );
		sort($keys);
		asrt( strtolower( $keys[0] ), 'id' );
		asrt( strtolower( $keys[1] ), 'title' );
	}

	/**
	 * Test whether we can use the tableExist() method in OODB
	 * instances directly to help us determine
	 * the existance of a table.
	 *
	 * @return void
	 */
	public function testTableExist()
	{
		R::nuke();
		R::store( R::dispense( 'book' ) );
		R::freeze( FALSE );
		asrt( R::getRedBean()->tableExists( 'book' ), TRUE );
		asrt( R::getRedBean()->tableExists( 'book2' ), FALSE );
		R::freeze( TRUE );
		asrt( R::getRedBean()->tableExists( 'book' ), TRUE );
		asrt( R::getRedBean()->tableExists( 'book2' ), FALSE );
		R::freeze( FALSE );
	}

	/**
	 * Normally the check() method is always called indirectly when
	 * dealing with beans. This test ensures we can call check()
	 * directly. Even though frozen repositories do not rely on
	 * bean checking to improve performance the method should still
	 * offer the same functionality when called directly.
	 *
	 * @return void
	 */
	public function testCheckDirectly()
	{
		$bean = new OODBBean;
		$bean->id = 0;
		$bean->setMeta( 'type', 'book' );
		R::getRedBean()->check( $bean );
		$bean->setMeta( 'type', '.' );
		try {
			R::getRedBean()->check( $bean );
			fail();
		} catch ( \Exception $e ) {
			pass();
		}
		//check should remain the same even if frozen repo is used, method is public after all!
		//we dont want to break the API!
		R::freeze( TRUE );
		try {
			R::getRedBean()->check( $bean );
			fail();
		} catch ( \Exception $e ) {
			pass();
		}
		R::freeze( FALSE );
	}

	/**
	 * Test Backward compatibility writer ESC-method.
	 *
	 * @return void
	 */
	public function testLegacyCode()
	{
		testpack( 'Test Backward compatibility methods in writer.' );
		asrt( R::getWriter()->safeColumn( 'column', TRUE ), R::getWriter()->esc( 'column', TRUE ) );
		asrt( R::getWriter()->safeColumn( 'column', FALSE ), R::getWriter()->esc( 'column', FALSE ) );
		asrt( R::getWriter()->safeTable( 'table', TRUE ), R::getWriter()->esc( 'table', TRUE ) );
		asrt( R::getWriter()->safeTable( 'table', FALSE ), R::getWriter()->esc( 'table', FALSE ) );
	}

	/**
	 * Test beautification and array functions.
	 *
	 * @return void
	 */
	public function testBeauficationAndArrayFunctions()
	{
		$bean = R::dispense( 'bean' );
		$bean->isReallyAwesome = TRUE;
		asrt( isset( $bean->isReallyAwesome ), TRUE );
		asrt( isset( $bean->is_really_awesome ), TRUE );
		unset( $bean->is_really_awesome );
		asrt( isset( $bean->isReallyAwesome ), FALSE );
		asrt( isset( $bean->is_really_awesome ), FALSE );
	}

	/**
	 * Test beautification of column names.
	 *
	 * @return void
	 */
	public function testBeautifulColumnNames()
	{
		testpack( 'Beautiful column names' );
		$town = R::dispense( 'town' );
		$town->isCapital       = FALSE;
		$town->hasTrainStation = TRUE;
		$town->name            = 'BeautyVille';
		$houses = R::dispense( 'house', 2 );
		$houses[0]->isForSale = TRUE;
		$town->ownHouse = $houses;
		R::store( $town );
		$town = R::load( 'town', $town->id );
		asrt( ( $town->isCapital == FALSE ), TRUE );
		asrt( ( $town->hasTrainStation == TRUE ), TRUE );
		asrt( ( $town->name == 'BeautyVille' ), TRUE );
		testpack( 'Accept datetime objects.' );
		$cal = R::dispense( 'calendar' );
		$cal->when = new\DateTime( '2000-01-01', new\DateTimeZone( 'Pacific/Nauru' ) );
		asrt( $cal->when, '2000-01-01 00:00:00' );
		testpack( 'Affected rows test' );
		$currentDriver = $this->currentlyActiveDriverID;
		$toolbox = R::getToolBox();
		$adapter = $toolbox->getDatabaseAdapter();
		$writer  = $toolbox->getWriter();
		$redbean = $toolbox->getRedBean();
		$pdo     = $adapter->getDatabase();
		$bean = $redbean->dispense( 'bean' );
		$bean->prop = 3; //make test run with strict mode as well
		$redbean->store( $bean );
		$adapter->exec( 'UPDATE bean SET prop = 2' );
		asrt( $adapter->getAffectedRows(), 1 );
		testpack( 'Testing Logger' );
		R::getDatabaseAdapter()->getDatabase()->setLogger( new RDefault );
		asrt( ( R::getDatabaseAdapter()->getDatabase()->getLogger() instanceof Logger ), TRUE );
		asrt( ( R::getDatabaseAdapter()->getDatabase()->getLogger() instanceof RDefault ), TRUE );
		$bean = R::dispense( 'bean' );
		$bean->property = 1;
		$bean->unsetAll( array( 'property' ) );
		asrt( $bean->property, NULL );
		asrt( ( $bean->setAttr( 'property', 2 ) instanceof OODBBean ), TRUE );
		asrt( $bean->property, 2 );
		asrt( preg_match( '/\d\d\d\d\-\d\d\-\d\d/', R::isoDate() ), 1 );
		asrt( preg_match( '/\d\d\d\d\-\d\d\-\d\d\s\d\d:\d\d:\d\d/', R::isoDateTime() ), 1 );
		$redbean = R::getRedBean();
		$adapter = R::getDatabaseAdapter();
		$writer  = R::getWriter();
		asrt( ( $redbean instanceof OODB ), TRUE );
		asrt( ( $adapter instanceof Adapter ), TRUE );
		asrt( ( $writer instanceof QueryWriter ), TRUE );
		R::setRedBean( $redbean );
		pass(); //cant really test this
		R::setDatabaseAdapter( $adapter );
		pass(); //cant really test this
		R::setWriter( $writer );
		pass(); //cant really test this
		$u1 = R::dispense( 'user' );
		$u1->name  = 'Gabor';
		$u1->login = 'g';
		$u2 = R::dispense( 'user' );
		$u2->name  = 'Eric';
		$u2->login = 'e';
		R::store( $u1 );
		R::store( $u2 );
		$list = R::getAssoc( 'select login,' . R::getWriter()->esc( 'name' ) . ' from ' . R::getWriter()->esc( 'user' ) . ' ' );
		asrt( $list['e'], 'Eric' );
		asrt( $list['g'], 'Gabor' );
		$painting = R::dispense( 'painting' );
		$painting->name = 'Nighthawks';
		$id = R::store( $painting );
		testpack( 'Testing SQL Error Types' );
		foreach ( $writer->typeno_sqltype as $code => $text ) {
			asrt( is_integer( $code ), TRUE );
			asrt( is_string( $text ), TRUE );
		}
		foreach ( $writer->sqltype_typeno as $text => $code ) {
			asrt( is_integer( $code ), TRUE );
			asrt( is_string( $text ), TRUE );
		}
		testpack( 'Testing Nowhere Pt. 1 (unfrozen)' );
		foreach (
			array(
				'exec', 'getAll', 'getCell', 'getAssoc', 'getRow', 'getCol'
			)
			as $method ) {
			R::$method( 'select * from nowhere' );
			pass();
		}
		testpack( 'Testing Nowhere Pt. 2 (frozen)' );
		R::freeze( TRUE );
		foreach (
			array(
				'exec', 'getAll', 'getCell', 'getAssoc', 'getRow', 'getCol'
			)
			as $method ) {
			try {
				R::$method( 'select * from nowhere' );
				fail();
			} catch ( SQL $e ) {
				pass();
			}
		}
		R::freeze( FALSE );
	}

	/**
	 * Test reflectional functions of database.
	 *
	 * @return void
	 */
	public function testDatabaseProperties()
	{
		testpack( 'Testing Database Properties' );
		$adapter = R::getDatabaseAdapter();
		if ( method_exists( R::getDatabaseAdapter()->getDatabase(), 'getPDO' ) ){
			asrt( $adapter->getDatabase()->getPDO() instanceof \PDO, TRUE );
		}
		asrt( strlen( $adapter->getDatabase()->getDatabaseVersion() ) > 0, TRUE );
		asrt( strlen( $adapter->getDatabase()->getDatabaseType() ) > 0, TRUE );
	}

	/**
	 * Test Transactions.
	 *
	 * @return void
	 */
	public function testTransactions()
	{
		testpack( 'transactions' );
		R::begin();
		$bean = R::dispense( 'bean' );
		R::store( $bean );
		R::commit();
		asrt( R::count( 'bean' ), 1 );
		R::wipe( 'bean' );
		R::freeze( 1 );
		R::begin();
		$bean = R::dispense( 'bean' );
		R::store( $bean );
		R::rollback();
		asrt( R::count( 'bean' ), 0 );
		R::freeze( FALSE );
		testpack( 'genSlots' );
		asrt( R::genSlots( array( 'a', 'b' ) ), '?,?' );
		asrt( R::genSlots( array( 'a' ) ), '?' );
		asrt( R::genSlots( array() ), '' );
	}

	/**
	 * Test nested FUSE scenarios.
	 *
	 * @return void
	 */
	public function testFUSEnested()
	{
		testpack( 'FUSE models cant touch nested beans in update() - issue 106' );
		$spoon       = R::dispense( 'spoon' );
		$spoon->name = 'spoon for test bean';
		$deep        = R::dispense( 'deep' );
		$deep->name  = 'deepbean';
		$item        = R::dispense( 'item' );
		$item->val   = 'Test';
		$item->deep  = $deep;
		$test = R::dispense( 'test' );
		$test->item          = $item;
		$test->sharedSpoon[] = $spoon;
		$test->isnowtainted = TRUE;
		$id   = R::store( $test );
		$test = R::load( 'test', $id );
		asrt( $test->item->val, 'Test2' );
		$can   = reset( $test->ownCan );
		$spoon = reset( $test->sharedSpoon );
		asrt( $can->name, 'can for bean' );
		asrt( $spoon->name, 'S2' );
		asrt( $test->item->deep->name, '123' );
		asrt( count( $test->ownCan ), 1 );
		asrt( count( $test->sharedSpoon ), 1 );
		asrt( count( $test->sharedPeas ), 10 );
		asrt( count( $test->ownChip ), 9 );
	}

	/**
	 * Tests FUSE and lists, FUSE enforces no more than
	 * 3 sugar cubes in coffee.
	 *
	 * @return void
	 */
	public function testCoffeeWithSugarAndFUSE()
	{
		$coffee = R::dispense( 'coffee' );
		$coffee->size     = 'XL';
		$coffee->ownSugar = R::dispense( 'sugar', 5 );
		$id = R::store( $coffee );
		$coffee = R::load( 'coffee', $id );
		asrt( count( $coffee->ownSugar ), 3 );
		$coffee->ownSugar = R::dispense( 'sugar', 2 );
		$id     = R::store( $coffee );
		$coffee = R::load( 'coffee', $id );
		asrt( count( $coffee->ownSugar ), 2 );
		$cocoa = R::dispense( 'cocoa' );
		$cocoa->name = 'Fair Cocoa';
		list( $taste1, $taste2 ) = R::dispense( 'taste', 2 );
		$taste1->name = 'sweet';
		$taste2->name = 'bitter';
		$cocoa->ownTaste = array( $taste1, $taste2 );
		R::store( $cocoa );
		$cocoa->name = 'Koko';
		R::store( $cocoa );
		if ( method_exists( R::getDatabaseAdapter()->getDatabase(), 'getPDO' ) ) {
			$pdo    = R::getDatabaseAdapter()->getDatabase()->getPDO();
			$driver = new RPDO( $pdo );
			pass();
			asrt( $pdo->getAttribute(\PDO::ATTR_ERRMODE ),\PDO::ERRMODE_EXCEPTION );
			asrt( $pdo->getAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE ),\PDO::FETCH_ASSOC );
			asrt( strval( $driver->GetCell( 'select 123' ) ), '123' );
		}
		$a = new SQL;
		$a->setSqlState( 'test' );
		$b = strval( $a );
		asrt( ( strpos( $b, '[test] - ' ) === 0 ), TRUE );
	}

	/**
	* ENUM Basic tests.
	*
	* @return void
	*/
	public function testENUMBasics() {
		asrt( R::enum( 'gender:male' )->name, 'MALE' );
		asrt( R::enum( 'country:South-Africa' )->name, 'SOUTH_AFRICA' );
		asrt( R::enum( 'tester:T@E  S_t' )->name, 'T_E_S_T' );
	}

	/**
	 * Test ENUM in Queries and with short hand notation.
	 *
	 * @return void
	 */
	public function testENUMInQuery()
	{
		testpack('Test ENUM in Query and test ENUM short notation');
		R::nuke();
		$coffee = R::dispense( 'coffee' );
		$coffee->taste = R::enum( 'flavour:mocca' );
		R::store( $coffee );
		$coffee = R::dispense( 'coffee' );
		$coffee->taste = R::enum( 'flavour:banana' );
		R::store( $coffee );
		$coffee = R::dispense( 'coffee' );
		$coffee->taste = R::enum( 'flavour:banana' );
		R::store( $coffee );
		//now we have two flavours
		asrt( R::count('flavour'), 2 );
		//use in query
		asrt( R::count( 'coffee', ' taste_id = ? ', array( R::enum( 'flavour:mocca' )->id ) ), 1);
		//use in quer with short notation
		asrt( R::count( 'coffee', ' taste_id = ? ', array( EID( 'flavour:mocca' ) ) ), 1);
		//use in query
		asrt( R::count( 'coffee', ' taste_id = ? ', array( R::enum( 'flavour:banana' )->id ) ), 2);
		//use in quer with short notation
		asrt( R::count( 'coffee', ' taste_id = ? ', array( EID( 'flavour:banana' ) ) ), 2);
		//use in query
		asrt( R::count( 'coffee', ' taste_id = ? ', array( R::enum( 'flavour:strawberry' )->id ) ), 0);
		//use in quer with short notation
		asrt( R::count( 'coffee', ' taste_id = ? ', array( EID( 'flavour:strawberry' ) ) ), 0);
	}

	/**
	 * Test ENUM functionality offered by Label Maker.
	 *
	 * @return void
	 */
	public function testENUM() {
		testpack('test ENUM');
		$coffee = R::dispense( 'coffee' );
		$coffee->taste = R::enum( 'flavour:mocca' );
		//did we create an enum?
		asrt( implode( '', R::gatherLabels( R::enum( 'flavour' ) ) ), 'MOCCA' );
		R::store( $coffee );
		$coffee = $coffee->fresh();
		//test enum identity check - with alias
		asrt( $coffee->fetchAs( 'flavour' )->taste->equals( R::enum('flavour:mocca') ), TRUE );
		asrt( $coffee->fetchAs( 'flavour' )->taste->equals( R::enum('flavour:banana') ), FALSE );
		//now we have two flavours
		asrt( R::count( 'flavour' ), 2 );
		asrt( implode( ',', R::gatherLabels( R::enum( 'flavour') ) ), 'BANANA,MOCCA' );
		$coffee->flavour = R::enum( 'flavour:mocca' );
		R::store($coffee);
		//same results, can we have multiple flavours?
		asrt( $coffee->fetchAs( 'flavour' )->taste->equals( R::enum( 'flavour:mocca' ) ), TRUE );
		asrt( $coffee->fetchAs( 'flavour' )->taste->equals( R::enum( 'flavour:banana' ) ), FALSE );
		asrt( $coffee->flavour->equals( R::enum( 'flavour:mocca' ) ), TRUE );
		//no additional mocca enum...
		asrt( R::count( 'flavour' ), 2 );
		$drink = R::dispense( 'drink' );
		$drink->flavour = R::enum( 'flavour:choco' );
		R::store( $drink );
		//now we have three!
		asrt( R::count('flavour'), 3 );
		$drink = R::load( 'drink', $drink->id );
		asrt( $drink->flavour->equals( R::enum('flavour:mint') ), FALSE );
		asrt( $drink->flavour->equals( R::enum('flavour:choco') ), TRUE );
		asrt( R::count( 'flavour' ), 4 );
		//trash should not affect flavour!
		R::trash( $drink );
		asrt( R::count( 'flavour' ), 4 );
	}

	/**
	 * Test trashAll().
	 */
	public function testMultiDeleteUpdate()
	{
		testpack( 'test multi delete and multi update' );
		$beans = R::dispenseLabels( 'bean', array( 'a', 'b' ) );
		$ids   = R::storeAll( $beans );
		asrt( (int) R::count( 'bean' ), 2 );
		R::trashAll( R::batch( 'bean', $ids ) );
		asrt( (int) R::count( 'bean' ), 0 );
		testpack( 'test assocManager check' );
		$rb = new OODB( R::getWriter() );
		try {
			$rb->getAssociationManager();
			fail();
		} catch ( RedException $e ) {
			pass();
		}
	}

	/**
	 * Test Bean identity equality.
	 */
	public function testBeanIdentityEquality() {
		$beanA = R::dispense( 'bean' );
		$beanB = R::dispense( 'bean' );
		$beanA->id = 1;
		$beanB->id = 1;
		asrt( $beanA->equals( $beanB ), TRUE );
		asrt( $beanB->equals( $beanA ), TRUE );
		asrt( $beanA->equals( $beanA ), TRUE );
		asrt( $beanB->equals( $beanB ), TRUE );
		$beanB->id = 2;
		asrt( $beanA->equals( $beanB ), FALSE );
		asrt( $beanB->equals( $beanA ), FALSE );
		$beanA->id = '2';
		asrt( $beanA->equals( $beanB ), TRUE );
		asrt( $beanB->equals( $beanA ), TRUE );
		$beanB = R::dispense( 'carrot' );
		$beanB->id = $beanA->id;
		asrt( $beanA->equals( $beanB ), FALSE );
		asrt( $beanB->equals( $beanA ), FALSE );
	}

	/**
	 * Test if adding SimpleModles to a shared list will auto unbox them.
	 */
	public function testSharedListsAutoUnbox() {
		$boxedBean = R::dispense( 'boxedbean' );
		$bean = R::dispense( 'bean' );
		$model = new SimpleModel();
		$model->loadBean($boxedBean);
		$bean->ownBoxedbeanList[] = $model;
		try {
			R::store( $bean );
			pass();
		} catch ( \Exception $e ) {
			fail();
		}
	}
}