@Test public void testGettersSetters() { // Note - this method should *ONLY* use the jndi meta and not the odbc or native ones. // This is the only method in this test class that mutates the meta. jndiMeta.setUsername("FOO"); assertEquals("FOO", jndiMeta.getUsername()); jndiMeta.setPassword("BAR"); assertEquals("BAR", jndiMeta.getPassword()); jndiMeta.setAccessType(DatabaseMeta.TYPE_ACCESS_JNDI); assertEquals("", jndiMeta.getUsername()); assertEquals("", jndiMeta.getPassword()); assertFalse(jndiMeta.isChanged()); jndiMeta.setChanged(true); assertTrue(jndiMeta.isChanged()); jndiMeta.setName("FOO"); assertEquals("FOO", jndiMeta.getName()); assertEquals("FOO", jndiMeta.getDisplayName()); jndiMeta.setName(null); assertNull(jndiMeta.getName()); assertEquals("FOO", jndiMeta.getDisplayName()); jndiMeta.setDisplayName(null); assertNull(jndiMeta.getDisplayName()); jndiMeta.setDatabaseName("FOO"); assertEquals("FOO", jndiMeta.getDatabaseName()); assertEquals("-1", jndiMeta.getDatabasePortNumberString()); jndiMeta.setDatabasePortNumberString("9876"); assertEquals("9876", jndiMeta.getDatabasePortNumberString()); jndiMeta.setDatabasePortNumberString(null); assertEquals( "9876", jndiMeta.getDatabasePortNumberString()); // not sure I agree with this behavior jndiMeta.setHostname("FOO"); assertEquals("FOO", jndiMeta.getHostname()); LongObjectId id = new LongObjectId(9876); jndiMeta.setObjectId(id); assertEquals(id, jndiMeta.getObjectId()); jndiMeta.setServername("FOO"); assertEquals("FOO", jndiMeta.getServername()); jndiMeta.setDataTablespace("FOO"); assertEquals("FOO", jndiMeta.getDataTablespace()); jndiMeta.setIndexTablespace("FOO"); assertEquals("FOO", jndiMeta.getIndexTablespace()); Properties attrs = jndiMeta.getAttributes(); Properties testAttrs = new Properties(); testAttrs.setProperty("FOO", "BAR"); jndiMeta.setAttributes(testAttrs); assertEquals(testAttrs, jndiMeta.getAttributes()); jndiMeta.setAttributes(attrs); // reset attributes back to what they were... jndiMeta.setSupportsBooleanDataType(true); assertTrue(jndiMeta.supportsBooleanDataType()); jndiMeta.setSupportsTimestampDataType(true); assertTrue(jndiMeta.supportsTimestampDataType()); jndiMeta.setPreserveReservedCase(false); assertFalse(jndiMeta.preserveReservedCase()); jndiMeta.addExtraOption("JNDI", "FOO", "BAR"); Map<String, String> expectedOptionsMap = new HashMap<String, String>(); expectedOptionsMap.put("JNDI.FOO", "BAR"); assertEquals(expectedOptionsMap, jndiMeta.getExtraOptions()); jndiMeta.setConnectSQL("SELECT COUNT(*) FROM FOO"); assertEquals("SELECT COUNT(*) FROM FOO", jndiMeta.getConnectSQL()); jndiMeta.setUsingConnectionPool(true); assertTrue(jndiMeta.isUsingConnectionPool()); jndiMeta.setMaximumPoolSize(15); assertEquals(15, jndiMeta.getMaximumPoolSize()); jndiMeta.setInitialPoolSize(5); assertEquals(5, jndiMeta.getInitialPoolSize()); jndiMeta.setPartitioned(true); assertTrue(jndiMeta.isPartitioned()); PartitionDatabaseMeta[] clusterInfo = new PartitionDatabaseMeta[1]; PartitionDatabaseMeta aClusterDef = new PartitionDatabaseMeta("FOO", "BAR", "WIBBLE", "NATTIE"); aClusterDef.setUsername("FOOUSER"); aClusterDef.setPassword("BARPASSWORD"); clusterInfo[0] = aClusterDef; jndiMeta.setPartitioningInformation(clusterInfo); PartitionDatabaseMeta[] gotPartitions = jndiMeta.getPartitioningInformation(); // MB: Can't use arrayEquals because the PartitionDatabaseMeta doesn't have a toString. :( // assertArrayEquals( clusterInfo, gotPartitions ); assertTrue(gotPartitions != null); if (gotPartitions != null) { assertEquals(1, gotPartitions.length); PartitionDatabaseMeta compareWith = gotPartitions[0]; // MB: Can't use x.equals(y) because PartitionDatabaseMeta doesn't override equals... :( assertEquals(aClusterDef.getClass(), compareWith.getClass()); assertEquals(aClusterDef.getDatabaseName(), compareWith.getDatabaseName()); assertEquals(aClusterDef.getHostname(), compareWith.getHostname()); assertEquals(aClusterDef.getPartitionId(), compareWith.getPartitionId()); assertEquals(aClusterDef.getPassword(), compareWith.getPassword()); assertEquals(aClusterDef.getPort(), compareWith.getPort()); assertEquals(aClusterDef.getUsername(), compareWith.getUsername()); } Properties poolProperties = new Properties(); poolProperties.put("FOO", "BAR"); poolProperties.put("BAR", "FOO"); poolProperties.put("ZZZZZZZZZZZZZZ", "Z.Z.Z.Z.Z.Z.Z.Z.a.a.a.a.a.a.a.a.a"); poolProperties.put("TOM", "JANE"); poolProperties.put("AAAAAAAAAAAAA", "BBBBB.BBB.BBBBBBB.BBBBBBBB.BBBBBBBBBBBBBB"); jndiMeta.setConnectionPoolingProperties(poolProperties); Properties compareWithProps = jndiMeta.getConnectionPoolingProperties(); assertEquals(poolProperties, compareWithProps); jndiMeta.setStreamingResults(false); assertFalse(jndiMeta.isStreamingResults()); jndiMeta.setQuoteAllFields(true); jndiMeta.setForcingIdentifiersToLowerCase(true); jndiMeta.setForcingIdentifiersToUpperCase(true); assertTrue(jndiMeta.isQuoteAllFields()); assertTrue(jndiMeta.isForcingIdentifiersToLowerCase()); assertTrue(jndiMeta.isForcingIdentifiersToUpperCase()); jndiMeta.setUsingDoubleDecimalAsSchemaTableSeparator(true); assertTrue(jndiMeta.isUsingDoubleDecimalAsSchemaTableSeparator()); jndiMeta.setPreferredSchemaName("FOO"); assertEquals("FOO", jndiMeta.getPreferredSchemaName()); }