You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2015/04/17 18:42:41 UTC

[02/28] zest-qi4j git commit: QI-412: upgrade ElasticSearch from 1.2.1 to 1.3.4

QI-412: upgrade ElasticSearch from 1.2.1 to 1.3.4


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

Branch: refs/heads/develop
Commit: b8efcda1446afbf0dde033719d6956542bcec9d8
Parents: cf36351
Author: Paul Merlin <pa...@nosphere.org>
Authored: Tue Oct 14 14:57:23 2014 +0200
Committer: Paul Merlin <pa...@nosphere.org>
Committed: Tue Oct 14 14:57:23 2014 +0200

----------------------------------------------------------------------
 .../index/elasticsearch/ImmenseTermTest.java    | 143 +++++++++++++++++++
 libraries.gradle                                |   2 +-
 2 files changed, 144 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b8efcda1/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ImmenseTermTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ImmenseTermTest.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ImmenseTermTest.java
new file mode 100644
index 0000000..6308f40
--- /dev/null
+++ b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ImmenseTermTest.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2014 the original author or authors
+ *
+ * Licensed 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.qi4j.index.elasticsearch;
+
+import java.io.File;
+import java.util.List;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.qi4j.api.association.ManyAssociation;
+import org.qi4j.api.common.Optional;
+import org.qi4j.api.common.Visibility;
+import org.qi4j.api.entity.EntityComposite;
+import org.qi4j.api.entity.Queryable;
+import org.qi4j.api.property.Property;
+import org.qi4j.api.query.Query;
+import org.qi4j.api.unitofwork.UnitOfWork;
+import org.qi4j.bootstrap.AssemblyException;
+import org.qi4j.bootstrap.ModuleAssembly;
+import org.qi4j.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler;
+import org.qi4j.library.fileconfig.FileConfigurationOverride;
+import org.qi4j.library.fileconfig.FileConfigurationService;
+import org.qi4j.test.AbstractQi4jTest;
+import org.qi4j.test.EntityTestAssembler;
+import org.qi4j.test.util.DelTreeAfter;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import static org.qi4j.api.query.QueryExpressions.eq;
+import static org.qi4j.api.query.QueryExpressions.templateFor;
+import static org.qi4j.test.util.Assume.assumeNoIbmJdk;
+
+/**
+ * ImmenseTermTest.
+ * <p>
+ * See <a href="https://ops4j1.jira.com/browse/QI-412">QI-412</a>.
+ */
+public class ImmenseTermTest
+    extends AbstractQi4jTest
+{
+    private static final File DATA_DIR = new File( "build/tmp/immense-term-test" );
+    @Rule
+    public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
+
+    @BeforeClass
+    public static void beforeClass_IBMJDK()
+    {
+        assumeNoIbmJdk();
+    }
+
+    public interface TestEntity
+        extends EntityComposite
+    {
+        @Optional
+        Property<String> property();
+
+        @Queryable( false )
+        ManyAssociation<TestEntity2> manyAssociation();
+    }
+
+    public interface TestEntity2
+        extends EntityComposite
+    {
+        @Optional
+        Property<String> property();
+
+        @Optional
+        Property<List<Byte>> binaryProperty();
+    }
+
+    @Override
+    public void assemble( ModuleAssembly module )
+        throws AssemblyException
+    {
+        // Config module
+        ModuleAssembly config = module.layer().module( "config" );
+        new EntityTestAssembler().assemble( config );
+
+        // EntityStore
+        new EntityTestAssembler().assemble( module );
+
+        // Index/Query
+        new ESFilesystemIndexQueryAssembler().
+            withConfig( config, 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, "qi4j-data" ) ).
+            withLog( new File( DATA_DIR, "qi4j-logs" ) ).
+            withTemporary( new File( DATA_DIR, "qi4j-temp" ) );
+        module.services( FileConfigurationService.class ).
+            setMetaInfo( override );
+
+        // Entities & Values
+        module.entities( TestEntity.class, TestEntity2.class );
+    }
+
+    @Test
+    public void testManyAssociation()
+        throws Exception
+    {
+        long count = 10_000L;
+        TestEntity testEntity;
+        try( UnitOfWork uow = module.newUnitOfWork() )
+        {
+            testEntity = uow.newEntity( TestEntity.class );
+            for( long i = 0; i < count; i++ )
+            {
+                TestEntity2 testEntity2 = module.currentUnitOfWork().newEntity( TestEntity2.class );
+                testEntity2.property().set( "test" );
+                testEntity.manyAssociation().add( testEntity2 );
+            }
+            uow.complete();
+        }
+        try( UnitOfWork uow = module.newUnitOfWork() )
+        {
+            testEntity = uow.get( testEntity );
+            Query<TestEntity2> query = uow.newQuery(
+                module.newQueryBuilder( TestEntity2.class ).where(
+                    eq( templateFor( TestEntity2.class ).property(), "test" )
+                )
+            );
+            assertThat( query.count(), is( count ) );
+            assertThat( testEntity.manyAssociation().count(), is( (int) count ) );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/b8efcda1/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index 97e87a0..7903c59 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -12,7 +12,7 @@ def cxfVersion = '2.5.6' // 2.7.11 Unable to resolve dependencies! - 3.0.0 exist
 def derbyVersion = '10.10.2.0'
 def dnsJavaVersion = '2.1.6'
 def ehcacheVersion = '2.8.3'
-def elasticsearchVersion = '1.2.1'
+def elasticsearchVersion = '1.3.4'
 def freemarkerVersion = '2.3.20'
 def gaeVersion = '1.8.8'
 def groovyVersion = '2.3.2'