« first day    last day (235 days later) » 
01:00 - 20:0020:00 - 23:00

1:02 AM
heya @fge
I slept on the laptop while coding :P
@fge can you check this out hastebin.com/lerasokawo.avrasm
 
fge
1:18 AM
@ItachiUchiha sorry, I was away
Checking now
Well, that's OK except that the test class name is not what we want
A few other things as well
 
What is it?
shoot
 
fge
So, as to the class name -- we test some class x.y.z.MyClass; ideally, the matching test case, save for special circumstances, should be x.y.z.MyClassTest
 
fge
Your example is all the more confusing that class MemoryFileSystem exists in a library we depend on
 
I normally first create the class ABC and write ABCTest
 
fge
1:23 AM
Since here we will be testing com.github.fge.filesystem.deletion.FailFastDeletionVisitor, well...
We don't want to test MemoryFileSystem here, right?
 
F***, I was all sleepy last time when I was coding
just lemme scroll
so we have a filesystemprovider in FailFastDeletionVisitor
and one path
 
fge
Screw that for the moment -- the important thing is the class we want to test
And the name of the associated test file
 
fge
No, we do want a "live" filesystem to test the visitor
We don't want to mock it
While it would be possible in theory, it would be waaay to much trouble
 
So do we create it from the MemoryFileSystemBuilder?
 
fge
1:34 AM
That's the idea; in this test, in @BeforeClass, we create a MemoryFileSystem, and in @AfterClass we close it
Since it is a Java 7 FileSystem, it can produce Paths, and what is more we can also write to it -- create files, directories, AND change their permissions
 
ok, just let me update
fs = MemoryFileSystemBuilder.newLinux().build("x");
I wanted to know, why newLinux()?
 
fge
Well, that could have been newUnix() probably
But anyway, this works for our purposes so let's stick with that for now :p
 
:P
Test file done
Do we need the path?
Do you have any rules for naming methods in the test file ?
brb
 
fge
1:50 AM
Show me what you've done so far -- test file and the class to be tested
 
The test file just have a init() and destroy()
 
fge
OK. Name and path?
 
just a FileSystem for the time being
which gets initialized in the init()
and closes in destroy()
 
fge
OK
Note that since we use TestNG, the name of methods do not matte
s,$,r,
 
fge
2:02 AM
All that matters is the annotations
 
I have never worked with TestNG before :P
 
fge
Now, what the visitor will ultimately use is Files.walkFileTree()
 
So now we have a file FailFastDeletionVisitor with methods returning FileVisitResult.CONTINUE
 
fge
Yes
 
and a test class with initialized FS
 
fge
2:04 AM
For the test we will purposefully introduce a test where this visitor should fail with a certain error
But given the state of the visitor as it is now, it won't
Therefore we will need to write the code to make that test pass ;)
That is the basic principle of TDD (Test Driven Development)
 
No negative test case for the moment :P
 
fge
Well, no tests at all, so that is to be expected
 
I have a query
 
fge
?
 
Here we are dealing with FileSystem, FileSystemProvider, MemoryFileSystem, MemoryFileSystemBuilder and Path. Can you please just give a brief intro on these?
I know about Path, so I have no trouble with it
I read and understood that A provider is a factory for one or more FileSystem instances
and FS is an interface to a file system and is the factory for objects to access files and other objects in the file system.
 
2:15 AM
@ItachiUchiha GM bro
 
I am not an android dev
 
fge
OK, so, a little rundown
A FileSystemProvider provides FileSystems
 
@ItachiUchiha are you a java dev. ?
 
@AndoMasahashi yes I am
 
fge
A FileSystem can generate Paths
 
2:17 AM
i have issue with java only
can you please look
 
@AndoMasahashi then please visit

Java

Dedicated to the discussion of the Java programming language a...
 
fge
When, at the user level, you call Paths.get("something"), what is called is FileSystems.getDefault().getPath("something")
 
Ahh, I c!
 
fge
In a JRE (recall: that means Java Runtime Environment), you have one default FileSystem -- and that FileSystem has been issued by a FileSystemProvider
This provider has been registered using a ServiceLoader
 
