summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2022-07-12 17:28:59 +0200
committerGitHub <noreply@github.com>2022-07-12 17:28:59 +0200
commit393c46b52cb3580e563d755478481a197522553d (patch)
treebe1ec5adb5111883b44e746733b1dc0cb0b9529b
parent976c6accd58dcc8d14f91782968f357c9d0c07fe (diff)
parent21cb00e443783e0355d58f017ee7eec4a98ac0ff (diff)
Merge pull request #23477 from vespa-engine/mpolden/handle-abs-root
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java30
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithOnnxTestCase.java2
2 files changed, 16 insertions, 16 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java
index abd7ba3be9f..c88c1cdfc48 100644
--- a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java
+++ b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java
@@ -1,22 +1,22 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.test;
+import com.yahoo.component.Version;
+import com.yahoo.config.application.api.ApplicationFile;
import com.yahoo.config.application.api.ApplicationMetaData;
+import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.ComponentInfo;
import com.yahoo.config.application.api.UnparsedConfigDefinition;
-import com.yahoo.config.application.api.ApplicationFile;
-import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationName;
import com.yahoo.config.provision.InstanceName;
import com.yahoo.config.provision.TenantName;
import com.yahoo.io.IOUtils;
-import com.yahoo.path.Path;
import com.yahoo.io.reader.NamedReader;
+import com.yahoo.path.Path;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
import com.yahoo.vespa.config.ConfigDefinitionKey;
-import com.yahoo.config.application.api.ApplicationPackage;
import java.io.BufferedInputStream;
import java.io.File;
@@ -165,7 +165,7 @@ public class MockApplicationPackage implements ApplicationPackage {
@Override
public ApplicationFile getFile(Path file) {
if (files.containsKey(file)) return files.get(file);
- return new MockApplicationFile(file, Path.fromString(root.toString()));
+ return new MockApplicationFile(file, root);
}
@Override
@@ -288,7 +288,7 @@ public class MockApplicationPackage implements ApplicationPackage {
Map<Path, MockApplicationFile> mockFiles = new HashMap<>();
for (var file : files.entrySet())
mockFiles.put(file.getKey(), new MockApplicationFile(file.getKey(),
- Path.fromString(root.toString()), file.getValue()));
+ root, file.getValue()));
this.files = mockFiles;
return this;
}
@@ -374,8 +374,8 @@ public class MockApplicationPackage implements ApplicationPackage {
public static class MockApplicationFile extends ApplicationFile {
- /** The path to the application package root */
- private final Path root;
+ /** The application package root */
+ private final File root;
/** The File pointing to the actual file represented by this */
private final File file;
@@ -383,14 +383,14 @@ public class MockApplicationPackage implements ApplicationPackage {
/** The content of this file, or null to read it from the file system. */
private final String content;
- public MockApplicationFile(Path filePath, Path applicationPackagePath) {
- this(filePath, applicationPackagePath, null);
+ public MockApplicationFile(Path relativeFile, File root) {
+ this(relativeFile, root, null);
}
- private MockApplicationFile(Path filePath, Path applicationPackagePath, String content) {
- super(filePath);
- this.root = applicationPackagePath;
- file = applicationPackagePath.append(filePath).toFile();
+ private MockApplicationFile(Path relativeFile, File root, String content) {
+ super(relativeFile);
+ this.root = root;
+ this.file = root.toPath().resolve(relativeFile.toString()).toFile();
this.content = content;
}
@@ -491,7 +491,7 @@ public class MockApplicationPackage implements ApplicationPackage {
Iterator<String> pathIterator = path.iterator();
// Skip the path elements this shares with the root
- for (Iterator<String> rootIterator = root.iterator(); rootIterator.hasNext(); ) {
+ for (Iterator<String> rootIterator = Path.fromString(root.toString()).iterator(); rootIterator.hasNext(); ) {
String rootElement = rootIterator.next();
String pathElement = pathIterator.next();
if ( ! rootElement.equals(pathElement)) throw new RuntimeException("Assumption broken");
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithOnnxTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithOnnxTestCase.java
index 94a51d25717..bfd0520c62a 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithOnnxTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/RankingExpressionWithOnnxTestCase.java
@@ -391,7 +391,7 @@ public class RankingExpressionWithOnnxTestCase {
@Override
public ApplicationFile getFile(Path file) {
- return new MockApplicationFile(file, Path.fromString(root().toString()));
+ return new MockApplicationFile(file, root());
}
@Override