ignite-3477-master fix MarshallerContextSelfTest.testOnUpdated
@@ -31,12 +31,15 @@ import org.apache.ignite.internal.MarshallerContextImpl;
import org.apache.ignite.internal.processors.closure.GridClosureProcessor;
import org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem;
import org.apache.ignite.internal.processors.pool.PoolProcessor;
+import org.apache.ignite.internal.util.typedef.PA;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.GridTestKernalContext;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static java.nio.file.Files.readAllBytes;
import static org.apache.ignite.internal.MarshallerPlatformIds.JAVA_ID;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
/**
* Test marshaller context.
@@ -95,6 +98,9 @@ public class MarshallerContextSelfTest extends GridCommonAbstractTest {
ctx.onMappingAccepted(item1);
+ // Wait until marshaller context write class to file.
+ U.sleep(2_000);
+
checkFileName("java.lang.String", Paths.get(workDir + "/1.classname0"));
MarshallerMappingItem item2 = new MarshallerMappingItem((byte) 2, 2, "Random.Class.Name");
@@ -103,6 +109,7 @@ public class MarshallerContextSelfTest extends GridCommonAbstractTest {
ctx.onMappingAccepted(item2);
execSvc.shutdown();
+
if (execSvc.awaitTermination(1000, TimeUnit.MILLISECONDS))
checkFileName("Random.Class.Name", Paths.get(workDir + "/2.classname2"));
else
@@ -181,6 +188,10 @@ public class MarshallerContextSelfTest extends GridCommonAbstractTest {
* @param pathToReal Path to real.
*/
private void checkFileName(String expected, Path pathToReal) throws IOException {
- assertEquals(expected, new String(readAllBytes(pathToReal)));
+ byte[] fileContent = readAllBytes(pathToReal);
+
+ assert fileContent != null && fileContent.length > 0;
+
+ assertEquals(expected, new String(fileContent));
}
}