That is interesting. Does Paths always refer to default FS?
 
fge
2:19 AM
Yes, always
 
Can we change default FS?
 
fge
And what is more, a FileSystemProvider is only linked to one thing: a URI scheme
Yes, you can
So, take a Path you take by Paths.get()
If you get the URI from it, its scheme will always be file
Well, always
At least that is the scheme of all default fs providers provided by the JRE
 
Nice..
I am starting to get the hold of basics :P
 
fge
Well, onto that
We want to delete some file tree recursively, and our source is a Path
This Path has a FileSystem associated
And this FileSystem has a FileSystemProvider associated
 
Correct
 
fge
2:27 AM
And the provider holds all I/O (which is a design mistake to my eyes, and which is why I developed -base the way it is)
But nevermind that
If you have the provider you can do everything
And one thing that doesn't change is that for a given Path, you can be sure that all of its children will have the same provider
 
We already have it in our class, we fetched it from the path
 
fge
Exactly
We have it, we use it to perform deletions
 
the question is HOW?
 
fge
Well, using the methods the provider gives us ;)
 
it has a delete() which takes Path as an argument
 
fge
2:30 AM
Yes
 
and a deleteIfExists(Path) as well
 
fge
We don't care about that latter method
What matter is delete()
 
fge
Note that this method will NOT delete recursively
Hence our visitor ;)
 
So if I have a path /foo
and /foo contains bar and bar has abc.zip
/foo/bar/abc.zip
 
fge
2:32 AM
Yes?
 
and I say provider.delete(/foo) (Considering /foo as a path)
what happens?
 
fge
DirectoryNotEmptyException
;)
 
I c
Here is the issue :P
 
fge
Indeed
The visitor we are doing here is ONE possible visitor of a future MoreFiles.deleteRecursively()
There is another one but this is for later ;)
 
Alpha Clear, Charlie proceed..
 
fge
2:35 AM
The reason this one is named FailFast is that it will abort as soon as it finds it cannot delete a filesystem entry
The next one, which I cannot figure out the name of, will still try and delete more "content"
 
Can delete fail for any other reason other than AccessDenied ?
 
fge
But it will collect errors along the way, of course
Yes
 
Ok
@fge taking a leave now. Things are clearer now, hope to have faster results starting next time :)
 
fge
2:51 AM
Grr
Well, OK
I'll start java7-fs-googledrive then
 
 
8 hours later…
fge
10:34 AM
@Mr.777 ping
 
Yes, I got in this room already/
Left that room
 
fge
I can see that
When you are ready we can get started again :)
 
Okay.
 
fge
11:35 AM
Dum dedum
Filesystem implementation #3, started: Google Drive
 
Wow awesome
Good luck
 
fge
12:34 PM
Meh, the Java API is awfully complicated
 
 
5 hours later…
5:34 PM
@fge ping
 
fge
6:05 PM
Pong
Sorry, I was reading
 
fge
6:17 PM
So, how's it going?
(the test file)
 
6:38 PM
Hi
@fge
I am sorry
I had to go somewhere after office.
 
fge
No problem
I'm not much available today either
 
I am back as well
 
fge
room topic changed to fge's java.nio.file corner: Because File sucks! java7fs.wikia.com (go there with an adblock) [filesystems] [java] [java.nio.file]
room topic changed to fge's java.nio.file corner: NNo java.io.File in here! java7fs.wikia.com (go there with an adblock) [filesystems] [java] [java.nio.file]
room topic changed to fge's java.nio.file corner: No java.io.File in here! java7fs.wikia.com (go there with an adblock) [filesystems] [java] [java.nio.file]
Grrr
OK, so, let's continue? ;)
 
Yes sure please
 
Yay!
 
fge
6:44 PM
So, the problem here was setting up the test environments
@ItachiUchiha can you show what you have done so far?
 
yeah
this was my test class so far
nothing interesting in it
 
fge
@Mr.777 you'll need to create a FileSystem too for the test
 
@fge Ehmmm
 
fge
@Mr.777 look at the pastebin of @ItachiUchiha
You only need to create it
 
