Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • harold.debuyst.etu/m4102_tp3
  • yvan.peter/m4102_tp3
  • hugo.dautricourt.etu/m4102_tp3
  • hugo.derigny.etu/m4102_tp3
  • clement.dessingue.etu/m4102_tp3
  • quentin.prognon.etu/m4102_tp3
  • hugo.briatte.etu/m4102_tp3
  • vincent.sailliot.etu/m4102_tp3
  • ophelie.kaminski.etu/m4102_tp3
  • carmelo.dellaterra.etu/m4102_tp3
  • tom.danion.etu/m4102_tp3
  • louis.bellefemine.etu/m4102_tp3
  • gireg.lezoraine.etu/m4102_tp3
  • yanis.sadi.etu/m4102_tp3
  • antoine.pochet.etu/m4102_tp3
  • julien.michot.etu/m4102_tp3
  • yohan.tryoen.etu/m4102_tp3
  • gautier.lantoine.etu/m4102_tp3
  • xavier.lezzoche.etu/m4102_tp3
  • laurent.strachowski.etu/m4102_tp3
  • robin.gallifa.etu/m4102_tp3
  • lucas.tavernier.etu/m4102_tp3
  • ryan.rossez.etu/m4102_tp3
  • neo.lefranc.etu/m4102_tp3
  • madeline.carpentier.etu/m4102_tp3
  • quentin.dinel.etu/m4102_tp3
  • alexandre.bouchez.etu/m4102_tp3
  • yacine.messaadi.etu/m4102_tp3
  • geoffrey.vaniscotte.etu/m4102_tp3
  • aymeric.defossez.etu/m4102_tp3
  • benoit.bankaert.etu/m4102_tp3
  • benoit.barbier.etu/m4102_tp3
  • florian.chiraux.etu/m4102_tp3
  • coline.guyard.etu/m4102_tp3
  • aurelien.gozet.etu/m4102_tp3
  • florian.dieryckx.etu/m4102_tp3
  • clement.bisson.etu/m4102_tp3
  • robin.hotton.etu/m4102_tp3
  • maxime.cassoret.etu/m4102_tp3
  • guillaume.roelandt.etu/m4102_tp3
  • lucas.derouck.etu/m4102_tp3
  • maxence.becquet.etu/m4102_tp3
  • hugo.wieder.etu/m4102_tp3
  • allan.boukhebza.etu/m4102_tp3
  • kevin.froissart.etu/m4102_tp3
  • matthias.merlin.etu/m4102_tp3
  • maxence.bourdin2.etu/m4102_tp3
  • loic.bombard.etu/m4102_tp3
  • julien.delevallez.etu/m4102_tp3
  • nathanael.pereira.etu/m4102_tp3
  • vincent.dheilly.etu/m4102_tp3
  • adrien.bassail.etu/m4102_tp3
  • alexis.vandersteene.etu/m4102_tp3
  • martin.birlouez.etu/m4102_tp3
  • jade.bellereau.etu/m4102_tp3
  • quentin.verchere.etu/m4102_tp3
  • sylvain.bretin.etu/m4102_tp3
  • lucas.constant.etu/m4102_tp3
  • victoire.lenglart.etu/m4102_tp3
  • jacques.wagret.etu/m4102_tp3
  • omar.diallo.etu/m4102_tp3
  • remi.laine.etu/m4102_tp3
  • thomas.shipman.etu/m4102_tp3
  • benjamin.tellier.etu/m4102_tp3
  • theo.canonne.etu/m4102_tp3
  • hugo.blanquart.etu/m4102_tp3
  • pierre.delgrange.etu/m4102_tp3
  • guilhem.heugue.etu/m4102_tp3
  • bastien.moncheaux.etu/m4102_tp3
  • emeric.thebaud.etu/m4102_tp3
  • florentin.plaisant.etu/m4102_tp3
  • guillaume.dubois.etu/m4102_tp3
  • theo.petit.etu/m4102_tp3
  • baptiste.carion.etu/m4102_tp3
  • benoit.lefebvre.etu/m4102_tp3
  • william.jacquot.etu/m4102_tp3
  • charles.tronel.etu/m4102_tp3
  • simon.saintmichel.etu/m4102_tp3
  • bastien.tjampens.etu/m4102_tp3
  • maxime.maronet.etu/m4102_tp3
  • ayoub.lahouaichri.etu/m4102_tp3
  • leonard.corre.etu/m4102_tp3
  • martin.dorange.etu/m4102_tp3
  • lucas.ple.etu/m4102_tp3
  • bastien.cortequisse.etu/m4102_tp3
  • mathis.senicourt.etu/m4102_tp3
  • maxime.boutry.etu/m4102_tp3
  • alexis.duhem2.etu/m4102_tp3
  • romain.gabet.etu/m4102_tp3
  • thomas.wacquet.etu/m4102_tp3
  • simon.prevost2.etu/m4102_tp3
  • david.battais.etu/m4102_tp3
  • tom.delahaye.etu/m4102_tp3
  • martin.mille.etu/m4102_tp3
  • colin.hocquet.etu/m4102_tp3
  • felicien.delannoy.etu/m4102_tp3
  • remy.dekeister.etu/m4102_tp3
  • tom.varingot.etu/m4102_tp3
  • thomas.vantroys/m4102_tp3
  • quentin.dubois3.etu/m4102_tp3
  • tanguy.carrette.etu/m4102_tp3
  • nathan.devigne.etu/m4102_tp3
  • baptiste.lantoine2.etu/m4102_tp3
  • quentin.gillot.etu/m4102_tp3
  • matheo.gallego.etu/m4102_tp3
  • gauthier.solignac.etu/m4102_tp3
  • paul.ripault.etu/m4102_tp3
  • adrien.lazaro.etu/m4102_tp3
  • lucas.hottin.etu/m4102_tp3
  • thomas.obry.etu/m4102_tp3
  • antoine.maille.etu/m4102_tp3
  • clotaire.dufresne.etu/m4102_tp3
  • antoine.delaby.etu/m4102_tp3
  • martin.thibaut.etu/m4102_tp3
  • romain.saintmaxent.etu/m4102_tp3
  • tanguy.bonnet.etu/m4102_tp3
  • amine.allouch.etu/m4102_tp3
  • valentin.bout.etu/m4102_tp3
  • sacha.lepage.etu/m4102_tp3
  • maxime.magnier.etu/m4102_tp3
  • antoine.delfosse.etu/m4102_tp3
  • rayd.tarafi.etu/m4102_tp3
  • thomas.tourdot.etu/m4102_tp3
  • jessy.fanguimache.etu/m4102_tp3
  • aurelien.brillet.etu/m4102_tp3
  • aurelien.carray.etu/m4102_tp3
  • ali.ketencimen.etu/m4102_tp3
  • theo.lange.etu/m4102_tp3
  • theo.noiriel.etu/m4102_tp3
  • julien.desmons2.etu/m4102_tp3
  • lohan.calot.etu/m4102_tp3
  • corentin.lebleu.etu/m4102_tp3
  • cody.dumortier.etu/m4102_tp3
  • aubrian.duhayon.etu/m4102_tp3
  • enzo.cocchi.etu/m4102_tp3
  • mohamed.bourdim.etu/m4102_tp3
  • trophime.dussart.etu/m4102_tp3
  • adil.benameur.etu/m4102_tp3
  • maxime.wallart.etu/m4102_tp3
  • matthieu.vannin.etu/m4102_tp3
  • hugo.dutoit.etu/m4102_tp3
  • alban.sannier.etu/m4102_tp3
  • maxime.molines.etu/m4102_tp3
  • paul.daquin.etu/m4102_tp3
  • baptiste.hardelin.etu/m4102_tp3
  • aymane.ismail.etu/m4102_tp3
  • noe.delcroix.etu/m4102_tp3
