polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From soelvs...@apache.org
Subject zest-java git commit: added a few test for indexers using a multi-module architecture
Date Tue, 06 Oct 2015 20:41:39 GMT
Repository: zest-java
Updated Branches:
  refs/heads/develop 30a00d33f -> 9e820943c


added a few test for indexers using a multi-module architecture


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/9e820943
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/9e820943
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/9e820943

Branch: refs/heads/develop
Commit: 9e820943c7e9c44437a8d91113a0540c21f8d1f7
Parents: 30a00d3
Author: Kent Sølvsten <soelvsten@apache.org>
Authored: Tue Oct 6 22:41:12 2015 +0200
Committer: Kent Sølvsten <soelvsten@apache.org>
Committed: Tue Oct 6 22:41:12 2015 +0200

----------------------------------------------------------------------
 .../test/indexing/AbstractAnyQueryTest.java     | 19 +++++--
 .../test/indexing/AbstractNamedQueryTest.java   | 21 +++-----
 .../ElasticSearchQueryMultimoduleTest.java      | 57 ++++++++++++++++++++
 .../elasticsearch/ElasticSearchQueryTest.java   |  2 +-
 .../index/rdf/RdfNamedQueryMultimoduleTest.java | 34 ++++++++++++
 .../zest/index/rdf/RdfNamedQueryTest.java       | 13 ++---
 .../zest/index/rdf/RdfQueryMultimoduleTest.java | 49 +++++++++++++++++
 .../org/apache/zest/index/rdf/RdfQueryTest.java | 20 ++-----
 8 files changed, 172 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
old mode 100644
new mode 100755
index 03ff7cb..9c34fb8
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractAnyQueryTest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.zest.test.indexing;
 
+import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.unitofwork.UnitOfWork;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
@@ -48,21 +49,30 @@ public class AbstractAnyQueryTest
     public void assemble( ModuleAssembly module )
         throws AssemblyException
     {
+        assembleEntities( module, Visibility.module );
+        assembleValues( module, Visibility.module );
+        new EntityTestAssembler().assemble( module );
+    }
+
+    protected void assembleEntities( ModuleAssembly module, Visibility visibility )
+    {
         module.entities( MaleEntity.class,
                          FemaleEntity.class,
                          CityEntity.class,
                          DomainEntity.class,
                          AccountEntity.class,
-                         CatEntity.class );
+                         CatEntity.class ). visibleIn( visibility );
+    }
+
+    protected void assembleValues( ModuleAssembly module, Visibility visibility )
+    {
         module.values( URL.class,
                        Address.class,
                        Protocol.class,
                        Host.class,
                        Port.class,
                        File.class,
-                       QueryParam.class );
-
-        new EntityTestAssembler().assemble( module );
+                       QueryParam.class ).visibleIn( visibility );
     }
 
     @Override
@@ -75,6 +85,7 @@ public class AbstractAnyQueryTest
         this.unitOfWork = this.module.newUnitOfWork();
     }
 
+
     @Override
     public void tearDown()
         throws Exception

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
----------------------------------------------------------------------
diff --git a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
old mode 100644
new mode 100755
index 1f52478..cb82864
--- a/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
+++ b/core/testsupport/src/main/java/org/apache/zest/test/indexing/AbstractNamedQueryTest.java
@@ -21,28 +21,26 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.function.Predicate;
-import org.junit.Test;
 import org.apache.zest.api.composite.Composite;
 import org.apache.zest.api.query.Query;
 import org.apache.zest.api.query.grammar.OrderBy;
-import org.apache.zest.bootstrap.AssemblyException;
-import org.apache.zest.bootstrap.ModuleAssembly;
 import org.apache.zest.spi.query.EntityFinderException;
 import org.apache.zest.spi.query.IndexExporter;
-import org.apache.zest.test.EntityTestAssembler;
 import org.apache.zest.test.indexing.model.Domain;
 import org.apache.zest.test.indexing.model.Female;
 import org.apache.zest.test.indexing.model.Male;
 import org.apache.zest.test.indexing.model.Nameable;
 import org.apache.zest.test.indexing.model.Person;
+import org.junit.Before;
+import org.junit.Test;
 
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
 import static org.apache.zest.api.query.QueryExpressions.orderBy;
 import static org.apache.zest.api.query.QueryExpressions.templateFor;
 import static org.apache.zest.test.indexing.NameableAssert.verifyOrderedResults;
 import static org.apache.zest.test.indexing.NameableAssert.verifyUnorderedResults;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsEqual.equalTo;
