"Fossies" - the Fresh Open Source Software Archive 
Member "gradle-8.1.1/subprojects/core/src/test/groovy/org/gradle/api/internal/file/archive/AbstractArchiveFileTreeSpec.groovy" (20 Apr 2023, 2704 Bytes) of package /linux/misc/gradle-8.1.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Java source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /*
2 * Copyright 2020 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.gradle.api.internal.file.archive
18
19 import org.gradle.api.file.FileVisitor
20 import org.gradle.api.internal.file.FileTreeInternal
21 import org.gradle.api.internal.file.collections.DirectoryFileTree
22 import org.gradle.api.internal.file.collections.MinimalFileTree
23 import org.gradle.api.provider.Provider
24 import org.gradle.cache.internal.DecompressionCache
25 import org.gradle.cache.internal.TestCaches
26 import org.gradle.test.fixtures.file.TestNameTestDirectoryProvider
27 import org.gradle.util.TestUtil
28 import org.junit.Rule
29 import spock.lang.Specification
30
31 /**
32 * Tests core functionality in {@link AbstractArchiveFileTree} using a minimal test implementation.
33 */
34 class AbstractArchiveFileTreeSpec extends Specification {
35 @Rule
36 TestNameTestDirectoryProvider tmpDir = new TestNameTestDirectoryProvider(getClass())
37
38 def "visits structure when backing file is known"() {
39 def owner = Stub(FileTreeInternal)
40 def visitor = Mock(MinimalFileTree.MinimalFileTreeStructureVisitor)
41 def backingFile = tmpDir.createFile("thing.bin")
42
43 def fileTree = new TestArchiveFileTree(TestCaches.decompressionCache(tmpDir.createDir("cache-dir")), backingFile)
44
45 when:
46 fileTree.visitStructure(visitor, owner)
47
48 then:
49 1 * visitor.visitFileTreeBackedByFile(backingFile, owner, fileTree)
50 0 * _
51 }
52
53 static class TestArchiveFileTree extends AbstractArchiveFileTree {
54 File backingFile
55 final String displayName = "<display>"
56
57 TestArchiveFileTree(DecompressionCache decompressionCache, File backingFile) {
58 super(decompressionCache)
59 this.backingFile = backingFile
60 }
61
62 @Override
63 DirectoryFileTree getMirror() {
64 throw new UnsupportedOperationException()
65 }
66
67 @Override
68 void visit(FileVisitor visitor) {
69 throw new UnsupportedOperationException()
70 }
71
72 @Override
73 protected Provider<File> getBackingFileProvider() {
74 TestUtil.providerFactory().provider { backingFile }
75 }
76 }
77 }