Skip to content

Commit

Permalink
Merge pull request #3562 from jamezp/format-6.2
Browse files Browse the repository at this point in the history
[6.2] [RESTEASY-3264] Add automatic formatting of source code
  • Loading branch information
jamezp committed Apr 18, 2023
2 parents 5de40e9 + e2a3176 commit 130f4f5
Show file tree
Hide file tree
Showing 3,734 changed files with 229,657 additions and 239,434 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
28 changes: 28 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@ on:
branches-ignore:
- 'dependabot/**'
paths-ignore:
- '.gitignore'
- ".github/workflows/manual-*.yml"
- "docbook"
- "distribution"
- "CONTRIBUTING.md"
- "License.html"
- "README.md"
pull_request:
branches:
- '**'
paths-ignore:
- '.gitignore'
- "docbook"
- "distribution"
- "CONTRIBUTING.md"
- "License.html"
- "README.md"

# Only run the latest job
concurrency:
Expand Down Expand Up @@ -104,3 +117,18 @@ jobs:
- name: Build Java Docs with Java 11
run: mvn clean site install -B -DskipTests

format-check:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
cache: 'maven'
- name: Validate Formatting
run: |
mvn -B validate -Pformat-check -Denforcer.skip=true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target
.cache

# Intellij
###################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
* @version $Revision: 1.1 $
*
* Copyright June 7, 2014
* Copyright June 7, 2014
*/
@Provider
public class TestApplication extends Application
{
public Set<Class<?>> getClasses()
{
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(TestResource.class);
return classes;
}
public class TestApplication extends Application {
public Set<Class<?>> getClasses() {
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(TestResource.class);
return classes;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.jboss.resteasy.resteasy1056;

import org.jboss.logging.Logger;

import jakarta.validation.constraints.Min;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
Expand All @@ -10,26 +8,26 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.jboss.logging.Logger;

/**
*
*
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
* @version $Revision: 1.1 $
*
* Copyright June 7, 2014
* Copyright June 7, 2014
*/
@Path("/")
public class TestResource
{
public class TestResource {

private static final Logger LOG = Logger.getLogger(TestResource.class);
private static final Logger LOG = Logger.getLogger(TestResource.class);

@GET
@Path("test/{param}")
@Produces(MediaType.TEXT_PLAIN)
public Response test(@Min(7) @PathParam("param") int param)
{
LOG.info("param: " + param);
return Response.ok().entity(param).build();
}
@GET
@Path("test/{param}")
@Produces(MediaType.TEXT_PLAIN)
public Response test(@Min(7) @PathParam("param") int param) {
LOG.info("param: " + param);
return Response.ok().entity(param).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.Assert.assertEquals;

import java.net.URI;

import jakarta.ws.rs.core.Response;

import org.jboss.arquillian.container.test.api.Deployment;
Expand Down Expand Up @@ -33,41 +34,42 @@
@RunWith(Arquillian.class)
@RunAsClient
public class MissingCDITest {
@Deployment
public static Archive<?> createTestArchive() {
WebArchive war = ShrinkWrap.create(WebArchive.class, "RESTEASY-1056.war")
.addClasses(TestApplication.class, TestResource.class)
.addAsWebInfResource("web.xml");
return war;
}
@Deployment
public static Archive<?> createTestArchive() {
WebArchive war = ShrinkWrap.create(WebArchive.class, "RESTEASY-1056.war")
.addClasses(TestApplication.class, TestResource.class)
.addAsWebInfResource("web.xml");
return war;
}

@ArquillianResource
URI baseUri;
@ArquillianResource
URI baseUri;

@Test
public void testMissingCDIValid() throws Exception {
Response response = ResteasyClientBuilder.newClient().target(baseUri.toString() + "test/17").request().get();
String entity = response.readEntity(String.class);
assertEquals(200, response.getStatus());
Assert.assertEquals("17", entity);
}
@Test
public void testMissingCDIValid() throws Exception {
Response response = ResteasyClientBuilder.newClient().target(baseUri.toString() + "test/17").request().get();
String entity = response.readEntity(String.class);
assertEquals(200, response.getStatus());
Assert.assertEquals("17", entity);
}

@Test
public void testMissingCDIInvalid() throws Exception {
Response response = ResteasyClientBuilder.newClient().target(baseUri.toString() + "test/0").request().get();
String entity = response.readEntity(String.class);
assertEquals(400, response.getStatus());
ResteasyViolationException e = new ResteasyViolationExceptionImpl(entity);
countViolations(e, 1, 0, 0, 1, 0);
ResteasyConstraintViolation cv = e.getParameterViolations().iterator().next();
Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 7"));
}
@Test
public void testMissingCDIInvalid() throws Exception {
Response response = ResteasyClientBuilder.newClient().target(baseUri.toString() + "test/0").request().get();
String entity = response.readEntity(String.class);
assertEquals(400, response.getStatus());
ResteasyViolationException e = new ResteasyViolationExceptionImpl(entity);
countViolations(e, 1, 0, 0, 1, 0);
ResteasyConstraintViolation cv = e.getParameterViolations().iterator().next();
Assert.assertTrue(cv.getMessage().equals("must be greater than or equal to 7"));
}

protected void countViolations(ResteasyViolationException e, int totalCount, int propertyCount, int classCount, int parameterCount, int returnValueCount) {
Assert.assertEquals(totalCount, e.getViolations().size());
Assert.assertEquals(propertyCount, e.getPropertyViolations().size());
Assert.assertEquals(classCount, e.getClassViolations().size());
Assert.assertEquals(parameterCount, e.getParameterViolations().size());
Assert.assertEquals(returnValueCount, e.getReturnValueViolations().size());
}
protected void countViolations(ResteasyViolationException e, int totalCount, int propertyCount, int classCount,
int parameterCount, int returnValueCount) {
Assert.assertEquals(totalCount, e.getViolations().size());
Assert.assertEquals(propertyCount, e.getPropertyViolations().size());
Assert.assertEquals(classCount, e.getClassViolations().size());
Assert.assertEquals(parameterCount, e.getParameterViolations().size());
Assert.assertEquals(returnValueCount, e.getReturnValueViolations().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import jakarta.ws.rs.ext.Provider;

@Provider
public class TestApplication extends Application
{
public Set<Class<?>> getClasses()
{
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(TestResource.class);
return classes;
}
public class TestApplication extends Application {
public Set<Class<?>> getClasses() {
HashSet<Class<?>> classes = new HashSet<Class<?>>();
classes.add(TestResource.class);
return classes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
import jakarta.ws.rs.core.Application;

@ApplicationPath("/two")
public class TestApplicationPath extends Application
{
public class TestApplicationPath extends Application {
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.jboss.resteasy.resteasy1630;

import org.jboss.logging.Logger;

import jakarta.validation.constraints.Min;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
Expand All @@ -10,20 +8,20 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.jboss.logging.Logger;

/**
*/
@Path("/")
public class TestResource
{
public class TestResource {

private static final Logger LOG = Logger.getLogger(TestResource.class);
private static final Logger LOG = Logger.getLogger(TestResource.class);

@GET
@Path("test/{param}")
@Produces(MediaType.TEXT_PLAIN)
public Response test(@Min(7) @PathParam("param") int param)
{
LOG.info("param: " + param);
return Response.ok().entity(param).build();
}
@GET
@Path("test/{param}")
@Produces(MediaType.TEXT_PLAIN)
public Response test(@Min(7) @PathParam("param") int param) {
LOG.info("param: " + param);
return Response.ok().entity(param).build();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.jboss.resteasy.test.resteasy1630;

import java.net.URI;
import static org.junit.Assert.assertEquals;

import java.io.File;
import java.net.URI;

import jakarta.ws.rs.core.Response;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
Expand All @@ -13,59 +17,58 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;

/**
See the Servlet 3.0 spec, section 8.2.4 for implementation and processing the details
of ServletContainerInitializer.
Resteasy's implementation of ServletContainerInitializer is declared in the
META-INF/services directory of archive org.jboss.resteasy:resteasy-servlet-initializer
as required by the spec. This archive MUST be included in the generated WAR file
so the server can find and call it. Shrinkwrap's Maven class and .addAsLibraries
method is used to achieve this.
This test checks that the implementation properly handles a jaxrs app that provides
resource and provider classes as well as no web.xml file.
* See the Servlet 3.0 spec, section 8.2.4 for implementation and processing the details
* of ServletContainerInitializer.
*
* Resteasy's implementation of ServletContainerInitializer is declared in the
* META-INF/services directory of archive org.jboss.resteasy:resteasy-servlet-initializer
* as required by the spec. This archive MUST be included in the generated WAR file
* so the server can find and call it. Shrinkwrap's Maven class and .addAsLibraries
* method is used to achieve this.
*
* This test checks that the implementation properly handles a jaxrs app that provides
* resource and provider classes as well as no web.xml file.
*/

@RunWith(Arquillian.class)
@RunAsClient
public class ServletInitializerTest {

@Deployment
public static Archive<?> createTestArchive() {
File pomFile = Maven.resolver().loadPomFromFile("pom.xml").resolve("org.jboss.resteasy:resteasy-servlet-initializer")
.withoutTransitivity().asSingleFile();
@Deployment
public static Archive<?> createTestArchive() {
File pomFile = Maven.resolver().loadPomFromFile("pom.xml").resolve("org.jboss.resteasy:resteasy-servlet-initializer")
.withoutTransitivity().asSingleFile();

WebArchive war = ShrinkWrap.create(WebArchive.class, "RESTEASY-1630-two.war")
.addClasses(TestApplication.class)
.addClasses(TestResource.class)
.addAsLibraries(pomFile)
.addAsWebInfResource("web.xml");
return war;
}
WebArchive war = ShrinkWrap.create(WebArchive.class, "RESTEASY-1630-two.war")
.addClasses(TestApplication.class)
.addClasses(TestResource.class)
.addAsLibraries(pomFile)
.addAsWebInfResource("web.xml");
return war;
}

@ArquillianResource
URI baseUri;
@ArquillianResource
URI baseUri;

/**
* App declares files via the web.xml
* @throws Exception
*/
@Test
public void testEndpoint() throws Exception {
Response response = ResteasyClientBuilder.newClient()
.target(baseUri.toString() + "test/17").request().get();
// System.out.println("Status: " + response.getStatus());
String entity = response.readEntity(String.class);
// System.out.println("Result: " + entity);
assertEquals(200, response.getStatus());
Assert.assertEquals("17", entity);
}
/**
* App declares files via the web.xml
*
* @throws Exception
*/
@Test
public void testEndpoint() throws Exception {
Response response = ResteasyClientBuilder.newClient()
.target(baseUri.toString() + "test/17").request().get();
// System.out.println("Status: " + response.getStatus());
String entity = response.readEntity(String.class);
// System.out.println("Result: " + entity);
assertEquals(200, response.getStatus());
Assert.assertEquals("17", entity);
}
}

0 comments on commit 130f4f5

Please sign in to comment.