Skip to content

Commit

Permalink
Code reformatting + clarified broken toString() message
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonzak committed Apr 19, 2018
1 parent cfe2fe5 commit 56c7be3
Show file tree
Hide file tree
Showing 25 changed files with 3,535 additions and 3,462 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>net.lonzak.common</groupId>
<artifactId>unittest-utilities</artifactId>
<name>Automating junit tests</name>
<version>2.0.7</version>
<version>2.0.8</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
5,010 changes: 2,527 additions & 2,483 deletions src/main/java/net/lonzak/common/unittest/AutoTester.java

Large diffs are not rendered by default.

31 changes: 12 additions & 19 deletions src/main/java/net/lonzak/common/unittest/InternalException.java
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
/*
* ===========================================
* unittest-utilities
* ===========================================
* =========================================== unittest-utilities ===========================================
*
* Project Info: https://github.com/Lonzak/unittest-utilities
* Project Info: https://github.com/Lonzak/unittest-utilities
*
* (C) Copyright 2012-2017 nepatec GmbH & Co. KG
*
* This file is part of unittest-utilities
* This file is part of unittest-utilities
*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details. You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package net.lonzak.common.unittest;


public class InternalException extends RuntimeException{
public class InternalException extends RuntimeException {

private static final long serialVersionUID = 9218252003006131300L;

public InternalException(String message) {
super(message);
}

public InternalException(String message, Throwable cause) {
super(message, cause);
}

public InternalException(Throwable cause) {
super(cause);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
/*
* ===========================================
* unittest-utilities
* ===========================================
* =========================================== unittest-utilities ===========================================
*
* Project Info: https://github.com/Lonzak/unittest-utilities
* Project Info: https://github.com/Lonzak/unittest-utilities
*
* (C) Copyright 2012-2017 nepatec GmbH & Co. KG
*
* This file is part of unittest-utilities
* This file is part of unittest-utilities
*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details. You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package net.lonzak.common.unittest;


public class PotentialErrorDetected extends RuntimeException{
public class PotentialErrorDetected extends RuntimeException {

private static final long serialVersionUID = 9218252003006131300L;

public PotentialErrorDetected(String message) {
super(message);
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/lonzak/common/unittest/Repeat.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention( RetentionPolicy.RUNTIME )
@Target({ METHOD, ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Target({METHOD, ANNOTATION_TYPE})
public @interface Repeat {
int value() default 1;
}
int value() default 1;
}
74 changes: 34 additions & 40 deletions src/main/java/net/lonzak/common/unittest/RepeatRule.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
/*
* ===========================================
* unittest-utilities
* ===========================================
* =========================================== unittest-utilities ===========================================
*
* Project Info: https://github.com/Lonzak/unittest-utilities
* Project Info: https://github.com/Lonzak/unittest-utilities
*
* (C) Copyright 2012-2017 nepatec GmbH & Co. KG
*
* This file is part of unittest-utilities
* This file is part of unittest-utilities
*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details. You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package net.lonzak.common.unittest;
Expand All @@ -29,63 +22,64 @@
import org.junit.runners.model.Statement;

/**
* This can be used to run junit test serveral times.
* Usage:
* This can be used to run junit test serveral times. Usage:
*
* <pre>
* {@code}
* {@code
* &#064;Rule
* public RepeatRule repeatRule = new RepeatRule();
* ...
* &#064;Repeat(100)
* public void testMethodTest(){...}
*
* }
* </pre>
* <p>
*
* @author 225010
*
*/
public class RepeatRule implements TestRule {

private static class RepeatStatement extends Statement {
private final Statement statement;
private final int repeat;
private final Statement statement;
private final int repeat;

public RepeatStatement(Statement statement, int repeat) {
this.statement = statement;
this.repeat = repeat;
}
public RepeatStatement(Statement statement, int repeat) {
this.statement = statement;
this.repeat = repeat;
}

@Override
public void evaluate() throws Throwable {
for (int i = 0; i < this.repeat; i++) {
this.statement.evaluate();
}
@Override
public void evaluate() throws Throwable {
for (int i = 0; i < this.repeat; i++) {
this.statement.evaluate();
}
}

}

/**
* Here's an example usage:
*
* <pre>
* {@code}
* {@code
* &#064;IFaceAnnotation(value="")
* public interface IFace {
*
* &#064;MethodAnnotation("")
* public String Method();
* }
* }
* </pre>
*/
@Override
public Statement apply(Statement statement, Description description) {
Statement result = statement;
Repeat repeat = description.getAnnotation(Repeat.class);
if (repeat != null) {
int times = repeat.value();
result = new RepeatStatement(statement, times);
}
return result;
Statement result = statement;
Repeat repeat = description.getAnnotation(Repeat.class);
if (repeat != null) {
int times = repeat.value();
result = new RepeatStatement(statement, times);
}
return result;
}
}
}
Loading

0 comments on commit 56c7be3

Please sign in to comment.