text:
<?xml version="1.0" encoding="UTF-8"?>
<entity_timezone>
  <fields id="name">
    <field name="name"/>
  </fields>
  <entities>
    <timezone id="Africa_Abidjan" name="Africa/Abidjan"/>
    <timezone id="Africa_Accra" name="Africa/Accra"/>
    <timezone id="Africa_Addis_Ababa" name="Africa/Addis_Ababa"/>
    <timezone id="Africa_Algiers" name="Africa/Algiers"/>
    <timezone id="Africa_Asmara" name="Africa/Asmara"/>
    <timezone id="Africa_Asmera" name="Africa/Asmera"/>
    <timezone id="Africa_Bamako" name="Africa/Bamako"/>
    <timezone id="Africa_Bangui" name="Africa/Bangui"/>
    <timezone id="Africa_Banjul" name="Africa/Banjul"/>
    <timezone id="Africa_Bissau" name="Africa/Bissau"/>
    <timezone id="Africa_Blantyre" name="Africa/Blantyre"/>
    <timezone id="Africa_Brazzaville" name="Africa/Brazzaville"/>
    <timezone id="Africa_Bujumbura" name="Africa/Bujumbura"/>
    <timezone id="Africa_Cairo" name="Africa/Cairo"/>
    <timezone id="Africa_Casablanca" name="Africa/Casablanca"/>
    <timezone id="Africa_Ceuta" name="Africa/Ceuta"/>
    <timezone id="Africa_Conakry" name="Africa/Conakry"/>
    <timezone id="Africa_Dakar" name="Africa/Dakar"/>
    <timezone id="Africa_Dar_es_Salaam" name="Africa/Dar_es_Salaam"/>
    <timezone id="Africa_Djibouti" name="Africa/Djibouti"/>
    <timezone id="Africa_Douala" name="Africa/Douala"/>
    <timezone id="Africa_El_Aaiun" name="Africa/El_Aaiun"/>
    <timezone id="Africa_Freetown" name="Africa/Freetown"/>
    <timezone id="Africa_Gaborone" name="Africa/Gaborone"/>
    <timezone id="Africa_Harare" name="Africa/Harare"/>
    <timezone id="Africa_Johannesburg" name="Africa/Johannesburg"/>
    <timezone id="Africa_Kampala" name="Africa/Kampala"/>
    <timezone id="Africa_Khartoum" name="Africa/Khartoum"/>
    <timezone id="Africa_Kigali" name="Africa/Kigali"/>
    <timezone id="Africa_Kinshasa" name="Africa/Kinshasa"/>
    <timezone id="Africa_Lagos" name="Africa/Lagos"/>
    <timezone id="Africa_Libreville" name="Africa/Libreville"/>
    <timezone id="Africa_Lome" name="Africa/Lome"/>
    <timezone id="Africa_Luanda" name="Africa/Luanda"/>
    <timezone id="Africa_Lubumbashi" name="Africa/Lubumbashi"/>
    <timezone id="Africa_Lusaka" name="Africa/Lusaka"/>
    <timezone id="Africa_Malabo" name="Africa/Malabo"/>
    <timezone id="Africa_Maputo" name="Africa/Maputo"/>
    <timezone id="Africa_Maseru" name="Africa/Maseru"/>
    <timezone id="Africa_Mbabane" name="Africa/Mbabane"/>
    <timezone id="Africa_Mogadishu" name="Africa/Mogadishu"/>
    <timezone id="Africa_Monrovia" name="Africa/Monrovia"/>
    <timezone id="Africa_Nairobi" name="Africa/Nairobi"/>
    <timezone id="Africa_Ndjamena" name="Africa/Ndjamena"/>
    <timezone id="Africa_Niamey" name="Africa/Niamey"/>
    <timezone id="Africa_Nouakchott" name="Africa/Nouakchott"/>
    <timezone id="Africa_Ouagadougou" name="Africa/Ouagadougou"/>
    <timezone id="Africa_Porto-Novo" name="Africa/Porto-Novo"/>
    <timezone id="Africa_Sao_Tome" name="Africa/Sao_Tome"/>
    <timezone id="Africa_Timbuktu" name="Africa/Timbuktu"/>
    <timezone id="Africa_Tripoli" name="Africa/Tripoli"/>
    <timezone id="Africa_Tunis" name="Africa/Tunis"/>
    <timezone id="Africa_Windhoek" name="Africa/Windhoek"/>
    <timezone id="America_Adak" name="America/Adak"/>
    <timezone id="America_Anchorage" name="America/Anchorage "/>
    <timezone id="America_Anguilla" name="America/Anguilla"/>
    <timezone id="America_Antigua" name="America/Antigua"/>
    <timezone id="America_Araguaina" name="America/Araguaina"/>
    <timezone id="America_Argentina_Buenos_Aires" name="America/Argentina/Buenos_Aires"/>
    <timezone id="America_Argentina_Catamarca" name="America/Argentina/Catamarca"/>
    <timezone id="America_Argentina_ComodRivadavia" name="America/Argentina/ComodRivadavia"/>
    <timezone id="America_Argentina_Cordoba" name="America/Argentina/Cordoba"/>
    <timezone id="America_Argentina_Jujuy" name="America/Argentina/Jujuy"/>
    <timezone id="America_Argentina_La_Rioja" name="America/Argentina/La_Rioja"/>
    <timezone id="America_Argentina_Mendoza" name="America/Argentina/Mendoza"/>
    <timezone id="America_Argentina_Rio_Gallegos" name="America/Argentina/Rio_Gallegos"/>
    <timezone id="America_Argentina_Salta" name="America/Argentina/Salta"/>
    <timezone id="America_Argentina_San_Juan" name="America/Argentina/San_Juan"/>
    <timezone id="America_Argentina_San_Luis" name="America/Argentina/San_Luis"/>
    <timezone id="America_Argentina_Tucuman" name="America/Argentina/Tucuman"/>
    <timezone id="America_Argentina_Ushuaia" name="America/Argentina/Ushuaia"/>
    <timezone id="America_Aruba" name="America/Aruba"/>
    <timezone id="America_Asuncion" name="America/Asuncion"/>
    <timezone id="America_Atikokan" name="America/Atikokan"/>
    <timezone id="America_Atka" name="America/Atka"/>
    <timezone id="America_Bahia" name="America/Bahia"/>
    <timezone id="America_Barbados" name="America/Barbados"/>
    <timezone id="America_Belem" name="America/Belem"/>
    <timezone id="America_Belize" name="America/Belize"/>
    <timezone id="America_Blanc-Sablon" name="America/Blanc-Sablon"/>
    <timezone id="America_Boa_Vista" name="America/Boa_Vista"/>
    <timezone id="America_Bogota" name="America/Bogota"/>
    <timezone id="America_Boise" name="America/Boise"/>
    <timezone id="America_Buenos_Aires" name="America/Buenos_Aires"/>
    <timezone id="America_Cambridge_Bay" name="America/Cambridge_Bay"/>
    <timezone id="America_Campo_Grande" name="America/Campo_Grande"/>
    <timezone id="America_Cancun" name="America/Cancun"/>
    <timezone id="America_Caracas" name="America/Caracas"/>
    <timezone id="America_Catamarca" name="America/Catamarca"/>
    <timezone id="America_Cayenne" name="America/Cayenne"/>
    <timezone id="America_Cayman" name="America/Cayman"/>
    <timezone id="America_Chicago" name="America/Chicago"/>
    <timezone id="America_Chihuahua" name="America/Chihuahua"/>
    <timezone id="America_Coral_Harbour" name="America/Coral_Harbour"/>
    <timezone id="America_Cordoba" name="America/Cordoba"/>
    <timezone id="America_Costa_Rica" name="America/Costa_Rica"/>
    <timezone id="America_Cuiaba" name="America/Cuiaba"/>
    <timezone id="America_Curacao" name="America/Curacao"/>
    <timezone id="America_Danmarkshavn" name="America/Danmarkshavn"/>
    <timezone id="America_Dawson" name="America/Dawson"/>
    <timezone id="America_Dawson_Creek" name="America/Dawson_Creek"/>
    <timezone id="America_Denver" name="America/Denver"/>
    <timezone id="America_Detroit" name="America/Detroit"/>
    <timezone id="America_Dominica" name="America/Dominica"/>
    <timezone id="America_Edmonton" name="America/Edmonton"/>
    <timezone id="America_Eirunepe" name="America/Eirunepe"/>
    <timezone id="America_El_Salvador" name="America/El_Salvador"/>
    <timezone id="America_Ensenada" name="America/Ensenada"/>
    <timezone id="America_Fort_Wayne" name="America/Fort_Wayne"/>
    <timezone id="America_Fortaleza" name="America/Fortaleza"/>
    <timezone id="America_Glace_Bay" name="America/Glace_Bay"/>
    <timezone id="America_Godthab" name="America/Godthab"/>
    <timezone id="America_Goose_Bay" name="America/Goose_Bay"/>
    <timezone id="America_Grand_Turk" name="America/Grand_Turk"/>
    <timezone id="America_Grenada" name="America/Grenada"/>
    <timezone id="America_Guadeloupe" name="America/Guadeloupe"/>
    <timezone id="America_Guatemala" name="America/Guatemala"/>
    <timezone id="America_Guayaquil" name="America/Guayaquil"/>
    <timezone id="America_Guyana" name="America/Guyana"/>
    <timezone id="America_Halifax" name="America/Halifax"/>
    <timezone id="America_Havana" name="America/Havana"/>
    <timezone id="America_Hermosillo" name="America/Hermosillo"/>
    <timezone id="America_Indiana_Indianapolis" name="America/Indiana/Indianapolis"/>
    <timezone id="America_Indiana_Knox" name="America/Indiana/Knox"/>
    <timezone id="America_Indiana_Marengo" name="America/Indiana/Marengo"/>
    <timezone id="America_Indiana_Petersburg" name="America/Indiana/Petersburg"/>
    <timezone id="America_Indiana_Tell_City" name="America/Indiana/Tell_City"/>
    <timezone id="America_Indiana_Vevay" name="America/Indiana/Vevay"/>
    <timezone id="America_Indiana_Vincennes" name="America/Indiana/Vincennes"/>
    <timezone id="America_Indiana_Winamac" name="America/Indiana/Winamac"/>
    <timezone id="America_Indianapolis" name="America/Indianapolis"/>
    <timezone id="America_Inuvik" name="America/Inuvik"/>
    <timezone id="America_Iqaluit" name="America/Iqaluit"/>
    <timezone id="America_Jamaica" name="America/Jamaica"/>
    <timezone id="America_Jujuy" name="America/Jujuy"/>
    <timezone id="America_Juneau" name="America/Juneau"/>
    <timezone id="America_Kentucky_Louisville" name="America/Kentucky/Louisville"/>
    <timezone id="America_Kentucky_Monticello" name="America/Kentucky/Monticello"/>
    <timezone id="America_Knox_IN" name="America/Knox_IN"/>
    <timezone id="America_La_Paz" name="America/La_Paz"/>
    <timezone id="America_Lima" name="America/Lima"/>
    <timezone id="America_Los_Angeles" name="America/Los_Angeles"/>
    <timezone id="America_Louisville" name="America/Louisville"/>
    <timezone id="America_Maceio" name="America/Maceio"/>
    <timezone id="America_Managua" name="America/Managua"/>
    <timezone id="America_Manaus" name="America/Manaus"/>
    <timezone id="America_Marigot" name="America/Marigot"/>
    <timezone id="America_Martinique" name="America/Martinique"/>
    <timezone id="America_Mazatlan" name="America/Mazatlan"/>
    <timezone id="America_Mendoza" name="America/Mendoza"/>
    <timezone id="America_Menominee" name="America/Menominee"/>
    <timezone id="America_Merida" name="America/Merida"/>
    <timezone id="America_Mexico_City" name="America/Mexico_City"/>
    <timezone id="America_Miquelon" name="America/Miquelon"/>
    <timezone id="America_Moncton" name="America/Moncton"/>
    <timezone id="America_Monterrey" name="America/Monterrey"/>
    <timezone id="America_Montevideo" name="America/Montevideo"/>
    <timezone id="America_Montreal" name="America/Montreal"/>
    <timezone id="America_Montserrat" name="America/Montserrat"/>
    <timezone id="America_Nassau" name="America/Nassau"/>
    <timezone id="America_New_York" name="America/New_York"/>
    <timezone id="America_Nipigon" name="America/Nipigon"/>
    <timezone id="America_Nome" name="America/Nome"/>
    <timezone id="America_Noronha" name="America/Noronha"/>
    <timezone id="America_North_Dakota_Center" name="America/North_Dakota/Center"/>
    <timezone id="America_North_Dakota_New_Salem" name="America/North_Dakota/New_Salem"/>
    <timezone id="America_Panama" name="America/Panama"/>
    <timezone id="America_Pangnirtung" name="America/Pangnirtung"/>
    <timezone id="America_Paramaribo" name="America/Paramaribo"/>
    <timezone id="America_Phoenix" name="America/Phoenix"/>
    <timezone id="America_Port-au-Prince" name="America/Port-au-Prince"/>
    <timezone id="America_Port_of_Spain" name="America/Port_of_Spain"/>
    <timezone id="America_Porto_Acre" name="America/Porto_Acre"/>
    <timezone id="America_Porto_Velho" name="America/Porto_Velho"/>
    <timezone id="America_Puerto_Rico" name="America/Puerto_Rico"/>
    <timezone id="America_Rainy_River" name="America/Rainy_River"/>
    <timezone id="America_Rankin_Inlet" name="America/Rankin_Inlet"/>
    <timezone id="America_Recife" name="America/Recife"/>
    <timezone id="America_Regina" name="America/Regina"/>
    <timezone id="America_Resolute" name="America/Resolute"/>
    <timezone id="America_Rio_Branco" name="America/Rio_Branco"/>
    <timezone id="America_Rosario" name="America/Rosario"/>
    <timezone id="America_Santarem" name="America/Santarem"/>
    <timezone id="America_Santiago" name="America/Santiago"/>
    <timezone id="America_Santo_Domingo" name="America/Santo_Domingo"/>
    <timezone id="America_Sao_Paulo" name="America/Sao_Paulo"/>
    <timezone id="America_Scoresbysund" name="America/Scoresbysund"/>
    <timezone id="America_Shiprock" name="America/Shiprock"/>
    <timezone id="America_St_Barthelemy" name="America/St_Barthelemy"/>
    <timezone id="America_St_Johns" name="America/St_Johns"/>
    <timezone id="America_St_Kitts" name="America/St_Kitts"/>
    <timezone id="America_St_Lucia" name="America/St_Lucia"/>
    <timezone id="America_St_Thomas" name="America/St_Thomas"/>
    <timezone id="America_St_Vincent" name="America/St_Vincent"/>
    <timezone id="America_Swift_Current" name="America/Swift_Current"/>
    <timezone id="America_Tegucigalpa" name="America/Tegucigalpa"/>
    <timezone id="America_Thule" name="America/Thule"/>
    <timezone id="America_Thunder_Bay" name="America/Thunder_Bay"/>
    <timezone id="America_Tijuana" name="America/Tijuana"/>
    <timezone id="America_Toronto" name="America/Toronto"/>
    <timezone id="America_Tortola" name="America/Tortola"/>
    <timezone id="America_Vancouver" name="America/Vancouver"/>
    <timezone id="America_Virgin" name="America/Virgin"/>
    <timezone id="America_Whitehorse" name="America/Whitehorse"/>
    <timezone id="America_Winnipeg" name="America/Winnipeg"/>
    <timezone id="America_Yakutat" name="America/Yakutat"/>
    <timezone id="America_Yellowknife" name="America/Yellowknife"/>
    <timezone id="Antarctica_Casey" name="Antarctica/Casey"/>
    <timezone id="Antarctica_Davis" name="Antarctica/Davis"/>
    <timezone id="Antarctica_DumontDUrville" name="Antarctica/DumontDUrville"/>
    <timezone id="Antarctica_Mawson" name="Antarctica/Mawson"/>
    <timezone id="Antarctica_McMurdo" name="Antarctica/McMurdo"/>
    <timezone id="Antarctica_Palmer" name="Antarctica/Palmer"/>
    <timezone id="Antarctica_Rothera" name="Antarctica/Rothera"/>
    <timezone id="Antarctica_South_Pole" name="Antarctica/South_Pole"/>
    <timezone id="Antarctica_Syowa" name="Antarctica/Syowa"/>
    <timezone id="Antarctica_Vostok" name="Antarctica/Vostok"/>
    <timezone id="Arctic_Longyearbyen" name="Arctic/Longyearbyen"/>
    <timezone id="Asia_Aden" name="Asia/Aden"/>
    <timezone id="Asia_Almaty" name="Asia/Almaty"/>
    <timezone id="Asia_Amman" name="Asia/Amman"/>
    <timezone id="Asia_Anadyr" name="Asia/Anadyr"/>
    <timezone id="Asia_Aqtau" name="Asia/Aqtau"/>
    <timezone id="Asia_Aqtobe" name="Asia/Aqtobe"/>
    <timezone id="Asia_Ashgabat" name="Asia/Ashgabat"/>
    <timezone id="Asia_Ashkhabad" name="Asia/Ashkhabad"/>
    <timezone id="Asia_Baghdad" name="Asia/Baghdad"/>
    <timezone id="Asia_Bahrain" name="Asia/Bahrain"/>
    <timezone id="Asia_Baku" name="Asia/Baku"/>
    <timezone id="Asia_Bangkok" name="Asia/Bangkok"/>
    <timezone id="Asia_Beirut" name="Asia/Beirut"/>
    <timezone id="Asia_Bishkek" name="Asia/Bishkek"/>
    <timezone id="Asia_Brunei" name="Asia/Brunei"/>
    <timezone id="Asia_Calcutta" name="Asia/Calcutta"/>
    <timezone id="Asia_Choibalsan" name="Asia/Choibalsan"/>
    <timezone id="Asia_Chongqing" name="Asia/Chongqing"/>
    <timezone id="Asia_Chungking" name="Asia/Chungking"/>
    <timezone id="Asia_Colombo" name="Asia/Colombo"/>
    <timezone id="Asia_Dacca" name="Asia/Dacca"/>
    <timezone id="Asia_Damascus" name="Asia/Damascus"/>
    <timezone id="Asia_Dhaka" name="Asia/Dhaka"/>
    <timezone id="Asia_Dili" name="Asia/Dili"/>
    <timezone id="Asia_Dubai" name="Asia/Dubai"/>
    <timezone id="Asia_Dushanbe" name="Asia/Dushanbe"/>
    <timezone id="Asia_Gaza" name="Asia/Gaza"/>
    <timezone id="Asia_Harbin" name="Asia/Harbin"/>
    <timezone id="Asia_Ho_Chi_Minh" name="Asia/Ho_Chi_Minh"/>
    <timezone id="Asia_Hong_Kong" name="Asia/Hong_Kong"/>
    <timezone id="Asia_Hovd" name="Asia/Hovd"/>
    <timezone id="Asia_Irkutsk" name="Asia/Irkutsk"/>
    <timezone id="Asia_Istanbul" name="Asia/Istanbul"/>
    <timezone id="Asia_Jakarta" name="Asia/Jakarta"/>
    <timezone id="Asia_Jayapura" name="Asia/Jayapura"/>
    <timezone id="Asia_Jerusalem" name="Asia/Jerusalem"/>
    <timezone id="Asia_Kabul" name="Asia/Kabul"/>
    <timezone id="Asia_Kamchatka" name="Asia/Kamchatka"/>
    <timezone id="Asia_Karachi" name="Asia/Karachi"/>
    <timezone id="Asia_Kashgar" name="Asia/Kashgar"/>
    <timezone id="Asia_Kathmandu" name="Asia/Kathmandu"/>
    <timezone id="Asia_Katmandu" name="Asia/Katmandu"/>
    <timezone id="Asia_Kolkata" name="Asia/Kolkata"/>
    <timezone id="Asia_Krasnoyarsk" name="Asia/Krasnoyarsk"/>
    <timezone id="Asia_Kuala_Lumpur" name="Asia/Kuala_Lumpur"/>
    <timezone id="Asia_Kuching" name="Asia/Kuching"/>
    <timezone id="Asia_Kuwait" name="Asia/Kuwait"/>
    <timezone id="Asia_Macao" name="Asia/Macao"/>
    <timezone id="Asia_Macau" name="Asia/Macau"/>
    <timezone id="Asia_Magadan" name="Asia/Magadan"/>
    <timezone id="Asia_Makassar" name="Asia/Makassar"/>
    <timezone id="Asia_Manila" name="Asia/Manila"/>
    <timezone id="Asia_Muscat" name="Asia/Muscat"/>
    <timezone id="Asia_Nicosia" name="Asia/Nicosia"/>
    <timezone id="Asia_Novosibirsk" name="Asia/Novosibirsk"/>
    <timezone id="Asia_Omsk" name="Asia/Omsk"/>
    <timezone id="Asia_Oral" name="Asia/Oral"/>
    <timezone id="Asia_Phnom_Penh" name="Asia/Phnom_Penh"/>
    <timezone id="Asia_Pontianak" name="Asia/Pontianak"/>
    <timezone id="Asia_Pyongyang" name="Asia/Pyongyang"/>
    <timezone id="Asia_Qatar" name="Asia/Qatar"/>
    <timezone id="Asia_Qyzylorda" name="Asia/Qyzylorda"/>
    <timezone id="Asia_Rangoon" name="Asia/Rangoon"/>
    <timezone id="Asia_Riyadh" name="Asia/Riyadh"/>
    <timezone id="Asia_Saigon" name="Asia/Saigon"/>
    <timezone id="Asia_Sakhalin" name="Asia/Sakhalin"/>
    <timezone id="Asia_Samarkand" name="Asia/Samarkand"/>
    <timezone id="Asia_Seoul" name="Asia/Seoul"/>
    <timezone id="Asia_Shanghai" name="Asia/Shanghai"/>
    <timezone id="Asia_Singapore" name="Asia/Singapore"/>
    <timezone id="Asia_Taipei" name="Asia/Taipei"/>
    <timezone id="Asia_Tashkent" name="Asia/Tashkent"/>
    <timezone id="Asia_Tbilisi" name="Asia/Tbilisi"/>
    <timezone id="Asia_Tehran" name="Asia/Tehran"/>
    <timezone id="Asia_Tel_Aviv" name="Asia/Tel_Aviv"/>
    <timezone id="Asia_Thimbu" name="Asia/Thimbu"/>
    <timezone id="Asia_Thimphu" name="Asia/Thimphu"/>
    <timezone id="Asia_Tokyo" name="Asia/Tokyo"/>
    <timezone id="Asia_Ujung_Pandang" name="Asia/Ujung_Pandang"/>
    <timezone id="Asia_Ulaanbaatar" name="Asia/Ulaanbaatar"/>
    <timezone id="Asia_Ulan_Bator" name="Asia/Ulan_Bator"/>
    <timezone id="Asia_Urumqi" name="Asia/Urumqi"/>
    <timezone id="Asia_Vientiane" name="Asia/Vientiane"/>
    <timezone id="Asia_Vladivostok" name="Asia/Vladivostok"/>
    <timezone id="Asia_Yakutsk" name="Asia/Yakutsk"/>
    <timezone id="Asia_Yekaterinburg" name="Asia/Yekaterinburg"/>
    <timezone id="Asia_Yerevan" name="Asia/Yerevan"/>
    <timezone id="Atlantic_Azores" name="Atlantic/Azores"/>
    <timezone id="Atlantic_Bermuda" name="Atlantic/Bermuda"/>
    <timezone id="Atlantic_Canary" name="Atlantic/Canary"/>
    <timezone id="Atlantic_Cape_Verde" name="Atlantic/Cape_Verde"/>
    <timezone id="Atlantic_Faeroe" name="Atlantic/Faeroe"/>
    <timezone id="Atlantic_Faroe" name="Atlantic/Faroe"/>
    <timezone id="Atlantic_Jan_Mayen" name="Atlantic/Jan_Mayen"/>
    <timezone id="Atlantic_Madeira" name="Atlantic/Madeira"/>
    <timezone id="Atlantic_Reykjavik" name="Atlantic/Reykjavik"/>
    <timezone id="Atlantic_South_Georgia" name="Atlantic/South_Georgia"/>
    <timezone id="Atlantic_St_Helena" name="Atlantic/St_Helena"/>
    <timezone id="Atlantic_Stanley" name="Atlantic/Stanley"/>
    <timezone id="Australia_ACT" name="Australia/ACT"/>
    <timezone id="Australia_Adelaide" name="Australia/Adelaide"/>
    <timezone id="Australia_Brisbane" name="Australia/Brisbane"/>
    <timezone id="Australia_Broken_Hill" name="Australia/Broken_Hill"/>
    <timezone id="Australia_Canberra" name="Australia/Canberra"/>
    <timezone id="Australia_Currie" name="Australia/Currie"/>
    <timezone id="Australia_Darwin" name="Australia/Darwin"/>
    <timezone id="Australia_Eucla" name="Australia/Eucla"/>
    <timezone id="Australia_Hobart" name="Australia/Hobart"/>
    <timezone id="Australia_LHI" name="Australia/LHI"/>
    <timezone id="Australia_Lindeman" name="Australia/Lindeman"/>
    <timezone id="Australia_Lord_Howe" name="Australia/Lord_Howe"/>
    <timezone id="Australia_Melbourne" name="Australia/Melbourne"/>
    <timezone id="Australia_North" name="Australia/North"/>
    <timezone id="Australia_NSW" name="Australia/NSW"/>
    <timezone id="Australia_Perth" name="Australia/Perth"/>
    <timezone id="Australia_Queensland" name="Australia/Queensland"/>
    <timezone id="Australia_South" name="Australia/South"/>
    <timezone id="Australia_Sydney" name="Australia/Sydney"/>
    <timezone id="Australia_Tasmania" name="Australia/Tasmania"/>
    <timezone id="Australia_Victoria" name="Australia/Victoria"/>
    <timezone id="Australia_West" name="Australia/West"/>
    <timezone id="Australia_Yancowinna" name="Australia/Yancowinna"/>
    <timezone id="Europe_Amsterdam" name="Europe/Amsterdam"/>
    <timezone id="Europe_Andorra" name="Europe/Andorra"/>
    <timezone id="Europe_Athens" name="Europe/Athens"/>
    <timezone id="Europe_Belfast" name="Europe/Belfast"/>
    <timezone id="Europe_Belgrade" name="Europe/Belgrade"/>
    <timezone id="Europe_Berlin" name="Europe/Berlin"/>
    <timezone id="Europe_Bratislava" name="Europe/Bratislava"/>
    <timezone id="Europe_Brussels" name="Europe/Brussels"/>
    <timezone id="Europe_Bucharest" name="Europe/Bucharest"/>
    <timezone id="Europe_Budapest" name="Europe/Budapest"/>
    <timezone id="Europe_Chisinau" name="Europe/Chisinau"/>
    <timezone id="Europe_Copenhagen" name="Europe/Copenhagen"/>
    <timezone id="Europe_Dublin" name="Europe/Dublin"/>
    <timezone id="Europe_Gibraltar" name="Europe/Gibraltar"/>
    <timezone id="Europe_Guernsey" name="Europe/Guernsey"/>
    <timezone id="Europe_Helsinki" name="Europe/Helsinki"/>
    <timezone id="Europe_Isle_of_Man" name="Europe/Isle_of_Man"/>
    <timezone id="Europe_Istanbul" name="Europe/Istanbul"/>
    <timezone id="Europe_Jersey" name="Europe/Jersey"/>
    <timezone id="Europe_Kaliningrad" name="Europe/Kaliningrad"/>
    <timezone id="Europe_Kiev" name="Europe/Kiev"/>
    <timezone id="Europe_Lisbon" name="Europe/Lisbon"/>
    <timezone id="Europe_Ljubljana" name="Europe/Ljubljana"/>
    <timezone id="Europe_London" name="Europe/London"/>
    <timezone id="Europe_Luxembourg" name="Europe/Luxembourg"/>
    <timezone id="Europe_Madrid" name="Europe/Madrid"/>
    <timezone id="Europe_Malta" name="Europe/Malta"/>
    <timezone id="Europe_Mariehamn" name="Europe/Mariehamn"/>
    <timezone id="Europe_Minsk" name="Europe/Minsk"/>
    <timezone id="Europe_Monaco" name="Europe/Monaco"/>
    <timezone id="Europe_Moscow" name="Europe/Moscow"/>
    <timezone id="Europe_Nicosia" name="Europe/Nicosia"/>
    <timezone id="Europe_Oslo" name="Europe/Oslo"/>
    <timezone id="Europe_Paris" name="Europe/Paris"/>
    <timezone id="Europe_Podgorica" name="Europe/Podgorica"/>
    <timezone id="Europe_Prague" name="Europe/Prague"/>
    <timezone id="Europe_Riga" name="Europe/Riga"/>
    <timezone id="Europe_Rome" name="Europe/Rome"/>
    <timezone id="Europe_Samara" name="Europe/Samara"/>
    <timezone id="Europe_San_Marino" name="Europe/San_Marino"/>
    <timezone id="Europe_Sarajevo" name="Europe/Sarajevo"/>
    <timezone id="Europe_Simferopol" name="Europe/Simferopol"/>
    <timezone id="Europe_Skopje" name="Europe/Skopje"/>
    <timezone id="Europe_Sofia" name="Europe/Sofia"/>
    <timezone id="Europe_Stockholm" name="Europe/Stockholm"/>
    <timezone id="Europe_Tallinn" name="Europe/Tallinn"/>
    <timezone id="Europe_Tirane" name="Europe/Tirane"/>
    <timezone id="Europe_Tiraspol" name="Europe/Tiraspol"/>
    <timezone id="Europe_Uzhgorod" name="Europe/Uzhgorod"/>
    <timezone id="Europe_Vaduz" name="Europe/Vaduz"/>
    <timezone id="Europe_Vatican" name="Europe/Vatican"/>
    <timezone id="Europe_Vienna" name="Europe/Vienna"/>
    <timezone id="Europe_Vilnius" name="Europe/Vilnius"/>
    <timezone id="Europe_Volgograd" name="Europe/Volgograd"/>
    <timezone id="Europe_Warsaw" name="Europe/Warsaw"/>
    <timezone id="Europe_Zagreb" name="Europe/Zagreb"/>
    <timezone id="Europe_Zaporozhye" name="Europe/Zaporozhye"/>
    <timezone id="Europe_Zurich" name="Europe/Zurich"/>
    <timezone id="Indian_Antananarivo" name="Indian/Antananarivo"/>
    <timezone id="Indian_Chagos" name="Indian/Chagos"/>
    <timezone id="Indian_Christmas" name="Indian/Christmas"/>
    <timezone id="Indian_Cocos" name="Indian/Cocos"/>
    <timezone id="Indian_Comoro" name="Indian/Comoro"/>
    <timezone id="Indian_Kerguelen" name="Indian/Kerguelen"/>
    <timezone id="Indian_Mahe" name="Indian/Mahe"/>
    <timezone id="Indian_Maldives" name="Indian/Maldives"/>
    <timezone id="Indian_Mauritius" name="Indian/Mauritius"/>
    <timezone id="Indian_Mayotte" name="Indian/Mayotte"/>
    <timezone id="Indian_Reunion" name="Indian/Reunion"/>
    <timezone id="Pacific_Apia" name="Pacific/Apia"/>
    <timezone id="Pacific_Auckland" name="Pacific/Auckland"/>
    <timezone id="Pacific_Chatham" name="Pacific/Chatham"/>
    <timezone id="Pacific_Easter" name="Pacific/Easter"/>
    <timezone id="Pacific_Efate" name="Pacific/Efate"/>
    <timezone id="Pacific_Enderbury" name="Pacific/Enderbury"/>
    <timezone id="Pacific_Fakaofo" name="Pacific/Fakaofo"/>
    <timezone id="Pacific_Fiji" name="Pacific/Fiji"/>
    <timezone id="Pacific_Funafuti" name="Pacific/Funafuti"/>
    <timezone id="Pacific_Galapagos" name="Pacific/Galapagos"/>
    <timezone id="Pacific_Gambier" name="Pacific/Gambier"/>
    <timezone id="Pacific_Guadalcanal" name="Pacific/Guadalcanal"/>
    <timezone id="Pacific_Guam" name="Pacific/Guam"/>
    <timezone id="Pacific_Honolulu" name="Pacific/Honolulu"/>
    <timezone id="Pacific_Johnston" name="Pacific/Johnston"/>
    <timezone id="Pacific_Kiritimati" name="Pacific/Kiritimati"/>
    <timezone id="Pacific_Kosrae" name="Pacific/Kosrae"/>
    <timezone id="Pacific_Kwajalein" name="Pacific/Kwajalein"/>
    <timezone id="Pacific_Majuro" name="Pacific/Majuro"/>
    <timezone id="Pacific_Marquesas" name="Pacific/Marquesas"/>
    <timezone id="Pacific_Midway" name="Pacific/Midway"/>
    <timezone id="Pacific_Nauru" name="Pacific/Nauru"/>
    <timezone id="Pacific_Niue" name="Pacific/Niue"/>
    <timezone id="Pacific_Norfolk" name="Pacific/Norfolk"/>
    <timezone id="Pacific_Noumea" name="Pacific/Noumea"/>
    <timezone id="Pacific_Pago_Pago" name="Pacific/Pago_Pago"/>
    <timezone id="Pacific_Palau" name="Pacific/Palau"/>
    <timezone id="Pacific_Pitcairn" name="Pacific/Pitcairn"/>
    <timezone id="Pacific_Ponape" name="Pacific/Ponape"/>
    <timezone id="Pacific_Port_Moresby" name="Pacific/Port_Moresby"/>
    <timezone id="Pacific_Rarotonga" name="Pacific/Rarotonga"/>
    <timezone id="Pacific_Saipan" name="Pacific/Saipan"/>
    <timezone id="Pacific_Samoa" name="Pacific/Samoa"/>
    <timezone id="Pacific_Tahiti" name="Pacific/Tahiti"/>
    <timezone id="Pacific_Tarawa" name="Pacific/Tarawa"/>
    <timezone id="Pacific_Tongatapu" name="Pacific/Tongatapu"/>
    <timezone id="Pacific_Truk" name="Pacific/Truk"/>
    <timezone id="Pacific_Wake" name="Pacific/Wake"/>
    <timezone id="Pacific_Wallis" name="Pacific/Wallis"/>
    <timezone id="Pacific_Yap" name="Pacific/Yap"/>
    <timezone id="Brazil_Acre" name="Brazil/Acre"/>
    <timezone id="Brazil_DeNoronha" name="Brazil/DeNoronha"/>
    <timezone id="Brazil_East" name="Brazil/East"/>
    <timezone id="Brazil_West" name="Brazil/West"/>
    <timezone id="Canada_Atlantic" name="Canada/Atlantic"/>
    <timezone id="Canada_Central" name="Canada/Central"/>
    <timezone id="Canada_East-Saskatchewan" name="Canada/East-Saskatchewan"/>
    <timezone id="Canada_Eastern" name="Canada/Eastern"/>
    <timezone id="Canada_Mountain" name="Canada/Mountain"/>
    <timezone id="Canada_Newfoundland" name="Canada/Newfoundland"/>
    <timezone id="Canada_Pacific" name="Canada/Pacific"/>
    <timezone id="Canada_Saskatchewan" name="Canada/Saskatchewan"/>
    <timezone id="Canada_Yukon" name="Canada/Yukon"/>
    <timezone id="CET" name="CET"/>
    <timezone id="Chile_Continental" name="Chile/Continental"/>
    <timezone id="Chile_EasterIsland" name="Chile/EasterIsland"/>
    <timezone id="CST6CDT" name="CST6CDT"/>
    <timezone id="Cuba" name="Cuba"/>
    <timezone id="EET" name="EET"/>
    <timezone id="Egypt" name="Egypt"/>
    <timezone id="Eire" name="Eire"/>
    <timezone id="EST" name="EST"/>
    <timezone id="EST5EDT" name="EST5EDT"/>
    <timezone id="Etc_GMT" name="Etc/GMT"/>
    <timezone id="Etc_GMT_0" name="Etc/GMT+0"/>
    <timezone id="Etc_GMT_1" name="Etc/GMT+1"/>
    <timezone id="Etc_GMT_10" name="Etc/GMT+10"/>
    <timezone id="Etc_GMT_11" name="Etc/GMT+11"/>
    <timezone id="Etc_GMT_12" name="Etc/GMT+12"/>
    <timezone id="Etc_GMT_2" name="Etc/GMT+2"/>
    <timezone id="Etc_GMT_3" name="Etc/GMT+3"/>
    <timezone id="Etc_GMT_4" name="Etc/GMT+4"/>
    <timezone id="Etc_GMT_5" name="Etc/GMT+5"/>
    <timezone id="Etc_GMT_6" name="Etc/GMT+6"/>
    <timezone id="Etc_GMT_7" name="Etc/GMT+7"/>
    <timezone id="Etc_GMT_8" name="Etc/GMT+8"/>
    <timezone id="Etc_GMT_9" name="Etc/GMT+9"/>
    <timezone id="Etc_GMT-0" name="Etc/GMT-0"/>
    <timezone id="Etc_GMT-1" name="Etc/GMT-1"/>
    <timezone id="Etc_GMT-10" name="Etc/GMT-10"/>
    <timezone id="Etc_GMT-11" name="Etc/GMT-11"/>
    <timezone id="Etc_GMT-12" name="Etc/GMT-12"/>
    <timezone id="Etc_GMT-13" name="Etc/GMT-13"/>
    <timezone id="Etc_GMT-14" name="Etc/GMT-14"/>
    <timezone id="Etc_GMT-2" name="Etc/GMT-2"/>
    <timezone id="Etc_GMT-3" name="Etc/GMT-3"/>
    <timezone id="Etc_GMT-4" name="Etc/GMT-4"/>
    <timezone id="Etc_GMT-5" name="Etc/GMT-5"/>
    <timezone id="Etc_GMT-6" name="Etc/GMT-6"/>
    <timezone id="Etc_GMT-7" name="Etc/GMT-7"/>
    <timezone id="Etc_GMT-8" name="Etc/GMT-8"/>
    <timezone id="Etc_GMT-9" name="Etc/GMT-9"/>
    <timezone id="Etc_GMT0" name="Etc/GMT0"/>
    <timezone id="Etc_Greenwich" name="Etc/Greenwich"/>
    <timezone id="Etc_UCT" name="Etc/UCT"/>
    <timezone id="Etc_Universal" name="Etc/Universal"/>
    <timezone id="Etc_UTC" name="Etc/UTC"/>
    <timezone id="Etc_Zulu" name="Etc/Zulu"/>
    <timezone id="Factory" name="Factory"/>
    <timezone id="GB" name="GB"/>
    <timezone id="GB-Eire" name="GB-Eire"/>
    <timezone id="GMT" name="GMT"/>
    <timezone id="GMT_0" name="GMT+0"/>
    <timezone id="GMT-0" name="GMT-0"/>
    <timezone id="GMT0" name="GMT0"/>
    <timezone id="Greenwich" name="Greenwich"/>
    <timezone id="Hongkong" name="Hongkong"/>
    <timezone id="HST" name="HST"/>
    <timezone id="Iceland" name="Iceland"/>
    <timezone id="Iran" name="Iran"/>
    <timezone id="Israel" name="Israel"/>
    <timezone id="Jamaica" name="Jamaica"/>
    <timezone id="Japan" name="Japan"/>
    <timezone id="Kwajalein" name="Kwajalein"/>
    <timezone id="Libya" name="Libya"/>
    <timezone id="MET" name="MET"/>
    <timezone id="Mexico_BajaNorte" name="Mexico/BajaNorte"/>
    <timezone id="Mexico_BajaSur" name="Mexico/BajaSur"/>
    <timezone id="Mexico_General" name="Mexico/General"/>
    <timezone id="MST" name="MST"/>
    <timezone id="MST7MDT" name="MST7MDT"/>
    <timezone id="Navajo" name="Navajo"/>
    <timezone id="NZ" name="NZ"/>
    <timezone id="NZ-CHAT" name="NZ-CHAT"/>
    <timezone id="Poland" name="Poland"/>
    <timezone id="Portugal" name="Portugal"/>
    <timezone id="PRC" name="PRC"/>
    <timezone id="PST8PDT" name="PST8PDT"/>
    <timezone id="ROC" name="ROC"/>
    <timezone id="ROK" name="ROK"/>
    <timezone id="Singapore" name="Singapore"/>
    <timezone id="Turkey" name="Turkey"/>
    <timezone id="UCT" name="UCT"/>
    <timezone id="Universal" name="Universal"/>
    <timezone id="US_Alaska" name="US/Alaska"/>
    <timezone id="US_Aleutian" name="US/Aleutian"/>
    <timezone id="US_Arizona" name="US/Arizona"/>
    <timezone id="US_Central" name="US/Central"/>
    <timezone id="US_East-Indiana" name="US/East-Indiana"/>
    <timezone id="US_Eastern" name="US/Eastern"/>
    <timezone id="US_Hawaii" name="US/Hawaii"/>
    <timezone id="US_Indiana-Starke" name="US/Indiana-Starke"/>
    <timezone id="US_Michigan" name="US/Michigan"/>
    <timezone id="US_Mountain" name="US/Mountain"/>
    <timezone id="US_Pacific" name="US/Pacific"/>
    <timezone id="US_Pacific-New" name="US/Pacific-New"/>
    <timezone id="US_Samoa" name="US/Samoa"/>
    <timezone id="UTC" name="UTC"/>
    <timezone id="W-SU" name="W-SU"/>
    <timezone id="WET" name="WET"/>
    <timezone id="Zulu" name="Zulu"/>
  </entities>
