better logging for cassandra-unit

This commit is contained in:
Albert Shift 2015-03-16 17:55:21 -07:00
parent 75200c6187
commit dc8f58bb7b
9 changed files with 128 additions and 28 deletions

19
pom.xml
View file

@ -121,12 +121,20 @@
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<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>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
@ -187,13 +195,6 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

View file

@ -40,6 +40,10 @@ public final class Casser {
return new SessionInitializer(session);
}
public static SessionInitializer init(Session session) {
return new SessionInitializer(session);
}
public static <E> E dsl(Class<E> iface) {
return dsl(iface, iface.getClassLoader());
}

View file

@ -36,6 +36,4 @@ public class SessionInitializer {
return new CasserSession(session);
}
}

View file

@ -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);
}
}

View file

@ -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!");
}
}

View file

@ -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();
}
}

View 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);
}

View 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

View file

@ -2,4 +2,5 @@ log4j.rootLogger=WARN, 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 - %m%n
log4j.logger.casser=INFO
log4j.logger.casser=WARN
log4j.logger.org.cassandraunit=ERROR