Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-7007 Added org.infinispan.remote module
- Loading branch information
1 parent
c02aee1
commit 3d60a53
Showing
6 changed files
with
142 additions
and
78 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...ly-modules/src/test/java/org/infinispan/test/integration/as/client/BaseHotRodQueryIT.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,71 @@ | |||
package org.infinispan.test.integration.as.client; | |||
|
|||
import static org.junit.Assert.assertEquals; | |||
import static org.junit.Assert.assertFalse; | |||
import static org.junit.Assert.assertNotNull; | |||
import static org.junit.Assert.assertTrue; | |||
|
|||
import java.util.List; | |||
|
|||
import org.infinispan.client.hotrod.RemoteCache; | |||
import org.infinispan.client.hotrod.RemoteCacheManager; | |||
import org.infinispan.client.hotrod.Search; | |||
import org.infinispan.client.hotrod.configuration.Configuration; | |||
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; | |||
import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; | |||
import org.infinispan.protostream.SerializationContext; | |||
import org.infinispan.protostream.annotations.ProtoSchemaBuilder; | |||
import org.infinispan.query.dsl.Query; | |||
import org.infinispan.query.dsl.QueryFactory; | |||
import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants; | |||
import org.junit.Test; | |||
|
|||
/** | |||
* @since 9.0 | |||
*/ | |||
public class BaseHotRodQueryIT { | |||
|
|||
private static RemoteCacheManager createCacheManager() { | |||
return new RemoteCacheManager(createConfiguration(), true); | |||
} | |||
|
|||
private static Configuration createConfiguration() { | |||
ConfigurationBuilder config = new ConfigurationBuilder(); | |||
config.addServer().host("127.0.0.1"); | |||
config.marshaller(new ProtoStreamMarshaller()); | |||
return config.build(); | |||
} | |||
|
|||
@Test | |||
public void testRemoteQuery() throws Exception { | |||
RemoteCacheManager rcm = createCacheManager(); | |||
|
|||
SerializationContext serializationContext = ProtoStreamMarshaller.getSerializationContext(rcm); | |||
ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); | |||
String protoFile = protoSchemaBuilder.fileName("test.proto") | |||
.addClass(Person.class) | |||
.build(serializationContext); | |||
|
|||
RemoteCache<String, String> metadataCache = rcm.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME); | |||
metadataCache.put("test.proto", protoFile); | |||
assertFalse(metadataCache.containsKey(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX)); | |||
|
|||
RemoteCache<String, Person> cache = rcm.getCache(); | |||
cache.clear(); | |||
cache.put("Adrian", new Person("Adrian")); | |||
|
|||
assertTrue(cache.containsKey("Adrian")); | |||
|
|||
QueryFactory qf = Search.getQueryFactory(cache); | |||
Query query = qf.from(Person.class) | |||
.having("name").eq("Adrian").toBuilder() | |||
.build(); | |||
List<Person> list = query.list(); | |||
assertNotNull(list); | |||
assertEquals(1, list.size()); | |||
assertEquals(Person.class, list.get(0).getClass()); | |||
assertEquals("Adrian", list.get(0).name); | |||
|
|||
rcm.stop(); | |||
} | |||
} |
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
16 changes: 16 additions & 0 deletions
16
...tests/wildfly-modules/src/test/java/org/infinispan/test/integration/as/client/Person.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
package org.infinispan.test.integration.as.client; | |||
|
|||
import org.infinispan.protostream.annotations.ProtoField; | |||
|
|||
public class Person { | |||
|
|||
@ProtoField(number = 1) | |||
public String name; | |||
|
|||
public Person(String name) { | |||
this.name = name; | |||
} | |||
|
|||
public Person() { | |||
} | |||
} |
37 changes: 37 additions & 0 deletions
37
.../src/test/java/org/infinispan/test/integration/as/remote/InfinispanRemoteWithQueryIT.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
package org.infinispan.test.integration.as.remote; | |||
|
|||
import org.infinispan.Version; | |||
import org.infinispan.test.integration.as.client.BaseHotRodQueryIT; | |||
import org.infinispan.test.integration.as.client.HotRodQueryIT; | |||
import org.infinispan.test.integration.as.client.Person; | |||
import org.jboss.arquillian.container.test.api.Deployment; | |||
import org.jboss.arquillian.junit.Arquillian; | |||
import org.jboss.shrinkwrap.api.Archive; | |||
import org.jboss.shrinkwrap.api.ShrinkWrap; | |||
import org.jboss.shrinkwrap.api.asset.StringAsset; | |||
import org.jboss.shrinkwrap.api.spec.WebArchive; | |||
import org.jboss.shrinkwrap.descriptor.api.Descriptors; | |||
import org.jboss.shrinkwrap.descriptor.api.spec.se.manifest.ManifestDescriptor; | |||
import org.junit.runner.RunWith; | |||
|
|||
/** | |||
* Tests for querying using 'org.infinispan.remote' aggregator module. | |||
* | |||
* @since 9.0 | |||
*/ | |||
@RunWith(Arquillian.class) | |||
public class InfinispanRemoteWithQueryIT extends BaseHotRodQueryIT { | |||
|
|||
@Deployment | |||
public static Archive<?> deployment() { | |||
String manifest = Descriptors.create(ManifestDescriptor.class) | |||
.attribute("Dependencies", "org.infinispan.remote:" + Version.getModuleSlot()) | |||
.exportAsString(); | |||
|
|||
return ShrinkWrap | |||
.create(WebArchive.class, "query-remote.war") | |||
.addClasses(HotRodQueryIT.class, BaseHotRodQueryIT.class, Person.class) | |||
.add(new StringAsset(manifest), "META-INF/MANIFEST.MF"); | |||
} | |||
|
|||
} |
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
14 changes: 14 additions & 0 deletions
14
wildfly-modules/src/main/resources/org/infinispan/remote/main/module.xml
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
|
|||
<module xmlns="urn:jboss:module:1.1" name="org.infinispan.remote" slot="${slot}"> | |||
<dependencies> | |||
<module name="javax.api"/> | |||
<module name="org.infinispan.client.hotrod" slot="${slot}" export="true"/> | |||
<module name="org.infinispan.commons" slot="${slot}" export="true"/> | |||
<module name="org.infinispan.protostream" slot="${slot}" export="true"/> | |||
<module name="org.infinispan.query.dsl" slot="${slot}" export="true"/> | |||
<module name="org.infinispan.query.remote.client" slot="${slot}" export="true"/> | |||
<module name="org.infinispan.cdi.remote" slot="${slot}" export="true"/> | |||
<module name="org.jboss.logging"/> | |||
</dependencies> | |||
</module> |