forked from mulesoft/mule
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
W-16584126: PolyMule fixes (mulesoft#13817)
* W-16584126: PolyMule fixes * Fix `equals` * Allowing lambda serialization * Serialization test * Review.
- Loading branch information
1 parent
05e9951
commit 0ec0360
Showing
6 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
.../runtime/core/internal/transformer/type/DynamicDelegateDataTypeSerializationTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2023 Salesforce, Inc. All rights reserved. | ||
* The software in this package is published under the terms of the CPAL v1.0 | ||
* license, a copy of which has been included with this distribution in the | ||
* LICENSE.txt file. | ||
*/ | ||
package org.mule.runtime.core.internal.transformer.type; | ||
|
||
import static org.mule.runtime.api.util.classloader.MuleImplementationLoaderUtils.isResolveMuleImplementationLoadersDynamically; | ||
|
||
import static org.apache.commons.lang3.SerializationUtils.deserialize; | ||
import static org.apache.commons.lang3.SerializationUtils.serialize; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.mockito.Mockito.mockStatic; | ||
|
||
import org.mule.runtime.api.metadata.DataType; | ||
import org.mule.runtime.api.metadata.DataType.DynamicDelegateDataType; | ||
import org.mule.runtime.api.util.classloader.MuleImplementationLoaderUtils; | ||
import org.mule.runtime.core.privileged.metadata.DefaultDataTypeBuilder; | ||
import org.mule.tck.junit4.AbstractMuleTestCase; | ||
import org.mule.tck.size.SmallTest; | ||
|
||
import java.io.Serializable; | ||
import java.util.function.Supplier; | ||
|
||
import io.qameta.allure.Issue; | ||
import org.junit.Test; | ||
import org.mockito.MockedStatic; | ||
|
||
@SmallTest | ||
@Issue("W-16584126") | ||
public class DynamicDelegateDataTypeSerializationTestCase extends AbstractMuleTestCase { | ||
|
||
@Test | ||
public void serializeDynamicDelegateDataType() { | ||
DataType delegate = new DefaultDataTypeBuilder().build(); | ||
DynamicDelegateDataType original = new DynamicDelegateDataType((Supplier<DataType> & Serializable) () -> delegate); | ||
byte[] serialized = serialize(original); | ||
DynamicDelegateDataType deserialized = deserialize(serialized); | ||
assertThat(deserialized, is(original)); | ||
|
||
try (final MockedStatic<MuleImplementationLoaderUtils> mockedLoaderUtils = mockStatic(MuleImplementationLoaderUtils.class)) { | ||
mockedLoaderUtils.when(MuleImplementationLoaderUtils::isResolveMuleImplementationLoadersDynamically).thenReturn(true); | ||
mockedLoaderUtils.when(MuleImplementationLoaderUtils::getMuleImplementationsLoader) | ||
.thenReturn(this.getClass().getClassLoader()); | ||
assertThat(isResolveMuleImplementationLoadersDynamically(), is(true)); | ||
|
||
assertThat(deserialized.getDelegate(), is(original.getDelegate())); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters