Search in sources :

Example 1 with EnumConstructor

use of com.hazelcast.test.starter.constructor.EnumConstructor in project hazelcast by hazelcast.

the class EnumConstructorTest method testConstructor.

@Test
public void testConstructor() {
    EnumConstructor constructor = new EnumConstructor(TestEnum.class);
    assertEquals(TestEnum.FOO, constructor.createNew(TestEnum.FOO));
    assertEquals(TestEnum.BAR, constructor.createNew(TestEnum.BAR));
}
Also used : EnumConstructor(com.hazelcast.test.starter.constructor.EnumConstructor) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with EnumConstructor

use of com.hazelcast.test.starter.constructor.EnumConstructor in project hazelcast by hazelcast.

the class HazelcastProxyFactory method construct.

private static Object construct(Class<?> clazz, Object delegate) {
    ConstructorFunction<Object, Object> constructorFunction = CONSTRUCTORS.applyIfAbsent(clazz, input -> {
        String className = input.getName();
        Constructor<ConstructorFunction<Object, Object>> constructor = NO_PROXYING_WHITELIST.get(className);
        if (constructor != null) {
            try {
                return constructor.newInstance(input);
            } catch (Exception e) {
                throw new IllegalStateException(e);
            }
        } else if (input.isEnum()) {
            return new EnumConstructor(input);
        }
        throw new UnsupportedOperationException("Cannot construct target object for target " + input + " on classloader " + input.getClassLoader());
    });
    return constructorFunction.createNew(delegate);
}
Also used : EnumConstructor(com.hazelcast.test.starter.constructor.EnumConstructor) ConstructorFunction(com.hazelcast.internal.util.ConstructorFunction)

Aggregations

EnumConstructor (com.hazelcast.test.starter.constructor.EnumConstructor)2 ConstructorFunction (com.hazelcast.internal.util.ConstructorFunction)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1