-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fixes two problems: * Calling toString() the Optional ObjectName * Using toMap() which does not support null values
- Loading branch information
Showing
4 changed files
with
60 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
presto-jmx/src/test/java/com/facebook/presto/connector/jmx/TestJmxMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.facebook.presto.connector.jmx; | ||
|
||
import com.facebook.presto.spi.ConnectorSession; | ||
import com.facebook.presto.spi.SchemaTableName; | ||
import com.facebook.presto.spi.type.BigintType; | ||
import com.google.common.collect.ImmutableList; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.List; | ||
|
||
import static com.facebook.presto.spi.type.TimeZoneKey.UTC_KEY; | ||
import static com.facebook.presto.spi.type.VarcharType.VARCHAR; | ||
import static java.lang.management.ManagementFactory.getPlatformMBeanServer; | ||
import static java.util.Locale.ENGLISH; | ||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
public class TestJmxMetadata | ||
{ | ||
private static final ConnectorSession SESSION = new ConnectorSession("user", UTC_KEY, ENGLISH, System.currentTimeMillis(), null); | ||
private static final String RUNTIME_OBJECT = "java.lang:type=Runtime"; | ||
private static final SchemaTableName RUNTIME_TABLE = new SchemaTableName("jmx", RUNTIME_OBJECT.toLowerCase(ENGLISH)); | ||
|
||
private final JmxMetadata metadata = new JmxMetadata("test", getPlatformMBeanServer()); | ||
|
||
@Test | ||
public void testListSchemas() | ||
throws Exception | ||
{ | ||
assertEquals(metadata.listSchemaNames(SESSION), ImmutableList.of("jmx")); | ||
} | ||
|
||
@Test | ||
public void testListTables() | ||
{ | ||
assertTrue(metadata.listTables(SESSION, "jmx").contains(RUNTIME_TABLE)); | ||
} | ||
|
||
@Test | ||
public void testGetTableHandle() | ||
throws Exception | ||
{ | ||
JmxTableHandle handle = metadata.getTableHandle(SESSION, RUNTIME_TABLE); | ||
assertEquals(handle.getConnectorId(), "test"); | ||
assertEquals(handle.getObjectName(), RUNTIME_OBJECT); | ||
|
||
List<JmxColumnHandle> columns = handle.getColumns(); | ||
assertTrue(columns.contains(new JmxColumnHandle("test", "node", VARCHAR))); | ||
assertTrue(columns.contains(new JmxColumnHandle("test", "Name", VARCHAR))); | ||
assertTrue(columns.contains(new JmxColumnHandle("test", "StartTime", BigintType.BIGINT))); | ||
} | ||
} |