Skip to content

Commit

Permalink
Add @fileexists validation to presto-local-file
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo authored and losipiuk committed Jun 9, 2020
1 parent a55dfd9 commit 267c6f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@

import io.airlift.configuration.Config;
import io.airlift.configuration.ConfigDescription;
import io.airlift.configuration.validation.FileExists;

public class LocalFileConfig
{
private String httpRequestLogLocation = "var/log/http-request.log";
private String httpRequestLogFileNamePattern;

@FileExists
public String getHttpRequestLogLocation()
{
return httpRequestLogLocation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import com.google.common.collect.ImmutableMap;
import org.testng.annotations.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;

import static io.airlift.configuration.testing.ConfigAssertions.assertFullMapping;
Expand All @@ -34,14 +37,17 @@ public void testDefaults()

@Test
public void testExplicitPropertyMappings()
throws IOException
{
Path httpRequestLogFile = Files.createTempFile(null, null);

Map<String, String> properties = new ImmutableMap.Builder<String, String>()
.put("presto-logs.http-request-log.location", "/data/foo.log")
.put("presto-logs.http-request-log.location", httpRequestLogFile.toString())
.put("presto-logs.http-request-log.pattern", "bar")
.build();

LocalFileConfig expected = new LocalFileConfig()
.setHttpRequestLogLocation("/data/foo.log")
.setHttpRequestLogLocation(httpRequestLogFile.toString())
.setHttpRequestLogFileNamePattern("bar");

assertFullMapping(properties, expected);
Expand Down

0 comments on commit 267c6f4

Please sign in to comment.