Skip to content

Commit

Permalink
KAA-1: Improve cassandra dao unit tests. Fix kaa node tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikulikov committed Jan 27, 2016
1 parent 1da2f36 commit a5c6f36
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 237 deletions.
Expand Up @@ -71,7 +71,7 @@ public CTLSchemaMetaInfo incrementCount(CTLSchemaMetaInfo metaInfo) {
} }


@Override @Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS) @Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW)
public CTLSchemaMetaInfo findByFqnAndVersion(String fqn, Integer version) { public CTLSchemaMetaInfo findByFqnAndVersion(String fqn, Integer version) {
LOG.debug("Searching ctl metadata by fqn [{}] and version [{}]", fqn, version); LOG.debug("Searching ctl metadata by fqn [{}] and version [{}]", fqn, version);
CTLSchemaMetaInfo ctlSchema = findOneByCriterion(Restrictions.and( CTLSchemaMetaInfo ctlSchema = findOneByCriterion(Restrictions.and(
Expand Down
14 changes: 14 additions & 0 deletions server/common/nosql/cassandra-dao/pom.xml
Expand Up @@ -75,6 +75,11 @@
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.takari.junit</groupId>
<artifactId>takari-cpsuite</artifactId>
<version>1.2.7</version>
</dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
Expand Down Expand Up @@ -126,6 +131,15 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*TestSuite.java</include>
</includes>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>
@@ -0,0 +1,34 @@
/*
* Copyright 2014-2016 CyberVision, 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 org.kaaproject.kaa.server.common;

import org.cassandraunit.CassandraCQLUnit;
import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.ClassRule;
import org.junit.extensions.cpsuite.ClasspathSuite;
import org.junit.extensions.cpsuite.ClasspathSuite.ClassnameFilters;
import org.junit.runner.RunWith;

@RunWith(ClasspathSuite.class)
@ClassnameFilters({"org.kaaproject.kaa.server.common.dao.service.Cassandra.*Test",
"org.kaaproject.kaa.server.common.nosql.cassandra.dao.*Test"})
public class CassandraTestSuite {

@ClassRule
public static CassandraCQLUnit cassandraUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

}

This file was deleted.

Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,13 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraApplicationServiceImplTest extends ApplicationServiceImplTest { public class CassandraApplicationServiceImplTest extends ApplicationServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()) {
}
}
} }
Expand Up @@ -16,11 +16,7 @@


package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -30,12 +26,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraCTLSchemaServiceImplTest extends CTLServiceImplTest { public class CassandraCTLSchemaServiceImplTest extends CTLServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}
} }
Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,13 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraConfigurationServiceImplTest extends ConfigurationServiceImplTest { public class CassandraConfigurationServiceImplTest extends ConfigurationServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}

} }
Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,13 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraEndpointServiceImplTest extends EndpointServiceImplTest { public class CassandraEndpointServiceImplTest extends EndpointServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}

} }
Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,13 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraHistoryServiceImplTest extends HistoryServiceImplTest { public class CassandraHistoryServiceImplTest extends HistoryServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}

} }
Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,13 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraLogAppenderServiceImplTest extends LogAppenderServiceImplTest { public class CassandraLogAppenderServiceImplTest extends LogAppenderServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}

} }
Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,12 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraLogSchemaServiceImplTest extends LogSchemaServiceImplTest { public class CassandraLogSchemaServiceImplTest extends LogSchemaServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}
} }
Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,13 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraProfileServiceImplTest extends ProfileServiceImplTest { public class CassandraProfileServiceImplTest extends ProfileServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}

} }
Expand Up @@ -16,27 +16,15 @@


package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit; import org.kaaproject.kaa.server.common.dao.service.ServerProfileServiceImplTest;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;


@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "/cassandra-dao-test-context.xml") @ContextConfiguration(locations = "/cassandra-dao-test-context.xml")
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraServerProfileServiceImpl extends ServerProfileServiceImplTest { public class CassandraServerProfileServiceImplTest extends ServerProfileServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()) {
}
}
} }
Expand Up @@ -15,11 +15,7 @@
*/ */
package org.kaaproject.kaa.server.common.dao.service; package org.kaaproject.kaa.server.common.dao.service;


import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
import org.junit.AfterClass;
import org.junit.ClassRule;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.kaaproject.kaa.server.common.CustomCassandraCQLUnit;
import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
Expand All @@ -29,12 +25,4 @@
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
public class CassandraTopicServiceImplTest extends TopicServiceImplTest { public class CassandraTopicServiceImplTest extends TopicServiceImplTest {


@ClassRule
public static CustomCassandraCQLUnit cassandraUnit = new CustomCassandraCQLUnit(new ClassPathCQLDataSet("cassandra.cql", false, false));

@AfterClass
public static void after() throws Exception {
cassandraUnit.cluster.close();
while (!cassandraUnit.cluster.isClosed()){}
}
} }

0 comments on commit a5c6f36

Please sign in to comment.