aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/skyframe
diff options
context:
space:
mode:
authorGravatar janakr <janakr@google.com>2018-04-26 18:56:54 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-26 18:58:15 -0700
commit968059d59719d7789b4b3fe97fe0d6be0e86682d (patch)
tree4107dae5a5898eb7b671e0a9376a79029d22b7c5 /src/test/java/com/google/devtools/build/lib/skyframe
parent805f54c28836d6eadfbbf3f0815816cb5ecaff82 (diff)
Allow class prefix names to be blacklisted from DynamicCodec use.
PiperOrigin-RevId: 194487570
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skyframe')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/serialization/ObjectCodecRegistryTest.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/ObjectCodecRegistryTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/ObjectCodecRegistryTest.java
index b5272defcc..42daccb6b2 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/ObjectCodecRegistryTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/ObjectCodecRegistryTest.java
@@ -147,6 +147,28 @@ public class ObjectCodecRegistryTest {
assertThat(underTest.maybeGetTagForConstant("cab".substring(1))).isNotNull();
}
+ private static ObjectCodecRegistry.Builder builderWithThisClass() {
+ return ObjectCodecRegistry.newBuilder().addClassName(ObjectCodecRegistryTest.class.getName());
+ }
+
+ @Test
+ public void blacklistingPrefix() throws NoCodecException {
+ ObjectCodecRegistry underTest = builderWithThisClass().build();
+ CodecDescriptor descriptor = underTest.getCodecDescriptorForObject(this);
+ assertThat(descriptor).isNotNull();
+ assertThat(descriptor.getCodec()).isInstanceOf(DynamicCodec.class);
+ ObjectCodecRegistry underTestWithBlacklist =
+ builderWithThisClass()
+ .blacklistClassNamePrefix(this.getClass().getPackage().getName())
+ .build();
+ assertThrows(
+ NoCodecException.class, () -> underTestWithBlacklist.getCodecDescriptorForObject(this));
+ ObjectCodecRegistry underTestWithWideBlacklist =
+ builderWithThisClass().blacklistClassNamePrefix("com").build();
+ assertThrows(
+ NoCodecException.class, () -> underTestWithWideBlacklist.getCodecDescriptorForObject(this));
+ }
+
@Test
public void testGetBuilder() throws NoCodecException {
SingletonCodec<String> codec1 = SingletonCodec.of("value1", "mnemonic1");