Android Open Source - slf4android Message Value Supplier Tests From Project Back to project page slf4android .
License The source code is released under:
MIT License
If you think the Android project slf4android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package pl.brightinventions.slf4android.roboelectric;
/ / f r o m w w w . j a v a 2 s . c o m
import org.junit.Test;
import java.util.logging.Level;
import pl.brightinventions.slf4android.LogRecord;
import pl.brightinventions.slf4android.MessageValueSupplier;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
public class MessageValueSupplierTests extends RoboelectricTest {
@Test
public void canProvideValueOfSimpleString() throws Exception {
String message = value("simple message" );
assertThat(message, is(equalTo("simple message" )));
}
String value(String message, Object... args) {
MessageValueSupplier messageValueSupplier = new MessageValueSupplier();
StringBuilder builder = new StringBuilder();
LogRecord record = new LogRecord(Level.FINE, message);
record.setParameters(args);
messageValueSupplier.append(record, builder);
return builder.toString();
}
@Test
public void canProvideValueOfSimpleMessageWithOneArgument() throws Exception {
assertThat(value("message {}" , "arg" ), is(equalTo("message arg" )));
}
@Test
public void canProvideValueOfSimpleMessageWithTwoArguments() throws Exception {
assertThat(value("message {} {}" , "arg1" , "arg2" ), is(equalTo("message arg1 arg2" )));
}
@Test
public void canProvideValueOfSimpleMessageWithManyArguments() throws Exception {
assertThat(value("message {} and {} and {}" , "arg1" , "arg2" , "arg3" ), is(equalTo("message arg1 and arg2 and arg3" )));
}
@Test
public void canAppendExceptionInformationAtTheEndOfMessage() throws Exception {
assertThat(value("message" , new NullPointerException()), containsString("message" ));
assertThat(value("message" , new NullPointerException()), containsString("NullPointerException" ));
}
@Test
public void canProvideFormattedValueWithExceptionInformationAtTheEndOfMessage() throws Exception {
assertThat(value("message {}" , "arg" , new NullPointerException()), containsString("message arg" ));
assertThat(value("message {}" , new NullPointerException()), containsString("NullPointerException" ));
}
}
Java Source Code List com.squareup.seismic.ShakeDetector.java org.slf4j.impl.StaticLoggerBinder.java pl.brightinventions.slf4android.ActivityStateListener.java pl.brightinventions.slf4android.AndroidLoggerAdapter.java pl.brightinventions.slf4android.AndroidLoggerFactory.java pl.brightinventions.slf4android.AtLeastFilter.java pl.brightinventions.slf4android.ConstLoggerValueSupplier.java pl.brightinventions.slf4android.DateValueSupplier.java pl.brightinventions.slf4android.Disposable.java pl.brightinventions.slf4android.EmailErrorReport.java pl.brightinventions.slf4android.FileHandlerExpose.java pl.brightinventions.slf4android.FileLogHandlerConfiguration.java pl.brightinventions.slf4android.FileLogHandler.java pl.brightinventions.slf4android.HandlerFormatterCompiler.java pl.brightinventions.slf4android.LevelValueSupplier.java pl.brightinventions.slf4android.ListLogRecordFormatter.java pl.brightinventions.slf4android.Lists.java pl.brightinventions.slf4android.LogLevel.java pl.brightinventions.slf4android.LogRecordFormatterUtilFormatterAdapter.java pl.brightinventions.slf4android.LogRecordFormatter.java pl.brightinventions.slf4android.LogRecord.java pl.brightinventions.slf4android.LogcatHandler.java pl.brightinventions.slf4android.LoggerConfiguration.java pl.brightinventions.slf4android.LoggerNameValueSupplier.java pl.brightinventions.slf4android.LoggerPatternConfiguration.java pl.brightinventions.slf4android.LoggerPatternValueSupplier.java pl.brightinventions.slf4android.LoggerPattern.java pl.brightinventions.slf4android.MakeScreenShotAsyncTask.java pl.brightinventions.slf4android.MessageValueSupplier.java pl.brightinventions.slf4android.NotifyDeveloperDialogDisplayActivity.java pl.brightinventions.slf4android.NotifyDeveloperHandler.java pl.brightinventions.slf4android.ReadLogcatEntriesAsyncTask.java pl.brightinventions.slf4android.ThreadValueSupplier.java pl.brightinventions.slf4android.androidTest.FileHandlerTests.java pl.brightinventions.slf4android.androidTest.LoggerAdapterTests.java pl.brightinventions.slf4android.androidTest.NotifyDeveloperHandlerTests.java pl.brightinventions.slf4android.androidTest.TestActivity.java pl.brightinventions.slf4android.roboelectric.HandlerFormatterCompilerTests.java pl.brightinventions.slf4android.roboelectric.MessageValueSupplierTests.java pl.brightinventions.slf4android.roboelectric.RoboelectricTest.java pl.brightinventions.slf4android.roboelectric.RobolectricTestRunner.java