</entity_timezone>


text:
require 'spec_helper'
require 'fakefs/spec_helpers'
require 'mortar/command/projects'
require 'launchy'
require "mortar/api"

module Mortar::Command
  describe Projects do

    before(:each) do
      stub_core
      @git = Mortar::Git::Git.new
    end

    before("create") do
      @tmpdir = Dir.mktmpdir
      Dir.chdir(@tmpdir)
    end

    project1 = {'name' => "Project1",
                'status' => Mortar::API::Projects::STATUS_ACTIVE,
                'project_id' => 'abcd1234',
                'git_url' => "git@github.com:mortarcode-dev/Project1"}
    project2 = {'name' => "Project2",
                'status' => Mortar::API::Projects::STATUS_ACTIVE,
                'project_id' => 'defg5678',
                'git_url' => "git@github.com:mortarcode-dev/Project2"}

    context("index") do

      it "shows appropriate message when user has no projects" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => []}))

        stderr, stdout = execute("projects")
        stdout.should == <<-STDOUT
You have no projects.
STDOUT
      end

      it "shows appropriate message when user has multiple projects" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))

        stderr, stdout = execute("projects")
        stdout.should == <<-STDOUT
=== projects
Project1
Project2

STDOUT
      end
    end

    context("delete") do
      it "shows error message when user doesn't include project name" do
        stderr, stdout = execute("projects:delete")
        stderr.should == <<-STDERR
 !    Usage: mortar projects:delete PROJECTNAME
 !    Must specify PROJECTNAME.
