Skip to content

Commit

Permalink
IGN-2681 .NET: Enable RegisterSameJavaType for Cache API
Browse files Browse the repository at this point in the history
Merge in OSPT/ignite from IGN-2681 to master

Squashed commit of the following:

commit 52c96c308aca0e2baeb7a1c476d990a215d69810
Author: Nikolay Izhikov <nizhikov@apache.org>
Date:   Wed Feb 17 18:42:57 2021 +0300

    IGN-2681: Enable RegisterSameJavaType mode for a cache operations.
  • Loading branch information
nizhikov committed Feb 22, 2022
1 parent 3bf8812 commit 330ef81
Show file tree
Hide file tree
Showing 13 changed files with 377 additions and 100 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@
import org.apache.ignite.platform.model.Parameter;
import org.apache.ignite.platform.model.Role;
import org.apache.ignite.platform.model.User;
import org.apache.ignite.platform.model.V10;
import org.apache.ignite.platform.model.V11;
import org.apache.ignite.platform.model.V12;
import org.apache.ignite.platform.model.V5;
import org.apache.ignite.platform.model.V6;
import org.apache.ignite.platform.model.V7;
import org.apache.ignite.platform.model.V8;
import org.apache.ignite.platform.model.V9;
import org.apache.ignite.platform.model.Value;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.services.Service;
Expand Down Expand Up @@ -651,6 +655,23 @@ public void testLocalDateFromCache() {
cache.put(8, ts2);
}

/** */
public void putValsForCache() {
ignite.<Integer, V9>getOrCreateCache("V9").put(1, new V9("1"));

IgniteCache<Integer, V10> v10 = ignite.getOrCreateCache("V10");

v10.put(1, new V10("1"));
v10.put(2, new V10("2"));

ignite.<Integer, V11>getOrCreateCache("V11").put(1, new V11("1"));

IgniteCache<Integer, V12> v12 = ignite.getOrCreateCache("V12");

v12.put(1, new V12("1"));
v12.put(2, new V12("2"));
}

/** */
private final AtomicInteger cntMsgs = new AtomicInteger(0);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.platform.model;

/** Test V10 object. */
public class V10 {
/** */
private final String name;

/** */
public V10(String name) {
this.name = name;
}

/** */
public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.platform.model;

/** Test V11 object. */
public class V11 {
/** */
private final String name;

/** */
public V11(String name) {
this.name = name;
}

/** */
public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.platform.model;

/** Test V12 object. */
public class V12 {
/** */
private final String name;

/** */
public V12(String name) {
this.name = name;
}

/** */
public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.platform.model;

/** Test V9 object. */
public class V9 {
/** */
private final String name;

/** */
public V9(String name) {
this.name = name;
}

/** */
public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public interface IJavaService
/** */
void sleep(long delayMs);

/** */
void putValsForCache();

/** */
void startReceiveMessage();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ public void testSendMessage()
_svc.testSendMessage();
}

/** <inheritDoc /> */
public void putValsForCache()
{
_svc.putValsForCache();
}

/** <inheritDoc /> */
public object testRoundtrip(object x)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,32 @@ public class V5 { public String Name { get; set; } }
public class V6 { public String Name { get; set; } }

/// <summary>
/// A class is a clone of Java class V6 with the same namespace.
/// A class is a clone of Java class V7 with the same namespace.
/// </summary>
public class V7 { public String Name { get; set; } }

/// <summary>
/// A class is a clone of Java class V6 with the same namespace.
/// A class is a clone of Java class V8 with the same namespace.
/// </summary>
public class V8 { public String Name { get; set; } }

/// <summary>
/// A class is a clone of Java class V9 with the same namespace.
/// </summary>
public class V9 { public String Name { get; set; } }

/// <summary>
/// A class is a clone of Java class V10 with the same namespace.
/// </summary>
public class V10 { public String Name { get; set; } }

/// <summary>
/// A class is a clone of Java class V11 with the same namespace.
/// </summary>
public class V11 { public String Name { get; set; } }

/// <summary>
/// A class is a clone of Java class V12 with the same namespace.
/// </summary>
public class V12 { public String Name { get; set; } }
}
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,23 @@ public void testSendMessage()
throw new NotImplementedException();
}

public void putValsForCache()
{
_ignite.GetOrCreateCache<int, V9>("V9").Put(1, new V9 {Name = "1"});

var v10 = _ignite.GetOrCreateCache<int, V10>("V10");

v10.Put(1, new V10 {Name = "1"});
v10.Put(2, new V10 {Name = "2"});

_ignite.GetOrCreateCache<int, V11>("V11").Put(1, new V11 {Name = "1"});

var v12 = _ignite.GetOrCreateCache<int, V12>("V12");

v12.Put(1, new V12 {Name = "1"});
v12.Put(2, new V12 {Name = "2"});
}

/** <inheritDoc /> */
public object testRoundtrip(object x)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,36 @@ private void DoTestService(IJavaService svc, bool isPlatform = false)

if (_useBinaryArray)
Assert.AreEqual(typeof(User[]), users2.GetType());

svc.putValsForCache();

Assert.AreEqual("1", _grid1.GetCache<int, V9>("V9").Get(1).Name);

var v10 = _grid1.GetCache<int, V10>("V10").GetAll(new List<int> {1, 2});

Assert.AreEqual(2, v10.Count);

foreach (var entry in v10)
{
if (entry.Key == 1)
Assert.AreEqual("1", entry.Value.Name);
else
Assert.AreEqual("2", entry.Value.Name);
}

Assert.AreEqual("1", _grid1.GetCache<int, V11>("V11").GetAsync(1).Result.Name);

var v12 = _grid1.GetCache<int, V12>("V12").GetAllAsync(new List<int> {1, 2}).Result;

Assert.AreEqual(2, v12.Count);

foreach (var entry in v12)
{
if (entry.Key == 1)
Assert.AreEqual("1", entry.Value.Name);
else
Assert.AreEqual("2", entry.Value.Name);
}
}

/// <summary>
Expand Down

0 comments on commit 330ef81

Please sign in to comment.