Skip to content

Commit ce49bed

Browse files
refactor AppTest (#13)
Cleaning Duplicates in AppTest.java closes #7 --------- Co-authored-by: Catarina Gamboa <catarina.vg@hotmail.com>
1 parent 99613a7 commit ce49bed

3 files changed

Lines changed: 148 additions & 274 deletions

File tree

latte/pom.xml

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
<version>0.0.1-SNAPSHOT</version>
1010

1111
<name>latte</name>
12-
<!-- FIXME change it to the project's website -->
1312
<url>http://www.example.com</url>
1413

1514
<properties>
1615
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1716
<maven.compiler.source>1.8</maven.compiler.source>
1817
<maven.compiler.target>1.8</maven.compiler.target>
19-
<!-- versions -->
2018
<version.spoon>10.4.2</version.spoon>
2119
</properties>
2220

@@ -28,52 +26,55 @@
2826
<version>2.11.0</version>
2927
</dependency>
3028

31-
3229
<dependency>
3330
<groupId>org.javatuples</groupId>
3431
<artifactId>javatuples</artifactId>
3532
<version>1.2</version>
3633
</dependency>
3734

38-
3935
<dependency>
40-
<groupId>org.jboss.maven.surefire.modular</groupId>
41-
<artifactId>maven-surefire-plugin</artifactId>
42-
<version>1.0.0.Alpha3</version>
43-
<type>maven-plugin</type>
36+
<groupId>org.junit.jupiter</groupId>
37+
<artifactId>junit-jupiter-api</artifactId>
38+
<version>5.11.4</version> <!-- Version is fine -->
39+
<scope>test</scope>
4440
</dependency>
4541

46-
42+
<!-- JUnit Jupiter Params (for Parameterized tests) -->
4743
<dependency>
4844
<groupId>org.junit.jupiter</groupId>
49-
<artifactId>junit-jupiter-api</artifactId>
50-
<version>5.11.4</version>
45+
<artifactId>junit-jupiter-params</artifactId>
46+
<version>5.11.4</version> <!-- Same version for consistency -->
47+
<scope>test</scope>
5148
</dependency>
5249

50+
<!-- JUnit Jupiter Engine (for running tests) -->
51+
<dependency>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-engine</artifactId>
54+
<version>5.11.4</version> <!-- Same version for consistency -->
55+
<scope>test</scope>
56+
</dependency>
5357

5458
<dependency>
5559
<groupId>ch.qos.logback</groupId>
5660
<artifactId>logback-classic</artifactId>
5761
<version>1.5.12</version>
5862
</dependency>
5963

60-
6164
<dependency>
6265
<groupId>org.slf4j</groupId>
6366
<artifactId>slf4j-log4j12</artifactId>
6467
<version>2.1.0-alpha1</version>
6568
<type>pom</type>
6669
</dependency>
6770

68-
6971
<dependency>
7072
<groupId>ch.qos.logback</groupId>
7173
<artifactId>logback</artifactId>
7274
<version>0.5</version>
7375
<type>pom</type>
7476
</dependency>
7577

76-
7778
<dependency>
7879
<groupId>org.apache.logging.log4j</groupId>
7980
<artifactId>log4j</artifactId>
@@ -87,24 +88,23 @@
8788
<version>4.11</version>
8889
<scope>test</scope>
8990
</dependency>
90-
91-
<!-- https://mvnrepository.com/artifact/fr.inria.gforge.spoon/spoon-core -->
92-
<dependency>
93-
<groupId>fr.inria.gforge.spoon</groupId>
94-
<artifactId>spoon-core</artifactId>
95-
<version>${version.spoon}</version>
96-
</dependency>
91+
92+
<!-- Spoon Core Dependency -->
93+
<dependency>
94+
<groupId>fr.inria.gforge.spoon</groupId>
95+
<artifactId>spoon-core</artifactId>
96+
<version>${version.spoon}</version>
97+
</dependency>
98+
9799
</dependencies>
98100

99101
<build>
100-
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
102+
<pluginManagement>
101103
<plugins>
102-
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
103104
<plugin>
104105
<artifactId>maven-clean-plugin</artifactId>
105106
<version>3.1.0</version>
106107
</plugin>
107-
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
108108
<plugin>
109109
<artifactId>maven-resources-plugin</artifactId>
110110
<version>3.0.2</version>
@@ -115,7 +115,7 @@
115115
</plugin>
116116
<plugin>
117117
<artifactId>maven-surefire-plugin</artifactId>
118-
<version>2.22.1</version>
118+
<version>3.0.0-M5</version> <!-- Updated to newer version for better JUnit 5 support -->
119119
</plugin>
120120
<plugin>
121121
<artifactId>maven-jar-plugin</artifactId>
@@ -129,7 +129,6 @@
129129
<artifactId>maven-deploy-plugin</artifactId>
130130
<version>2.8.2</version>
131131
</plugin>
132-
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
133132
<plugin>
134133
<artifactId>maven-site-plugin</artifactId>
135134
<version>3.7.1</version>

latte/src/main/java/api/App.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public static void main( String[] args ){
3030
if (args.length == 0) {
3131
System.out.println("Please enter the path to the file you want to process");
3232
String allPath = "latte/src/main/java/examples/MyStackTest.java";
33-
launcher(allPath);
33+
launcher(allPath, true);
3434

3535
} else if (args.length == 1 && args[0].equals("-multi")) {
3636
// Analyze multiple files from command line
3737
Scanner scanner = new Scanner(System.in);
3838
while(scanner.hasNextLine()){
3939
String filePath = scanner.nextLine();
40-
launcher(filePath);
40+
launcher(filePath, true);
4141
}
4242
scanner.close();
4343
}
@@ -47,7 +47,7 @@ public static void main( String[] args ){
4747
*
4848
* @param filePath
4949
*/
50-
public static void launcher(String filePath) {
50+
public static void launcher(String filePath, boolean justJson) {
5151

5252
if (filePath == null) throw new InvalidParameterException("The path to the file is null");
5353

@@ -109,6 +109,9 @@ public static void launcher(String filePath) {
109109
sp.getEndLine(), sp.getEndColumn(), e.getMessage(), e.getFullMessage());
110110
String json = new Gson().toJson(error); // using Gson to convert object to JSON
111111
System.err.println(json);
112+
if (!justJson)
113+
throw e;
114+
112115

113116
} finally {
114117
// Delete the output directory
@@ -138,4 +141,4 @@ public static boolean deleteDirectory(File directory) {
138141
}
139142
return isDeleted;
140143
}
141-
}
144+
}

0 commit comments

Comments
 (0)