STDERR
      end

      it "deletes project" do
        project_id = "abcd1234"

        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        mock(Mortar::Auth.api).delete_project(project_id).returns(Excon::Response.new(:body => {}, :status => 200 ))
        stderr, stdout = execute("projects:delete Project1")
        stdout.should == <<-STDOUT
Sending request to delete project: Project1... done

Your project has been deleted.
STDOUT
      end

    end

    context("create") do

      it "registers and generates a project" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        project_id = "1234abcd1234abcd1234"
        project_name = "some_new_project"
        project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
        mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_ACTIVE,
                                                                                "git_url" => project_git_url})).ordered
        mock(@git).remotes.with_any_args.returns({})
        mock(@git).remote_add("mortar", project_git_url)

        # if the git stuff doesn't work, the registration will fail, so we can pretend it does work here
        mock(@git).git("add .").returns(true)
        mock(@git).git("commit -m \"Mortar project scaffolding\"").returns(true)
        mock(@git).push_master

        stderr, stdout = execute("projects:create #{project_name}", nil, @git)
        Dir.pwd.end_with?("some_new_project").should be_true
        File.exists?("macros").should be_true
        File.exists?("pigscripts").should be_true
        File.exists?("udfs").should be_true
        File.exists?("project.properties").should be_true
        File.exists?("project.manifest").should be_true
        File.exists?("requirements.txt").should be_true
        File.exists?("README.md").should be_true
        File.exists?("Gemfile").should be_false
        File.exists?("macros/.gitkeep").should be_true
        File.exists?("pigscripts/some_new_project.pig").should be_true
        File.exists?("udfs/python/some_new_project.py").should be_true
        File.exists?("luigiscripts/README").should be_true
        File.exists?("lib/README").should be_true
        File.exists?("params/README").should be_true

        File.read("pigscripts/some_new_project.pig").each_line { |line| line.match(/<%.*%>/).should be_nil }

        stdout.should == <<-STDOUT
