-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
159 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>com.hazelcast</groupId> | ||
<artifactId>hazelcast-jdbc-root</artifactId> | ||
<version>5.4.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>smoke-test</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.hazelcast</groupId> | ||
<artifactId>${jdbcArtifact}</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>license-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>add-third-party</id> | ||
<goals> | ||
<goal>add-third-party</goal> | ||
</goals> | ||
<phase/> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
66 changes: 66 additions & 0 deletions
66
smoke-test/src/main/java/com/hazelcast/smoke/test/SmokeTestDriver.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,66 @@ | ||
package com.hazelcast.smoke.test; | ||
|
||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
import java.util.logging.Logger; | ||
|
||
public class SmokeTestDriver { | ||
|
||
private static final Logger logger = Logger.getLogger(SmokeTestDriver.class.getName()); | ||
|
||
public static void main(String[] args) throws SQLException { | ||
|
||
if (args.length < 2) { | ||
logger.severe("Usage: 'java " | ||
+ SmokeTestDriver.class.getName() | ||
+ " <port> <clusterName>"); | ||
throw new IllegalArgumentException("Too few arguments"); | ||
} | ||
|
||
String hzPort = args[0]; | ||
String clusterName = args[1]; | ||
try (Connection con = DriverManager.getConnection( | ||
"jdbc:hazelcast://localhost:" + hzPort + "/?clusterName=" + clusterName)) { | ||
logger.info("Database: " + con.getMetaData().getDatabaseProductName() | ||
+ ": " + con.getMetaData().getDatabaseProductVersion()); | ||
|
||
try (Statement s = con.createStatement()) { | ||
s.execute("CREATE OR REPLACE MAPPING map " | ||
+ "TYPE IMap OPTIONS(" | ||
+ " 'keyFormat'='integer', " | ||
+ " 'valueFormat'='varchar'" | ||
+ ")"); | ||
|
||
int insertCount = s.executeUpdate( | ||
"INSERT INTO map " | ||
+ "SELECT v, 'name-' || v " | ||
+ "FROM TABLE(generate_series(0, 9))" | ||
); | ||
assert insertCount == 0; | ||
|
||
ResultSet rs = s.executeQuery( | ||
"SELECT __key, this " | ||
+ "FROM map " | ||
+ "ORDER BY __key" | ||
); | ||
int rowCount = 0; | ||
while (rs.next()) { | ||
String row = String.format("__key: %d value: %s", | ||
rs.getInt("__key"), rs.getString("this")); | ||
logger.info(row); | ||
rowCount++; | ||
} | ||
|
||
assert rowCount == 10; | ||
|
||
int deleteCount = s.executeUpdate("DELETE FROM map"); | ||
assert deleteCount == insertCount; | ||
|
||
s.execute("DROP MAPPING map"); | ||
} | ||
} | ||
} | ||
} |