147 results
Show changes
Commits on Source (18)
Showing
with 955 additions and 680 deletions
......@@ -206,5 +206,7 @@ local.properties
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.project
.settings
.classpath
# End of https://www.gitignore.io/api/eclipse,visualstudiocode
This diff is collapsed.
<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/maven-v4_0_0.xsd">
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<groupId>fr.ulille.iut.pizzaland</groupId>
<artifactId>pizzaland_jdbi</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>pizzaland</name>
<groupId>fr.ulille.iut.pizzaland</groupId>
<artifactId>pizzaland_jdbi</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>pizzaland_jdbi</name>
<build>
<finalName>pizzaland</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-bom</artifactId>
<type>pom</type>
<version>${jdbi.version}</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-bom</artifactId>
<type>pom</type>
<version>3.12.0</version>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<!-- uncomment this to get JSON support -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
</dependency>
<!-- -->
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>2.30</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.30.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jdbi/jdbi3-core -->
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-core</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-sqlobject</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-sqlite</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-testing</artifactId>
<version>3.12.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<properties>
<jersey.version>2.30</jersey.version>
<jetty-version>9.4.26.v20200117</jetty-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- uncomment this to get JSON support: -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
</dependency>
<!-- -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite-jdbc.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jdbi/jdbi3-core -->
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-core</artifactId>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-sqlobject</artifactId>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-sqlite</artifactId>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-testing</artifactId>
<version>3.27.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>3.0.2</version>
<scope>runtime</scope>
</dependency>
<!-- dependency>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
</dependency-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<inherited>true</inherited>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>fr.ulille.iut.pizzaland.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${shade.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>fr.ulille.iut.pizzaland.Main</mainClass>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<jersey.version>3.0.3</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<shade.version>3.2.4</shade.version>
<lombok.version>1.18.16</lombok.version>
<jdbi.version>3.27.0</jdbi.version>
<sqlite-jdbc.version>3.36.0.3</sqlite-jdbc.version>
<jaxb.version>2.4.0-b180830.0359</jaxb.version>
</properties>
</project>
......@@ -4,7 +4,7 @@ import org.glassfish.jersey.server.ResourceConfig;
import java.util.logging.Logger;
import javax.ws.rs.ApplicationPath;
import jakarta.ws.rs.ApplicationPath;
@ApplicationPath("api/v1/")
public class ApiV1 extends ResourceConfig {
......
......@@ -3,30 +3,42 @@ package fr.ulille.iut.pizzaland;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Properties;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.Jdbi;
import org.jdbi.v3.sqlite3.SQLitePlugin;
import org.jdbi.v3.sqlobject.SqlObjectPlugin;
import fr.ulille.iut.pizzaland.dao.UUIDArgumentFactory;
public class BDDFactory {
private static Jdbi jdbi = null;
private static String dbPath = "jdbc:sqlite:"
+ System.getProperty("java.io.tmpdir")
+ System.getProperty("file.separator")
+ System.getProperty("user.name")
+ "_";
public static Jdbi getJdbi() {
if ( jdbi == null ) {
jdbi = Jdbi.create("jdbc:sqlite:"
+ System.getProperty("java.io.tmpdir")
+ System.getProperty("file.separator") + "pizza.db")
Properties properties = new Properties();
properties.setProperty("foreign_keys", "true");
jdbi = Jdbi.create(dbPath + "pizzas.db", properties)
.installPlugin(new SQLitePlugin())
.installPlugin(new SqlObjectPlugin());
.installPlugin(new SqlObjectPlugin()).registerArgument(new UUIDArgumentFactory());
}
return jdbi;
}
public static void setJdbiForTests() {
if ( jdbi == null ) {
jdbi = Jdbi.create("jdbc:sqlite:"
+ System.getProperty("java.io.tmpdir")
+ System.getProperty("file.separator") + "pizza_test.db")
Properties properties = new Properties();
properties.setProperty("foreign_keys", "true");
jdbi = Jdbi.create(dbPath + "pizza_test.db", properties)
.installPlugin(new SQLitePlugin())
.installPlugin(new SqlObjectPlugin());
}
......@@ -40,7 +52,18 @@ public class BDDFactory {
return exist;
}
public static void dropTables() throws SQLException {
Handle handle = getJdbi().open();
DatabaseMetaData dbm = handle.getConnection().getMetaData();
ResultSet tables = dbm.getTables(null, null, "", null);
ArrayList<String> tableNames = new ArrayList<String>();
while ( tables.next() ) {
tableNames.add(tables.getString("TABLE_NAME"));
}
tableNames.forEach(name -> handle.execute("drop table " + name));
}
public static <T> T buildDao(Class<T> daoClass) {
return getJdbi().onDemand(daoClass);
}
}
\ No newline at end of file
}
}
package fr.ulille.iut.pizzaland;
import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.server.ResourceConfig;
/**
* Main class.
*
*/
public class Main {
// Base URI the Grizzly HTTP server will listen on
public static final String BASE_URI = "http://localhost:8080/api/v1/";
private static final LogManager logManager = LogManager.getLogManager();
static {
try {
logManager.readConfiguration(Main.class.getClassLoader().getResourceAsStream("logging.properties"));
}
catch ( Exception ex ) {
ex.printStackTrace();
}
}
/**
* Starts Grizzly HTTP server exposing JAX-RS resources defined in this
* application.
*
* @return Grizzly HTTP server.
*/
public static HttpServer startServer() {
// create a resource config that scans for JAX-RS resources and providers
// in fr.ulille.iut.todo package
/* ResourceConfig rc = new ResourceConfig().packages("fr.ulille.iut.pizzaland");
// Activation des log des requêtes et réponses
String logging = System.getenv("LOG_MESSAGES");
if ( logging != null && logging.equalsIgnoreCase("true") ) {
rc.register(new LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), Level.INFO,
LoggingFeature.Verbosity.PAYLOAD_ANY, 10000));
}
String debug = System.getenv("DEBUG_INTERNAL");
if ( debug != null && debug.equalsIgnoreCase("true") ) {
rc.register(DebugMapper.class);
}*/
// create and start a new instance of grizzly http server
// exposing the Jersey application at BASE_URI
return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), new ApiV1());
}
/**
* Main method.
*
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
final HttpServer server = startServer();
System.out.println(String.format(
"Jersey app started with WADL available at " + "%sapplication.wadl\nexport LOG_MESSAGES=true pour voir les requêtes et réponses\nexport DEBUG_INTERNAL=true pour voir les erreurs 500\nHit enter to stop it...",
BASE_URI));
System.in.read();
server.stop();
}
}
package fr.ulille.iut.pizzaland.dao;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.UUID;
import org.jdbi.v3.core.argument.Argument;
import org.jdbi.v3.core.statement.StatementContext;
public class UUIDArgument implements Argument {
private final UUID value;
public UUIDArgument(UUID value) {
this.value = value;
}
@Override
public void apply(int position, PreparedStatement statement, StatementContext ctx) throws SQLException {
statement.setString(position, value.toString());
}
}
package fr.ulille.iut.pizzaland.dao;
import java.sql.Types;
import java.util.UUID;
import org.jdbi.v3.core.argument.AbstractArgumentFactory;
import org.jdbi.v3.core.argument.Argument;
import org.jdbi.v3.core.config.ConfigRegistry;
public class UUIDArgumentFactory extends AbstractArgumentFactory<UUID> {
public UUIDArgumentFactory() {
super(Types.VARCHAR);
}
@Override
protected Argument build(UUID value, ConfigRegistry config) {
return (position, statement, ctx) -> statement.setString(position, value.toString());
}
}
package fr.ulille.iut.pizzaland.resources;
import java.sql.SQLException;
import fr.ulille.iut.pizzaland.BDDFactory;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
/**
* BDDClearRessource
*/
@Path("clearDatabase")
public class BDDClearRessource {
@GET
public void clearDatabase() throws SQLException {
BDDFactory.dropTables();
}
}
......@@ -5,11 +5,11 @@ import java.util.List;
import java.util.ArrayList;
import java.util.logging.Logger;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
import fr.ulille.iut.pizzaland.dto.IngredientDto;
......@@ -27,6 +27,6 @@ public class IngredientResource {
public List<IngredientDto> getAll() {
LOGGER.info("IngredientResource:getAll");
return null;
return new ArrayList<IngredientDto>();
}
}
[
{ "name": "mozzarella"},
{ "name": "jambon"},
{ "name": "champignons"},
{ "name": "olives"},
{ "name": "tomate"},
{ "name": "merguez"},
{ "name": "lardons"},
{ "name": "fromage"},
{ "name": "oeuf"},
{ "name": "poivrons"},
{ "name": "ananas"},
{ "name": "reblochon"}
{ "id": "f38806a8-7c85-49ef-980c-149dcd81d306", "name": "mozzarella"},
{ "id": "d36903e1-0cc0-4bd6-a0ed-e0e9bf7b4037", "name": "jambon"},
{ "id": "bc5b315f-442f-4ee4-96de-486d48f20c2f", "name": "champignons"},
{ "id": "6a04320c-3a4f-4570-96d3-61faf3f898b0", "name": "olives"},
{ "id": "c77deeee-d50d-49d5-9695-c98ec811f762", "name": "tomate"},
{ "id": "c9375542-8142-43f6-b54d-0d63597cf614", "name": "merguez"},
{ "id": "dee27dd6-f9b6-4d03-ac4b-216b5c9c8bd7", "name": "lardons"},
{ "id": "657f8dd4-6bc1-4622-9af7-37d248846a23", "name": "fromage"},
{ "id": "070d8077-a713-49a0-af37-3936b63d5ff2", "name": "oeuf"},
{ "id": "5d9ca5c4-517f-40fd-aac3-5a823d680c1d", "name": "poivrons"},
{ "id": "52f68024-24ec-46c0-8e77-c499dba1e27e", "name": "ananas"},
{ "id": "dfdf6fae-f1b2-45fa-8c39-54e522c1933f", "name": "reblochon"}
]
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
<logger name="fr.ulille.iut.pizzaland" level="debug"/>
</configuration>
handlers= java.util.logging.ConsoleHandler
.level= INFO
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
\ No newline at end of file
......@@ -9,10 +9,10 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Application;
import jakarta.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
......@@ -21,24 +21,25 @@ import java.util.logging.Logger;
/*
* JerseyTest facilite l'écriture des tests en donnant accès aux
* méthodes de l'interface javax.ws.rs.client.Client.
* méthodes de l'interface jakarta.ws.rs.client.Client.
* la méthode configure() permet de démarrer la ressource à tester
*/
public class IngredientResourceTest extends JerseyTest {
private static final Logger LOGGER = Logger.getLogger(IngredientResourceTest.class.getName());
@Override
protected Application configure() {
return new ApiV1();
return new ApiV1();
}
// Les méthodes setEnvUp() et tearEnvDown() serviront à terme à initialiser la base de données
// Les méthodes setEnvUp() et tearEnvDown() serviront à terme à initialiser la
// base de données
// et les DAO
// https://stackoverflow.com/questions/25906976/jerseytest-and-junit-throws-nullpointerexception
@Before
public void setEnvUp() {
}
@After
......@@ -48,20 +49,20 @@ public class IngredientResourceTest extends JerseyTest {
@Test
public void testGetEmptyList() {
// La méthode target() permet de préparer une requête sur une URI.
// La classe Response permet de traiter la réponse HTTP reçue.
// La méthode target() permet de préparer une requête sur une URI.
// La classe Response permet de traiter la réponse HTTP reçue.
Response response = target("/ingredients").request().get();
// On vérifie le code de la réponse (200 = OK)
// On vérifie le code de la réponse (200 = OK)
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
// On vérifie la valeur retournée (liste vide)
// L'entité (readEntity() correspond au corps de la réponse HTTP.
// La classe javax.ws.rs.core.GenericType<T> permet de définir le type
// de la réponse lue quand on a un type complexe (typiquement une liste).
List<IngredientDto> ingredients;
ingredients = response.readEntity(new GenericType<List<IngredientDto>>(){});
// On vérifie la valeur retournée (liste vide)
// L'entité (readEntity() correspond au corps de la réponse HTTP.
// La classe jakarta.ws.rs.core.GenericType<T> permet de définir le type
// de la réponse lue quand on a un type paramétré (typiquement une liste).
List<IngredientDto> ingredients;
ingredients = response.readEntity(new GenericType<List<IngredientDto>>() {
});
assertEquals(0, ingredients.size());
......
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</appender>
<root level="info">
<appender-ref ref="STDOUT"/>
</root>
<logger name="fr.ulille.iut.pizzaland" level="debug"/>
</configuration>
handlers= java.util.logging.ConsoleHandler
.level= INFO
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
\ No newline at end of file