From 229849d692dd53ca6c6260df9be68328066d8fc8 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Sat, 17 Sep 2011 19:33:52 +0300 Subject: [PATCH] SGF-51 + wrap up tests --- .../gemfire/config/IndexNamespaceTest.java | 35 ++++++++++++++++--- .../data/gemfire/config/index-ns.xml | 4 ++- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java b/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java index ad823b3a..ecd60028 100644 --- a/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java +++ b/src/test/java/org/springframework/data/gemfire/config/IndexNamespaceTest.java @@ -16,14 +16,20 @@ package org.springframework.data.gemfire.config; +import static org.junit.Assert.assertEquals; + +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.data.gemfire.IndexFactoryBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.query.Index; +import com.gemstone.gemfire.cache.query.IndexType; + /** * * @author Costin Leau @@ -32,19 +38,38 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration("index-ns.xml") public class IndexNamespaceTest { + private String name = "test-index"; @Autowired private ApplicationContext context; + + @Before + public void setUp() throws Exception { + Cache cache = (Cache) context.getBean("gemfire-cache"); + if (cache.getRegion(name) == null) { + cache.createRegionFactory().create("test-index"); + } + } + @Test public void testBasicIndex() throws Exception { - IndexFactoryBean ifb = null; + Index idx = (Index) context.getBean("simple"); - ifb = (IndexFactoryBean) context.getBean("&simple"); - System.out.println("Ifb is " + ifb); + assertEquals("/test-index", idx.getFromClause()); + assertEquals("status", idx.getIndexedExpression()); + assertEquals("simple", idx.getName()); + assertEquals(name, idx.getRegion().getName()); + assertEquals(IndexType.FUNCTIONAL, idx.getType()); } @Test public void testComplexIndex() throws Exception { - } + Index idx = (Index) context.getBean("complex"); + assertEquals("/test-index tsi", idx.getFromClause()); + assertEquals("tsi.name", idx.getIndexedExpression()); + assertEquals("complex-index", idx.getName()); + assertEquals(name, idx.getRegion().getName()); + assertEquals(IndexType.PRIMARY_KEY, idx.getType()); + } } diff --git a/src/test/resources/org/springframework/data/gemfire/config/index-ns.xml b/src/test/resources/org/springframework/data/gemfire/config/index-ns.xml index ed92e517..f97b3c5c 100644 --- a/src/test/resources/org/springframework/data/gemfire/config/index-ns.xml +++ b/src/test/resources/org/springframework/data/gemfire/config/index-ns.xml @@ -15,7 +15,9 @@ - + + +