better logging for cassandra-unit
This commit is contained in:
parent
75200c6187
commit
dc8f58bb7b
9 changed files with 128 additions and 28 deletions
19
pom.xml
19
pom.xml
|
@ -121,12 +121,20 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>ch.qos.logback</groupId>
|
||||||
|
<artifactId>logback-classic</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -187,13 +195,6 @@
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>ch.qos.logback</groupId>
|
|
||||||
<artifactId>logback-classic</artifactId>
|
|
||||||
<version>${logback}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -40,6 +40,10 @@ public final class Casser {
|
||||||
return new SessionInitializer(session);
|
return new SessionInitializer(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SessionInitializer init(Session session) {
|
||||||
|
return new SessionInitializer(session);
|
||||||
|
}
|
||||||
|
|
||||||
public static <E> E dsl(Class<E> iface) {
|
public static <E> E dsl(Class<E> iface) {
|
||||||
return dsl(iface, iface.getClassLoader());
|
return dsl(iface, iface.getClassLoader());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,4 @@ public class SessionInitializer {
|
||||||
return new CasserSession(session);
|
return new CasserSession(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package casser.test.integration.core;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import casser.core.Casser;
|
||||||
|
import casser.core.CasserSession;
|
||||||
|
import casser.test.integration.build.AbstractEmbeddedCassandraTest;
|
||||||
|
|
||||||
|
public class ContextInitTest extends AbstractEmbeddedCassandraTest {
|
||||||
|
|
||||||
|
CasserSession session = Casser.init(getSession()).get();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
|
||||||
|
System.out.println("Works! " + session);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,16 +0,0 @@
|
||||||
package casser.test.integration.core;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import casser.test.integration.build.AbstractEmbeddedCassandraTest;
|
|
||||||
|
|
||||||
public class SimpleTest extends AbstractEmbeddedCassandraTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
|
|
||||||
System.out.println("Works!");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package casser.test.integration.core.flat;
|
||||||
|
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import casser.core.Casser;
|
||||||
|
import casser.core.CasserSession;
|
||||||
|
import casser.test.integration.build.AbstractEmbeddedCassandraTest;
|
||||||
|
|
||||||
|
public class FlatObjectTest extends AbstractEmbeddedCassandraTest {
|
||||||
|
|
||||||
|
User user = Casser.dsl(User.class);
|
||||||
|
|
||||||
|
CasserSession session = Casser.init(getSession()).create(user).get();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFake() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//@Test
|
||||||
|
public void testCruid() {
|
||||||
|
|
||||||
|
User alex = Casser.pojo(User.class);
|
||||||
|
alex.setId(123L);
|
||||||
|
alex.setName("alex");
|
||||||
|
alex.setAge(34);
|
||||||
|
|
||||||
|
session.upsert(alex).sync();
|
||||||
|
|
||||||
|
Long id = session.select(user::getId).where(user::getId, "==", 123L).sync().findFirst().get().v1;
|
||||||
|
|
||||||
|
Assert.assertEquals(Long.valueOf(123L), id);
|
||||||
|
|
||||||
|
session.delete().where(user::getId, "==", 123L).sync();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
20
src/test/java/casser/test/integration/core/flat/User.java
Normal file
20
src/test/java/casser/test/integration/core/flat/User.java
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
package casser.test.integration.core.flat;
|
||||||
|
|
||||||
|
import casser.mapping.Table;
|
||||||
|
|
||||||
|
@Table("user")
|
||||||
|
public interface User {
|
||||||
|
|
||||||
|
Long getId();
|
||||||
|
|
||||||
|
void setId(Long id);
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
void setName(String name);
|
||||||
|
|
||||||
|
Integer getAge();
|
||||||
|
|
||||||
|
void setAge(Integer age);
|
||||||
|
|
||||||
|
}
|
30
src/test/resources/log4j-embedded-cassandra.properties
Normal file
30
src/test/resources/log4j-embedded-cassandra.properties
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
# or more contributor license agreements. See the NOTICE file
|
||||||
|
# distributed with this work for additional information
|
||||||
|
# regarding copyright ownership. The ASF licenses this file
|
||||||
|
# to you 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.
|
||||||
|
|
||||||
|
# for production, you should probably set the root to INFO
|
||||||
|
# and the pattern to %c instead of %l. (%l is slower.)
|
||||||
|
|
||||||
|
# output messages into a rolling log file as well as stdout
|
||||||
|
log4j.rootLogger=ERROR,stdout
|
||||||
|
|
||||||
|
# stdout
|
||||||
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c{3} - %m%n
|
||||||
|
log4j.appender.stdout.follow=true
|
||||||
|
|
||||||
|
log4j.logger.org.apache=WARN
|
||||||
|
log4j.logger.org.cassandraunit=ERROR
|
|
@ -2,4 +2,5 @@ log4j.rootLogger=WARN, stdout
|
||||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
|
||||||
log4j.logger.casser=INFO
|
log4j.logger.casser=WARN
|
||||||
|
log4j.logger.org.cassandraunit=ERROR
|
Loading…
Reference in a new issue