-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #483 from aparnamichael/testcase-issue54
#305 Improving automated tests for diagnostics and quick-fixes
- Loading branch information
Showing
42 changed files
with
1,330 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
jakarta.jdt/org.eclipse.lsp4jakarta.jdt.test/projects/demo-servlet-no-diagnostics/.project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>demo-servlet-no-diagnostics</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
117 changes: 117 additions & 0 deletions
117
jakarta.jdt/org.eclipse.lsp4jakarta.jdt.test/projects/demo-servlet-no-diagnostics/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.openliberty</groupId> | ||
<artifactId>demo-servlet-no-diagnostics</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<name>demo-servlet-no-diagnostics</name> | ||
<!-- FIXME change it to the project's website --> | ||
<url>http://www.example.com</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.7</maven.compiler.source> | ||
<maven.compiler.target>1.7</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- Provided dependencies --> | ||
<dependency> | ||
<groupId>jakarta.platform</groupId> | ||
<artifactId>jakarta.jakartaee-api</artifactId> | ||
<version>9.0.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.microprofile</groupId> | ||
<artifactId>microprofile</artifactId> | ||
<version>3.3</version> | ||
<type>pom</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- For tests --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-rs-client</artifactId> | ||
<version>3.2.6</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.cxf</groupId> | ||
<artifactId>cxf-rt-rs-extension-providers</artifactId> | ||
<version>3.2.6</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>javax.json</artifactId> | ||
<version>1.0.4</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> | ||
<artifactId>hibernate-validator</artifactId> | ||
<version>7.0.0.Final</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>jakarta.el</artifactId> | ||
<version>4.0.0</version> | ||
</dependency> | ||
<!-- Support for JDK 9 and above --> | ||
<dependency> | ||
<groupId>javax.xml.bind</groupId> | ||
<artifactId>jaxb-api</artifactId> | ||
<version>2.3.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<!-- Enable liberty-maven plugin --> | ||
<!-- tag::libertyMavenPlugin[] --> | ||
<plugin> | ||
<groupId>io.openliberty.tools</groupId> | ||
<artifactId>liberty-maven-plugin</artifactId> | ||
<version>3.3.4</version> | ||
<configuration> | ||
<runtimeArtifact> | ||
<groupId>io.openliberty.beta</groupId> | ||
<artifactId>openliberty-jakartaee9</artifactId> | ||
<version>21.0.0.2-beta</version> | ||
<type>zip</type> | ||
</runtimeArtifact> | ||
</configuration> | ||
</plugin> | ||
<!-- end::libertyMavenPlugin[] --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.2.2</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.22.2</version> | ||
</plugin> | ||
<!-- Plugin to run functional tests --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>2.22.2</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
...gnostics/src/main/java/io/openliberty/sample/jakarta/annotations/GeneratedAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.openliberty.sample.jakarta.annotations; | ||
|
||
import jakarta.fake.Generated; | ||
|
||
@Generated(value = "demoServlet", date="") | ||
public class GeneratedAnnotation { | ||
|
||
@Generated(value = "demoServlet", date="not_ISO_compliant") | ||
private Integer studentId; | ||
|
||
@Generated(value = "demoServlet", date="2001-07-04T12:08:56.235-0700") | ||
private boolean isHappy; | ||
|
||
@Generated(value = "demoServletijiojioj", date="NOTISOCOMPLIANT2") | ||
private boolean isSad; | ||
|
||
@Generated("com.sun.xml.rpc.AProcessor") | ||
private String emailAddress; | ||
|
||
@Generated(value="com.sun.xml.rpc.AProcessor") | ||
private String homeTown; | ||
|
||
public GeneratedAnnotation(Integer studentId, Boolean isHappy, boolean isSad, String graduationDate, Integer gpa, | ||
String emailAddress) { | ||
this.studentId = studentId; | ||
this.isHappy = isHappy; | ||
this.isSad = isSad; | ||
this.emailAddress = emailAddress; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...tics/src/main/java/io/openliberty/sample/jakarta/annotations/PostConstructAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.openliberty.sample.jakarta.annotations; | ||
|
||
import jakarta.fake.PostConstruct; | ||
import jakarta.fake.Resource; | ||
|
||
@Resource(type = Object.class, name = "aa") | ||
public class PostConstructAnnotation { | ||
|
||
private Integer studentId; | ||
|
||
private boolean isHappy; | ||
|
||
private boolean isSad; | ||
|
||
@PostConstruct() | ||
public Integer getStudentId() { | ||
return this.studentId; | ||
} | ||
|
||
@PostConstruct | ||
public void getHappiness(String type) { | ||
|
||
} | ||
|
||
@PostConstruct | ||
public void throwTantrum() throws Exception { | ||
System.out.println("I'm sad"); | ||
} | ||
|
||
private String emailAddress; | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...nostics/src/main/java/io/openliberty/sample/jakarta/annotations/PreDestroyAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.openliberty.sample.jakarta.annotations; | ||
|
||
import jakarta.fake.PreDestroy; | ||
import jakarta.fake.Resource; | ||
|
||
@Resource(type = Object.class, name = "aa") | ||
public class PreDestroyAnnotation { | ||
|
||
private Integer studentId; | ||
|
||
private boolean isHappy; | ||
|
||
private boolean isSad; | ||
|
||
@PreDestroy() | ||
public Integer getStudentId() { | ||
return this.studentId; | ||
} | ||
|
||
@PreDestroy() | ||
public boolean getHappiness(String type) { | ||
if (type.equals("happy")) return this.isHappy; | ||
return this.isSad; | ||
} | ||
|
||
@PreDestroy() | ||
public static void makeUnhappy() { | ||
System.out.println("I'm sad"); | ||
} | ||
|
||
@PreDestroy() | ||
public void throwTantrum() throws Exception { | ||
System.out.println("I'm sad"); | ||
} | ||
|
||
|
||
private String emailAddress; | ||
|
||
|
||
} | ||
|
||
|
||
|
45 changes: 45 additions & 0 deletions
45
...agnostics/src/main/java/io/openliberty/sample/jakarta/annotations/ResourceAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.openliberty.sample.jakarta.annotations; | ||
|
||
import jakarta.fake.Resource; | ||
|
||
@Resource(type = Object.class, name = "aa") | ||
public class ResourceAnnotation { | ||
|
||
private Integer studentId; | ||
|
||
|
||
@Resource(shareable = true) | ||
private boolean isHappy; | ||
|
||
@Resource(name = "test") | ||
private boolean isSad; | ||
|
||
|
||
private String emailAddress; | ||
|
||
|
||
} | ||
|
||
@Resource(name = "aa") | ||
class PostDoctoralStudent { | ||
|
||
private Integer studentId; | ||
|
||
|
||
@Resource(shareable = true) | ||
private boolean isHappy; | ||
|
||
@Resource | ||
private boolean isSad; | ||
|
||
|
||
private String emailAddress; | ||
|
||
} | ||
|
||
@Resource(type = Object.class) | ||
class MasterStudent { | ||
|
||
private Integer studentId; | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...src/main/java/io/openliberty/sample/jakarta/beanvalidation/FieldConstraintValidation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.openliberty.sample.jakarta.beanvalidation; | ||
|
||
import java.util.Calendar; | ||
import java.util.List; | ||
|
||
import jakarta.fake.constraints.*; | ||
|
||
public class FieldConstraintValidation { | ||
|
||
@AssertTrue | ||
private int isHappy; // invalid types | ||
|
||
@AssertFalse | ||
private Double isSad; | ||
|
||
@DecimalMax("30.0") | ||
@DecimalMin("10.0") | ||
private String bigDecimal; | ||
|
||
@Digits(fraction = 0, integer = 0) | ||
private boolean digits; | ||
|
||
private Integer emailAddress; | ||
|
||
@FutureOrPresent | ||
private boolean graduationDate; | ||
|
||
@Future | ||
private double fergiesYear; | ||
|
||
@Min(value = 50) | ||
@Max(value = 100) | ||
private boolean gpa; | ||
|
||
@Negative | ||
private boolean subZero; | ||
|
||
@NegativeOrZero | ||
private String notPos; | ||
|
||
@NotBlank | ||
private boolean saysomething; | ||
|
||
@Pattern(regexp = "") | ||
private Calendar thisIsUsed; | ||
|
||
@Past | ||
private double theGoodOldDays; | ||
|
||
@PastOrPresent | ||
private char[] aGoodFieldName; | ||
|
||
@Positive | ||
private String[] area; | ||
|
||
@PositiveOrZero | ||
private List<String> maybeZero; | ||
|
||
@AssertTrue | ||
private static boolean typeValid; // static | ||
|
||
@Past | ||
private static boolean doubleBad; // static and invalid type | ||
} |
Oops, something went wrong.