|
19 | 19 | import com.facebook.presto.session.SessionMatchSpec; |
20 | 20 | import com.facebook.presto.spi.session.SessionPropertyConfigurationManager; |
21 | 21 | import com.google.common.collect.ImmutableMap; |
| 22 | +import org.testng.annotations.Test; |
22 | 23 |
|
23 | 24 | import java.io.IOException; |
24 | 25 | import java.nio.file.Files; |
25 | 26 | import java.nio.file.Path; |
26 | 27 | import java.util.Arrays; |
27 | 28 | import java.util.Map; |
| 29 | +import java.util.Optional; |
28 | 30 |
|
29 | 31 | import static com.facebook.presto.session.file.FileSessionPropertyManager.CODEC; |
30 | 32 | import static org.testng.Assert.assertEquals; |
@@ -59,4 +61,60 @@ protected void assertProperties(Map<String, String> defaultProperties, Map<Strin |
59 | 61 | assertEquals(manager.getCatalogSessionProperties(CONTEXT), catalogProperties); |
60 | 62 | } |
61 | 63 | } |
| 64 | + |
| 65 | + @Test |
| 66 | + public void testNullSessionProperties() |
| 67 | + throws IOException |
| 68 | + { |
| 69 | + ImmutableMap<String, Map<String, String>> catalogProperties = ImmutableMap.of("CATALOG", ImmutableMap.of("PROPERTY", "VALUE")); |
| 70 | + SessionMatchSpec spec = new SessionMatchSpec( |
| 71 | + Optional.empty(), |
| 72 | + Optional.empty(), |
| 73 | + Optional.empty(), |
| 74 | + Optional.empty(), |
| 75 | + Optional.empty(), |
| 76 | + Optional.empty(), |
| 77 | + Optional.empty(), |
| 78 | + null, |
| 79 | + catalogProperties); |
| 80 | + |
| 81 | + assertProperties(ImmutableMap.of(), ImmutableMap.of(), catalogProperties, spec); |
| 82 | + } |
| 83 | + |
| 84 | + @Test |
| 85 | + public void testNullCatalogSessionProperties() |
| 86 | + throws IOException |
| 87 | + { |
| 88 | + Map<String, String> properties = ImmutableMap.of("PROPERTY1", "VALUE1", "PROPERTY2", "VALUE2"); |
| 89 | + SessionMatchSpec spec = new SessionMatchSpec( |
| 90 | + Optional.empty(), |
| 91 | + Optional.empty(), |
| 92 | + Optional.empty(), |
| 93 | + Optional.empty(), |
| 94 | + Optional.empty(), |
| 95 | + Optional.empty(), |
| 96 | + Optional.empty(), |
| 97 | + properties, |
| 98 | + null); |
| 99 | + |
| 100 | + assertProperties(properties, spec); |
| 101 | + } |
| 102 | + |
| 103 | + @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Either sessionProperties or catalogSessionProperties must be provided") |
| 104 | + public void testNullBothSessionProperties() |
| 105 | + throws IOException |
| 106 | + { |
| 107 | + SessionMatchSpec spec = new SessionMatchSpec( |
| 108 | + Optional.empty(), |
| 109 | + Optional.empty(), |
| 110 | + Optional.empty(), |
| 111 | + Optional.empty(), |
| 112 | + Optional.empty(), |
| 113 | + Optional.empty(), |
| 114 | + Optional.empty(), |
| 115 | + null, |
| 116 | + null); |
| 117 | + |
| 118 | + assertProperties(ImmutableMap.of(), spec); |
| 119 | + } |
62 | 120 | } |
0 commit comments