kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 605634f891eaed1b385329e41ea4d05c8861d35892437e8072ebc6ecb69c2394 |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2016-03-09 11:36 +01:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-03-11 13:23 -06:00 |
| Parents | d969dcfd7ef6 |
3 files changed
modified driver-core/src/test/java/com/datastax/driver/core/UserTypesTest.java +27 −9
| @@ -28,8 +28,11 @@ | ||
| 28 | 28 | import java.net.InetAddress; |
| 29 | 29 | import java.nio.ByteBuffer; |
| 30 | 30 | import java.util.*; |
| 31 | +import java.util.concurrent.Callable; | |
| 31 | 32 | |
| 33 | +import static com.datastax.driver.core.ConditionChecker.check; | |
| 32 | 34 | import static com.datastax.driver.core.Metadata.quote; |
| 35 | +import static java.util.concurrent.TimeUnit.MINUTES; | |
| 33 | 36 | import static org.testng.Assert.assertEquals; |
| 34 | 37 | import static org.testng.Assert.assertNotEquals; |
| 35 | 38 | |
| @@ -37,15 +40,29 @@ | ||
| 37 | 40 | public class UserTypesTest extends CCMTestsSupport { |
| 38 | 41 | |
| 39 | 42 | private final static List<DataType> DATA_TYPE_PRIMITIVES = new ArrayList<DataType>(DataType.allPrimitiveTypes()); |
| 43 | + | |
| 44 | + static { | |
| 45 | + DATA_TYPE_PRIMITIVES.remove(DataType.counter()); | |
| 46 | + } | |
| 47 | + | |
| 40 | 48 | private final static List<DataType.Name> DATA_TYPE_NON_PRIMITIVE_NAMES = |
| 41 | 49 | new ArrayList<DataType.Name>(EnumSet.of(DataType.Name.LIST, DataType.Name.SET, DataType.Name.MAP, DataType.Name.TUPLE)); |
| 42 | 50 | |
| 51 | + private final Callable<Boolean> userTableExists = new Callable<Boolean>() { | |
| 52 | + @Override | |
| 53 | + public Boolean call() throws Exception { | |
| 54 | + return cluster().getMetadata().getKeyspace(keyspace).getTable("user") != null; | |
| 55 | + } | |
| 56 | + }; | |
| 57 | + | |
| 43 | 58 | @Override |
| 44 | 59 | public void onTestContextInitialized() { |
| 45 | 60 | String type1 = "CREATE TYPE phone (alias text, number text)"; |
| 46 | - String type2 = "CREATE TYPE address (street text, \"ZIP\" int, phones set<frozen<phone>>)"; | |
| 47 | - String table = "CREATE TABLE user (id int PRIMARY KEY, addr frozen<address>)"; | |
| 61 | + String type2 = "CREATE TYPE \"\"\"User Address\"\"\" (street text, \"ZIP\"\"\" int, phones set<frozen<phone>>)"; | |
| 62 | + String table = "CREATE TABLE user (id int PRIMARY KEY, addr frozen<\"\"\"User Address\"\"\">)"; | |
| 48 | 63 | execute(type1, type2, table); |
| 64 | + // Ci tests fail with "unconfigured columnfamily user" | |
| 65 | + check().that(userTableExists).before(5, MINUTES).becomesTrue(); | |
| 49 | 66 | } |
| 50 | 67 | |
| 51 | 68 | /** |
| @@ -59,13 +76,13 @@ | ||
| 59 | 76 | PreparedStatement ins = session().prepare("INSERT INTO user(id, addr) VALUES (?, ?)"); |
| 60 | 77 | PreparedStatement sel = session().prepare("SELECT * FROM user WHERE id=?"); |
| 61 | 78 | |
| 62 | - UserType addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("address"); | |
| 79 | + UserType addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType(quote("\"User Address\"")); | |
| 63 | 80 | UserType phoneDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("phone"); |
| 64 | 81 | |
| 65 | 82 | UDTValue phone1 = phoneDef.newValue().setString("alias", "home").setString("number", "0123548790"); |
| 66 | 83 | UDTValue phone2 = phoneDef.newValue().setString("alias", "work").setString("number", "0698265251"); |
| 67 | 84 | |
| 68 | - UDTValue addr = addrDef.newValue().setString("street", "1600 Pennsylvania Ave NW").setInt(quote("ZIP"), 20500).setSet("phones", ImmutableSet.of(phone1, phone2)); | |
| 85 | + UDTValue addr = addrDef.newValue().setString("street", "1600 Pennsylvania Ave NW").setInt(quote("ZIP\""), 20500).setSet("phones", ImmutableSet.of(phone1, phone2)); | |
| 69 | 86 | |
| 70 | 87 | session().execute(ins.bind(userId, addr)); |
| 71 | 88 | |
| @@ -83,13 +100,14 @@ | ||
| 83 | 100 | @Test(groups = "short") |
| 84 | 101 | public void simpleUnpreparedWriteReadTest() throws Exception { |
| 85 | 102 | int userId = 1; |
| 86 | - UserType addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("address"); | |
| 103 | + session().execute("USE " + keyspace); | |
| 104 | + UserType addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType(quote("\"User Address\"")); | |
| 87 | 105 | UserType phoneDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("phone"); |
| 88 | 106 | |
| 89 | 107 | UDTValue phone1 = phoneDef.newValue().setString("alias", "home").setString("number", "0123548790"); |
| 90 | 108 | UDTValue phone2 = phoneDef.newValue().setString("alias", "work").setString("number", "0698265251"); |
| 91 | 109 | |
| 92 | - UDTValue addr = addrDef.newValue().setString("street", "1600 Pennsylvania Ave NW").setInt(quote("ZIP"), 20500).setSet("phones", ImmutableSet.of(phone1, phone2)); | |
| 110 | + UDTValue addr = addrDef.newValue().setString("street", "1600 Pennsylvania Ave NW").setInt(quote("ZIP\""), 20500).setSet("phones", ImmutableSet.of(phone1, phone2)); | |
| 93 | 111 | |
| 94 | 112 | session().execute("INSERT INTO user(id, addr) VALUES (?, ?)", userId, addr); |
| 95 | 113 | |
| @@ -111,7 +129,7 @@ | ||
| 111 | 129 | assertEquals(addrDef, null); |
| 112 | 130 | assertEquals(phoneDef, null); |
| 113 | 131 | |
| 114 | - addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("address"); | |
| 132 | + addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType(quote("\"User Address\"")); | |
| 115 | 133 | phoneDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("phone"); |
| 116 | 134 | assertNotEquals(addrDef, null); |
| 117 | 135 | assertNotEquals(phoneDef, null); |
| @@ -122,14 +140,14 @@ | ||
| 122 | 140 | "WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1'}"); |
| 123 | 141 | session().execute("USE " + nonExistingKeyspace); |
| 124 | 142 | |
| 125 | - addrDef = cluster().getMetadata().getKeyspace(nonExistingKeyspace).getUserType("address"); | |
| 143 | + addrDef = cluster().getMetadata().getKeyspace(nonExistingKeyspace).getUserType(quote("\"User Address\"")); | |
| 126 | 144 | phoneDef = cluster().getMetadata().getKeyspace(nonExistingKeyspace).getUserType("phone"); |
| 127 | 145 | assertEquals(addrDef, null); |
| 128 | 146 | assertEquals(phoneDef, null); |
| 129 | 147 | |
| 130 | 148 | session().execute("USE " + keyspace); |
| 131 | 149 | |
| 132 | - addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("address"); | |
| 150 | + addrDef = cluster().getMetadata().getKeyspace(keyspace).getUserType(quote("\"User Address\"")); | |
| 133 | 151 | phoneDef = cluster().getMetadata().getKeyspace(keyspace).getUserType("phone"); |
| 134 | 152 | assertNotEquals(addrDef, null); |
| 135 | 153 | assertNotEquals(phoneDef, null); |
modified driver-examples/osgi/pom.xml +9 −43
| @@ -138,7 +138,7 @@ | ||
| 138 | 138 | <plugin> |
| 139 | 139 | <groupId>org.apache.maven.plugins</groupId> |
| 140 | 140 | <artifactId>maven-failsafe-plugin</artifactId> |
| 141 | - <version>2.18.1</version> | |
| 141 | + <version>2.16</version> | |
| 142 | 142 | <executions> |
| 143 | 143 | <execution> |
| 144 | 144 | <goals> |
| @@ -195,60 +195,26 @@ | ||
| 195 | 195 | <plugins> |
| 196 | 196 | <plugin> |
| 197 | 197 | <groupId>org.apache.maven.plugins</groupId> |
| 198 | - <artifactId>maven-failsafe-plugin</artifactId> | |
| 199 | - <version>2.18.1</version> | |
| 198 | + <artifactId>maven-surefire-plugin</artifactId> | |
| 199 | + <version>2.16</version> | |
| 200 | 200 | <configuration> |
| 201 | 201 | <skip>true</skip> |
| 202 | 202 | </configuration> |
| 203 | 203 | </plugin> |
| 204 | - <plugin> | |
| 205 | - <artifactId>maven-compiler-plugin</artifactId> | |
| 206 | - <configuration> | |
| 207 | - <compilerArgument>-Xlint:all</compilerArgument> | |
| 208 | - <showWarnings>true</showWarnings> | |
| 209 | - <showDeprecation>true</showDeprecation> | |
| 210 | - </configuration> | |
| 211 | - </plugin> | |
| 212 | - </plugins> | |
| 213 | - </build> | |
| 214 | - </profile> | |
| 215 | - | |
| 216 | - <profile> | |
| 217 | - <id>short</id> | |
| 218 | - <build> | |
| 219 | - <plugins> | |
| 220 | 204 | <plugin> |
| 221 | 205 | <groupId>org.apache.maven.plugins</groupId> |
| 222 | 206 | <artifactId>maven-failsafe-plugin</artifactId> |
| 223 | - <version>2.18.1</version> | |
| 207 | + <version>2.16</version> | |
| 224 | 208 | <configuration> |
| 225 | - <groups>${test.groups}</groups> | |
| 226 | - <useFile>false</useFile> | |
| 227 | - <systemPropertyVariables> | |
| 228 | - <cassandra.version>${cassandra.version}</cassandra.version> | |
| 229 | - <ipprefix>${ipprefix}</ipprefix> | |
| 230 | - </systemPropertyVariables> | |
| 209 | + <skip>true</skip> | |
| 231 | 210 | </configuration> |
| 232 | 211 | </plugin> |
| 233 | - </plugins> | |
| 234 | - </build> | |
| 235 | - </profile> | |
| 236 | - | |
| 237 | - <profile> | |
| 238 | - <id>long</id> | |
| 239 | - <build> | |
| 240 | - <plugins> | |
| 241 | 212 | <plugin> |
| 242 | - <groupId>org.apache.maven.plugins</groupId> | |
| 243 | - <artifactId>maven-failsafe-plugin</artifactId> | |
| 244 | - <version>2.18.1</version> | |
| 213 | + <artifactId>maven-compiler-plugin</artifactId> | |
| 245 | 214 | <configuration> |
| 246 | - <groups>${test.groups}</groups> | |
| 247 | - <useFile>false</useFile> | |
| 248 | - <systemPropertyVariables> | |
| 249 | - <cassandra.version>${cassandra.version}</cassandra.version> | |
| 250 | - <ipprefix>${ipprefix}</ipprefix> | |
| 251 | - </systemPropertyVariables> | |
| 215 | + <compilerArgument>-Xlint:all</compilerArgument> | |
| 216 | + <showWarnings>true</showWarnings> | |
| 217 | + <showDeprecation>true</showDeprecation> | |
| 252 | 218 | </configuration> |
| 253 | 219 | </plugin> |
| 254 | 220 | </plugins> |
modified pom.xml +25 −1
| @@ -133,7 +133,7 @@ | ||
| 133 | 133 | </properties> |
| 134 | 134 | </profile> |
| 135 | 135 | <profile> |
| 136 | - <!-- default profile settings for 'isolated' test group, will skip tests unless overriden in child module. --> | |
| 136 | + <!-- default profile settings for 'isolated' test group, will skip tests unless overridden in child module. --> | |
| 137 | 137 | <id>isolated</id> |
| 138 | 138 | <properties> |
| 139 | 139 | <env>default</env> |
| @@ -298,6 +298,30 @@ | ||
| 298 | 298 | </properties> |
| 299 | 299 | </configuration> |
| 300 | 300 | </plugin> |
| 301 | + <plugin> | |
| 302 | + <groupId>org.apache.maven.plugins</groupId> | |
| 303 | + <artifactId>maven-failsafe-plugin</artifactId> | |
| 304 | + <version>2.16</version> | |
| 305 | + <configuration> | |
| 306 | + <groups>${test.groups}</groups> | |
| 307 | + <useFile>false</useFile> | |
| 308 | + <systemPropertyVariables> | |
| 309 | + <cassandra.version>${cassandra.version}</cassandra.version> | |
| 310 | + <ipprefix>${ipprefix}</ipprefix> | |
| 311 | + <com.datastax.driver.NEW_NODE_DELAY_SECONDS>60</com.datastax.driver.NEW_NODE_DELAY_SECONDS> | |
| 312 | + </systemPropertyVariables> | |
| 313 | + <classpathDependencyExcludes> | |
| 314 | + <classpathDependencyExcludes>io.netty:netty-transport-native-epoll</classpathDependencyExcludes> | |
| 315 | + </classpathDependencyExcludes> | |
| 316 | + <properties> | |
| 317 | + <property> | |
| 318 | + <!-- Don't skip tests after a @Before method throws a SkipException --> | |
| 319 | + <name>configfailurepolicy</name> | |
| 320 | + <value>continue</value> | |
| 321 | + </property> | |
| 322 | + </properties> | |
| 323 | + </configuration> | |
| 324 | + </plugin> | |
| 301 | 325 | </plugins> |
| 302 | 326 | |
| 303 | 327 | </build> |