/me opens Ita's link and try to understand what needs to be done
Is that it? :O
 
fge
6:47 PM
The test is simple: we will call MorePaths.resolve() with a Path issued from the memoryfs and resolve it against a local, absolute path
 
That's already been done in MemoryFsTest.java ;)
 
fge
@Mr.777 oh?
 
Yes, the thing @ita pasted in hastebin is already being done in MemoryFsTest.java in src/test/java
 
fge
room topic changed to fge's java.nio.file corner: Because File sucks! java7fs.wikia.com (go there with an adblock) [filesystems] [java] [java.nio.file]
 
:P lol what's this?
 
fge
6:49 PM
Grrr
Why can't I insert a link in the room title?
 
File sucks... Say after me, File Sucks!!!
 
fge
@Mr.777 uhm, looking
 
You already have there: java7fs.wikia.com , no?
 
why are all the methods static in MemoryfsExample.java
 
fge
@ItachiUchiha it is only an example to use for reference
It will be removed once it's not needed anymore
@Mr.777 I don't have that file
 
6:51 PM
@fge :O I have
com.github.fge.filesystem.testfs package in src/test/java
 
fge
Uh
 
MemoryfsExample.java
 
fge
Yes, but that's not the file to use here
 
I know
That is for reference
 
Ok, so what next on the Visitor test?
 
fge
6:55 PM
@Mr.777, in fact you will need two -- one Jimfs as well. See github.com/google/jimfs for sample usages, it's easy
 
I will need two -- one jimfs? Didn't understand two--one relationship
 
@fge It seems easy to use..
 
fge
@ItachiUchiha in the filesystem in question, create a directory, a file in that directory, remove the write access to the directory, and issue the visitor on the directory. It should fail with AccessDeniedException
Which it won't at that point, of course
 
@Mr.777 he meant, we will also be using the Jimfs to get a new FS instance
 
fge
@Mr.777 we need an absolute path for both paths to test correctly
@Mr.777 and we have to account for the host OS; if it's Windows we can't do the test the way we want (/foo/bar won't work as a Windows path)
 
6:58 PM
@fge Yes, I agree.
 
fge
So we need two different filesystems with two different providers, both with Unix-like paths
 
@fge We need to do everything in the testcase itself?
 
fge
Therefore memoryfs and himfs
 
/ I am bad with test cases
 
fge
@ItachiUchiha hmm, yeah, you may create these in @BeforeClass
 
6:59 PM
@fge Aaah, now I got your point. Thanks. Let me set the testcase up and will paste
 
But I will eventually improve :P
@fge on it
 
fge
@Mr.777 there are both dependencies in build.gradle, I have added jimfs yesterday
 
Okay great
 
7:10 PM
@fge one quick question. I have seen all examples that require a path to create a directory. Do you want a specific address for the directory?
 
fge
@ItachiUchiha what do you mean, "address"? Name?
 
i mean the path and name of the directory
is C:/foo/bar good enough?
 
I am coding on one machine and setting up all this javafs stuff on ubuntu machine ;)
 
