-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked test enities to a SimpleTable and a TortureTable to include …
…all data types. Includes bugfixes found while testing TortureTable.
- Loading branch information
1 parent
fa1fe9c
commit e680688
Showing
26 changed files
with
611 additions
and
250 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,101 @@ | ||
#!/bin/sh | ||
# | ||
# Helper script to spin up docker and regenerate test models | ||
# | ||
|
||
VERSION=2.0-SNAPSHOT | ||
KEYSPACE=junittest | ||
INSTANCE=casquatch-driver-tests | ||
OUTPUT_FOLDER=src/test/java/com/tmobile/opensource/casquatch/tests/ | ||
GENERATOR=../casquatch-generator/target/casquatch-generator-$VERSION.jar | ||
PACKAGE=com.tmobile.opensource.casquatch.tests | ||
PORT=9044 | ||
|
||
echo "---------------------------------------------" | ||
echo "Starting Docker (30 second pause to startup)" | ||
echo "---------------------------------------------" | ||
docker kill $INSTANCE | ||
docker run --rm -p $PORT:9042 -d --name $INSTANCE -d cassandra:latest | ||
sleep 30 | ||
|
||
echo "---------------------------------------------" | ||
echo "Installing CQL" | ||
echo "---------------------------------------------" | ||
docker exec -i $INSTANCE cqlsh <<EOF | ||
CREATE KEYSPACE $KEYSPACE WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; | ||
CREATE TABLE $KEYSPACE.simple_table ( | ||
key_one int, | ||
key_two int, | ||
col_one text, | ||
col_two text, | ||
solr_query text, | ||
PRIMARY KEY (key_one, key_two) | ||
) WITH CLUSTERING ORDER BY (key_two ASC); | ||
CREATE TYPE $KEYSPACE.udt ( val1 text, val2 text ); | ||
CREATE TABLE $KEYSPACE.torture_table ( | ||
id uuid PRIMARY KEY, | ||
col_ascii ascii, | ||
col_bigint bigint, | ||
col_blob blob, | ||
col_boolean boolean, | ||
col_date date, | ||
col_decimal decimal, | ||
col_double double, | ||
col_float float, | ||
col_inet inet, | ||
col_int int, | ||
col_list list<text>, | ||
col_map map<text, text>, | ||
col_set set<text>, | ||
col_smallint smallint, | ||
col_text text, | ||
col_time time, | ||
col_timestamp timestamp, | ||
col_timeuuid timeuuid, | ||
col_tinyint tinyint, | ||
col_uuid uuid, | ||
col_varchar text, | ||
col_varint varint, | ||
col_udt frozen<udt> | ||
); | ||
CREATE TABLE $KEYSPACE.counter_table ( | ||
id uuid PRIMARY KEY, | ||
col_counter counter | ||
); | ||
CREATE TABLE $KEYSPACE.tuple_table ( | ||
id uuid PRIMARY KEY, | ||
col_tuple tuple<text,text,text> | ||
); | ||
EOF | ||
|
||
echo "---------------------------------------------" | ||
echo "Generate Models" | ||
echo "---------------------------------------------" | ||
java -Dcasquatch.basic.contact-points.0=localhost:$PORT \ | ||
-Dcasquatch.basic.load-balancing-policy.local-datacenter=datacenter1 \ | ||
-Dcasquatch.basic.session-keyspace=$KEYSPACE \ | ||
-Dcasquatch.generator.outputFolder=$OUTPUT_FOLDER \ | ||
-Dcasquatch.generator.overwrite=true \ | ||
-Dcasquatch.generator.file=true \ | ||
-Dcasquatch.generator.packageName=$PACKAGE \ | ||
-DCASQUATCH_LOG_LEVEL=TRACE \ | ||
-jar $GENERATOR | ||
|
||
echo "---------------------------------------------" | ||
echo "Modify Output" | ||
echo "---------------------------------------------" | ||
rm $OUTPUT_FOLDER/*_EmbeddedTests.java | ||
sed -i .bak 's/^\@CasquatchEntity\(\)$/\@CasquatchEntity\(generateTests = true\)/' $OUTPUT_FOLDER/*.java | ||
rm $OUTPUT_FOLDER/*.java.bak | ||
|
||
|
||
echo "---------------------------------------------" | ||
echo "Kill Docker" | ||
echo "---------------------------------------------" | ||
docker kill $INSTANCE |
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
46 changes: 46 additions & 0 deletions
46
...-tests/src/main/java/com/tmobile/opensource/casquatch/tests/podam/BigIntegerStrategy.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,46 @@ | ||
/* | ||
* Copyright 2018 T-Mobile US, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.tmobile.opensource.casquatch.tests.podam; | ||
|
||
import uk.co.jemos.podam.api.AttributeMetadata; | ||
import uk.co.jemos.podam.api.DataProviderStrategy; | ||
import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; | ||
|
||
import java.lang.reflect.Type; | ||
import java.math.BigInteger; | ||
import java.util.Map; | ||
|
||
/** | ||
* Implements BigInteger generation | ||
*/ | ||
class BigIntegerStrategy extends AbstractTypeManufacturer<BigInteger> { | ||
|
||
/** | ||
* Required interface to implement BigInteger generation. | ||
* @param strategy passed strategy | ||
* @param attributeMetadata passed attribute metadata | ||
* @param genericTypesArgumentsMap passed map | ||
* @return generated BigInteger | ||
*/ | ||
@Override | ||
public BigInteger getType(DataProviderStrategy strategy, | ||
AttributeMetadata attributeMetadata, | ||
Map<String, Type> genericTypesArgumentsMap) { | ||
|
||
return BigInteger.valueOf(strategy.getTypeValue(attributeMetadata,genericTypesArgumentsMap,Integer.class)); | ||
} | ||
} |
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
46 changes: 46 additions & 0 deletions
46
...tests/src/main/java/com/tmobile/opensource/casquatch/tests/podam/InetAddressStrategy.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,46 @@ | ||
/* | ||
* Copyright 2018 T-Mobile US, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.tmobile.opensource.casquatch.tests.podam; | ||
|
||
import uk.co.jemos.podam.api.AttributeMetadata; | ||
import uk.co.jemos.podam.api.DataProviderStrategy; | ||
import uk.co.jemos.podam.typeManufacturers.AbstractTypeManufacturer; | ||
|
||
import java.lang.reflect.Type; | ||
import java.net.InetAddress; | ||
import java.util.Map; | ||
|
||
/** | ||
* Implements InetAddress generation | ||
*/ | ||
class InetAddressStrategy extends AbstractTypeManufacturer<InetAddress> { | ||
|
||
/** | ||
* Required interface to implement InetAddress generation. | ||
* @param strategy passed strategy | ||
* @param attributeMetadata passed attribute metadata | ||
* @param genericTypesArgumentsMap passed map | ||
* @return generated InetAddress | ||
*/ | ||
@Override | ||
public InetAddress getType(DataProviderStrategy strategy, | ||
AttributeMetadata attributeMetadata, | ||
Map<String, Type> genericTypesArgumentsMap) { | ||
|
||
return InetAddress.getLoopbackAddress(); | ||
} | ||
} |
Oops, something went wrong.