Skip to content

Commit

Permalink
Fix NPE in PlainTextTableWriter (fixes #314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Schäfer committed May 7, 2017
1 parent 9c475ca commit d2fe787
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.15.1

## Fixed Issues

* Fixed a `NullPointerException` when using `@Table(includeNullColumns = true)` and columns with null values [#315](https://github.com/TNG/JGiven/issues/315)

# v0.15.0

## New Features
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=0.15.0
version=0.15.1
org.gradle.jvmargs=-Xmx1536M
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static private Collection<List<String>> splitRow( List<String> row ) {

static private boolean hasNewline( List<String> row ) {
for( String cell : row ) {
if( cell.contains( "\n" ) ) {
if( cell != null && cell.contains( "\n" ) ) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,13 @@ public void handleArbitraryStringsWithoutNewlines( Pair<String, String> randomPa
assertThat( s ).isEqualTo( "| " + expected1 + " | " + expected2 + " |" + System.getProperty("line.separator") );

}

@Test
public void handleNullValues() throws Exception {
String[][] testData = new String[][] {
{ null } };
List<List<String>> result = PlainTextTableWriter.handleNewLines( toListOfList( testData ) );
assertThat( result ).isEqualTo( toListOfList( testData ) );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Calendar;
import java.util.List;

import junitparams.internal.InvokeParameterisedMethod;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -74,8 +74,11 @@ private static Object dataProviderFrameworkMethod( Method method, Object... args
return new DataProviderFrameworkMethod( method, 1, args, "%s" );
}

private static Object junitParamsStatement( Method method, String args ) {
return new InvokeParameterisedMethod( new FrameworkMethod( method ), ScenarioTestRuleTest.class, args, 1 );
private static Object junitParamsStatement( Method method, String args ) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass("junitparams.internal.InvokeParameterisedMethod");
Constructor<?> constructor = clazz.getDeclaredConstructors()[0];
constructor.setAccessible(true);
return constructor.newInstance(new FrameworkMethod(method), ScenarioTestRuleTest.class, args, 1 );
}

private static Method twoParamsMethod() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.tngtech.jgiven.tags;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import com.tngtech.jgiven.annotation.IsTag;

@FeatureCore
@IsTag( name = "@Table Annotation",
description = "Using the @Table annotation to format arguments as tables" )
@Retention( RetentionPolicy.RUNTIME )
public @interface FeatureTableAnnotation {

}

0 comments on commit d2fe787

Please sign in to comment.