+import static org.junit.Assert.assertThat;
 
 /**
  * Abstract satisfiedBy with tests for named queries against Index/Query engines.
@@ -51,14 +49,11 @@ public abstract class AbstractNamedQueryTest
     extends AbstractAnyQueryTest
 {
 
-    private final Map<String, Predicate<Composite>> queries = new HashMap<>();
+    protected final Map<String, Predicate<Composite>> queries = new HashMap<>();
 
-    @Override
-    public void assemble( ModuleAssembly module )
-        throws AssemblyException
+    @Before
+    public void assembleQueryStrings()
     {
-        super.assemble( module );
-        new EntityTestAssembler().assemble( module );
         String[] query = queryStrings();
         for( int i = 0; i < query.length; i++ )
         {

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
new file mode 100755
index 0000000..9f41a60
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
@@ -0,0 +1,57 @@
+package org.apache.zest.index.elasticsearch;
+
+import java.io.File;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.apache.zest.library.fileconfig.FileConfigurationOverride;
+import org.apache.zest.library.fileconfig.FileConfigurationService;
+import org.apache.zest.test.EntityTestAssembler;
+import org.apache.zest.test.util.DelTreeAfter;
+import org.junit.Rule;
+
+/**
+ * User: ksr
+ * Date: 28-09-2015
+ * Time: 23:40
+ */
+public class ElasticSearchQueryMultimoduleTest extends ElasticSearchQueryTest
+{
+    @Rule
+    public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        assembleEntities( module, Visibility.module );
+        assembleValues( module, Visibility.layer );
+
+        module = module.layer().module( "module2" );
+        new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( module );
+
+        // Config module
+        LayerAssembly configLayer = module.layer().application().layer( "config" );
+        module.layer().uses( configLayer );
+        ModuleAssembly config = configLayer.module( "config" );
+        new EntityTestAssembler().assemble( config );
+
+        // Index/Query
+        new ESFilesystemIndexQueryAssembler().
+            withConfig( config, Visibility.application ).visibleIn( Visibility.layer ).
+            assemble( module );
+        ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
+        esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
+
+        // FileConfig
+        FileConfigurationOverride override = new FileConfigurationOverride().
+            withData( new File( DATA_DIR, "zest-data" ) ).
+            withLog( new File( DATA_DIR, "zest-logs" ) ).
+            withTemporary( new File( DATA_DIR, "zest-temp" ) );
+        module.services( FileConfigurationService.class ).
+            setMetaInfo( override );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
old mode 100644
new mode 100755
index 4c1e79f..a55229b
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
@@ -40,7 +40,7 @@ public class ElasticSearchQueryTest
     extends AbstractQueryTest
 {
 
-    private static final File DATA_DIR = new File( "build/tmp/es-query-test" );
+    protected static final File DATA_DIR = new File( "build/tmp/es-query-test" );
     @Rule
     public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
 

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
new file mode 100755
index 0000000..b16eed9
--- /dev/null
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryMultimoduleTest.java
@@ -0,0 +1,34 @@
+package org.apache.zest.index.rdf;
+
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
+import org.apache.zest.test.EntityTestAssembler;
+
+/**
+ * User: ksr
+ * Date: 28-09-2015
+ * Time: 10:28
+ */
+public class RdfNamedQueryMultimoduleTest
+    extends RdfNamedQueryTest
+{
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        LayerAssembly layer = module.layer();
+        assembleEntities( module, Visibility.module );
+        assembleValues( module, Visibility.module );
+
+        ModuleAssembly storeModule = layer.module( "store" );
+        new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( storeModule );
+        assembleValues( storeModule, Visibility.module );
+
+        ModuleAssembly indexModule = layer.module( "index" );
+        new RdfMemoryStoreAssembler( Visibility.layer, Visibility.module ).assemble( indexModule
);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
old mode 100644
new mode 100755
index 526f8b2..eb54caa
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfNamedQueryTest.java
@@ -18,17 +18,13 @@
 package org.apache.zest.index.rdf;
 
 import java.util.function.Predicate;
+import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.composite.Composite;
-import org.apache.zest.api.value.ValueSerialization;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.index.rdf.query.RdfQueryParserFactory;
+import org.apache.zest.index.rdf.assembly.RdfMemoryStoreAssembler;
 import org.apache.zest.index.rdf.query.SesameExpressions;
-import org.apache.zest.library.rdf.entity.EntityStateSerializer;
-import org.apache.zest.library.rdf.entity.EntityTypeSerializer;
-import org.apache.zest.library.rdf.repository.MemoryRepositoryService;
 import org.apache.zest.test.indexing.AbstractNamedQueryTest;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
 
 public class RdfNamedQueryTest extends AbstractNamedQueryTest
 {
@@ -49,10 +45,7 @@ public class RdfNamedQueryTest extends AbstractNamedQueryTest
         throws AssemblyException
     {
         super.assemble( module );
-        module.services( MemoryRepositoryService.class, RdfQueryParserFactory.class ).instantiateOnStartup();
-        module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON
);
-        module.objects( EntityStateSerializer.class, EntityTypeSerializer.class );
-        module.services( RdfIndexingEngineService.class );
+        new RdfMemoryStoreAssembler( Visibility.module, Visibility.module ).assemble( module
);
     }
 
     private static String[] queryStrings =

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
new file mode 100755
index 0000000..d37c770
--- /dev/null
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryMultimoduleTest.java
@@ -0,0 +1,49 @@
+package org.apache.zest.index.rdf;
+
+import java.io.File;
+import org.apache.zest.api.common.Visibility;
+import org.apache.zest.bootstrap.AssemblyException;
+import org.apache.zest.bootstrap.LayerAssembly;
+import org.apache.zest.bootstrap.ModuleAssembly;
+import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler;
+import org.apache.zest.library.rdf.repository.NativeConfiguration;
+import org.apache.zest.test.EntityTestAssembler;
+import org.apache.zest.test.util.DelTreeAfter;
+import org.junit.Rule;
+
+/**
+ * User: ksr
+ * Date: 27-09-2015
+ * Time: 23:32
+ */
+public class RdfQueryMultimoduleTest
+    extends RdfQueryTest
+{
+    private static final File DATA_DIR = new File( "build/tmp/rdf-query-test" );
+    @Rule
+    public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        LayerAssembly layer = module.layer();
+        assembleValues( module, Visibility.module );
+        assembleEntities( module, Visibility.module );
+
+        ModuleAssembly storeModule = layer.module( "store" );
+        new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( storeModule );
+        assembleValues( storeModule, Visibility.module );
+
+        ModuleAssembly indexModule = layer.module( "index" );
+        new RdfNativeSesameStoreAssembler( Visibility.layer, Visibility.module ).assemble(
indexModule );
+
+        LayerAssembly configLayer = module.layer().application().layer( "config" );
+        module.layer().uses( configLayer );
+        ModuleAssembly config = configLayer.module( "config" );
+        config.entities( NativeConfiguration.class ).visibleIn( Visibility.application );
+        config.forMixin( NativeConfiguration.class ).declareDefaults().dataDirectory().set(
DATA_DIR.getAbsolutePath() );
+        new EntityTestAssembler().assemble( config );
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/zest-java/blob/9e820943/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
old mode 100644
new mode 100755
index 78d1a75..867a3a4
--- a/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
+++ b/extensions/indexing-rdf/src/test/java/org/apache/zest/index/rdf/RdfQueryTest.java
@@ -19,24 +19,18 @@
 package org.apache.zest.index.rdf;
 
 import java.io.File;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
 import org.apache.zest.api.common.Visibility;
-import org.apache.zest.api.value.ValueSerialization;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
-import org.apache.zest.index.rdf.query.RdfQueryParserFactory;
-import org.apache.zest.library.fileconfig.FileConfigurationService;
-import org.apache.zest.library.rdf.entity.EntityStateSerializer;
-import org.apache.zest.library.rdf.entity.EntityTypeSerializer;
+import org.apache.zest.index.rdf.assembly.RdfNativeSesameStoreAssembler;
 import org.apache.zest.library.rdf.repository.NativeConfiguration;
-import org.apache.zest.library.rdf.repository.NativeRepositoryService;
 import org.apache.zest.spi.query.EntityFinderException;
 import org.apache.zest.test.EntityTestAssembler;
 import org.apache.zest.test.indexing.AbstractQueryTest;
 import org.apache.zest.test.util.DelTreeAfter;
-import org.apache.zest.valueserialization.orgjson.OrgJsonValueSerializationService;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
 
 public class RdfQueryTest
     extends AbstractQueryTest
@@ -51,11 +45,7 @@ public class RdfQueryTest
         throws AssemblyException
     {
         super.assemble( module );
-        module.services( FileConfigurationService.class );
-        module.services( NativeRepositoryService.class, RdfQueryParserFactory.class ).instantiateOnStartup();
-        module.services( RdfIndexingEngineService.class ).instantiateOnStartup();
-        module.services( OrgJsonValueSerializationService.class ).taggedWith( ValueSerialization.Formats.JSON
);
-        module.objects( EntityStateSerializer.class, EntityTypeSerializer.class );
+        new RdfNativeSesameStoreAssembler( Visibility.module, Visibility.module ).assemble(
module );
 
         ModuleAssembly config = module.layer().module( "Config" );
         config.entities( NativeConfiguration.class ).visibleIn( Visibility.layer );


Mime
View raw message