DATACASS-93 - finished incomplete tests
This commit is contained in:
@@ -2,15 +2,20 @@ package org.springframework.data.cassandra.test.integration.forcequote.composite
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.cassandra.mapping.Column;
|
||||
import org.springframework.data.cassandra.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
|
||||
@Table(forceQuote = true)
|
||||
@Table(forceQuote = true, value = Explicit.TABLE_NAME)
|
||||
public class Explicit {
|
||||
|
||||
public static final String TABLE_NAME = "JavaExplicitTable";
|
||||
public static final String STRING_VALUE_COLUMN_NAME = "JavaExplicitStringValue";
|
||||
|
||||
@PrimaryKey
|
||||
ExplicitKey primaryKey;
|
||||
|
||||
@Column(value = STRING_VALUE_COLUMN_NAME, forceQuote = true)
|
||||
String stringValue = UUID.randomUUID().toString();
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -32,4 +37,8 @@ public class Explicit {
|
||||
public String getStringValue() {
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
public void setStringValue(String stringValue) {
|
||||
this.stringValue = stringValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
|
||||
@PrimaryKeyClass
|
||||
public class ExplicitKey implements Serializable {
|
||||
|
||||
public static final String EXPLICIT_KEY_ZERO = "FirstKey";
|
||||
public static final String EXPLICIT_KEY_ONE = "SecondKey";
|
||||
public static final String EXPLICIT_KEY_ZERO = "JavaExplicitKeyZero";
|
||||
public static final String EXPLICIT_KEY_ONE = "JavaExplicitKeyOne";
|
||||
|
||||
private static final long serialVersionUID = 4459456944472099332L;
|
||||
|
||||
|
||||
@@ -12,9 +12,7 @@ import org.springframework.data.cassandra.core.CassandraTemplate;
|
||||
public class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests {
|
||||
|
||||
ImplicitRepository i;
|
||||
// ImplicitPropertiesRepository ip;
|
||||
ExplicitRepository e;
|
||||
// ExplicitPropertiesRepository ep;
|
||||
CassandraTemplate t;
|
||||
|
||||
public void before() {
|
||||
@@ -33,75 +31,56 @@ public class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTests {
|
||||
ImplicitKey key = new ImplicitKey(UUID.randomUUID().toString(), UUID.randomUUID().toString());
|
||||
Implicit entity = new Implicit(key);
|
||||
|
||||
// insert
|
||||
Implicit s = i.save(entity);
|
||||
assertSame(s, entity);
|
||||
|
||||
// select
|
||||
Implicit f = i.findOne(key);
|
||||
assertNotSame(f, entity);
|
||||
|
||||
String stringValue = query("stringvalue", "\"Implicit\"", "\"keyZero\"", f.getPrimaryKey().getKeyZero(),
|
||||
"\"keyOne\"", f.getPrimaryKey().getKeyOne());
|
||||
assertEquals(f.getStringValue(), stringValue);
|
||||
|
||||
i.delete(key);
|
||||
// update
|
||||
f.setStringValue(f.getStringValue() + "X");
|
||||
Implicit u = i.save(f);
|
||||
assertSame(u, f);
|
||||
f = i.findOne(u.getPrimaryKey());
|
||||
assertNotSame(f, u);
|
||||
assertEquals(u.getStringValue(), f.getStringValue());
|
||||
|
||||
// delete
|
||||
i.delete(key);
|
||||
assertNull(i.findOne(key));
|
||||
}
|
||||
|
||||
public void testExplicit() {
|
||||
public void testExplicit(String tableName, String stringValueColumnName, String keyZeroColumnName,
|
||||
String keyOneColumnName) {
|
||||
ExplicitKey key = new ExplicitKey(UUID.randomUUID().toString(), UUID.randomUUID().toString());
|
||||
Explicit entity = new Explicit(key);
|
||||
|
||||
// insert
|
||||
Explicit s = e.save(entity);
|
||||
assertSame(s, entity);
|
||||
|
||||
// select
|
||||
Explicit f = e.findOne(key);
|
||||
assertNotSame(f, entity);
|
||||
|
||||
String stringValue = query("stringvalue", "\"Explicit\"", String.format("\"%s\"", ExplicitKey.EXPLICIT_KEY_ZERO), f
|
||||
.getPrimaryKey().getKeyZero(), String.format("\"%s\"", ExplicitKey.EXPLICIT_KEY_ONE), f.getPrimaryKey()
|
||||
.getKeyOne());
|
||||
String stringValue = query(stringValueColumnName, tableName, keyZeroColumnName, f.getPrimaryKey().getKeyZero(),
|
||||
keyOneColumnName, f.getPrimaryKey().getKeyOne());
|
||||
assertEquals(f.getStringValue(), stringValue);
|
||||
|
||||
e.delete(key);
|
||||
// update
|
||||
f.setStringValue(f.getStringValue() + "X");
|
||||
Explicit u = e.save(f);
|
||||
assertSame(u, f);
|
||||
f = e.findOne(u.getPrimaryKey());
|
||||
assertNotSame(f, u);
|
||||
assertEquals(u.getStringValue(), f.getStringValue());
|
||||
|
||||
// delete
|
||||
e.delete(key);
|
||||
assertNull(e.findOne(key));
|
||||
}
|
||||
|
||||
// public void testImplicitProperties() {
|
||||
// ImplicitProperties entity = new ImplicitProperties();
|
||||
// String key = entity.getPrimaryKey();
|
||||
//
|
||||
// ImplicitProperties s = ip.save(entity);
|
||||
// assertSame(s, entity);
|
||||
//
|
||||
// ImplicitProperties f = ip.findOne(key);
|
||||
// assertNotSame(f, entity);
|
||||
//
|
||||
// String stringValue = query("\"stringValue\"", "implicitproperties", "\"primaryKey\"", f.getPrimaryKey());
|
||||
// assertEquals(f.getStringValue(), stringValue);
|
||||
//
|
||||
// ip.delete(key);
|
||||
//
|
||||
// assertNull(ip.findOne(key));
|
||||
// }
|
||||
|
||||
// public void testExplicitProperties(String stringValueColumnName, String primaryKeyColumnName) {
|
||||
// ExplicitProperties entity = new ExplicitProperties();
|
||||
// String key = entity.getPrimaryKey();
|
||||
//
|
||||
// ExplicitProperties s = ep.save(entity);
|
||||
// assertSame(s, entity);
|
||||
//
|
||||
// ExplicitProperties f = ep.findOne(key);
|
||||
// assertNotSame(f, entity);
|
||||
//
|
||||
// String stringValue = query(String.format("\"%s\"", ExplicitProperties.EXPLICIT_STRING_VALUE), "explicitproperties",
|
||||
// String.format("\"%s\"", ExplicitProperties.EXPLICIT_PRIMARY_KEY), f.getPrimaryKey());
|
||||
// assertEquals(f.getStringValue(), stringValue);
|
||||
//
|
||||
// ip.delete(key);
|
||||
//
|
||||
// assertNull(ip.findOne(key));
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -38,8 +38,9 @@ public abstract class ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDe
|
||||
tests.testImplicit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExplicit() {
|
||||
tests.testExplicit();
|
||||
public void testExplicit(String tableName, String stringValueColumnName, String keyZeroColumnName,
|
||||
String keyOneColumnName) {
|
||||
|
||||
tests.testExplicit(tableName, stringValueColumnName, keyZeroColumnName, keyOneColumnName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
|
||||
import org.springframework.data.cassandra.test.integration.support.IntegrationTestConfig;
|
||||
@@ -13,4 +14,11 @@ public class ForceQuotedCompositePrimaryKeyRepositoryJavaConfigIntegrationTests
|
||||
@EnableCassandraRepositories(basePackageClasses = ImplicitRepository.class)
|
||||
public static class Config extends IntegrationTestConfig {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExplicit() {
|
||||
testExplicit(String.format("\"%s\"", Explicit.TABLE_NAME),
|
||||
String.format("\"%s\"", Explicit.STRING_VALUE_COLUMN_NAME),
|
||||
String.format("\"%s\"", ExplicitKey.EXPLICIT_KEY_ZERO), String.format("\"%s\"", ExplicitKey.EXPLICIT_KEY_ONE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
@ContextConfiguration
|
||||
public class ForceQuotedCompositePrimaryKeyRepositoryXmlConfigIntegrationTests extends
|
||||
ForceQuotedCompositePrimaryKeyRepositoryIntegrationTestsDelegator {
|
||||
|
||||
@Test
|
||||
public void testExplicit() {
|
||||
testExplicit(String.format("\"%s\"", "XmlExplicitTable"), String.format("\"%s\"", "XmlExplicitStringValue"),
|
||||
String.format("\"%s\"", "XmlExplicitKeyZero"), String.format("\"%s\"", "XmlExplicitKeyOne"));
|
||||
}
|
||||
}
|
||||
@@ -32,4 +32,8 @@ public class Implicit {
|
||||
public String getStringValue() {
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
public void setStringValue(String stringValue) {
|
||||
this.stringValue = stringValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,40 +13,33 @@
|
||||
<import resource="classpath:/spring-data-cassandra-basic.xml" />
|
||||
|
||||
<cass:mapping
|
||||
entity-base-packages="org.springframework.data.cassandra.test.integration.forcequote.config">
|
||||
entity-base-packages="org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey">
|
||||
<cass:entity
|
||||
class="org.springframework.data.cassandra.test.integration.forcequote.config.Implicit">
|
||||
class="org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey.Implicit">
|
||||
<cass:table force-quote="true" />
|
||||
</cass:entity>
|
||||
<cass:entity
|
||||
class="org.springframework.data.cassandra.test.integration.forcequote.config.Explicit">
|
||||
<cass:table force-quote="true" name="Zz" />
|
||||
class="org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey.Explicit">
|
||||
<cass:table force-quote="true" name="XmlExplicitTable" />
|
||||
<cass:property name="stringValue" force-quote="true" column-name="XmlExplicitStringValue"/>
|
||||
</cass:entity>
|
||||
<cass:entity
|
||||
class="org.springframework.data.cassandra.test.integration.forcequote.config.ImplicitProperties">
|
||||
<cass:property name="primaryKey" force-quote="true" />
|
||||
<cass:property name="stringValue" force-quote="true" />
|
||||
</cass:entity>
|
||||
<cass:entity
|
||||
class="org.springframework.data.cassandra.test.integration.forcequote.config.ExplicitProperties">
|
||||
<!-- these values must match those in
|
||||
org.springframework.data.cassandra.test.integration.forcequote.config.ForceQuotedRepositoryXmlConfigIntegrationTests
|
||||
testExplicitPropertiesWithXmlValues() -->
|
||||
<cass:property name="primaryKey" force-quote="true" column-name="XmlPrimaryKey"/>
|
||||
<cass:property name="stringValue" force-quote="true" column-name="XmlStringValue"/>
|
||||
class="org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey.ExplicitKey">
|
||||
<cass:property name="keyZero" force-quote="true" column-name="XmlExplicitKeyZero"/>
|
||||
<cass:property name="keyOne" force-quote="true" column-name="XmlExplicitKeyOne"/>
|
||||
</cass:entity>
|
||||
</cass:mapping>
|
||||
|
||||
<cass:cluster port="${cassandra.native_transport_port}">
|
||||
<cass:keyspace name="ForceQuoteRepositoryXmlConfigIntegrationTests"
|
||||
<cass:keyspace name="#{randomKeyspaceName}"
|
||||
action="CREATE" durable-writes="true">
|
||||
</cass:keyspace>
|
||||
</cass:cluster>
|
||||
|
||||
<cass:session keyspace-name="ForceQuoteRepositoryXmlConfigIntegrationTests"
|
||||
schema-action="RECREATE">
|
||||
<cass:session keyspace-name="#{randomKeyspaceName}"
|
||||
schema-action="RECREATE_DROP_UNUSED">
|
||||
</cass:session>
|
||||
|
||||
<cass:repositories
|
||||
base-package="org.springframework.data.cassandra.test.integration.forcequote.config" />
|
||||
base-package="org.springframework.data.cassandra.test.integration.forcequote.compositeprimarykey" />
|
||||
</beans>
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<bean name="randomKeyspaceName" class="java.lang.String">
|
||||
<constructor-arg value="#{'ks' + T(java.util.UUID).randomUUID().toString().replaceAll('-', '')}"/>
|
||||
</bean>
|
||||
|
||||
<context:property-placeholder
|
||||
location="classpath:/spring-data-cassandra-build.properties" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user