Search in sources :

Example 6 with SerializationClassNameFilter

use of com.hazelcast.internal.serialization.SerializationClassNameFilter in project hazelcast by hazelcast.

the class SerializationClassNameFilterTest method testPackageInWhitelist.

/**
 * <pre>
 * Given: Whitelist is set.
 * When: {@link SerializationClassNameFilter#filter(String)} is called for a class which has whitelisted package.
 * Then: no exception is thrown
 * </pre>
 */
@Test
public void testPackageInWhitelist() {
    JavaSerializationFilterConfig config = new JavaSerializationFilterConfig();
    config.getWhitelist().addPackages("com.whitelisted");
    new SerializationClassNameFilter(config).filter("com.whitelisted.Test2");
}
Also used : SerializationClassNameFilter(com.hazelcast.internal.serialization.SerializationClassNameFilter) JavaSerializationFilterConfig(com.hazelcast.config.JavaSerializationFilterConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with SerializationClassNameFilter

use of com.hazelcast.internal.serialization.SerializationClassNameFilter in project hazelcast by hazelcast.

the class SerializationClassNameFilterTest method testClassInWhitelist.

/**
 * <pre>
 * Given: Default is disabled and explicit whitelist is used.
 * When: {@link SerializationClassNameFilter#filter(String)} is called for a whitelisted class.
 * Then: no exception is thrown
 * </pre>
 */
@Test
public void testClassInWhitelist() {
    JavaSerializationFilterConfig config = new JavaSerializationFilterConfig().setDefaultsDisabled(true);
    config.getWhitelist().addClasses("java.lang.Test1", "java.lang.Test2", "java.lang.Test3");
    new SerializationClassNameFilter(config).filter("java.lang.Test2");
}
Also used : SerializationClassNameFilter(com.hazelcast.internal.serialization.SerializationClassNameFilter) JavaSerializationFilterConfig(com.hazelcast.config.JavaSerializationFilterConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

JavaSerializationFilterConfig (com.hazelcast.config.JavaSerializationFilterConfig)7 SerializationClassNameFilter (com.hazelcast.internal.serialization.SerializationClassNameFilter)7 QuickTest (com.hazelcast.test.annotation.QuickTest)6 Test (org.junit.Test)6