// ĠCopyright Ġ 2 0 0 0 - 2 0 1 9 ĠJetBrains Ġs . r . o . ĠUse Ġof Ġthis Ġsource Ġcode Ġis Ġgoverned Ġby Ġthe ĠApache Ġ 2 . 0 Ġlicense Ġthat Ġcan Ġbe Ġfound Ġin Ġthe ĠLICENSE Ġfile . Ċ package Ġcom . intellij . util . indexing Ċ Ċ import Ġcom . intellij . openapi . util . io . File Util Ċ import Ġcom . intellij . util . indexing . zip Fs . Un compressed Zip FileSystem Ċ import Ġcom . intellij . util . indexing . zip Fs . Un compressed Zip FileSystem Provider Ċ import Ġcom . intellij . util . io . zip . JB Zip File Ċ import Ġjunit . framework . TestCase Ċ Ċ import Ġjava . io . File Ċ import Ġjava . nio . file . Files Ċ Ċ class ĠUn compressed Zip Test Ġ: ĠTestCase () Ġ{ ĊĊĠ Ġ@ Throws ( Exception :: class ) ĊĠ Ġoverride Ġfun ĠsetUp () Ġ{ ĊĠ Ġ} ĊĊĠ Ġ@ Throws ( Exception :: class ) ĊĠ Ġoverride Ġfun ĠtearDown () Ġ{ ĊĠ Ġ} ĊĊĠ Ġfun Ġtest Fs Structure () Ġ{ ĊĠĠĠ Ġval Ġdir Ġ= ĠFile Util . create Temp Directory (" zip 0 - fs - structure - dir ", Ġnull ) ĊĊĠĠĠ Ġval Ġfile Ġ= ĠFile ( dir , Ġ" a . zip ") ĊĠĠĠ Ġval Ġzip Ġ= ĠJ B Zip File ( file ) ĊĠĠĠ Ġval Ġstr Ġ= Ġ" Hello " ĊĠĠĠ Ġval Ġhello Bytes Ġ= Ġstr . toByteArray ( Charsets . UTF _ 8 ) ĊĠĠĠ Ġzip . use Ġ{ ĊĠĠĠĠĠ Ġzip . get OrCreate Entry (" b . txt "). data Ġ= Ġhello Bytes ĊĠĠĠĠĠ Ġzip . get OrCreate Entry (" a / b . txt "). data Ġ= Ġhello Bytes ĊĠĠĠĠĠ Ġzip . get OrCreate Entry (" a / c . txt "). data Ġ= Ġhello Bytes ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġfs Ġ= ĠUn compressed Zip FileSystem ( file . to Path (), ĠUn compressed Zip FileSystem Provider ()) ĊĠĠĠ Ġval Ġfile 1 Ġ= Ġfs . getPath (" b . txt ") ĊĠĠĠ Ġval Ġfile 2 Ġ= Ġfs . getPath (" a ", Ġ" b . txt ") ĊĠĠĠ Ġval Ġfile 3 Ġ= Ġfs . getPath (" a ", Ġ" c . txt ") ĊĊĠĠĠ ĠassertTrue ( Files . exists ( file 1 )) ĊĠĠĠ ĠassertTrue ( Files . exists ( file 2 )) ĊĠĠĠ ĠassertTrue ( Files . exists ( file 3 )) ĊĊĠĠĠ ĠassertTrue ( hello Bytes . content Equals ( Files . read All Bytes ( file 1 ))) ĊĠĠĠ ĠassertTrue ( hello Bytes . content Equals ( Files . read All Bytes ( file 2 ))) ĊĠĠĠ ĠassertTrue ( hello Bytes . content Equals ( Files . read All Bytes ( file 3 ))) ĊĊĠĠĠ Ġval Ġparent 2 Ġ= Ġfile 2 . parent ĊĠĠĠ Ġval Ġparent 3 Ġ= Ġfile 3 . parent ĊĠĠĠ ĠassertTrue ( Files . is Same File ( parent 2 , Ġparent 3 )) ĊĊĠĠĠ Ġval Ġpp 2 Ġ= Ġparent 2 . parent ĊĠĠĠ Ġval Ġpp 3 Ġ= Ġparent 3 . parent ĊĠĠĠ Ġval Ġpp 1 Ġ= Ġfile 1 . parent ĊĠĠĠ ĠassertTrue ( Files . is Same File ( pp 1 , Ġpp 2 )) ĊĠĠĠ ĠassertTrue ( Files . is Same File ( pp 1 , Ġpp 3 )) ĊĠĠĠ ĠassertTrue ( Files . is Same File ( pp 2 , Ġpp 3 )) ĊĊĠĠĠ Ġfs . close () ĊĠ Ġ} Ċ } Ċ