fge
@ItachiUchiha uh, please, use a Unix memoryfs
We need access privileges to work
@Mr.777 erm... 1. you should use a try-with-resources block to create the filesystems
2. no need to create the files, we only need the paths -- we don't care if they point to actual files
(resolution doesn't care)
 
try with resources block?
 
fge
7:18 PM
3. .printStackTrace() <-- no; let the test throw the exception
@Mr777 try (final FileSytem fs1 = ...; final FileSystem fs2 = ...;) { /* create paths and test here */ }
@Mr.777 the filesystems will be automatically closed after the try block has completed (successfully or not)
@ItachiUchiha in order to remove the write permission on the directory, see how I do it in the provided test file
 
@fge should i use -r--r--r--?
ahh
got it
 
fge
@ItachiUchiha no, r-xr-xr-x
We want an AccessDeniedException
 
yeah got it
 
fge
Well, change the permissions after creating the file in the directory
 
so execute access should be granted
 
fge
7:23 PM
Yes, we don't want to prevent entry into the directory
 
fge
@Mr.777 like I said we don't need to create any content
 
Not even directory?
 
fge
@Mr.777 a Path is an abstract resource; it may, or may not, point to something
Not even them
 
Okay, sorry
 
fge
7:25 PM
Also, both filesystems should be created in the same try-with-resources
room topic changed to fge's java.nio.file corner: No java.io.file in here! java7fs.wikia.com (go there with an adblock) [filesystems] [java] [java.nio.file]
 
@fge I got it's reason. Because we want both of them open @ same time, right? On the contrary, like i did, it will first create filesystem1, will close it and then create the second, am I right?
 
fge
Yes
If you try and do an operation on a closed filesystem, even on Paths issued from it, you'll get a ClosedFileSystemException
And we don't want that
 
hastebin.com/bifogimosa.avrasm Is it somehow better?
 
fge
Yes, however please choose a different path for fs2
 
@fge Okay but I was trying to simulate the scenario, if filesystems are different but path is same :(
 
fge
7:31 PM
If you choose the same name you have the problem that you can't test the correctness of the generated path's name ;)
 
Alright so, now I can do: MorePaths.resolve(path1,path2)
 
fge
Grab the result too :)
We need to test both its name and filesystem
Its name should be the same as path2, and its filesystem should be fs1
 
:P
null
 
fge
So, assertThat(path.getFileSystem()).isSameAs(fs1);
Uh, didn't you implement it?
 
Ops no
You were thinking something yesterday :D
 
7:38 PM
Can you please review
 
so didn't tell what exactly should be done if we find the matching root
 
fge
@ItachiUchiha line 36 --> leading space in the perms string, not sure that will work
@Mr.777 I thought I did :/
 
@fge Ummm
 
@fge oops :P
 
Let me scroll up and read :(
 
7:41 PM
So we have a dir created, a file created in it, the access changed
now we want to visit it
 
fge
@ItachiUchiha yep, so that will be the first test
 
I have created a method visitDirectory()
if you see in the hastebin
 
fge
@ItachiUchiha that won't work ;) We will use Files.walkFileTree() anyway
It is meant to manipulate FileVisitors ;)
 
@fge yes, my bad, you did yesterday. Well, I implemented that
And good news is , test passed :D
 
@fge FailFastDeletionVisitor which implements the FileVisitor has nothing to do now?
 
fge
7:47 PM
@Mr.777 also test the .toString() (should be "/bar")
 
/ Man, it is gonna take me some time to really start
 
fge
@ItachiUchiha for now it does nothing
But the goal is to have it do something because the test will fail
So, the test is: try { Files.walkFileTree(dir, new FailFastDeletionVisitor(dir)); shouldHaveThrown(AccessDeniedException.class); } catch (IOException e) { assertThat(e).isExactlyInstanceOf(AccessDeniedException.class); }
 
@fge Done
 
fge
@Mr.777 OK, now what remains is the case where path2 is not absolute ;)
 
@fge Okay, going to do that now
 
fge
7:52 PM
@Mr.777 and first things first, if it is not absolute but has a root, we fail (message: "path to resolve is not absolute but has a root")
By now you should know how to write this test ;)
 
So, should I implement two more cases? 1. Not absolute, no root. 2. Not absolute with some root?
Yes, I hope I can write this :D
 
fge
Use the same exception class as for other failure cases
@ItachiUchiha if you have difficulties, tell me
 
I have written the test case :)
 
@fge By this you mean path2 is absolute but has no root?
 
I have written the test case :)
 
fge
7:57 PM
@ItachiUchiha pastebin?
@Mr.777 no, I do mean a path which is not absolute but has a root
 
I am trying to find out what we are exactly doing, and were are we exactly visiting the dir..
 
fge
@Mr.777 such beasts actually exist (c:foo under Windows is an example)
 
@fge In Unix bar/foo is not absolute but has root
 
fge
@Mr.777 no, it does not have a root
@ItachiUchiha missing shouldHaveThrown() after Files.walkFileTree()
@ItachiUchiha if you forget it the test won't fail
 
01:00 - 20:0020:00 - 23:00

« first day    last day (235 days later) »