Sending request to register project: some_new_project... done
\e[1;32m      create\e[0m
\e[1;32m      create\e[0m  README.md
\e[1;32m      create\e[0m  project.properties
\e[1;32m      create\e[0m  project.manifest
\e[1;32m      create\e[0m  requirements.txt
\e[1;32m      create\e[0m  .gitignore
\e[1;32m      create\e[0m  pigscripts
\e[1;32m      create\e[0m  pigscripts/some_new_project.pig
\e[1;32m      create\e[0m  macros
\e[1;32m      create\e[0m  macros/.gitkeep
\e[1;32m      create\e[0m  udfs
\e[1;32m      create\e[0m  udfs/python
\e[1;32m      create\e[0m  udfs/python/some_new_project.py
\e[1;32m      create\e[0m  udfs/jython
\e[1;32m      create\e[0m  udfs/jython/.gitkeep
\e[1;32m      create\e[0m  udfs/java
\e[1;32m      create\e[0m  udfs/java/.gitkeep
\e[1;32m      create\e[0m  luigiscripts
\e[1;32m      create\e[0m  luigiscripts/README
\e[1;32m      create\e[0m  lib
\e[1;32m      create\e[0m  lib/README
\e[1;32m      create\e[0m  params
\e[1;32m      create\e[0m  params/README
\n\r\e[0KStatus: ACTIVE  \n\nYour project is ready for use.  Type 'mortar help' to see the commands you can perform on the project.\n
NOTE: You'll need to change to the new directory to use your project:
    cd some_new_project

STDOUT
      end

      it "generates and registers an embedded project" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))

        project_id = "1234abcd1234abcd1234"
        project_name = "some_new_project"
        project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
        mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_ACTIVE,
                                                                                "git_url" => project_git_url})).ordered

        # test that sync_embedded_project is called. the method itself is tested in git_spec.
        mock(@git).sync_embedded_project.with_any_args.times(1) { true }

        stderr, stdout = execute("projects:create #{project_name} --embedded", nil, @git)
        Dir.pwd.end_with?("some_new_project").should be_true
        File.exists?(".mortar-project-remote").should be_true
        File.exists?("macros").should be_true
        File.exists?("pigscripts").should be_true
        File.exists?("udfs").should be_true
        File.exists?("README.md").should be_true
        File.exists?("Gemfile").should be_false
        File.exists?("macros/.gitkeep").should be_true
        File.exists?("pigscripts/some_new_project.pig").should be_true
        File.exists?("udfs/python/some_new_project.py").should be_true

        File.read("pigscripts/some_new_project.pig").each_line { |line| line.match(/<%.*%>/).should be_nil }
      end

    end

    context("register") do

      it "show appropriate error message when user doesn't include project name" do
        stderr, stdout = execute("projects:register")
        stderr.should == <<-STDERR
 !    Usage: mortar projects:register PROJECT
 !    Must specify PROJECT.
STDERR
      end

      it "tells you to cd to the directory if one exists with the project name" do
        with_no_git_directory do
          # create the project, but a level down from current directory
          project_name = "existing_project_one_level_down"
          FileUtils.mkdir_p(File.join(Dir.pwd, project_name))
          stderr, stdout = execute("projects:register #{project_name}")
          stderr.should == <<-STDERR
 !    mortar projects:register must be run from within the project directory.
 !    Please "cd existing_project_one_level_down" and rerun this command.
STDERR
        end
      end

      it "tells you to create the git project in directory that doesn't have a git repository" do
        with_no_git_directory do
          stderr, stdout = execute("projects:register some_new_project")
          stderr.should == <<-STDERR
 !    No git repository found in the current directory.
 !    To register a project that is not its own git repository, use the --embedded option.
 !    If you do want this project to be its own git repository, please initialize git in this directory, and then rerun the register command.
 !    To initialize your project in git, use:
 !
 !    git init
 !    git add .
 !    git commit -a -m "first commit"
STDERR
        end
      end

      it "errors when a project already exists with the name requested" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        with_git_initialized_project do |p|
          stderr, stdout = execute("projects:register Project1 --embedded", nil, @git)
          stderr.should == <<-STDERR
 !    Your account already contains a project named Project1.
 !    Please choose a different name for your new project, or clone the existing Project1 code using:
 !
 !    mortar projects:clone Project1
STDERR
        end
      end

      it "show appropriate error message when user tries to register a project inside of an existing project" do
         with_git_initialized_project do |p|
           stderr, stdout = execute("projects:register some_new_project", nil, @git)
           stderr.should == <<-STDERR
 !    Currently in project: myproject.  You can not register a new project inside of an existing mortar project.
STDERR
         end
      end

      it "Confirms if user wants to create a public project, exits when user says no" do
        project_name = "some_new_project"
        project_id = "1234"
        any_instance_of(Mortar::Command::Projects) do |base|
          mock(base).ask.with_any_args.times(1) { 'n' }
        end
        stderr, stdout = execute("projects:create #{project_name} --public", nil, @git)
        stderr.should == <<-STDERR
 !    Mortar project was not registered
STDERR
      end

      it "Confirms if user wants to create a public project, creates it if so" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        project_id = "1234abcd1234abcd1234"
        project_name = "some_new_project"
        project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
        mock(Mortar::Auth.api).post_project("some_new_project", false) {Excon::Response.new(:body => {"project_id" => project_id})}
        status = Mortar::API::Projects::STATUS_ACTIVE
        response = Excon::Response.new(:body => {"status" => status, "git_url" => project_git_url})
        mock(Mortar::Auth.api).get_project(project_id).returns(response).ordered

        mock(@git).has_dot_git?().returns(true)
        mock(@git).remotes.with_any_args.returns({})
        mock(@git).remote_add("mortar", project_git_url)
        mock(@git).push_master
        any_instance_of(Mortar::Command::Projects) do |base|
          mock(base).ask.with_any_args.times(1) { 'y' }
        end

        stderr, stdout = execute("projects:register #{project_name} --public", nil, @git)
        stdout.should == <<-STDOUT
Public projects allow anyone to view and fork the code in this project's repository. Are you sure? (y/n) Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: ACTIVE  \n\nYour project is ready for use.  Type 'mortar help' to see the commands you can perform on the project.\n
STDOUT
      end

      it "register a new project successfully - with status" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        project_id = "1234abcd1234abcd1234"
        project_name = "some_new_project"
        project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
        mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_PENDING})).ordered
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_CREATING})).ordered
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status" => Mortar::API::Projects::STATUS_ACTIVE,
                                                                                "git_url" => project_git_url})).ordered

        mock(@git).has_dot_git?().returns(true)
        mock(@git).remotes.with_any_args.returns({})
        mock(@git).remote_add("mortar", project_git_url)
        mock(@git).push_master

        stderr, stdout = execute("projects:register #{project_name}  --polling_interval 0.05", nil, @git)
        stdout.should == <<-STDOUT
Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: PENDING... /\r\e[0KStatus: CREATING... -\r\e[0KStatus: ACTIVE  \n\nYour project is ready for use.  Type 'mortar help' to see the commands you can perform on the project.\n
STDOUT
      end

      it "register a new project successfully - with status_code and status_description" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        project_id = "1234abcd1234abcd1234"
        project_name = "some_new_project"
        project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
        mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Pending", "status_code" => Mortar::API::Projects::STATUS_PENDING})).ordered
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Creating", "status_code" => Mortar::API::Projects::STATUS_CREATING})).ordered
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Active", "status_code" => Mortar::API::Projects::STATUS_ACTIVE,
                                                                                "git_url" => project_git_url})).ordered

        mock(@git).has_dot_git?().returns(true)
        mock(@git).remotes.with_any_args.returns({})
        mock(@git).remote_add("mortar", project_git_url)
        mock(@git).push_master

        stderr, stdout = execute("projects:register #{project_name}  --polling_interval 0.05", nil, @git)
        stdout.should == <<-STDOUT
Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: Pending... /\r\e[0KStatus: Creating... -\r\e[0KStatus: Active  \n\nYour project is ready for use.  Type 'mortar help' to see the commands you can perform on the project.\n
STDOUT
      end

      it "registers an embedded project" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        project_id = "1234abcd1234abcd1234"
        project_name = "some_new_project"
        project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
        mock(Mortar::Auth.api).post_project("some_new_project", true) {Excon::Response.new(:body => {"project_id" => project_id})}
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Pending", "status_code" => Mortar::API::Projects::STATUS_PENDING})).ordered
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Creating", "status_code" => Mortar::API::Projects::STATUS_CREATING})).ordered
        mock(Mortar::Auth.api).get_project(project_id).returns(Excon::Response.new(:body => {"status_description" => "Active", "status_code" => Mortar::API::Projects::STATUS_ACTIVE,
                                                                                "git_url" => project_git_url})).ordered

        any_instance_of(Mortar::Command::Projects) do |obj|
          mock(obj).project.returns(nil)
          mock(obj).validate_project_structure.returns(true)
        end

        # test that sync_embedded_project is called. the method itself is tested in git_spec.
        mock(@git).sync_embedded_project.with_any_args.times(1) { true }

        stderr, stdout = execute("projects:register some_new_project --embedded --polling_interval 0.05", nil, @git)
      end

    end

    context("set_remote") do

      it "sets the remote of a project" do
        with_git_initialized_project do |p|
          project_name = p.name
          project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
          `git remote rm mortar`
          mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [ { "name" => project_name, "status" => Mortar::API::Projects::STATUS_ACTIVE, "git_url" => project_git_url } ] })).ordered

          mock(@git).remote_add("mortar", project_git_url)

          stderr, stdout = execute("projects:set_remote #{project_name}", p, @git)
          stdout.should == <<-STDOUT
Successfully added the mortar remote to the myproject project
STDOUT
        end
      end

      it "remote already added" do
        with_git_initialized_project do |p|
          project_name = p.name

          stderr, stdout = execute("projects:set_remote #{project_name}", p, @git)
          stdout.should == <<-STDERR
The remote has already been set for project: myproject
STDERR
        end
      end

      it "No project given" do
        with_git_initialized_project do |p|
          stderr, stdout = execute("projects:set_remote", p, @git)
          stderr.should == <<-STDERR
 !    Usage: mortar projects:set_remote PROJECT
 !    Must specify PROJECT.
STDERR
        end
      end

      it "No project with that name" do
        with_git_initialized_project do |p|
          project_name = p.name
          project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
          mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [ { "name" => "derp", "status" => Mortar::API::Projects::STATUS_ACTIVE, "git_url" => project_git_url } ] })).ordered
          `git remote rm mortar`

          stderr, stdout = execute("projects:set_remote #{project_name}", p, @git)
          stderr.should == <<-STDERR
 !    No project named: myproject exists. You can create this project using:
 !
 !     mortar projects:create
STDERR
        end
      end
    end

    context("clone") do

      it "shows appropriate error message when user doesn't include project name" do
        stderr, stdout = execute("projects:clone")
        stderr.should == <<-STDERR
 !    Usage: mortar projects:clone PROJECT
 !    Must specify PROJECT.
STDERR
      end

      it "shows appropriate error message when user tries to clone non-existent project" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))

        stderr, stdout = execute('projects:clone sillyProjectName')
        stderr.should == <<-STDERR
 !    No project named: sillyProjectName exists.  Your valid projects are:
 !    Project1
 !    Project2
STDERR
      end

      it "shows appropriate error message when user tries to clone into existing directory" do
        with_no_git_directory do
          mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
          starting_dir = Dir.pwd
          project_dir = File.join(Dir.pwd, project1['name'])
          FileUtils.mkdir_p(project_dir)

          stderr, stdout = execute("projects:clone #{project1['name']}")
          stderr.should == <<-STDERR
 !    Can't clone project: #{project1['name']} since directory with that name already exists.
STDERR
        end

      end

      it "calls git clone when existing project is cloned" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        mock(@git).clone(project1['git_url'], project1['name'])

        stderr, stdout = execute('projects:clone Project1', nil, @git)
      end

    end

    context("fork") do
      it "shows correct error message when user doesn't give git_url" do
        stderr, stdout = execute("projects:fork")
        stderr.should == <<-STDERR
 !    Usage: mortar projects:fork GIT_URL PROJECT
 !    Must specify GIT_URL and PROJECT.
STDERR
      end

      it "errors when a project already exists with the name requested" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        with_git_initialized_project do |p|
          stderr, stdout = execute("projects:fork GIT_URL Project1", nil, @git)
          stderr.should == <<-STDERR
 !    Your account already contains a project named Project1.
 !    Please choose a different name for your new project, or clone the existing Project1 code using:
 !
 !    mortar projects:clone Project1
STDERR
        end
      end

      it "shows error when in git repo already" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))

        with_git_initialized_project do |p|
          stderr, stdout = execute("projects:fork GIT_URL Project3", nil, @git)
          stderr.should == <<-STDERR
 !    Currently in git repo.  You can not fork a new project inside of an existing git repository.
STDERR
        end
      end

      it "calls correct git commands on success" do
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        mock(Mortar::Auth.api).get_projects().returns(Excon::Response.new(:body => {"projects" => [project1, project2]}))
        project_id = "1234abcd1234abcd1234"
        project_name = "some_new_project"
        project_git_url = "git@github.com:mortarcode-dev/#{project_name}"
        original_git_url = "git@github.com:mortardata/mortar-recsys-fake"

        mock(Mortar::Auth.api).post_project("some_new_project", false) {Excon::Response.new(:body => {"project_id" => project_id})}
        status = Mortar::API::Projects::STATUS_ACTIVE
        response = Excon::Response.new(:body => {"status" => status, "git_url" => project_git_url})
        mock(Mortar::Auth.api).get_project(project_id).returns(response).ordered

        mock(@git).has_dot_git?().returns(false)
        mock(@git).clone(original_git_url, project_name, "base")
        stub(Dir).chdir

        mock(@git).remote_add("mortar", project_git_url)
        mock(@git).push_master
        mock(@git).git("fetch --all")
        mock(@git).set_upstream("mortar/master")
        any_instance_of(Mortar::Command::Projects) do |base|
          mock(base).ask.with_any_args.times(1) { 'y' }
        end

        stderr, stdout = execute("projects:fork #{original_git_url} #{project_name} --public", nil, @git)
        stdout.should == <<-STDOUT
Public projects allow anyone to view and fork the code in this project's repository. Are you sure? (y/n) Sending request to register project: some_new_project... done\n\n\r\e[0KStatus: ACTIVE  \n\nYour project is ready for use.  Type 'mortar help' to see the commands you can perform on the project.\n
STDOUT
      end

    end

  end
end

redpajama_set_name: RedPajamaGithub


text:
import time
import os
import subprocess
#import thread

def omxservice():
	while (True):
		if (os.popen("ps ax | grep -v grep | grep omxplayer").read()==''):
			subprocess.Popen("omxplayer /home/pi/tvchannel.mov --loop --no-keys", shell=True, stdin=subprocess.PIPE)
		else:
			time.sleep(1)
omxservice()
#thread.start_new_thread( omxservice, () )

#while (True):pass


text:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:util="http://www.springframework.org/schema/util"
	xsi:schemaLocation="
			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       		http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
    ">

	<bean class="org.kaleidofoundry.spring.context.BeanContextPostProcessor" name="kaleidoPostProcessor"/>

	<bean id="myService" class="org.kaleidofoundry.spring.context.xml.MyXmlSpringService"/>

	<bean id="myCdiService" class="org.kaleidofoundry.spring.context.xml.MyXmlCdiSpringService"/>

	<bean id="myContext" class="org.kaleidofoundry.core.context.RuntimeContext">
		<constructor-arg type="java.lang.String" value="myContext"/>
		<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.store.FileStore"/>
		<constructor-arg type="java.util.concurrent.ConcurrentMap" >
			<util:map map-class="java.util.concurrent.ConcurrentHashMap">
			</util:map>
		</constructor-arg>
		<constructor-arg type="org.kaleidofoundry.core.config.Configuration[]"><null/></constructor-arg>
	</bean>

	<bean id="myNamedContext" class="org.kaleidofoundry.core.context.RuntimeContext">
		<constructor-arg type="java.lang.String" value="namedCtx"/>
		<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.store.FileStore"/>
		<constructor-arg type="java.util.concurrent.ConcurrentMap" >
			<util:map map-class="java.util.concurrent.ConcurrentHashMap">
			</util:map>
		</constructor-arg>
		<constructor-arg type="org.kaleidofoundry.core.config.Configuration[]"><null/></constructor-arg>
	</bean>

	<bean id="myStore" class="org.kaleidofoundry.core.store.ClasspathFileStore">
		<constructor-arg>
			<bean class="org.kaleidofoundry.core.context.RuntimeContext">
				<constructor-arg type="java.lang.String" value="myStore"/>
				<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.store.FileStore"/>
				<constructor-arg type="java.util.concurrent.ConcurrentMap" >
					<util:map map-class="java.util.concurrent.ConcurrentHashMap">
						<entry key="baseUri" value="classpath:/store" />
					</util:map>
				</constructor-arg>
				<constructor-arg type="org.kaleidofoundry.core.config.Configuration[]"><null/></constructor-arg>
			</bean>
		</constructor-arg>
	</bean>

	<bean id="myConfig" class="org.kaleidofoundry.core.config.PropertiesConfiguration" init-method="load" destroy-method="unload">
		<constructor-arg>
			<bean class="org.kaleidofoundry.core.context.RuntimeContext">
				<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.config.Configuration"/>
				<constructor-arg type="java.util.concurrent.ConcurrentMap" >
					<util:map map-class="java.util.concurrent.ConcurrentHashMap">
						<entry key="name" value="myConfig" />
						<entry key="fileStoreUri" value="classpath:/config/myConfig.properties" />
					</util:map>
				</constructor-arg>
			</bean>
		</constructor-arg>
	</bean>

	<bean id="myDefaultCacheManager" class="org.kaleidofoundry.core.cache.LocalCacheManagerImpl">
		<constructor-arg>
			<bean class="org.kaleidofoundry.core.context.RuntimeContext">
				<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.cache.CacheManager"/>
				<constructor-arg type="java.util.concurrent.ConcurrentMap" >
					<util:map map-class="java.util.concurrent.ConcurrentHashMap"/>
				</constructor-arg>
			</bean>
		</constructor-arg>
	</bean>

	<bean id="myDefaultCache" class="org.kaleidofoundry.core.cache.LocalCacheImpl">
		<constructor-arg value="myDefaultCache"/>
		<constructor-arg ref="myDefaultCacheManager"/>
	</bean>

	<bean id="myCustomCacheManager" class="org.kaleidofoundry.core.cache.InfinispanCacheManagerImpl">
		<constructor-arg>
			<bean class="org.kaleidofoundry.core.context.RuntimeContext">
				<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.cache.CacheManager"/>
				<constructor-arg type="java.util.concurrent.ConcurrentMap" >
					<util:map map-class="java.util.concurrent.ConcurrentHashMap">
						<entry key="fileStoreUri" value="classpath:/cache/infinispan-local.xml" />
					</util:map>
				</constructor-arg>
			</bean>
		</constructor-arg>
	</bean>

	<bean id="myCustomCache" class="org.kaleidofoundry.core.cache.InfinispanCacheImpl">
		<constructor-arg type="java.lang.String" value="myNamedCache"/>
		<constructor-arg type="org.kaleidofoundry.core.cache.InfinispanCacheManagerImpl" ref="myCustomCacheManager"/>
		<constructor-arg type="org.kaleidofoundry.core.context.RuntimeContext">
			<bean class="org.kaleidofoundry.core.context.RuntimeContext">
				<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.cache.Cache"/>
				<constructor-arg type="java.util.concurrent.ConcurrentMap" >
					<util:map map-class="java.util.concurrent.ConcurrentHashMap">
					</util:map>
				</constructor-arg>
			</bean>
		</constructor-arg>
	</bean>

	<bean id="myNamingService" class="org.kaleidofoundry.core.naming.JndiNamingService">
		<constructor-arg>
			<bean class="org.kaleidofoundry.core.context.RuntimeContext">
				<constructor-arg type="java.lang.Class" value="org.kaleidofoundry.core.naming.NamingService"/>
				<constructor-arg type="java.util.concurrent.ConcurrentMap" >
					<util:map map-class="java.util.concurrent.ConcurrentHashMap">
						<entry key="java.naming.factory.initial" value="com.sun.enterprise.naming.SerialInitContextFactory" />
						<entry key="java.naming.factory.url.pkgs" value="com.sun.enterprise.naming" />
						<entry key="java.naming.factory.state" value="com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl" />
						<entry key="org.omg.CORBA.ORBInitialHost" value="127.0.0.1" />
						<entry key="org.omg.CORBA.ORBInitialPort" value="3700" />
					</util:map>
				</constructor-arg>
			</bean>
		</constructor-arg>
	</bean>
</beans>


text:
package org.osmdroid.util;

import android.graphics.Rect;

import org.junit.Assert;
import org.junit.Test;

import java.util.Random;

/**
 * @author Fabrice Fontaine
 * @since 6.0.2
 * <p>
 * VERY IMPORTANT NOTICE
 * In class RectL, don't use syntaxes like Point.set, Point.offset or Point.center.
 * Use "Point.x=" and "Point.y=" syntaxes instead. Same for Rect.
 * Why?
 * Because class Point - though relatively low level - is part of an Android package
 * that does not belong to standard Java.
 * As a result, using it in Unit Test is a bit heavier.
 * I prefer the light version of unit test.
 * For more info, search "android unit test mock"
 */

public class RectLTest {

    private static final Random mRandom = new Random();
    private static final int mMaxCoordinate = 2000;
    private static final int mIterations = 100;

    /**
     * The rotation center is kept whatever the degrees are
     */
    @Test
    public void testGetRotatedCenter() {
        for (int i = 0; i < mIterations; i++) {
            final long x = getRandomCoordinate();
            final long y = getRandomCoordinate();
            final double degrees = getRandomAngle();
            Assert.assertEquals(x, RectL.getRotatedX(x, y, degrees, x, y));
            Assert.assertEquals(y, RectL.getRotatedY(x, y, degrees, x, y));
        }
    }

    /**
     * For a 0 degree rotation: x = x and y = y
     */
    @Test
    public void testGetRotated0() {
        final double degrees = 0;
        for (int i = 0; i < mIterations; i++) {
            final long x = getRandomCoordinate();
            final long y = getRandomCoordinate();
            final long centerX = getRandomCoordinate();
            final long centerY = getRandomCoordinate();
            Assert.assertEquals(x, RectL.getRotatedX(x, y, degrees, centerX, centerY));
            Assert.assertEquals(y, RectL.getRotatedY(x, y, degrees, centerX, centerY));
        }
    }

    /**
     * For a 90 degree rotation: x = -y and y = x
     * With translation steps around the rotation center
     */
    @Test
    public void testGetRotated90() {
        final double degrees = 90;
        for (int i = 0; i < mIterations; i++) {
            final long x = getRandomCoordinate();
            final long y = getRandomCoordinate();
            final long centerX = getRandomCoordinate();
            final long centerY = getRandomCoordinate();
            Assert.assertEquals(centerX - (y - centerY), RectL.getRotatedX(x, y, degrees, centerX, centerY));
            Assert.assertEquals(centerY + (x - centerX), RectL.getRotatedY(x, y, degrees, centerX, centerY));
        }
    }

    /**
     * For a 180 degree rotation: x = -x and y = -y
     * With translation steps around the rotation center
     */
    @Test
    public void testGetRotated180() {
        final double degrees = 180;
        for (int i = 0; i < mIterations; i++) {
            final long x = getRandomCoordinate();
            final long y = getRandomCoordinate();
            final long centerX = getRandomCoordinate();
            final long centerY = getRandomCoordinate();
            Assert.assertEquals(centerX - (x - centerX), RectL.getRotatedX(x, y, degrees, centerX, centerY));
            Assert.assertEquals(centerY - (y - centerY), RectL.getRotatedY(x, y, degrees, centerX, centerY));
        }
    }

    /**
     * For a 270 degree rotation: x = y and y = -x
     * With translation steps around the rotation center
     */
    @Test
    public void testGetRotated270() {
        final double degrees = 270;
        for (int i = 0; i < mIterations; i++) {
            final long x = getRandomCoordinate();
            final long y = getRandomCoordinate();
            final long centerX = getRandomCoordinate();
            final long centerY = getRandomCoordinate();
            Assert.assertEquals(centerX + (y - centerY), RectL.getRotatedX(x, y, degrees, centerX, centerY));
            Assert.assertEquals(centerY - (x - centerX), RectL.getRotatedY(x, y, degrees, centerX, centerY));
        }
    }

    /**
     * For a 0 degree rotation the rect is kept
     */
    @Test
    public void testGetBounds0() {
        final double degrees = 0;
        final RectL in = new RectL();
        final RectL out = new RectL();
        for (int i = 0; i < mIterations; i++) {
            in.top = getRandomCoordinate();
            in.left = getRandomCoordinate();
            in.bottom = getRandomCoordinate();
            in.right = getRandomCoordinate();
            final long centerX = getRandomCoordinate();
            final long centerY = getRandomCoordinate();
            RectL.getBounds(in, centerX, centerY, degrees, out);
            Assert.assertEquals(in.top, out.top);
            Assert.assertEquals(in.left, out.left);
            Assert.assertEquals(in.bottom, out.bottom);
            Assert.assertEquals(in.right, out.right);
        }
    }

    /**
     * For a 180 degree rotation the rect is mirrored on the rotation center
     */
    @Test
    public void testGetBounds180() {
        final double degrees = 180;
        final RectL in = new RectL();
        final RectL out = new RectL();
        for (int i = 0; i < mIterations; i++) {
            in.top = getRandomCoordinate();
            in.left = getRandomCoordinate();
            in.bottom = getRandomCoordinate();
            in.right = getRandomCoordinate();
            final long centerX = getRandomCoordinate();
            final long centerY = getRandomCoordinate();
            RectL.getBounds(in, centerX, centerY, degrees, out);
            final long top = centerY - (in.top - centerY);
            final long bottom = centerY - (in.bottom - centerY);
            final long left = centerX - (in.left - centerX);
            final long right = centerX - (in.right - centerX);
            Assert.assertEquals(Math.min(top, bottom), out.top);
            Assert.assertEquals(Math.min(left, right), out.left);
            Assert.assertEquals(Math.max(top, bottom), out.bottom);
            Assert.assertEquals(Math.max(left, right), out.right);
        }
    }

    @Test
    public void testGetBoundsSamplesRectL() {
        final RectL in = new RectL();
        final RectL out = new RectL();

        in.set(0, 0, 4, 6);
        RectL.getBounds(in, 0, 0, 180, out);
        Assert.assertEquals(-6, out.top);
        Assert.assertEquals(0, out.bottom);
        Assert.assertEquals(-4, out.left);
        Assert.assertEquals(0, out.right);

        in.set(0, 0, 5, 7);
        RectL.getBounds(in, 0, 0, 90, out);
        Assert.assertEquals(0, out.top);
        Assert.assertEquals(-7, out.left);
        Assert.assertEquals(5, out.bottom);
        Assert.assertEquals(0, out.right);

        in.set(0, 0, 8, 8);
        RectL.getBounds(in, 0, 0, 45, out);
        Assert.assertEquals(0, out.top);
        Assert.assertEquals(-Math.round(8 * Math.sqrt(2) / 2.), out.left);
        Assert.assertEquals(Math.round(8 * Math.sqrt(2)), out.bottom);
        Assert.assertEquals(Math.round(8 * Math.sqrt(2) / 2.), out.right);
    }

    @Test
    public void testGetBoundsSamplesRect() {
        final Rect in = new Rect();
        final Rect out = new Rect();
        in.top = 0; // lousy member setting for Rect - see javadoc comments on class
        in.left = 0;

        in.bottom = 6;
        in.right = 4;
        RectL.getBounds(in, 0, 0, 180, out);
        Assert.assertEquals(-6, out.top);
        Assert.assertEquals(0, out.bottom);
        Assert.assertEquals(-4, out.left);
        Assert.assertEquals(0, out.right);

        in.bottom = 7;
        in.right = 5;
        RectL.getBounds(in, 0, 0, 90, out);
        Assert.assertEquals(0, out.top);
        Assert.assertEquals(-7, out.left);
        Assert.assertEquals(5, out.bottom);
        Assert.assertEquals(0, out.right);

        in.bottom = 8;
        in.right = 8;
        RectL.getBounds(in, 0, 0, 45, out);
        Assert.assertEquals(0, out.top);
        Assert.assertEquals(-Math.round(8 * Math.sqrt(2) / 2.), out.left);
        Assert.assertEquals(Math.round(8 * Math.sqrt(2)), out.bottom);
        Assert.assertEquals(Math.round(8 * Math.sqrt(2) / 2.), out.right);
    }

    private long getRandomCoordinate() {
        return mRandom.nextInt(mMaxCoordinate) * (mRandom.nextBoolean() ? 1 : -1);
    }

    private double getRandomAngle() {
        return mRandom.nextInt(360);
    }
}


text:
':' //; exec "$(command -v nodejs || command -v node)" "$0" "$@"
'use strict';

// Replacing local undefined
console.log('Undefined can be replaced in the local scope:');
var testLocalRedefine = function() {
    var undefined = 'not undefined';
    console.log(undefined);// not undefined
    console.log(typeof undefined === 'undefined');// false
}
testLocalRedefine();

// Check if a variable is undefined without using the undefined keyword
console.log('\nChecking that a variable is undefined when undefined was redefined:');
var testNoKeywordUndefined = function() {
    var a;

    console.log(a === undefined);// true
    var undefined = 'not undefined';
    console.log(a === undefined);// false
    console.log(typeof a === 'undefined');// true
}
testNoKeywordUndefined();

// Check if a variable is undefined without using the undefined keyword
console.log('\nExplicitly setting to undefined when the keyword was redefined:');
var testSetToUndefined = function() {
    var a = 'test';
    var undefined = 'not undefined';

    a = undefined;
    console.log(a);// not undefined
    a = void 0;
    console.log(a);// undefined
}
testSetToUndefined();


text:
require 'formula'

class Inspircd < Formula
  homepage 'http://www.inspircd.org'
  url 'https://github.com/inspircd/inspircd/archive/v2.0.17.tar.gz'
  sha1 '79c1a2438b926f5cb945db6dd02c4a1416dc9946'

  head 'https://github.com/inspircd/inspircd.git'

  bottle do
    sha1 "e00f0f3742a4868937bd1d609c37c3ab3fc50fd5" => :mavericks
    sha1 "cd9bcce5522b4154fe8793fc505769c9e22e8eed" => :mountain_lion
    sha1 "1fabcc797fe120beefc7f4228d35d7519192c505" => :lion
  end

  skip_clean 'data'
  skip_clean 'logs'

  depends_on 'pkg-config' => :build
  depends_on 'geoip' => :optional
  depends_on 'gnutls' => :optional
  depends_on 'libgcrypt' if build.with? 'gnutls'
  depends_on :mysql => :optional
  depends_on 'pcre' => :optional
  depends_on 'postgresql' => :optional
  depends_on 'sqlite' => :optional
  depends_on 'tre' => :optional

  option 'without-ldap', 'Build without ldap support'
  option 'without-openssl', 'Build without openssl support'

  def install
    modules = []
    modules << 'm_geoip.cpp' if build.with? 'geoip'
    modules << 'm_ssl_gnutls.cpp' if build.with? 'gnutls'
    modules << 'm_mysql.cpp' if build.with? 'mysql'
    modules << 'm_ssl_openssl.cpp' if build.with? 'openssl'
    modules << 'm_ldapauth.cpp' if build.with? 'ldap'
    modules << 'm_ldapoper.cpp' if build.with? 'ldap'
    modules << 'm_regex_pcre.cpp' if build.with? 'pcre'
    modules << 'm_pgsql.cpp' if build.with? 'postgresql'
    modules << 'm_sqlite3.cpp' if build.with? 'sqlite'
    modules << 'm_regex_tre.cpp' if build.with? 'tre'

    system './configure', "--enable-extras=#{modules.join(',')}" unless modules.empty?
    system './configure', "--prefix=#{prefix}", "--with-cc=#{ENV.cc}"
    system 'make install'

    inreplace "#{prefix}/org.inspircd.plist", 'ircdaemon', ENV['USER']
  end
end


text:
package com.ltree.dtm.dubbo.rpc.filter;

import com.alibaba.dubbo.common.extension.Activate;
import com.alibaba.dubbo.common.utils.StringUtils;
import com.alibaba.dubbo.rpc.*;
import com.ltree.dtm.Constants;
import com.ltree.dtm.transaction.Trace.MethodInvokeTrace;

/**
 * 事务相关信息拦截处理过滤器,此过滤器主要用于获取调用方法的相关信息,如名称、方法、参数等,且指针对consumer
 *
 * @author lemontree
 * @version 1.0, 2017/8/8
 * @since 1.0
 */
@Activate(group = Constants.CONSUMER)
public class TransactionFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        Result result = invoker.invoke(invocation);
        // 如果是injvm协议,则使用不用理会直接使用jdbc本地事务回滚
        if (StringUtils.isEquals(invoker.getUrl().getProtocol(), Constants.LOCAL_PROTOCOL)) {
            return result;
        }

        MethodInvokeTrace.put(invocation);

        return result;
    }
}


text:
package org.kie.pmml.models.regression.compiler.factories;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.ConstructorDeclaration;
import com.github.javaparser.ast.expr.Expression;
import com.github.javaparser.ast.expr.NameExpr;
import com.github.javaparser.ast.expr.ObjectCreationExpr;
import com.github.javaparser.ast.expr.StringLiteralExpr;
import org.dmg.pmml.DataDictionary;
import org.dmg.pmml.DataField;
import org.dmg.pmml.DataType;
import org.dmg.pmml.MiningField;
import org.dmg.pmml.MiningFunction;
import org.dmg.pmml.MiningSchema;
import org.dmg.pmml.OpType;
import org.dmg.pmml.TransformationDictionary;
import org.dmg.pmml.regression.CategoricalPredictor;
import org.dmg.pmml.regression.NumericPredictor;
import org.dmg.pmml.regression.PredictorTerm;
import org.dmg.pmml.regression.RegressionModel;
import org.dmg.pmml.regression.RegressionTable;
import org.junit.BeforeClass;
import org.junit.Test;
import org.kie.pmml.api.enums.MINING_FUNCTION;
import org.kie.pmml.api.enums.OP_TYPE;
import org.kie.pmml.api.enums.PMML_MODEL;
import org.kie.pmml.api.iinterfaces.SerializableFunction;
import org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock;
import org.kie.pmml.models.regression.model.KiePMMLRegressionClassificationTable;
import org.kie.pmml.models.regression.model.KiePMMLRegressionModel;
import org.kie.pmml.models.regression.model.KiePMMLRegressionTable;
import org.kie.pmml.models.regression.model.enums.REGRESSION_NORMALIZATION_METHOD;
import org.kie.pmml.models.regression.model.tuples.KiePMMLTableSourceCategory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.kie.pmml.commons.utils.KiePMMLModelUtils.getSanitizedClassName;
import static org.kie.pmml.compiler.commons.testutils.CodegenTestUtils.commonEvaluateConstructor;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getCategoricalPredictor;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getDataDictionary;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getDataField;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getMiningField;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getMiningSchema;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getNumericPredictor;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getPredictorTerm;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getRegressionModel;
import static org.kie.pmml.compiler.commons.testutils.PMMLModelTestUtils.getRegressionTable;
import static org.kie.pmml.compiler.commons.utils.JavaParserUtils.getFromFileName;
import static org.kie.pmml.models.regression.compiler.factories.KiePMMLRegressionModelFactory.KIE_PMML_REGRESSION_MODEL_TEMPLATE;
import static org.kie.pmml.models.regression.compiler.factories.KiePMMLRegressionModelFactory.KIE_PMML_REGRESSION_MODEL_TEMPLATE_JAVA;

public class KiePMMLRegressionModelFactoryTest {

    private static final String PACKAGE_NAME = "packagename";

    private static CompilationUnit COMPILATION_UNIT;
    private static ClassOrInterfaceDeclaration MODEL_TEMPLATE;

    private static final String modelName = "firstModel";
    private static final double tableIntercept =  3.5;
    private static final Object tableTargetCategory = "professional";
    private static List<RegressionTable> regressionTables;
    private static List<DataField> dataFields;
    private static List<MiningField> miningFields;
    private static MiningField targetMiningField;
    private static DataDictionary dataDictionary;
    private static TransformationDictionary transformationDictionary;
    private static MiningSchema miningSchema;
    private static RegressionModel regressionModel;

    @BeforeClass
    public static void setup() {
        Random random = new Random();
        Set<String> fieldNames = new HashSet<>();
        regressionTables = IntStream.range(0, 3).mapToObj(i -> {
                                                              List<CategoricalPredictor> categoricalPredictors = new ArrayList<>();
                                                              List<NumericPredictor> numericPredictors = new ArrayList<>();
                                                              List<PredictorTerm> predictorTerms = new ArrayList<>();
                                                              IntStream.range(0, 3).forEach(j -> {
                                                                  String catFieldName = "CatPred-" + j;
                                                                  String numFieldName = "NumPred-" + j;
                                                                  categoricalPredictors.add(getCategoricalPredictor(catFieldName, random.nextDouble(), random.nextDouble()));
                                                                  numericPredictors.add(getNumericPredictor(numFieldName, random.nextInt(), random.nextDouble()));
                                                                  predictorTerms.add(getPredictorTerm("PredTerm-" + j, random.nextDouble(), Arrays.asList(catFieldName, numFieldName)));
                                                                  fieldNames.add(catFieldName);
                                                                  fieldNames.add(numFieldName);
                                                              });
                                                              return getRegressionTable(categoricalPredictors, numericPredictors, predictorTerms, tableIntercept + random.nextDouble(), tableTargetCategory + "-" + i);
                                                          }
        ).collect(Collectors.toList());
        dataFields = new ArrayList<>();
        miningFields = new ArrayList<>();
        fieldNames.forEach(fieldName -> {
            dataFields.add(getDataField(fieldName, OpType.CATEGORICAL, DataType.STRING));
            miningFields.add(getMiningField(fieldName, MiningField.UsageType.ACTIVE));
        });
        targetMiningField = miningFields.get(0);
        targetMiningField.setUsageType(MiningField.UsageType.TARGET);
        dataDictionary = getDataDictionary(dataFields);
        transformationDictionary = new TransformationDictionary();
        miningSchema = getMiningSchema(miningFields);
        regressionModel = getRegressionModel(modelName, MiningFunction.REGRESSION, miningSchema, regressionTables);
        COMPILATION_UNIT = getFromFileName(KIE_PMML_REGRESSION_MODEL_TEMPLATE_JAVA);
        MODEL_TEMPLATE = COMPILATION_UNIT.getClassByName(KIE_PMML_REGRESSION_MODEL_TEMPLATE).get();
    }

    @Test
    public void getKiePMMLRegressionModelClasses() throws IOException, IllegalAccessException, InstantiationException {
        KiePMMLRegressionModel retrieved = KiePMMLRegressionModelFactory.getKiePMMLRegressionModelClasses(dataDictionary,
                                                                                transformationDictionary,
                                                                                regressionModel,
                                                                                PACKAGE_NAME,
                                                                                new HasClassLoaderMock());
        assertNotNull(retrieved);
        assertEquals(regressionModel.getModelName(), retrieved.getName());
        assertEquals(MINING_FUNCTION.byName(regressionModel.getMiningFunction().value()), retrieved.getMiningFunction());
        assertEquals(miningFields.get(0).getName().getValue(), retrieved.getTargetField());
        final KiePMMLRegressionTable regressionTable = retrieved.getRegressionTable();
        assertNotNull(regressionTable);
        assertTrue(regressionTable instanceof KiePMMLRegressionClassificationTable);
        evaluateCategoricalRegressionTable((KiePMMLRegressionClassificationTable) regressionTable);
    }

    @Test
    public void getKiePMMLRegressionModelSourcesMap() throws IOException {
        Map<String, String> retrieved = KiePMMLRegressionModelFactory.getKiePMMLRegressionModelSourcesMap(dataDictionary, transformationDictionary, regressionModel, PACKAGE_NAME);
        assertNotNull(retrieved);
        int expectedSize = regressionTables.size()
                + 2; // One for classification and one for the whole model
        assertEquals(expectedSize, retrieved.size());
    }

    @Test
    public void getRegressionTablesMap() throws IOException {
        String targetFieldName = "targetFieldName";
        Map<String, KiePMMLTableSourceCategory> retrieved = KiePMMLRegressionModelFactory
                .getRegressionTablesMap(dataDictionary,
                                        regressionModel,
                                        targetFieldName,
                                        Collections.emptyList(),
                                        PACKAGE_NAME);
        int expectedSize = regressionTables.size() + 1; // One for classification
        assertEquals(expectedSize, retrieved.size());
        final Collection<KiePMMLTableSourceCategory> values = retrieved.values();
        regressionTables.forEach(regressionTable ->
                                         assertTrue(values.stream().anyMatch(kiePMMLTableSourceCategory -> kiePMMLTableSourceCategory.getCategory().equals(regressionTable.getTargetCategory()))));

    }

    @Test
    public void setConstructor() {
        String nestedTable = "NestedTable";
        MINING_FUNCTION miningFunction = MINING_FUNCTION.byName(regressionModel.getMiningFunction().value());
        final ClassOrInterfaceDeclaration modelTemplate = MODEL_TEMPLATE.clone();
        KiePMMLRegressionModelFactory.setConstructor(regressionModel,
                                                     dataDictionary,
                                                     transformationDictionary,
                                                     modelTemplate,
                                                     nestedTable);
        Map<Integer, Expression> superInvocationExpressionsMap = new HashMap<>();
        superInvocationExpressionsMap.put(0, new NameExpr(String.format("\"%s\"", regressionModel.getModelName())));
        Map<String, Expression> assignExpressionMap = new HashMap<>();
        assignExpressionMap.put("targetField", new StringLiteralExpr(targetMiningField.getName().getValue()));
        assignExpressionMap.put("miningFunction", new NameExpr(miningFunction.getClass().getName() + "." + miningFunction.name()));
        assignExpressionMap.put("pmmlMODEL", new NameExpr(PMML_MODEL.class.getName() + "." + PMML_MODEL.REGRESSION_MODEL.name()));
        ObjectCreationExpr objectCreationExpr = new ObjectCreationExpr();
        objectCreationExpr.setType(nestedTable);
        assignExpressionMap.put("regressionTable", objectCreationExpr);
        ConstructorDeclaration constructorDeclaration = modelTemplate.getDefaultConstructor().get();
        assertTrue(commonEvaluateConstructor(constructorDeclaration, getSanitizedClassName(regressionModel.getModelName()), superInvocationExpressionsMap, assignExpressionMap));
    }

    @Test
    public void isRegression() {
        assertTrue(KiePMMLRegressionModelFactory.isRegression(MiningFunction.REGRESSION, null, null));
        assertTrue(KiePMMLRegressionModelFactory.isRegression(MiningFunction.REGRESSION, "TARGET", OpType.CONTINUOUS));
        assertFalse(KiePMMLRegressionModelFactory.isRegression(MiningFunction.REGRESSION, "TARGET", OpType.CATEGORICAL));
        assertFalse(KiePMMLRegressionModelFactory.isRegression(MiningFunction.CLASSIFICATION, null, null));
    }

    private void evaluateCategoricalRegressionTable(KiePMMLRegressionClassificationTable regressionTable) {
        assertEquals(REGRESSION_NORMALIZATION_METHOD.byName(regressionModel.getNormalizationMethod().value()), regressionTable.getRegressionNormalizationMethod());
        assertEquals(OP_TYPE.CATEGORICAL, regressionTable.getOpType());
        final Map<String, KiePMMLRegressionTable> categoryTableMap = regressionTable.getCategoryTableMap();
        for (RegressionTable originalRegressionTable : regressionTables) {
            assertTrue(categoryTableMap.containsKey(originalRegressionTable.getTargetCategory().toString()));
            evaluateRegressionTable(categoryTableMap.get(originalRegressionTable.getTargetCategory().toString()), originalRegressionTable);
        }
    }

    private void evaluateRegressionTable(KiePMMLRegressionTable regressionTable, RegressionTable originalRegressionTable) {
        assertEquals(originalRegressionTable.getIntercept(), regressionTable.getIntercept());
        final Map<String, SerializableFunction<Double, Double>> numericFunctionMap = regressionTable.getNumericFunctionMap();
        for (NumericPredictor numericPredictor : originalRegressionTable.getNumericPredictors()) {
            assertTrue(numericFunctionMap.containsKey(numericPredictor.getName().getValue()));
        }
        final Map<String, SerializableFunction<Object, Double>> categoricalFunctionMap = regressionTable.getCategoricalFunctionMap();
        for (CategoricalPredictor categoricalPredictor : originalRegressionTable.getCategoricalPredictors()) {
            assertTrue(categoricalFunctionMap.containsKey(categoricalPredictor.getName().getValue()));
        }
        final Map<String, SerializableFunction<Map<String, Object>, Double>> predictorTermsFunctionMap = regressionTable.getPredictorTermsFunctionMap();
        for (PredictorTerm predictorTerm : originalRegressionTable.getPredictorTerms()) {
            assertTrue(predictorTermsFunctionMap.containsKey(predictorTerm.getName().getValue()));
        }
    }
}


text:
package com.cognizant.devops.platformservice.test.CorrelationBuilder;

import java.io.IOException;

import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;

import com.cognizant.devops.platformcommons.exception.InsightsCustomException;
import com.cognizant.devops.platformservice.correlationbuilder.service.CorrelationBuilderServiceImpl;

@Test
public class CorrelationBuilderTest extends CorrelationBuilderTestData {

	public static final CorrelationBuilderTestData correlationBuilderTestData = new CorrelationBuilderTestData();
	public static final CorrelationBuilderServiceImpl correlationBuilderImpl = new CorrelationBuilderServiceImpl();

	@Test(priority = 1)
	public void testSaveConfig() throws InsightsCustomException {
		Boolean response = correlationBuilderImpl.saveConfig(correlationBuilderTestData.saveDataConfig);
		Assert.assertTrue(response);
	}

	@Test(priority = 2)
	public void testGetAllCorrelations() throws InsightsCustomException {

		String actualOutCome = correlationBuilderImpl.getAllCorrelations().toString();
		Assert.assertTrue(correlationBuilderTestData.getConfigDetails.length() > 0);
	}

	@Test(priority = 3)
	public void testUpdateCorrelationStatus() throws InsightsCustomException {
		Boolean response = correlationBuilderImpl
				.updateCorrelationStatus(correlationBuilderTestData.UpdateConfigDetails);
		Assert.assertTrue(response);
	}

	@Test(priority = 4)
	public void testDeleteCorrelation() throws InsightsCustomException {
		Boolean response = correlationBuilderImpl.deleteCorrelation(correlationBuilderTestData.DeleteConfigDetails);
		Assert.assertTrue(response);
	}

	@AfterClass
	public void cleanUP() throws IOException {
		String resetConfigData = "[{\"destination\":{\"toolName\":\"JENKINS\",\"toolCategory\":\"CI\",\"fields\":[\"scmcommitId\"]},\"source\":{\"toolName\":\"GIT\",\"toolCategory\":\"SCM\",\"fields\":[\"commitId\"]},\"relationName\":\"TEST_FROM_GIT_TO_JENKINS\"}]";
		CorrelationBuilderTestData.resetConfig(resetConfigData);

	}
}


text:
/*
 * Module: safe_string.c
 *
 * This is a bunch of generic string operation
 * that are safe regarding buffer overflow.
 *
 * All string functions terminate the process with an error message
 * on buffer overflow.
 */

#ifdef HAVE_CONFIG_H
#  include "config.h"
#endif
#include "safe_string.h"
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>

static void string_overflow_handler(const char* format, ...)
{
    va_list args;
    va_start(args, format);
    vfprintf(stderr,format,args);
    va_end(args);
    exit(1);
}

int vsn_printf(char* dst, size_t size, const char* format, va_list args)
{
    int ret = vsnprintf(dst, size, format, args);
    if (ret >= size || ret < 0) {
	string_overflow_handler("Buffer truncated '%s'\n",dst);
    }
    return ret;
}

int sn_printf(char* dst, size_t size, const char* format, ...)
{
    va_list args;
    int ret;
    va_start(args, format);
    ret = vsn_printf(dst,size,format,args);
    va_end(args);
    return ret;
}

int strn_cpy(char* dst, size_t size, const char* src)
{
    return sn_printf(dst,size,"%s",src);
}

int strn_cat(char* dst, size_t size, const char* src)
{
    return strn_catf(dst,size,"%s",src);
}

int strn_catf(char* dst, size_t size, const char* format, ...)
{
    int ret;
    va_list args;
#ifdef _GNU_SOURCE
    int len = strnlen(dst,size);
#else
    int len = strlen(dst);
#endif

    if (len >= size) {
	string_overflow_handler("Buffer already overflowed '%.*s'\n",
				size, dst);
    }
    va_start(args, format);
    ret = vsn_printf(dst+len, size-len, format, args);
    va_end(args);
    return len+ret;
}

char* find_str(const char* haystack, int hsize, const char* needle)
{
    int i = 0;
    int nsize = strlen(needle);
    hsize -= nsize - 1;
    for (i=0; i<hsize; i++) {
	if (haystack[i]==needle[0] && strncmp(haystack+i,needle,nsize)==0) {
	    return (char*)(haystack+i);
	}
    }
    return NULL;
}

#ifndef HAVE_MEMMOVE
void* memmove(void *dest, const void *src, size_t n)
{
    int i;
    if (src > dest) {
	for (i=0; i<n; i++) ((char*)dest)[i] = ((char*)src)[i];
    }
    else {
	for (i=(int)(n-1); i>=0; i--) ((char*)dest)[i] = ((char*)src)[i];
    }
    return dest;
}
#endif /* HAVE_MEMMOVE */


text:
#include "task.h"
#include "deps/clog/clog.h"
#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <time.h>
#include <grp.h> /* setgroups() */

void
task_start (task_t *task)
{
    assert (task != NULL);

    time_t now = time (NULL);
    unsigned sleep_time = (difftime (now, task->started) > 1) ? 0 : 1;

    clog_debug("Last start %us ago, will wait for %us",
               (unsigned) difftime(now, task->started), sleep_time);
    memcpy (&task->started, &now, sizeof (time_t));

    if ((task->pid = fork ()) < 0)
        die ("fork failed: %s\n", ERRSTR);

    task->action = A_NONE;

    /* We got a valid PID, return */
    if (task->pid > 0) {
        clog_debug("Child pid = %i", task->pid);
        return;
    }

    /*
     * Sleep before exec'ing the child: this is needed to avoid performing
     * the classical "continued fork-exec without child reaping" DoS attack.
     * We do this here, as soon as the child has been forked.
     */
    safe_sleep (sleep_time);

    /* Execute child */
    if (task->write_fd >= 0) {
        clog_debug("Redirecting write_fd = %i -> %i", task->write_fd, STDOUT_FILENO);
        if (dup2 (task->write_fd, STDOUT_FILENO) < 0) {
            fprintf (stderr, "dup2() redirection failed: %s\n", ERRSTR);
            _exit (111);
        }
    }
    if (task->read_fd >= 0) {
        clog_debug("Redirecting read_fd = %i -> %i", task->read_fd, STDIN_FILENO);
        if (dup2 (task->read_fd, STDIN_FILENO) < 0) {
            fprintf (stderr, "dup2() redirection failed: %s\n", ERRSTR);
            _exit (111);
        }
    }

    if (task->redir_errfd) {
        clog_debug("Redirecting stderr -> stdout");
        if (dup2 (STDOUT_FILENO, STDERR_FILENO) < 0) {
            fprintf (stderr, "dup2() failed for stderr: %s\n", ERRSTR);
            _exit (111);
        }
    }

    /* Groups must be changed first, while we have privileges */
    if (task->user.gid > 0) {
        clog_debug("Set group id %i", task->pid);
        if (setgid (task->user.gid))
            die ("could not set group id: %s\n", ERRSTR);
    }

    if (task->user.ngid > 0) {
        clog_debug("Calling setgroups (%u groups)\n", task->user.ngid);
        if (setgroups (task->user.ngid, task->user.gids))
            die ("could not set additional groups: %s\n", ERRSTR);
    }

    /* Now drop privileges */
    if (task->user.uid > 0) {
        clog_debug("Set user id %u", (unsigned) task->user.uid);
        if (setuid (task->user.uid))
            die ("could not set user id: %s\n", ERRSTR);
    }

    execvp (task->argv[0], task->argv);
    _exit (111);
}

void
task_signal_dispatch (task_t *task)
{
    assert (task != NULL);

    if (task->signal == NO_SIGNAL) /* Invalid signal, nothing to do */
        return;

    clog_debug("Signal %i to process %i", task->signal, task->pid);

    if (kill (task->pid, task->signal) < 0) {
        die ("cannot send signal %i to process %lu: %s\n",
             task->signal, (unsigned long) task->pid, ERRSTR);
    }
    task_signal_queue (task, NO_SIGNAL);
}

void
task_signal (task_t *task, int signum)
{
    assert (task != NULL);

    /* Dispatch pending signal first if needed */
    task_signal_dispatch (task);

    /* Then send our own */
    task_signal_queue (task, signum);
    task_signal_dispatch (task);
}

void
task_action_dispatch (task_t *task)
{
    assert (task != NULL);

    switch (task->action) {
        case A_NONE: /* Nothing to do */
            return;
        case A_START:
            task_start (task);
            break;
        case A_STOP:
            task_action_queue (task, A_NONE);
            if (task->pid != NO_PID) {
                task_signal (task, SIGTERM);
                task_signal (task, SIGCONT);
            }
            break;
        case A_SIGNAL:
            task_action_queue (task, A_NONE);
            task_signal_dispatch (task);
            break;
    }
}

void
task_action (task_t *task, action_t action)
{
    assert (task != NULL);

    /* Dispatch pending action. */
    task_action_dispatch (task);

    /* Send our own action. */
    task_action_queue (task, action);
    task_action_dispatch (task);
}

/* vim: expandtab tabstop=4 shiftwidth=4
 */