Skip to content

Commit bfffcc1

Browse files
authored
IGNITE-15803 Remove setMarshaller from tests (#11938)
1 parent dc959b9 commit bfffcc1

File tree

50 files changed

+84
-2231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+84
-2231
lines changed

modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import org.apache.ignite.cache.store.jdbc.dialect.OracleDialect;
6161
import org.apache.ignite.cache.store.jdbc.dialect.SQLServerDialect;
6262
import org.apache.ignite.internal.binary.BinaryEnumObjectImpl;
63-
import org.apache.ignite.internal.binary.BinaryMarshaller;
6463
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
6564
import org.apache.ignite.internal.util.typedef.C1;
6665
import org.apache.ignite.internal.util.typedef.F;
@@ -543,33 +542,13 @@ private void checkTypeConfiguration(@Nullable String cacheName, TypeKind kind, S
543542

544543
/**
545544
* @param type Type name to check.
546-
* @param binarySupported True if binary marshaller enable.
547545
* @return {@code True} if class not found.
548546
*/
549-
protected TypeKind kindForName(String type, boolean binarySupported) {
547+
protected TypeKind kindForName(String type) {
550548
if (BUILT_IN_TYPES.contains(type))
551549
return TypeKind.BUILT_IN;
552550

553-
if (binarySupported)
554-
return TypeKind.BINARY;
555-
556-
try {
557-
Class.forName(type);
558-
559-
return TypeKind.POJO;
560-
}
561-
catch (ClassNotFoundException e) {
562-
throw new CacheException("Failed to find class " + type +
563-
" (make sure the class is present in classPath or use BinaryMarshaller)", e);
564-
}
565-
}
566-
567-
/**
568-
* @param type Type name to check.
569-
* @return {@code True} if class not found.
570-
*/
571-
protected TypeKind kindForName(String type) {
572-
return kindForName(type, ignite.configuration().getMarshaller() instanceof BinaryMarshaller);
551+
return TypeKind.BINARY;
573552
}
574553

575554
/**
@@ -600,13 +579,11 @@ private Map<Object, EntryMapping> getOrCreateCacheMappings(@Nullable String cach
600579
entryMappings = U.newHashMap(cacheTypes.size());
601580

602581
if (!cacheTypes.isEmpty()) {
603-
boolean binarySupported = ignite.configuration().getMarshaller() instanceof BinaryMarshaller;
604-
605582
for (JdbcType type : cacheTypes) {
606583
String keyType = type.getKeyType();
607584
String valType = type.getValueType();
608585

609-
TypeKind keyKind = kindForName(keyType, binarySupported);
586+
TypeKind keyKind = kindForName(keyType);
610587

611588
checkTypeConfiguration(cacheName, keyKind, keyType, type.getKeyFields());
612589

@@ -616,7 +593,7 @@ private Map<Object, EntryMapping> getOrCreateCacheMappings(@Nullable String cach
616593
throw new CacheException("Key type must be unique in type metadata [cache=" +
617594
U.maskName(cacheName) + ", type=" + keyType + "]");
618595

619-
TypeKind valKind = kindForName(valType, binarySupported);
596+
TypeKind valKind = kindForName(valType);
620597

621598
checkTypeConfiguration(cacheName, valKind, valType, type.getValueFields());
622599

modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/sorted/inline/JavaObjectKeySerializer.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,18 @@ public class JavaObjectKeySerializer {
3838
* @param cfg Ignite configuration.
3939
*/
4040
public JavaObjectKeySerializer(IgniteConfiguration cfg) {
41-
marshaller = cfg.getMarshaller();
42-
clsLdr = U.resolveClassLoader(cfg);
41+
this(U.resolveClassLoader(cfg), cfg.getMarshaller());
42+
}
43+
44+
/**
45+
* Constructor.
46+
*
47+
* @param marshaller Marshaller.
48+
* @param clsLdr Class loader.
49+
*/
50+
public JavaObjectKeySerializer(ClassLoader clsLdr, Marshaller marshaller) {
51+
this.clsLdr = clsLdr;
52+
this.marshaller = marshaller;
4353
}
4454

4555
/** */

modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.ignite.IgniteCheckedException;
3131
import org.apache.ignite.IgniteLogger;
3232
import org.apache.ignite.internal.IgniteEx;
33-
import org.apache.ignite.internal.binary.BinaryMarshaller;
3433
import org.apache.ignite.internal.util.typedef.F;
3534
import org.apache.ignite.internal.util.typedef.internal.A;
3635
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -229,10 +228,7 @@ public SharedFsCheckpointSpi setDirectoryPaths(Collection<String> dirPaths) {
229228

230229
this.igniteInstanceName = igniteInstanceName;
231230

232-
if (ignite.configuration().getMarshaller() instanceof BinaryMarshaller)
233-
marsh = ((IgniteEx)ignite).context().marshallerContext().jdkMarshaller();
234-
else
235-
marsh = ignite.configuration().getMarshaller();
231+
marsh = ((IgniteEx)ignite).context().marshallerContext().jdkMarshaller();
236232

237233
folder = getNextSharedPath();
238234

modules/core/src/test/java/org/apache/ignite/internal/GridLifecycleAwareSelfTest.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.apache.ignite.configuration.ConnectorConfiguration;
2424
import org.apache.ignite.configuration.ConnectorMessageInterceptor;
2525
import org.apache.ignite.configuration.IgniteConfiguration;
26-
import org.apache.ignite.internal.binary.BinaryMarshaller;
2726
import org.apache.ignite.lifecycle.LifecycleAware;
2827
import org.apache.ignite.lifecycle.LifecycleBean;
2928
import org.apache.ignite.lifecycle.LifecycleEventType;
@@ -102,30 +101,6 @@ private static class TestLifecycleBean extends TestLifecycleAware implements Lif
102101
}
103102
}
104103

105-
/**
106-
*/
107-
private static class TestMarshaller extends BinaryMarshaller implements LifecycleAware {
108-
/** */
109-
private final TestLifecycleAware lifecycleAware = new TestLifecycleAware(null);
110-
111-
/** {@inheritDoc} */
112-
@Override public void start() {
113-
lifecycleAware.start();
114-
}
115-
116-
/** {@inheritDoc} */
117-
@Override public void stop() {
118-
lifecycleAware.stop();
119-
}
120-
121-
/**
122-
* @return Lifecycle aware.
123-
*/
124-
TestLifecycleAware lifecycleAware() {
125-
return lifecycleAware;
126-
}
127-
}
128-
129104
/**
130105
*/
131106
private static class TestLogger extends JavaLogger implements LifecycleAware {
@@ -182,12 +157,6 @@ TestLifecycleAware lifecycleAware() {
182157

183158
lifecycleAwares.add(lifecycleBean);
184159

185-
TestMarshaller marshaller = new TestMarshaller();
186-
187-
cfg.setMarshaller(marshaller);
188-
189-
lifecycleAwares.add(marshaller.lifecycleAware());
190-
191160
TestLogger testLog = new TestLogger();
192161

193162
cfg.setGridLogger(testLog);

modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import org.apache.ignite.IgniteBinary;
2121
import org.apache.ignite.binary.BinaryObject;
2222
import org.apache.ignite.binary.BinaryObjectBuilder;
23-
import org.apache.ignite.configuration.IgniteConfiguration;
24-
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
2523
import org.apache.ignite.testframework.config.GridTestProperties;
2624
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
2725
import org.junit.Test;
@@ -32,19 +30,6 @@
3230
* Tests testing framewrok, epecially BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER test property.
3331
*/
3432
public class BinarySimpleNameTestPropertySelfTest extends GridCommonAbstractTest {
35-
/**
36-
* flag for facade disabled test. As we use binary marshaller by default al
37-
*/
38-
private boolean enableJdkMarshaller;
39-
40-
/** {@inheritDoc} */
41-
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
42-
final IgniteConfiguration configuration = super.getConfiguration(igniteInstanceName);
43-
if (enableJdkMarshaller)
44-
configuration.setMarshaller(new JdkMarshaller());
45-
return configuration;
46-
}
47-
4833
/** {@inheritDoc} */
4934
@Override protected void afterTest() throws Exception {
5035
super.afterTest();
@@ -77,16 +62,6 @@ public void testPropertyDisabled() throws Exception {
7762
checkProperty("org.ignite.test.TestClass");
7863
}
7964

80-
/**
81-
* Check if Binary facade is disabled test. Test uses JDK marshaller to provide warranty facade is not available
82-
* @throws Exception If failed.
83-
*/
84-
@Test
85-
public void testBinaryDisabled() throws Exception {
86-
enableJdkMarshaller = true;
87-
assertNull(startGrid().binary());
88-
}
89-
9065
/**
9166
* @param expTypeName Type name.
9267
* @throws Exception If failed.

modules/core/src/test/java/org/apache/ignite/internal/managers/communication/GridIoManagerSelfTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.ignite.internal.GridTopic;
2929
import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
3030
import org.apache.ignite.internal.util.typedef.F;
31-
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
3231
import org.apache.ignite.plugin.extensions.communication.Message;
3332
import org.apache.ignite.plugin.extensions.communication.MessageReader;
3433
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
@@ -72,7 +71,6 @@ public GridIoManagerSelfTest() throws IgniteCheckedException {
7271
/** {@inheritDoc} */
7372
@Override protected void beforeTest() throws Exception {
7473
ctx.config().setCommunicationSpi(new TcpCommunicationSpi());
75-
ctx.config().setMarshaller(new JdkMarshaller());
7674

7775
// Turn off peer class loading to simplify mocking.
7876
ctx.config().setPeerClassLoadingEnabled(false);

modules/core/src/test/java/org/apache/ignite/internal/managers/deployment/GridDeploymentManagerStopSelfTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.apache.ignite.internal.GridComponent;
2222
import org.apache.ignite.internal.processors.resource.GridResourceProcessor;
2323
import org.apache.ignite.lang.IgniteFuture;
24-
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
2524
import org.apache.ignite.spi.IgniteSpiContext;
2625
import org.apache.ignite.spi.IgniteSpiException;
2726
import org.apache.ignite.spi.deployment.DeploymentListener;
@@ -46,7 +45,6 @@ public void testOnKernalStop() throws Exception {
4645

4746
GridTestKernalContext ctx = newContext();
4847

49-
ctx.config().setMarshaller(new JdkMarshaller());
5048
ctx.config().setDeploymentSpi(spi);
5149

5250
GridResourceProcessor resProc = new GridResourceProcessor(ctx);

modules/core/src/test/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,21 @@
1717

1818
package org.apache.ignite.internal.marshaller.optimized;
1919

20-
import org.apache.ignite.IgniteCheckedException;
21-
import org.apache.ignite.IgniteLogger;
22-
import org.apache.ignite.configuration.IgniteConfiguration;
23-
import org.apache.ignite.internal.GridKernalContext;
24-
import org.apache.ignite.internal.processors.cache.persistence.filename.SharedFileTree;
25-
import org.apache.ignite.internal.util.typedef.internal.U;
26-
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
27-
import org.apache.ignite.testframework.junits.GridTestKernalContext;
28-
import org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger;
20+
import org.apache.ignite.marshaller.Marshaller;
21+
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
2922
import org.junit.Test;
3023

31-
import static org.junit.Assert.assertEquals;
32-
3324
/**
3425
*
3526
*/
36-
public class OptimizedMarshallerEnumSelfTest {
37-
/** */
38-
private String igniteHome = System.getProperty("user.dir");
39-
40-
/** */
41-
private final IgniteLogger rootLog = new GridTestLog4jLogger(false);
27+
public class OptimizedMarshallerEnumSelfTest extends GridCommonAbstractTest {
4228

4329
/**
4430
* @throws Exception If failed.
4531
*/
4632
@Test
4733
public void testEnumSerialisation() throws Exception {
48-
OptimizedMarshaller marsh = new OptimizedMarshaller();
49-
50-
MarshallerContextTestImpl ctx = new MarshallerContextTestImpl();
51-
52-
ctx.setMarshallerMappingFileStoreDir(new SharedFileTree(U.defaultWorkDirectory()).marshaller());
53-
ctx.onMarshallerProcessorStarted(newContext(), null);
54-
55-
marsh.setContext(ctx);
34+
Marshaller marsh = initTestMarshallerContext(new OptimizedMarshaller());
5635

5736
byte[] bytes = marsh.marshal(TestEnum.Bond);
5837

@@ -62,16 +41,6 @@ public void testEnumSerialisation() throws Exception {
6241
assertEquals(TestEnum.Bond.desc, unmarshalled.desc);
6342
}
6443

65-
/** */
66-
private GridKernalContext newContext() throws IgniteCheckedException {
67-
IgniteConfiguration cfg = new IgniteConfiguration();
68-
69-
cfg.setIgniteHome(igniteHome);
70-
cfg.setClientMode(false);
71-
72-
return new GridTestKernalContext(rootLog.getLogger(OptimizedMarshallerEnumSelfTest.class), cfg);
73-
}
74-
7544
/** */
7645
private enum TestEnum {
7746
/** */

0 commit comments

Comments
 (0)