Return-Path: X-Original-To: apmail-geode-commits-archive@minotaur.apache.org Delivered-To: apmail-geode-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 295AA18B17 for ; Mon, 6 Jul 2015 21:47:50 +0000 (UTC) Received: (qmail 244 invoked by uid 500); 6 Jul 2015 21:47:50 -0000 Delivered-To: apmail-geode-commits-archive@geode.apache.org Received: (qmail 212 invoked by uid 500); 6 Jul 2015 21:47:50 -0000 Mailing-List: contact commits-help@geode.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.incubator.apache.org Delivered-To: mailing list commits@geode.incubator.apache.org Received: (qmail 203 invoked by uid 99); 6 Jul 2015 21:47:49 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jul 2015 21:47:49 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 4ED7A1A6802 for ; Mon, 6 Jul 2015 21:47:49 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id bAKhOkahsOem for ; Mon, 6 Jul 2015 21:47:27 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id BAD1A249EA for ; Mon, 6 Jul 2015 21:47:26 +0000 (UTC) Received: (qmail 97297 invoked by uid 99); 6 Jul 2015 21:47:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Jul 2015 21:47:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8B454E02D3; Mon, 6 Jul 2015 21:47:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dschneider@apache.org To: commits@geode.incubator.apache.org Date: Mon, 06 Jul 2015 21:47:26 -0000 Message-Id: <1db02747601a4fa4abe23361aca0cbb7@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/18] incubator-geode git commit: GEODE-80: Imported databrowser from geode-1.0.0-SNAPSHOT-2.src.tar Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-80 [created] e2ccf3da7 http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/CustomerQueryDUnitTest.java ---------------------------------------------------------------------- diff --git a/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/CustomerQueryDUnitTest.java b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/CustomerQueryDUnitTest.java new file mode 100644 index 0000000..911bad2 --- /dev/null +++ b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/CustomerQueryDUnitTest.java @@ -0,0 +1,74 @@ +package com.gemstone.gemfire.tools.databrowser.dunit; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.Assert; + +import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember; +import com.gemstone.gemfire.tools.databrowser.data.Customer; + +import dunit.SerializableRunnable; + +public class CustomerQueryDUnitTest extends DataBrowserDUnitTestCase { + + public CustomerQueryDUnitTest(String name) { + super(name); + } + + @Override + public void populateData() { + List result = new ArrayList(); + result.add(new Customer(1, "Tom", "Pune")); + result.add(new Customer(2, "Jack", "Bombay")); + populateRegion(DEFAULT_REGION_PATH, result.toArray()); + } + + public void testCustomerObjectQuery() { + browser.invoke(new SerializableRunnable() { + public void run() { +// GemFireMember[] members = connection.getMembers(); +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); +// Assert.assertEquals(1, members[0].getCacheServers().length); + + String query1 = "SELECT * FROM "+DEFAULT_REGION_PATH; + + int gfe_count = executeDirectQuery(connection.getQueryService(null), query1); + int browser_count = executeQueryThroughBrowser(connection, null, query1); + + Assert.assertEquals(2, gfe_count); + Assert.assertEquals(2, browser_count); + + String query2 = "SELECT distinct name FROM "+DEFAULT_REGION_PATH; + + gfe_count = executeDirectQuery(connection.getQueryService(null), query2); + browser_count = executeQueryThroughBrowser(connection, null, query2); + + Assert.assertEquals(2 , gfe_count); + Assert.assertEquals(2 , browser_count); + + + String query3 = "SELECT * FROM "+DEFAULT_REGION_PATH+" WHERE name='Tom'"; + + gfe_count = executeDirectQuery(connection.getQueryService(null), query3); + browser_count = executeQueryThroughBrowser(connection, null, query3); + + int expectedCount = 1; + Assert.assertEquals(expectedCount , gfe_count); + Assert.assertEquals(expectedCount, browser_count); + + + String query4 = "SELECT * FROM "+DEFAULT_REGION_PATH+" WHERE address='Bombay'"; + + gfe_count = executeDirectQuery(connection.getQueryService(null), query4); + browser_count = executeQueryThroughBrowser(connection, null, query4); + + expectedCount = 1; + Assert.assertEquals(expectedCount , gfe_count); + Assert.assertEquals(expectedCount, browser_count); + + } + }); + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/DataBrowserDUnitTestCase.java ---------------------------------------------------------------------- diff --git a/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/DataBrowserDUnitTestCase.java b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/DataBrowserDUnitTestCase.java new file mode 100644 index 0000000..7cb4d23 --- /dev/null +++ b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/DataBrowserDUnitTestCase.java @@ -0,0 +1,277 @@ +package com.gemstone.gemfire.tools.databrowser.dunit; + +import hydra.BridgeHelper; +import hydra.CacheHelper; +import hydra.ConfigHashtable; +import hydra.GemFireDescription; +import hydra.GemFirePrms; +import hydra.HostHelper; +import hydra.Log; +import hydra.RegionHelper; +import hydra.TestConfig; + +import java.net.InetAddress; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import junit.framework.Assert; +import util.NameFactory; + +import com.gemstone.gemfire.cache.server.CacheServer; +import com.gemstone.gemfire.admin.DistributedSystemConfig; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.query.Query; +import com.gemstone.gemfire.cache.query.QueryService; +import com.gemstone.gemfire.cache.query.SelectResults; +import com.gemstone.gemfire.distributed.DistributedSystem; +import com.gemstone.gemfire.mgmt.DataBrowser.connection.ClientConfiguration; +import com.gemstone.gemfire.mgmt.DataBrowser.connection.ConnectionFactory; +import com.gemstone.gemfire.mgmt.DataBrowser.connection.ConnectionFailureException; +import com.gemstone.gemfire.mgmt.DataBrowser.connection.EndPoint; +import com.gemstone.gemfire.mgmt.DataBrowser.connection.GemFireConnection; +import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember; +import com.gemstone.gemfire.mgmt.DataBrowser.query.ColumnNotFoundException; +import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult; +import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException; +import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryResult; +import com.gemstone.gemfire.mgmt.DataBrowser.query.internal.PrimitiveTypeResultImpl; + +import dunit.DistributedTestCase; +import dunit.Host; +import dunit.SerializableRunnable; +import dunit.SerializableCallable; +import dunit.VM; + +public abstract class DataBrowserDUnitTestCase extends DistributedTestCase { + static ConfigHashtable conftab = TestConfig.tab(); + public static final String DEFAULT_SERVER_CACHE_CONFIG = "server"; + public static final String DEFAULT_CACHE_SERVER_CONFIG_NAME = "bridge"; + + public static final String DEFAULT_REGION_NAME = "Customer"; + public static final String DEFAULT_REGION_PATH = "/"+DEFAULT_REGION_NAME; + + protected VM server; + protected VM browser; + protected static GemFireConnection connection; + + public DataBrowserDUnitTestCase(String name) { + super(name); + } + + public boolean startCacheServer() { + return true; + } + + public boolean shutdown() { + return false; + } + + @Override + public void setUp() throws Exception { + super.setUp(); + final Host host = Host.getHost(0); + server = host.getVM(0); + browser = host.getVM(1); + + /** + * During Test setup, following steps are executed. + * 1. Start the GemFire distributed system. + * 2. Prepare the regions to be used. + * 3. Populate the regions. + **/ + final EndPoint endpt = (EndPoint)server.invoke(new SerializableCallable() { + public Object call() { + boolean isConnected = isConnectedToDS(); + if(!isConnected) { + Log.getLogWriter().info("connecting to GemFire distributed system."); + DistributedSystem system = getSystem(); + initCache(system, startCacheServer()); + + Log.getLogWriter().info("connected to GemFire distributed system."); + } + + CacheServer server = BridgeHelper.getBridgeServer(); + + InetAddress addr = HostHelper.getIPAddress(); + EndPoint endpt = new EndPoint(); + endpt.setHostName(addr.getHostName()); + endpt.setPort(server.getPort()); + + Log.getLogWriter().info("CACHE-SERVER ENDPOINT :"+endpt); + + populateData(); + + return endpt; + } + }); + + + final ClientConfiguration conf = new ClientConfiguration(); + conf.addCacheServer(endpt); + Log.getLogWriter().info("CACHE-SERVER ENDPOINT :"+endpt); + + browser.invoke(new SerializableRunnable() { + public void run() { + if (connection != null) + return; + + try { + Log.getLogWriter().info("DataBrowser connecting "+endpt); + connection = ConnectionFactory.createGemFireConnection(conf); + Log.getLogWriter().info("DataBrowser connected successfully."); + Assert.assertNotNull(connection); + } + catch (ConnectionFailureException e) { + fail("DataBrowser failed to connect to the GemFire system...", e); + } + } + }); + + Log.getLogWriter().info("completed setUp :"+this.getName()); + } + + public void tearDown2() throws Exception { + super.tearDown2(); + + server.invoke(new SerializableRunnable() { + public void run() { + if(isConnectedToDS()) { + cleanUpData(); + } + + if(shutdown()) { + Log.getLogWriter().info("disconnecting from GemFire distributed system."); + disconnectFromDS(); + Log.getLogWriter().info("disconnected from GemFire distributed system."); + } + } + }); + } + + + + public Cache initCache(DistributedSystem system, boolean isCacheServer) { + Cache cache = CacheHelper.createCache(DEFAULT_SERVER_CACHE_CONFIG); + + Map regions = TestConfig.getInstance().getRegionDescriptions(); + Set keySet = regions.keySet(); + Iterator iter = keySet.iterator(); + while(iter.hasNext()) { + String name = (String)iter.next(); + if(name.startsWith(DEFAULT_SERVER_CACHE_CONFIG)) { + RegionHelper.createRegion(name); + } + } + + Region root = cache.getRegion(DEFAULT_REGION_PATH); + Assert.assertNotNull(root); + + if(isCacheServer) + BridgeHelper.startBridgeServer(DEFAULT_CACHE_SERVER_CONFIG_NAME); + return cache; + } + + public void populateData() { + //Do nothing. The individual test has to populate the data that is required for testing. + } + + public void cleanUpData() { + cleanUpRegion(DEFAULT_REGION_PATH); + } + + public void populateRegion(String regionPath, Object[] objects) { + Log.getLogWriter().info("Inside populateRegion 1"); + Cache cache = CacheHelper.getCache(); + Assert.assertNotNull(cache); + + Region region = cache.getRegion(regionPath); + Assert.assertNotNull(region); + + Log.getLogWriter().info("Inside populateRegion 2"); + for(int i = 0 ; i < objects.length ; i++) { + Object key = NameFactory.getNextPositiveObjectName(); + Object value = objects[i]; + region.put(key, value); + Log.getLogWriter().info("Put object :"+value+" in Region :"+regionPath); + } + Log.getLogWriter().info("Inside populateRegion 3"); + } + + public void cleanUpRegion(String regionPath) { + Cache cache = CacheHelper.getCache(); + Assert.assertNotNull(cache); + + Region region = cache.getRegion(regionPath); + Assert.assertNotNull(region); + + region.clear(); + Log.getLogWriter().info("All the data is cleared. Region :"+regionPath); + } + + protected int executeDirectQuery(QueryService svc, String query) { + Query queryObj = svc.newQuery(query) ; + Object gfe_result = null; + + try { + gfe_result = queryObj.execute(); + } catch (Exception e) { + fail("Failed to execute query : "+query, e); + } + + Assert.assertTrue((gfe_result instanceof SelectResults)); + SelectResults gfe_selectresult = (SelectResults)gfe_result; + return gfe_selectresult.size(); + } + + protected int executeQueryThroughBrowser(GemFireConnection connection, GemFireMember member, String query) { + int count = 0; + try { + QueryResult db_result = connection.executeQuery(query, member); + count = db_result.getQueryResult().size(); + } + catch (QueryExecutionException e) { + fail("Failed to execute query through browser : "+query, e); + } + + return count; + } + + protected void verifyType(IntrospectionResult metaInfo, Class javaType, List expFields, List expClassTypes, List expTypes) { + Assert.assertEquals(javaType, metaInfo.getJavaType()); + Assert.assertEquals(expFields.size(), metaInfo.getColumnCount()); + + for(int i = 0 ; i < metaInfo.getColumnCount() ; i++) { + try { + String columnName = metaInfo.getColumnName(i); + String columnClassType = metaInfo.getColumnClass(i).getCanonicalName(); + int columnType = metaInfo.getColumnType(i); + + Assert.assertTrue("Column-Name :"+columnName, expFields.contains(columnName)); + int index = expFields.indexOf(columnName); + Assert.assertTrue("Column Name :"+columnName+getMessage(expClassTypes.get(index).toString(), columnClassType), expClassTypes.get(index).equals(columnClassType)); + Assert.assertTrue("Column Name :"+columnName+getMessage(expTypes.get(index).toString(), String.valueOf(columnType)), expTypes.get(index).intValue() == columnType); + } + catch (ColumnNotFoundException e) { + fail("Column with index "+i+" is not found.",e); + } + } + } + + private static String getMessage(String expectedVal, String actualVal) { + String result = "Expected value : "+expectedVal+" actual value : "+actualVal; + return result; + } + + protected void verifyPrimitiveType(IntrospectionResult metaInfo, Class type) { + List fields = Arrays.asList(new String[] {PrimitiveTypeResultImpl.CONST_COLUMN_NAME}); + List columnclasstypes = Arrays.asList(new String[] {type.getCanonicalName()}); + List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); + Log.getLogWriter().info("Verifying "+type+" type."); + verifyType(metaInfo, type, fields, columnclasstypes, columntypes); + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/MultipleTypeResultDUnitTest.java ---------------------------------------------------------------------- diff --git a/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/MultipleTypeResultDUnitTest.java b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/MultipleTypeResultDUnitTest.java new file mode 100644 index 0000000..f1a617d --- /dev/null +++ b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/MultipleTypeResultDUnitTest.java @@ -0,0 +1,109 @@ +package com.gemstone.gemfire.tools.databrowser.dunit; + +import hydra.Log; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import junit.framework.Assert; + +import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember; +import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult; +import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException; +import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryResult; +import com.gemstone.gemfire.tools.databrowser.data.Customer; +import com.gemstone.gemfire.tools.databrowser.data.Product; + +import dunit.SerializableRunnable; + +public class MultipleTypeResultDUnitTest extends DataBrowserDUnitTestCase { + + public MultipleTypeResultDUnitTest(String name) { + super(name); + } + + @Override + public void populateData() { + List result = new ArrayList(); + result.add(new Customer(1, "Tom", "Pune")); + result.add(new Product(1, "GemFire Enterprise", 40.0f)); + result.add("Hello World"); + populateRegion(DEFAULT_REGION_PATH, result.toArray()); + } + + public void testMultipleTypeQueryResult() throws Exception { + + browser.invoke(new SerializableRunnable() { + public void run() { +// GemFireMember[] members = connection.getMembers(); +// +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); + + String queryString = "SELECT * FROM "+DEFAULT_REGION_PATH; + QueryResult result = null; + try { + result = connection.executeQuery(queryString, null); + Assert.assertNotNull(result); + } + catch (QueryExecutionException e) { + fail("Failed to execute query through data browser",e); + } + + IntrospectionResult[] metaInfo = result.getIntrospectionResult(); + + Assert.assertEquals(3, metaInfo.length); + + List expectedTypes = Arrays.asList(new String[] {"com.gemstone.gemfire.tools.databrowser.data.Product", + "com.gemstone.gemfire.tools.databrowser.data.Customer", + "java.lang.String"}); + + boolean product = false, customer = false, str = false; + for(int i = 0 ; i < metaInfo.length ; i++) { + Assert.assertNotNull(metaInfo[i].getJavaType()); + + if(metaInfo[i].getJavaType().getCanonicalName().equals(expectedTypes.get(0))) { + product = true; + verifyProductType(metaInfo[i]); + } else if (metaInfo[i].getJavaType().getCanonicalName().equals(expectedTypes.get(1))) { + customer = true; + verifyCustomerType(metaInfo[i]); + } else if (metaInfo[i].getJavaType().getCanonicalName().equals(expectedTypes.get(2))) { + try { + Class t = Class.forName(expectedTypes.get(2)); + verifyPrimitiveType(metaInfo[i], t ); + str = true; + } + catch (ClassNotFoundException e) { fail(e.getMessage()); } + } + } + + Assert.assertTrue(product); + Assert.assertTrue(customer); + Assert.assertTrue(str); + } + }); + } + + protected void verifyProductType(IntrospectionResult metaInfo) { + List fields = Arrays.asList(new String[] {"id", "name", "price"}); + List classtypes = Arrays.asList(new String[] {"int","java.lang.String", "float"}); + List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN, + IntrospectionResult.PRIMITIVE_TYPE_COLUMN, + IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); + Log.getLogWriter().info("Verifying Product type"); + verifyType(metaInfo, Product.class, fields, classtypes, columntypes); + } + + protected void verifyCustomerType(IntrospectionResult metaInfo) { + List fields = Arrays.asList(new String[] { "name", "id", "address" }); + List classtypes = Arrays.asList(new String[] { "java.lang.String", + "java.lang.Integer", "java.lang.String" }); + List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN, + IntrospectionResult.PRIMITIVE_TYPE_COLUMN, + IntrospectionResult.PRIMITIVE_TYPE_COLUMN }); + Log.getLogWriter().info("Verifying Customer type"); + verifyType(metaInfo, Customer.class, fields, classtypes, columntypes); + } +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/ObjectTypeQueryResultDUnitTest.java ---------------------------------------------------------------------- diff --git a/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/ObjectTypeQueryResultDUnitTest.java b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/ObjectTypeQueryResultDUnitTest.java new file mode 100644 index 0000000..8c51376 --- /dev/null +++ b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/ObjectTypeQueryResultDUnitTest.java @@ -0,0 +1,192 @@ +package com.gemstone.gemfire.tools.databrowser.dunit; + +import java.util.ArrayList; +import java.util.List; +import java.util.Collection; +import java.util.Iterator; +import java.util.Arrays; +import junit.framework.Assert; +import com.gemstone.gemfire.cache.query.types.StructType; +import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember; +import com.gemstone.gemfire.mgmt.DataBrowser.query.IntrospectionResult; +import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryExecutionException; +import com.gemstone.gemfire.mgmt.DataBrowser.query.QueryResult; +import com.gemstone.gemfire.tools.databrowser.data.Customer; + +import dunit.SerializableRunnable; + +public class ObjectTypeQueryResultDUnitTest extends DataBrowserDUnitTestCase { + + public ObjectTypeQueryResultDUnitTest(String name) { + super(name); + } + + @Override + public void populateData() { + List result = new ArrayList(); + result.add(new Customer(1, "Hrishi", "Pune")); + populateRegion(DEFAULT_REGION_PATH, result.toArray()); + } + + public void testPrimitiveObjectQueryResult() throws Exception { + + browser.invoke(new SerializableRunnable() { + public void run() { +// GemFireMember[] members = connection.getMembers(); +// +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); + + String queryString = "SELECT distinct name FROM "+DEFAULT_REGION_PATH+" where name = 'Hrishi'"; + QueryResult result = null; + try { + result = connection.executeQuery(queryString, null); + Assert.assertNotNull(result); + } + catch (QueryExecutionException e) { + fail("Failed to execute query through data browser",e); + } + + IntrospectionResult [] result_t = result.getIntrospectionResult(); + Assert.assertEquals(1, result_t.length); + IntrospectionResult metaInfo = result_t[0]; + + verifyPrimitiveType(metaInfo, String.class); + + Collection q_result = result.getQueryResult(); + Iterator iter = q_result.iterator(); + Object temp = iter.next(); + + try { + Assert.assertEquals("Hrishi", result.getColumnValue(temp, 0)); + } + catch (Exception e) { + fail("Failed to read the value for column 0.",e); + } + } + }); + } + + public void testCompositeObjectQueryResult() throws Exception { + + browser.invoke(new SerializableRunnable() { + public void run() { +// GemFireMember[] members = connection.getMembers(); +// +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); + + String queryString = "SELECT * FROM "+DEFAULT_REGION_PATH+" where name = 'Hrishi'"; + QueryResult result = null; + try { + result = connection.executeQuery(queryString, null); + Assert.assertNotNull(result); + } + catch (QueryExecutionException e) { + fail("Failed to execute query through data browser",e); + } + + IntrospectionResult [] result_t = result.getIntrospectionResult(); + Assert.assertEquals(1, result_t.length); + IntrospectionResult metaInfo = result_t[0]; + + Assert.assertEquals(3, metaInfo.getColumnCount()); + + List fields = Arrays.asList(new String[]{"name", "id", "address"}); + List classtypes = Arrays.asList(new String[]{"java.lang.String","java.lang.Integer", "java.lang.String"}); + List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN, + IntrospectionResult.PRIMITIVE_TYPE_COLUMN, + IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); + + verifyType(metaInfo, Customer.class, fields, classtypes, columntypes); + } + }); + } + + public void testStructQueryResult() { + + browser.invoke(new SerializableRunnable() { + public void run() { + +// GemFireMember[] members = connection.getMembers(); +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); + + String queryString = "SELECT id , name FROM "+DEFAULT_REGION_PATH; + + QueryResult result = null; + try { + result = connection.executeQuery(queryString, null); + Assert.assertNotNull(result); + } + catch (QueryExecutionException e) { + fail("Failed to execute query through data browser",e); + } + + IntrospectionResult [] temp = result.getIntrospectionResult(); + Assert.assertEquals(1, temp.length); + IntrospectionResult metaInfo = temp[0]; + + Assert.assertEquals(2, metaInfo.getColumnCount()); + + List fields = Arrays.asList(new String[]{"name", "id"}); + List classtypes = Arrays.asList(new String[]{"java.lang.Object","java.lang.Object"}); + List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.UNKNOWN_TYPE_COLUMN, + IntrospectionResult.UNKNOWN_TYPE_COLUMN }); + + verifyType(metaInfo, StructType.class, fields, classtypes, columntypes); + + Collection temp1 = result.getQueryResult(); + Assert.assertEquals(1, temp1.size()); + + Iterator iter = temp1.iterator(); + Object tuple = iter.next(); + + try { + int index = metaInfo.getColumnIndex("id"); + Class colClass = metaInfo.getColumnClass(tuple, index); + Assert.assertTrue(colClass.getCanonicalName().equals("java.lang.Integer")); + Assert.assertTrue(metaInfo.getColumnType(tuple,index) == IntrospectionResult.PRIMITIVE_TYPE_COLUMN); + + index = metaInfo.getColumnIndex("name"); + colClass = metaInfo.getColumnClass(tuple, index); + Assert.assertTrue(colClass.getCanonicalName().equals("java.lang.String")); + Assert.assertTrue(metaInfo.getColumnType(tuple,index) == IntrospectionResult.PRIMITIVE_TYPE_COLUMN); + } + catch (Exception e) { + fail("Failed to execute test ",e); + } + + } + }); + } + + public void testIntegerType() { + browser.invoke(new SerializableRunnable() { + public void run() { + +// GemFireMember[] members = connection.getMembers(); +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); + + String queryString = DEFAULT_REGION_PATH+".size"; + + QueryResult result = null; + try { + result = connection.executeQuery(queryString, null); + Assert.assertNotNull(result); + } + catch (QueryExecutionException e) { + fail("Failed to execute query through data browser",e); + } + + IntrospectionResult [] temp = result.getIntrospectionResult(); + Assert.assertEquals(1, temp.length); + IntrospectionResult metaInfo = temp[0]; + + verifyPrimitiveType(metaInfo, Integer.class); + } + }); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/TestMapTypeDUnitTest.java ---------------------------------------------------------------------- diff --git a/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/TestMapTypeDUnitTest.java b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/TestMapTypeDUnitTest.java new file mode 100644 index 0000000..99580ca --- /dev/null +++ b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/TestMapTypeDUnitTest.java @@ -0,0 +1,312 @@ +package com.gemstone.gemfire.tools.databrowser.dunit; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import dunit.DistributedTestCase; +import dunit.Host; +import dunit.SerializableRunnable; +import dunit.VM; +import junit.framework.Assert; +import com.gemstone.gemfire.cache.query.types.StructType; +import com.gemstone.gemfire.tools.databrowser.data.Address; +import com.gemstone.gemfire.tools.databrowser.data.GemStoneCustomer; +import com.gemstone.gemfire.tools.databrowser.data.Portfolio; +import com.gemstone.gemfire.tools.databrowser.data.Position; +import com.gemstone.gemfire.tools.databrowser.data.Product; +import com.gemstone.gemfire.mgmt.DataBrowser.query.*; +import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember; + +public class TestMapTypeDUnitTest extends DataBrowserDUnitTestCase { + + public TestMapTypeDUnitTest(String name) { + super(name); + } + + @Override + public void populateData() { + List result = new ArrayList(); + + Portfolio pf = new Portfolio(); + pf.setId("IBM"); + pf.setType("Equity"); + pf.setStatus("Active"); + + HashMap values = new HashMap(); + values.put("sec1", new Position("sec1",30.4, 1000d)); + values.put("sec2", new Position("sec2",20.6, 1700d)); + + pf.setPositions(values); + + result.add(pf); + + populateRegion(DEFAULT_REGION_PATH, result.toArray()); + } + + public void testPortfolioObject() { +// browser.invoke(new SerializableRunnable() { +// public void run() { +// GemFireMember[] members = connection.getMembers(); +// +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); +// +// String queryString = "SELECT * FROM "+DEFAULT_REGION_PATH + " pf WHERE pf.id = 'IBM'"; +// QueryResult result = null; +// try { +// result = connection.executeQuery(queryString, null); +// Assert.assertNotNull(result); +// } +// catch (QueryExecutionException e) { +// fail("Failed to execute query through data browser",e); +// } +// +// IntrospectionResult [] result_t = result.getIntrospectionResult(); +// Assert.assertEquals(1, result_t.length); +// IntrospectionResult metaInfo = result_t[0]; +// +// Assert.assertEquals(4, metaInfo.getColumnCount()); +// +// { +// List fields = Arrays.asList(new String[]{"id", "type", "status", "positions"}); +// List classtypes = Arrays.asList(new String[]{"java.lang.String","java.lang.String","java.lang.String","java.util.HashMap"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.MAP_TYPE_COLUMN}); +// +// verifyType(metaInfo, Portfolio.class, fields, classtypes, columntypes); +// } +// +// Collection temp = result.getQueryResult(); +// Assert.assertEquals(1, temp.size()); +// Iterator iter = temp.iterator(); +// Object tuple = iter.next(); +// +// try { +// int index = metaInfo.getColumnIndex("positions"); +// Object columnVal = result.getColumnValue(tuple, index); +// +// Assert.assertTrue(columnVal instanceof MapResult); +// MapResult rset = (MapResult)columnVal; +// Assert.assertEquals(2, rset.getMap().size()); +// +// //Verify Key set. +// { +// ResultSet temp1 = rset.getResultSetForKeys(); +// IntrospectionResult[] c_result = temp1.getIntrospectionResult(); +// Assert.assertEquals(1, c_result.length); +// IntrospectionResult metaInfo1 = c_result[0]; +// +// Assert.assertEquals(1, metaInfo1.getColumnCount()); +// +// List fields = Arrays.asList(new String[]{"Result"}); +// List classtypes = Arrays.asList(new String[]{"java.lang.String"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); +// verifyType(metaInfo1, java.lang.String.class, fields, classtypes, columntypes); +// } +// +// //Verify Value set. +// { +// ResultSet temp1 = rset.getResultSetForValues(); +// IntrospectionResult[] c_result = temp1.getIntrospectionResult(); +// Assert.assertEquals(1, c_result.length); +// IntrospectionResult metaInfo1 = c_result[0]; +// +// Assert.assertEquals(3, metaInfo1.getColumnCount()); +// +// List fields = Arrays.asList(new String[]{"secId", "mktValue", "qty" }); +// List classtypes = Arrays.asList(new String[]{"java.lang.String","double","double"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); +// verifyType(metaInfo1, Position.class, fields, classtypes, columntypes); +// } +// } +// catch (Exception e) { +// fail("Failed to execute test ",e); +// } +// } +// }); + } + + public void testMapData() { +// browser.invoke(new SerializableRunnable() { +// public void run() { +// GemFireMember[] members = connection.getMembers(); +// +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); +// +// String queryString = "SELECT pf.positions FROM "+DEFAULT_REGION_PATH + " pf WHERE pf.id = 'IBM'"; +// QueryResult result = null; +// try { +// result = connection.executeQuery(queryString, null); +// Assert.assertNotNull(result); +// } +// catch (QueryExecutionException e) { +// fail("Failed to execute query through data browser",e); +// } +// +// IntrospectionResult [] result_t = result.getIntrospectionResult(); +// Assert.assertEquals(1, result_t.length); +// IntrospectionResult metaInfo = result_t[0]; +// +// Assert.assertEquals(1, metaInfo.getColumnCount()); +// +// { +// List fields = Arrays.asList(new String[]{IntrospectionResult.CONST_COLUMN_NAME}); +// List classtypes = Arrays.asList(new String[]{"java.util.HashMap"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.MAP_TYPE_COLUMN}); +// +// verifyType(metaInfo, java.util.HashMap.class, fields, classtypes, columntypes); +// } +// +// Collection temp = result.getQueryResult(); +// Assert.assertEquals(1, temp.size()); +// +// Iterator iter = temp.iterator(); +// Object tuple = iter.next(); +// +// try { +// tuple = result.getColumnValue(tuple, 0); +// +// Assert.assertTrue(tuple instanceof MapResult); +// MapResult rset = (MapResult)tuple; +// Assert.assertEquals(2, rset.getMap().size()); +// +// //Verify Key set. +// { +// ResultSet temp1 = rset.getResultSetForKeys(); +// IntrospectionResult[] c_result = temp1.getIntrospectionResult(); +// Assert.assertEquals(1, c_result.length); +// IntrospectionResult metaInfo1 = c_result[0]; +// +// Assert.assertEquals(1, metaInfo1.getColumnCount()); +// +// List fields = Arrays.asList(new String[]{"Result"}); +// List classtypes = Arrays.asList(new String[]{"java.lang.String"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); +// verifyType(metaInfo1, java.lang.String.class, fields, classtypes, columntypes); +// } +// +// //Verify Value set. +// { +// ResultSet temp1 = rset.getResultSetForValues(); +// IntrospectionResult[] c_result = temp1.getIntrospectionResult(); +// Assert.assertEquals(1, c_result.length); +// IntrospectionResult metaInfo1 = c_result[0]; +// +// Assert.assertEquals(3, metaInfo1.getColumnCount()); +// +// List fields = Arrays.asList(new String[]{"secId", "mktValue", "qty" }); +// List classtypes = Arrays.asList(new String[]{"java.lang.String","double","double"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); +// verifyType(metaInfo1, Position.class, fields, classtypes, columntypes); +// } +// } +// catch (Exception e) { +// fail("Failed to execute test ",e); +// } +// } +// }); + } + + public void testStructType() { +// browser.invoke(new SerializableRunnable() { +// public void run() { +// GemFireMember[] members = connection.getMembers(); +// +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); +// +// String queryString = "SELECT pf.id, pf.positions FROM "+DEFAULT_REGION_PATH + " pf WHERE pf.id = 'IBM'"; +// QueryResult result = null; +// try { +// result = connection.executeQuery(queryString, null); +// Assert.assertNotNull(result); +// } +// catch (QueryExecutionException e) { +// fail("Failed to execute query through data browser",e); +// } +// +// IntrospectionResult [] result_t = result.getIntrospectionResult(); +// Assert.assertEquals(1, result_t.length); +// IntrospectionResult metaInfo = result_t[0]; +// +// Assert.assertEquals(2, metaInfo.getColumnCount()); +// +// { +// List fields = Arrays.asList(new String[]{"id", "positions"}); +// List classtypes = Arrays.asList(new String[]{"java.lang.Object","java.lang.Object"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.UNKNOWN_TYPE_COLUMN, +// IntrospectionResult.UNKNOWN_TYPE_COLUMN}); +// +// verifyType(metaInfo, StructType.class, fields, classtypes, columntypes); +// } +// +// Collection temp = result.getQueryResult(); +// Assert.assertEquals(1, temp.size()); +// +// Iterator iter = temp.iterator(); +// Object tuple = iter.next(); +// +// try { +// +// int index = metaInfo.getColumnIndex("id"); +// Class colClass = metaInfo.getColumnClass(tuple, index); +// Assert.assertTrue(colClass.getCanonicalName().equals("java.lang.String")); +// Assert.assertTrue(metaInfo.getColumnType(tuple,index) == IntrospectionResult.PRIMITIVE_TYPE_COLUMN); +// +// index = metaInfo.getColumnIndex("positions"); +// tuple = result.getColumnValue(tuple, index); +// +// Assert.assertTrue(tuple instanceof MapResult); +// MapResult rset = (MapResult)tuple; +// Assert.assertEquals(2, rset.getMap().size()); +// +// //Verify Key set. +// { +// ResultSet temp1 = rset.getResultSetForKeys(); +// IntrospectionResult[] c_result = temp1.getIntrospectionResult(); +// Assert.assertEquals(1, c_result.length); +// IntrospectionResult metaInfo1 = c_result[0]; +// +// Assert.assertEquals(1, metaInfo1.getColumnCount()); +// +// List fields = Arrays.asList(new String[]{"Result"}); +// List classtypes = Arrays.asList(new String[]{"java.lang.String"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); +// verifyType(metaInfo1, java.lang.String.class, fields, classtypes, columntypes); +// } +// +// //Verify Value set. +// { +// ResultSet temp1 = rset.getResultSetForValues(); +// IntrospectionResult[] c_result = temp1.getIntrospectionResult(); +// Assert.assertEquals(1, c_result.length); +// IntrospectionResult metaInfo1 = c_result[0]; +// +// Assert.assertEquals(3, metaInfo1.getColumnCount()); +// +// List fields = Arrays.asList(new String[]{"secId", "mktValue", "qty" }); +// List classtypes = Arrays.asList(new String[]{"java.lang.String","double","double"}); +// List columntypes = Arrays.asList(new Integer[] {IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN, +// IntrospectionResult.PRIMITIVE_TYPE_COLUMN}); +// verifyType(metaInfo1, Position.class, fields, classtypes, columntypes); +// } +// } +// catch (Exception e) { +// fail("Failed to execute test ",e); +// } +// } +// }); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/connection/GemFireClientServerTopologyDUnitTest.java ---------------------------------------------------------------------- diff --git a/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/connection/GemFireClientServerTopologyDUnitTest.java b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/connection/GemFireClientServerTopologyDUnitTest.java new file mode 100644 index 0000000..b41de85 --- /dev/null +++ b/databrowser/tests/dunit/com/gemstone/gemfire/tools/databrowser/dunit/connection/GemFireClientServerTopologyDUnitTest.java @@ -0,0 +1,141 @@ +package com.gemstone.gemfire.tools.databrowser.dunit.connection; + +import hydra.BridgeHelper; +import hydra.CacheHelper; +import hydra.Log; +import hydra.BridgeHelper.Endpoint; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.List; + +import junit.framework.Assert; + +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.Scope; +import com.gemstone.gemfire.mgmt.DataBrowser.model.member.CacheServerInfo; +import com.gemstone.gemfire.mgmt.DataBrowser.model.member.GemFireMember; +import com.gemstone.gemfire.mgmt.DataBrowser.model.region.GemFireRegion; +import com.gemstone.gemfire.tools.databrowser.dunit.DataBrowserDUnitTestCase; + +import dunit.Host; +import dunit.SerializableRunnable; + +public class GemFireClientServerTopologyDUnitTest extends DataBrowserDUnitTestCase { + + public static final String SUBREGION_NAME = "Region1"; + public static final String SUBREGION_PATH = DEFAULT_REGION_PATH+"/Region1"; + + public GemFireClientServerTopologyDUnitTest(String name) { + super(name); + } + +// @Override + public void setUp() throws Exception { + super.setUp(); + + server.invoke(new SerializableRunnable() { + public void run() { + Cache cache = CacheHelper.getCache(); + Assert.assertNotNull(cache); + + Assert.assertTrue("Cache Server is down", cache.getCacheServers().size() > 0); + + Region root = cache.getRegion(DEFAULT_REGION_PATH); + Assert.assertNotNull(root); + + AttributesFactory factory = new AttributesFactory(); + factory.setDataPolicy(DataPolicy.EMPTY); + factory.setScope(Scope.DISTRIBUTED_NO_ACK); + RegionAttributes attr = factory.create(); + + Region sub = root.createSubregion(SUBREGION_NAME, attr); + Assert.assertNotNull(sub); + + Assert.assertNotNull(cache.getRegion(SUBREGION_PATH)); + + Assert.assertTrue("Cache Server is down", cache.getCacheServers().size() > 0); + + }}); + } + + @Override + public void tearDown2() throws Exception { + super.tearDown2(); + + server.invoke(new SerializableRunnable() { + public void run() { + Cache cache = CacheHelper.getCache(); + Assert.assertNotNull(cache); + + Region region = cache.getRegion(SUBREGION_PATH); + Assert.assertNotNull(region); + + //region.destroyRegion(); + + }}); + + } + + public void testGemFireCacheServerConfiguration() { + final Host host = Host.getHost(0); + + try { + Thread.sleep(10000); + } + catch (InterruptedException e1) { + //Do nothing. + } + + browser.invoke(new SerializableRunnable() { + public void run() { +// GemFireMember[] members = connection.getMembers(); +// Assert.assertEquals(1, members.length); +// Assert.assertEquals(GemFireMember.GEMFIRE_CACHE_SERVER, members[0].getType()); +// CacheServerInfo[] info = members[0].getCacheServers(); +// Assert.assertEquals(1, info.length); +// Log.getLogWriter().info(members[0].toString()); +// +// String id = members[0].getId(); +// +// +// try { +// InetAddress address = InetAddress.getByName(host.getHostName()); +// Assert.assertNotNull(address); +// Assert.assertEquals(address.getHostAddress(), members[0].getHost()); +// } +// catch (UnknownHostException e) { +// fail("Could not identify the host information of the cache-server", e); +// } +// +// List endpts = BridgeHelper.getEndpoints(); +// Assert.assertEquals(1, endpts.size()); +// Endpoint endp = (Endpoint)endpts.get(0); +// Assert.assertEquals(endp.getPort(), info[0].getPort()); +// +// Log.getLogWriter().info(members[0].toString()); +// GemFireRegion[] rootRegions = (connection.getMember(id)).getRootRegions(); +// //GemFireRegion[] rootRegions = (members[0]).getRootRegions(); +// Assert.assertEquals(1, rootRegions.length); +// Assert.assertEquals(DEFAULT_REGION_NAME, rootRegions[0].getName()); +// Assert.assertEquals(DEFAULT_REGION_PATH, rootRegions[0].getFullPath()); +// Assert.assertEquals(String.valueOf(Scope.DISTRIBUTED_NO_ACK), rootRegions[0].getScope()); +// Assert.assertEquals(String.valueOf(DataPolicy.REPLICATE), rootRegions[0].getDataPolicy()); +// +// Assert.assertEquals(1, ((connection.getMember(id)).getRootRegions()[0]).getSubRegions().length); +// +// GemFireRegion sub = rootRegions[0].getSubRegions()[0]; +// Assert.assertEquals(SUBREGION_NAME, sub.getName()); +// Assert.assertEquals(SUBREGION_PATH, sub.getFullPath()); +// Assert.assertEquals(String.valueOf(Scope.DISTRIBUTED_NO_ACK), sub.getScope()); +// Assert.assertEquals(String.valueOf(DataPolicy.EMPTY), sub.getDataPolicy()); +// Assert.assertEquals(0, sub.getSubRegions().length); + } + }); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/dunit/config/databrowser.inc ---------------------------------------------------------------------- diff --git a/databrowser/tests/dunit/config/databrowser.inc b/databrowser/tests/dunit/config/databrowser.inc new file mode 100644 index 0000000..91bff60 --- /dev/null +++ b/databrowser/tests/dunit/config/databrowser.inc @@ -0,0 +1,30 @@ +INCLUDE $JTESTS/dunit/impl/dunitN.inc; + +hydra.BridgePrms-names = bridge; + +hydra.CachePrms-names = server client; + +hydra.RegionPrms-names = serverRegion1 clientRegion; +hydra.RegionPrms-regionName = Customer Customer; +hydra.RegionPrms-interestPolicy = All All; +hydra.RegionPrms-scope = default local; +hydra.RegionPrms-dataPolicy = replicate normal; +hydra.RegionPrms-partitionName = none none; +hydra.RegionPrms-multicastEnabled = true false; +hydra.RegionPrms-poolName = none edgeDescript; +hydra.RegionPrms-statisticsEnabled = true; + +admin.jmx.RecyclePrms-numberOfEntitiesInRegion = 10; + +//Pool attributes. +hydra.PoolPrms-names = edgeDescript; +hydra.PoolPrms-minConnections = 10; +hydra.PoolPrms-maxConnections = 50; +hydra.PoolPrms-subscriptionEnabled = true;//false +hydra.PoolPrms-threadLocalConnections = true; +hydra.PoolPrms-readTimeout = 60000; +hydra.PoolPrms-subscriptionRedundancy = 0; +hydra.PoolPrms-idleTimeout = -1; +hydra.PoolPrms-statisticInterval = 5000; + +hydra.GemFirePrms-logLevel = fine; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e2ccf3da/databrowser/tests/junit/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/FieldTypeAccessorTest.java ---------------------------------------------------------------------- diff --git a/databrowser/tests/junit/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/FieldTypeAccessorTest.java b/databrowser/tests/junit/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/FieldTypeAccessorTest.java new file mode 100644 index 0000000..2580f69 --- /dev/null +++ b/databrowser/tests/junit/com/gemstone/gemfire/mgmt/DataBrowser/query/internal/FieldTypeAccessorTest.java @@ -0,0 +1,130 @@ +package com.gemstone.gemfire.mgmt.DataBrowser.query.internal; + +import junit.framework.TestCase; + +public class FieldTypeAccessorTest extends TestCase { + + private FieldTypeAccessor fieldTypeAccessor; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + if (PdxHelper.getInstance().isPdxSupported()) { + Class fieldTypeClass = null; + try { + fieldTypeClass = Class.forName("com.gemstone.gemfire.pdx.FieldType"); + } catch (ClassNotFoundException e) { + fieldTypeClass = null; + } + + if (fieldTypeClass == null) { + try { + fieldTypeClass = Class.forName("com.gemstone.gemfire.pdx.internal.FieldType"); + } catch (ClassNotFoundException e) { + fieldTypeClass = null; + } + } + + assertNotNull("PDX is supported i.e. GemFire version > 6.6. But can't find class FieldType. It's :"+fieldTypeClass, fieldTypeClass); + + fieldTypeAccessor = new FieldTypeAccessor(fieldTypeClass); + + System.out.println(fieldTypeAccessor); + } + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + fieldTypeAccessor = null; + } + + public void testGetBoolean() { + assertNotNull(fieldTypeAccessor.getBoolean()); + } + + public void testGetByte() { + assertNotNull(fieldTypeAccessor.getByte()); + } + + public void testGetChar() { + assertNotNull(fieldTypeAccessor.getChar()); + } + + public void testGetShort() { + assertNotNull(fieldTypeAccessor.getBoolean()); + } + + public void testGetInt() { + assertNotNull(fieldTypeAccessor.getInt()); + } + + public void testGetLong() { + assertNotNull(fieldTypeAccessor.getLong()); + } + + public void testGetFloat() { + assertNotNull(fieldTypeAccessor.getFloat()); + } + + public void testGetDouble() { + assertNotNull(fieldTypeAccessor.getDouble()); + } + + public void testGetDate() { + assertNotNull(fieldTypeAccessor.getDate()); + } + + public void testGetString() { + assertNotNull(fieldTypeAccessor.getString()); + } + + public void testGetObject() { + assertNotNull(fieldTypeAccessor.getObject()); + } + + public void testGetBooleanArray() { + assertNotNull(fieldTypeAccessor.getBooleanArray()); + } + + public void testGetByteArray() { + assertNotNull(fieldTypeAccessor.getByteArray()); + } + + public void testGetCharArray() { + assertNotNull(fieldTypeAccessor.getCharArray()); + } + + public void testGetShortArray() { + assertNotNull(fieldTypeAccessor.getShortArray()); + } + + public void testGetIntArray() { + assertNotNull(fieldTypeAccessor.getIntArray()); + } + + public void testGetLongArray() { + assertNotNull(fieldTypeAccessor.getLongArray()); + } + + public void testGetFloatArray() { + assertNotNull(fieldTypeAccessor.getFloatArray()); + } + + public void testGetDoubleArray() { + assertNotNull(fieldTypeAccessor.getDoubleArray()); + } + + public void testGetStringArray() { + assertNotNull(fieldTypeAccessor.getStringArray()); + } + + public void testGetObjectArray() { + assertNotNull(fieldTypeAccessor.getObjectArray()); + } + + public void testGetArrayOfByteArrays() { + assertNotNull(fieldTypeAccessor.getArrayOfByteArrays()); + } +}