aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-25 13:48:36 +0100
committerSven Gothel <[email protected]>2015-03-25 13:48:36 +0100
commit1608c8a7e616994ffb50339dbb2c5121c8060b53 (patch)
tree42c631b45f3d452ff845ca3b46c5b0e1033b84f4 /src
parent4f1561336f4867e97cd8a6ad05b883e2058556a3 (diff)
Unit Tests: Extend SingletonJunitCase and use deterministic test order
Diffstat (limited to 'src')
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/CppReaderTest.java6
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/ErrorTest.java17
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java6
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java15
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/JoinReaderTest.java19
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/LexerSourceTest.java6
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/NumericValueTest.java25
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/PreprocessorTest.java6
-rw-r--r--src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java6
9 files changed, 77 insertions, 29 deletions
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/CppReaderTest.java b/src/test/java/com/jogamp/gluegen/jcpp/CppReaderTest.java
index e4ef1c5..870663d 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/CppReaderTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/CppReaderTest.java
@@ -7,13 +7,17 @@ import java.util.Collections;
import javax.annotation.Nonnull;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
import com.jogamp.gluegen.test.junit.generation.BuildEnvironment;
+import com.jogamp.junit.util.SingletonJunitCase;
import static org.junit.Assert.assertEquals;
-public class CppReaderTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class CppReaderTest extends SingletonJunitCase {
public static String testCppReader(@Nonnull final String in, final Feature... f) throws Exception {
final String inclpath = BuildEnvironment.gluegenRoot + "/jcpp/src/test/resources" ;
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/ErrorTest.java b/src/test/java/com/jogamp/gluegen/jcpp/ErrorTest.java
index 12a5160..ad6a1b4 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/ErrorTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/ErrorTest.java
@@ -1,17 +1,24 @@
package com.jogamp.gluegen.jcpp;
import java.io.IOException;
+
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.junit.util.SingletonJunitCase;
+
import static com.jogamp.gluegen.jcpp.Token.*;
import static org.junit.Assert.*;
-public class ErrorTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class ErrorTest extends SingletonJunitCase {
- private boolean testError(Preprocessor p)
+ private boolean testError(final Preprocessor p)
throws LexerException,
IOException {
for (;;) {
- Token tok = p.token();
+ final Token tok = p.token();
if (tok.getType() == EOF)
break;
if (tok.getType() == INVALID)
@@ -20,7 +27,7 @@ public class ErrorTest {
return false;
}
- private void testError(String input) throws Exception {
+ private void testError(final String input) throws Exception {
StringLexerSource sl;
DefaultPreprocessorListener pl;
Preprocessor p;
@@ -33,7 +40,7 @@ public class ErrorTest {
try {
assertTrue(testError(p));
fail("Lexing unexpectedly succeeded without listener.");
- } catch (LexerException e) {
+ } catch (final LexerException e) {
/* required */
}
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java b/src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java
index b44b900..e9d7b27 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/IncludeAbsoluteTest.java
@@ -4,12 +4,15 @@ import java.io.File;
import java.io.IOException;
import java.io.Reader;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
import com.jogamp.common.util.IOUtil;
import com.jogamp.gluegen.Logging;
import com.jogamp.gluegen.Logging.LoggerIf;
import com.jogamp.gluegen.test.junit.generation.BuildEnvironment;
+import com.jogamp.junit.util.SingletonJunitCase;
import static org.junit.Assert.*;
@@ -17,7 +20,8 @@ import static org.junit.Assert.*;
*
* @author shevek
*/
-public class IncludeAbsoluteTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class IncludeAbsoluteTest extends SingletonJunitCase {
private static final LoggerIf LOG = Logging.getLogger(IncludeAbsoluteTest.class);
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java b/src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java
index d867fb8..3477d97 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/JavaFileSystemTest.java
@@ -1,15 +1,22 @@
package com.jogamp.gluegen.jcpp;
import java.io.FileNotFoundException;
+
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.junit.util.SingletonJunitCase;
+
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-public class JavaFileSystemTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class JavaFileSystemTest extends SingletonJunitCase {
@Test
public void testJavaFileSystem() throws Exception {
- JavaFileSystem fs = new JavaFileSystem();
+ final JavaFileSystem fs = new JavaFileSystem();
VirtualFile f;
/* Anyone who has this file on their Unix box is messed up. */
@@ -18,7 +25,7 @@ public class JavaFileSystemTest {
f.getSource(); /* drop on floor */
assertTrue("Got a source for a non-file", f.isFile());
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
assertFalse("Got no source for a file", f.isFile());
}
@@ -29,7 +36,7 @@ public class JavaFileSystemTest {
System.out.println("Opened stdio.h");
assertTrue("Got a source for a non-file", f.isFile());
- } catch (FileNotFoundException e) {
+ } catch (final FileNotFoundException e) {
System.out.println("Failed to open stdio.h");
assertFalse("Got no source for a file", f.isFile());
}
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/JoinReaderTest.java b/src/test/java/com/jogamp/gluegen/jcpp/JoinReaderTest.java
index 628a7ec..4193f3f 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/JoinReaderTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/JoinReaderTest.java
@@ -1,19 +1,26 @@
package com.jogamp.gluegen.jcpp;
import java.io.StringReader;
+
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.junit.util.SingletonJunitCase;
+
import static org.junit.Assert.assertEquals;
-public class JoinReaderTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class JoinReaderTest extends SingletonJunitCase {
- private void testJoinReader(String in, String out, boolean tg)
+ private void testJoinReader(final String in, final String out, final boolean tg)
throws Exception {
System.out.println("Testing " + in + " => " + out);
- StringReader r = new StringReader(in);
- JoinReader j = new JoinReader(r, tg);
+ final StringReader r = new StringReader(in);
+ final JoinReader j = new JoinReader(r, tg);
for (int i = 0; i < out.length(); i++) {
- int c = j.read();
+ final int c = j.read();
System.out.println("At offset " + i + ": " + (char) c);
assertEquals(out.charAt(i), c);
}
@@ -21,7 +28,7 @@ public class JoinReaderTest {
assertEquals(-1, j.read());
}
- private void testJoinReader(String in, String out)
+ private void testJoinReader(final String in, final String out)
throws Exception {
testJoinReader(in, out, true);
testJoinReader(in, out, false);
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/LexerSourceTest.java b/src/test/java/com/jogamp/gluegen/jcpp/LexerSourceTest.java
index 43ccbe6..99324ff 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/LexerSourceTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/LexerSourceTest.java
@@ -2,16 +2,20 @@ package com.jogamp.gluegen.jcpp;
import java.util.Arrays;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
import com.jogamp.gluegen.Logging;
import com.jogamp.gluegen.Logging.LoggerIf;
+import com.jogamp.junit.util.SingletonJunitCase;
import static com.jogamp.gluegen.jcpp.PreprocessorTest.assertType;
import static com.jogamp.gluegen.jcpp.Token.*;
import static org.junit.Assert.*;
-public class LexerSourceTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class LexerSourceTest extends SingletonJunitCase {
private static final LoggerIf LOG = Logging.getLogger(LexerSourceTest.class);
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/NumericValueTest.java b/src/test/java/com/jogamp/gluegen/jcpp/NumericValueTest.java
index 2d612ce..84a0ff1 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/NumericValueTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/NumericValueTest.java
@@ -1,7 +1,13 @@
package com.jogamp.gluegen.jcpp;
import java.io.IOException;
+
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+import com.jogamp.junit.util.SingletonJunitCase;
+
import static com.jogamp.gluegen.jcpp.Token.*;
import static org.junit.Assert.*;
@@ -9,26 +15,27 @@ import static org.junit.Assert.*;
*
* @author shevek
*/
-public class NumericValueTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class NumericValueTest extends SingletonJunitCase {
- private Token testNumericValue(String in) throws IOException, LexerException {
- StringLexerSource s = new StringLexerSource(in);
+ private Token testNumericValue(final String in) throws IOException, LexerException {
+ final StringLexerSource s = new StringLexerSource(in);
- Token tok = s.token();
+ final Token tok = s.token();
System.out.println("Token is " + tok);
assertEquals(NUMBER, tok.getType());
- Token eof = s.token();
+ final Token eof = s.token();
assertEquals("Didn't get EOF, but " + tok, EOF, eof.getType());
return tok;
}
- private void testNumericValue(String in, double out) throws IOException, LexerException {
+ private void testNumericValue(final String in, final double out) throws IOException, LexerException {
System.out.println("Testing '" + in + "' -> " + out);
- Token tok = testNumericValue(in);
+ final Token tok = testNumericValue(in);
assertEquals(in, tok.getText());
- NumericValue value = (NumericValue) tok.getValue();
+ final NumericValue value = (NumericValue) tok.getValue();
assertEquals("Double mismatch", out, value.doubleValue(), 0.01d);
assertEquals("Float mismatch", (float) out, value.floatValue(), 0.01f);
assertEquals("Long mismatch", (long) out, value.longValue());
@@ -88,7 +95,7 @@ public class NumericValueTest {
try {
testNumericValue("097", 97);
fail("No warning.");
- } catch (LexerException e) {
+ } catch (final LexerException e) {
}
}
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/PreprocessorTest.java b/src/test/java/com/jogamp/gluegen/jcpp/PreprocessorTest.java
index 651af98..c4a4b06 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/PreprocessorTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/PreprocessorTest.java
@@ -10,15 +10,19 @@ import java.util.logging.Level;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
import com.jogamp.gluegen.Logging;
import com.jogamp.gluegen.Logging.LoggerIf;
+import com.jogamp.junit.util.SingletonJunitCase;
import static com.jogamp.gluegen.jcpp.Token.*;
import static org.junit.Assert.*;
-public class PreprocessorTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class PreprocessorTest extends SingletonJunitCase {
private static final LoggerIf LOG = Logging.getLogger(PreprocessorTest.class);
diff --git a/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java b/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java
index 756425b..ff556ad 100644
--- a/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java
+++ b/src/test/java/com/jogamp/gluegen/jcpp/TokenPastingWhitespaceTest.java
@@ -5,10 +5,13 @@ import com.jogamp.common.util.IOUtil;
import java.io.IOException;
import java.io.Reader;
+import org.junit.FixMethodOrder;
import org.junit.Test;
+import org.junit.runners.MethodSorters;
import com.jogamp.gluegen.Logging;
import com.jogamp.gluegen.Logging.LoggerIf;
+import com.jogamp.junit.util.SingletonJunitCase;
import static org.junit.Assert.*;
@@ -17,7 +20,8 @@ import static org.junit.Assert.*;
*
* @author shevek
*/
-public class TokenPastingWhitespaceTest {
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TokenPastingWhitespaceTest extends SingletonJunitCase {
private static final LoggerIf LOG = Logging.getLogger(TokenPastingWhitespaceTest.class);