Compare commits
4 Commits
de08bcfab5
...
032728f05d
Author | SHA1 | Date | |
---|---|---|---|
032728f05d | |||
bfe722f074 | |||
fddf41bea0 | |||
3fa48fc839 |
25
pom.xml
25
pom.xml
@ -56,29 +56,28 @@
|
||||
</dependency>
|
||||
<!-- Decode webP images -->
|
||||
<dependency>
|
||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||
<artifactId>imageio-webp</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||
<artifactId>imageio-webp</artifactId>
|
||||
<version>3.11.0</version>
|
||||
</dependency>
|
||||
<!-- Decode JPEG image -->
|
||||
<dependency>
|
||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||
<artifactId>imageio-jpeg</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<groupId>com.twelvemonkeys.imageio</groupId>
|
||||
<artifactId>imageio-jpeg</artifactId>
|
||||
<version>3.11.0</version>
|
||||
</dependency>
|
||||
<!-- Encode file in webp -->
|
||||
<dependency>
|
||||
<groupId>com.github.gotson</groupId>
|
||||
<artifactId>webp-imageio</artifactId>
|
||||
<version>0.2.2</version>
|
||||
<groupId>com.github.gotson</groupId>
|
||||
<artifactId>webp-imageio</artifactId>
|
||||
<version>0.2.2</version>
|
||||
</dependency>
|
||||
<!-- Detect type of a file with mime type -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId>
|
||||
<version>2.7.0</version>
|
||||
<groupId>org.apache.tika</groupId>
|
||||
<artifactId>tika-core</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-multipart -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
|
@ -64,18 +64,18 @@ public class DataResource {
|
||||
private final static int CHUNK_SIZE_IN = 50 * 1024 * 1024; // 1MB chunks
|
||||
/** Upload some datas */
|
||||
private static long tmpFolderId = 1;
|
||||
|
||||
|
||||
private static void createFolder(final String path) throws IOException {
|
||||
if (!Files.exists(java.nio.file.Path.of(path))) {
|
||||
// Log.print("Create folder: " + path);
|
||||
Files.createDirectories(java.nio.file.Path.of(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static long getTmpDataId() {
|
||||
return tmpFolderId++;
|
||||
}
|
||||
|
||||
|
||||
public static String getTmpFileInData(final long tmpFolderId) {
|
||||
final String filePath = ConfigBaseVariable.getTmpDataFolder() + File.separator + tmpFolderId;
|
||||
try {
|
||||
@ -85,7 +85,7 @@ public class DataResource {
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
public static String getFileDataOld(final long tmpFolderId) {
|
||||
final String filePath = ConfigBaseVariable.getMediaDataFolder() + File.separator + tmpFolderId + File.separator
|
||||
+ "data";
|
||||
@ -96,7 +96,7 @@ public class DataResource {
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
public static String getFileData(final UUID uuid) {
|
||||
final String stringUUID = uuid.toString();
|
||||
final String part1 = stringUUID.substring(0, 2);
|
||||
@ -113,11 +113,11 @@ public class DataResource {
|
||||
filePath += part3;
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
public static String getFileMetaData(final UUID uuid) {
|
||||
return getFileData(uuid) + ".json";
|
||||
}
|
||||
|
||||
|
||||
public static Data getWithSha512(final String sha512) {
|
||||
LOGGER.info("find sha512 = {}", sha512);
|
||||
try {
|
||||
@ -128,7 +128,7 @@ public class DataResource {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Data getWithId(final long id) {
|
||||
LOGGER.info("find id = {}", id);
|
||||
try {
|
||||
@ -139,7 +139,7 @@ public class DataResource {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static Data createNewData(final long tmpUID, final String originalFileName, final String sha512)
|
||||
throws IOException {
|
||||
// determine mime type:
|
||||
@ -159,7 +159,7 @@ public class DataResource {
|
||||
injectedData.sha512 = sha512;
|
||||
final String tmpPath = getTmpFileInData(tmpUID);
|
||||
injectedData.size = Files.size(Paths.get(tmpPath));
|
||||
|
||||
|
||||
try {
|
||||
injectedData = DataAccess.insert(injectedData);
|
||||
} catch (final Exception e) {
|
||||
@ -173,7 +173,7 @@ public class DataResource {
|
||||
LOGGER.info("Move done");
|
||||
return injectedData;
|
||||
}
|
||||
|
||||
|
||||
public static void modeFileOldModelToNewModel(final long id, final UUID uuid) throws IOException {
|
||||
String mediaCurentPath = getFileDataOld(id);
|
||||
String mediaDestPath = getFileData(uuid);
|
||||
@ -192,12 +192,12 @@ public class DataResource {
|
||||
}
|
||||
LOGGER.info("Move done");
|
||||
}
|
||||
|
||||
|
||||
public static String saveTemporaryFile(final InputStream uploadedInputStream, final long idData)
|
||||
throws FailException {
|
||||
return saveFile(uploadedInputStream, DataResource.getTmpFileInData(idData));
|
||||
}
|
||||
|
||||
|
||||
public static void removeTemporaryFile(final long idData) {
|
||||
final String filepath = DataResource.getTmpFileInData(idData);
|
||||
if (Files.exists(Paths.get(filepath))) {
|
||||
@ -209,7 +209,7 @@ public class DataResource {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// save uploaded file to a defined location on the server
|
||||
static String saveFile(final InputStream uploadedInputStream, final String serverLocation) throws FailException {
|
||||
String out = "";
|
||||
@ -243,7 +243,7 @@ public class DataResource {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
public static String bytesToHex(final byte[] bytes) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (final byte b : bytes) {
|
||||
@ -251,7 +251,7 @@ public class DataResource {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public Data getSmall(final UUID id) {
|
||||
try {
|
||||
return DataAccess.get(Data.class, id);
|
||||
@ -261,7 +261,7 @@ public class DataResource {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("/upload/")
|
||||
@Consumes({ MediaType.MULTIPART_FORM_DATA })
|
||||
@ -286,7 +286,7 @@ public class DataResource {
|
||||
}
|
||||
saveFile(fileInputStream, filePath);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{uuid}")
|
||||
@PermitTokenInURI
|
||||
@ -313,7 +313,7 @@ public class DataResource {
|
||||
throw new FailException(Response.Status.INTERNAL_SERVER_ERROR, "Fail to build output stream", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("thumbnail/{uuid}")
|
||||
@RolesAllowed("USER")
|
||||
@ -400,7 +400,7 @@ public class DataResource {
|
||||
throw new FailException(Response.Status.INTERNAL_SERVER_ERROR, "Fail to build output stream", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("{uuid}/{name}")
|
||||
@PermitTokenInURI
|
||||
@ -424,7 +424,7 @@ public class DataResource {
|
||||
return buildStream(getFileData(uuid), range,
|
||||
value.mimeType == null ? "application/octet-stream" : value.mimeType);
|
||||
}
|
||||
|
||||
|
||||
/** Adapted from http://stackoverflow.com/questions/12768812/video-streaming-to-ipad-does-not-work-with-tapestry5/12829541#12829541
|
||||
*
|
||||
* @param range range header
|
||||
@ -463,12 +463,12 @@ public class DataResource {
|
||||
out.type(mimeType);
|
||||
}
|
||||
return out.build();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
final String[] ranges = range.split("=")[1].split("-");
|
||||
final long from = Long.parseLong(ranges[0]);
|
||||
|
||||
|
||||
// logger.info("request range : {}", ranges.length);
|
||||
// Chunk media if the range upper bound is unspecified. Chrome, Opera sends "bytes=0-"
|
||||
long to = CHUNK_SIZE + from;
|
||||
@ -481,7 +481,7 @@ public class DataResource {
|
||||
// logger.info("responseRange: {}", responseRange);
|
||||
try (final RandomAccessFile raf = new RandomAccessFile(file, "r")) {
|
||||
raf.seek(from);
|
||||
|
||||
|
||||
final long len = to - from + 1;
|
||||
final MediaStreamer streamer = new MediaStreamer(len, raf);
|
||||
final Response.ResponseBuilder out = Response.ok(streamer).status(Response.Status.PARTIAL_CONTENT)
|
||||
@ -498,9 +498,9 @@ public class DataResource {
|
||||
throw new FailException(Response.Status.INTERNAL_SERVER_ERROR, "Fail to access to the required file.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void undelete(final Long id) throws Exception {
|
||||
DataAccess.unsetDelete(Data.class, id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import jakarta.ws.rs.core.Response.Status;
|
||||
//@Produces(MediaType.APPLICATION_JSON)
|
||||
public class ProxyResource {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ProxyResource.class);
|
||||
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_OCTET_STREAM)
|
||||
public Response getImageFromUrl(@QueryParam("url") final String url) {
|
||||
|
@ -27,7 +27,7 @@ public class RestErrorResponse {
|
||||
@NotNull
|
||||
@Column(length = 0)
|
||||
final public String statusMessage;
|
||||
|
||||
|
||||
public RestErrorResponse(final Response.Status status, final String time, final String error,
|
||||
final String message) {
|
||||
this.time = time;
|
||||
@ -36,7 +36,7 @@ public class RestErrorResponse {
|
||||
this.status = status.getStatusCode();
|
||||
this.statusMessage = status.getReasonPhrase();
|
||||
}
|
||||
|
||||
|
||||
public RestErrorResponse(final Response.Status status, final String error, final String message) {
|
||||
this.time = Instant.now().toString();
|
||||
this.name = error;
|
||||
@ -44,7 +44,7 @@ public class RestErrorResponse {
|
||||
this.status = status.getStatusCode();
|
||||
this.statusMessage = status.getReasonPhrase();
|
||||
}
|
||||
|
||||
|
||||
public RestErrorResponse(final Response.Status status) {
|
||||
this.name = "generic";
|
||||
this.message = "";
|
||||
@ -52,5 +52,5 @@ public class RestErrorResponse {
|
||||
this.status = status.getStatusCode();
|
||||
this.statusMessage = status.getReasonPhrase();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1297,6 +1297,7 @@ public class DataAccess {
|
||||
throws SQLException, IOException {
|
||||
final QueryOptions options = new QueryOptions(option);
|
||||
final DBEntry entry = DBInterfaceOption.getAutoEntry(options);
|
||||
LOGGER.info("Query : '{}'", query);
|
||||
try (final Statement stmt = entry.connection.createStatement()) {
|
||||
return stmt.executeUpdate(query);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ public class DataFactory {
|
||||
final String comment = AnnotationTools.getComment(elem);
|
||||
final String defaultValue = AnnotationTools.getDefault(elem);
|
||||
|
||||
if (fieldId == 0) {
|
||||
if (mainTableBuilder.toString().length() == 0) {
|
||||
mainTableBuilder.append("\n\t\t`");
|
||||
} else {
|
||||
mainTableBuilder.append(",\n\t\t`");
|
||||
@ -404,6 +404,7 @@ public class DataFactory {
|
||||
}
|
||||
final boolean dataInThisObject = tmpOut.toString().length() > 0;
|
||||
if (dataInThisObject) {
|
||||
LOGGER.info("Previous Object : '{}'", reverseOut.toString());
|
||||
final boolean dataInPreviousObject = reverseOut.toString().length() > 0;
|
||||
if (dataInPreviousObject) {
|
||||
tmpOut.append(", ");
|
||||
|
@ -109,13 +109,18 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
||||
@NotNull final CountInOut count,
|
||||
final QueryOptions options) throws Exception {
|
||||
final ManyToMany manyToMany = AnnotationTools.getManyToMany(field);
|
||||
final String linkTableName = generateLinkTableName(tableName, name);
|
||||
String linkTableName = generateLinkTableName(tableName, name);
|
||||
if (manyToMany.mappedBy() != null && manyToMany.mappedBy().length() != 0) {
|
||||
// TODO: get the remote table name .....
|
||||
final String remoteTableName = AnnotationTools.getTableName(manyToMany.targetEntity());
|
||||
linkTableName = generateLinkTableName(remoteTableName, manyToMany.mappedBy());
|
||||
}
|
||||
final Class<?> objectClass = (Class<?>) ((ParameterizedType) field.getGenericType())
|
||||
.getActualTypeArguments()[0];
|
||||
final String tmpVariable = "tmp_" + Integer.toString(count.value);
|
||||
querySelect.append(" (SELECT GROUP_CONCAT(");
|
||||
querySelect.append(tmpVariable);
|
||||
if (manyToMany.mappedBy() == null) {
|
||||
if (manyToMany.mappedBy() == null || manyToMany.mappedBy().length() == 0) {
|
||||
querySelect.append(".object2Id ");
|
||||
} else {
|
||||
querySelect.append(".object1Id ");
|
||||
@ -148,7 +153,7 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
||||
querySelect.append(" = ");
|
||||
querySelect.append(tmpVariable);
|
||||
querySelect.append(".");
|
||||
if (manyToMany.mappedBy() == null) {
|
||||
if (manyToMany.mappedBy() == null || manyToMany.mappedBy().length() == 0) {
|
||||
querySelect.append("object1Id ");
|
||||
} else {
|
||||
querySelect.append("object2Id ");
|
||||
@ -156,7 +161,7 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
||||
if (!"sqlite".equals(ConfigBaseVariable.getDBType())) {
|
||||
querySelect.append(" GROUP BY ");
|
||||
querySelect.append(tmpVariable);
|
||||
if (manyToMany.mappedBy() == null) {
|
||||
if (manyToMany.mappedBy() == null || manyToMany.mappedBy().length() == 0) {
|
||||
querySelect.append(".object1Id");
|
||||
} else {
|
||||
querySelect.append(".object2Id");
|
||||
@ -522,6 +527,12 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
||||
final boolean createIfNotExist,
|
||||
final boolean createDrop,
|
||||
final int fieldId) throws Exception {
|
||||
|
||||
final ManyToMany manyToMany = AnnotationTools.getManyToMany(field);
|
||||
if (manyToMany.mappedBy() != null && manyToMany.mappedBy().length() != 0) {
|
||||
// not the reference model to create base:
|
||||
return;
|
||||
}
|
||||
final String linkTableName = generateLinkTableNameField(tableName, field);
|
||||
final QueryOptions options = new QueryOptions(new OverrideTableName(linkTableName));
|
||||
final Class<?> objectClass = (Class<?>) ((ParameterizedType) field.getGenericType())
|
||||
@ -540,7 +551,6 @@ public class AddOnManyToMany implements DataAccessAddOn {
|
||||
postActionList.addAll(sqlCommand);
|
||||
}
|
||||
} else if (primaryType == UUID.class) {
|
||||
|
||||
if (objectClass == Long.class) {
|
||||
final List<String> sqlCommand = DataFactory.createTable(LinkTableUUIDLong.class, options);
|
||||
postActionList.addAll(sqlCommand);
|
||||
|
@ -63,6 +63,7 @@ public class DBEntry implements Closeable {
|
||||
this.connection = DriverManager.getConnection(this.config.getUrl(), this.config.getLogin(),
|
||||
this.config.getPassword());
|
||||
} catch (final SQLException ex) {
|
||||
LOGGER.error("Connection db fail: " + ex.getMessage() + " On URL: " + this.config.getUrl(true));
|
||||
throw new IOException("Connection db fail: " + ex.getMessage() + " On URL: " + this.config.getUrl(true));
|
||||
}
|
||||
|
||||
|
@ -71,4 +71,25 @@ public class AnalyzeApi {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public void displayAllApi() {
|
||||
LOGGER.info("List all API:");
|
||||
for (final ApiGroupModel model : getAllApi()) {
|
||||
LOGGER.info(" - {}: {}", model.name, model.getClass().getCanonicalName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void displayAllModel() {
|
||||
LOGGER.info("List all Model:");
|
||||
for (final ClassModel model : getAllModel()) {
|
||||
final StringBuilder out = new StringBuilder();
|
||||
for (final ClassModel classModel : model.getAlls()) {
|
||||
out.append(classModel.getOriginClasses().getCanonicalName());
|
||||
out.append(",");
|
||||
}
|
||||
LOGGER.info(" - {}", out.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import org.kar.archidata.externalRestApi.typescript.TsClassElementGroup;
|
||||
public class TsGenerateApi {
|
||||
/**
|
||||
* Generate a full API tree for Typescript in a specific folder.
|
||||
* This generate a folder containing a full API with "model" filder and "api" folder.
|
||||
* This generate a folder containing a full API with "model" folder and "api" folder.
|
||||
* The generation depend of Zod and can be strict compile.
|
||||
* @param api Data model to generate the api
|
||||
* @param pathPackage Path to store the api.
|
||||
@ -118,6 +118,8 @@ public class TsGenerateApi {
|
||||
}
|
||||
|
||||
private static List<TsClassElement> generateApiModel(final AnalyzeApi api) throws Exception {
|
||||
// needed for Rest interface
|
||||
api.addModel(RestErrorResponse.class);
|
||||
// First step is to add all specific basic elements the wrap correctly the model
|
||||
final List<TsClassElement> tsModels = new ArrayList<>();
|
||||
List<ClassModel> models = api.getCompatibleModels(List.of(Void.class, void.class));
|
||||
@ -205,8 +207,6 @@ public class TsGenerateApi {
|
||||
tsModels.add(new TsClassElement(models, "ZodLocalTime", "LocalTime", "isLocalTime", "zod.string().time()",
|
||||
DefinedPosition.BASIC));
|
||||
}
|
||||
// needed for Rest interface
|
||||
api.addModel(RestErrorResponse.class);
|
||||
for (final ClassModel model : api.getAllModel()) {
|
||||
boolean alreadyExist = false;
|
||||
for (final TsClassElement elem : tsModels) {
|
||||
|
@ -35,7 +35,7 @@ import com.nimbusds.jwt.SignedJWT;
|
||||
|
||||
class TestSigner implements JWSSigner {
|
||||
public static String test_signature = "TEST_SIGNATURE_FOR_LOCAL_TEST_AND_TEST_E2E";
|
||||
|
||||
|
||||
/** Signs the specified {@link JWSObject#getSigningInput input} of a {@link JWSObject JWS object}.
|
||||
*
|
||||
* @param header The JSON Web Signature (JWS) header. Must specify a supported JWS algorithm and must not be {@code null}.
|
||||
@ -49,13 +49,13 @@ class TestSigner implements JWSSigner {
|
||||
public Base64URL sign(final JWSHeader header, final byte[] signingInput) throws JOSEException {
|
||||
return new Base64URL(test_signature);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<JWSAlgorithm> supportedJWSAlgorithms() {
|
||||
// TODO Auto-generated method stub
|
||||
return Set.of(JWSAlgorithm.RS256);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JCAContext getJCAContext() {
|
||||
// TODO Auto-generated method stub
|
||||
@ -65,20 +65,20 @@ class TestSigner implements JWSSigner {
|
||||
|
||||
public class JWTWrapper {
|
||||
static final Logger LOGGER = LoggerFactory.getLogger(JWTWrapper.class);
|
||||
|
||||
|
||||
private static RSAKey rsaJWK = null;
|
||||
private static RSAKey rsaPublicJWK = null;
|
||||
|
||||
|
||||
public static class PublicKey {
|
||||
public String key;
|
||||
|
||||
|
||||
public PublicKey(final String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
|
||||
public PublicKey() {}
|
||||
}
|
||||
|
||||
|
||||
public static void initLocalTokenRemote(final String ssoUri, final String application)
|
||||
throws IOException, ParseException {
|
||||
// check Token:
|
||||
@ -95,11 +95,11 @@ public class JWTWrapper {
|
||||
con.setRequestProperty(AuthenticationFilter.APIKEY, ssoToken);
|
||||
}
|
||||
final int responseCode = con.getResponseCode();
|
||||
|
||||
|
||||
// LOGGER.debug("GET Response Code :: {}", responseCode);
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) { // success
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
|
||||
|
||||
String inputLine;
|
||||
final StringBuffer response = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
@ -115,7 +115,7 @@ public class JWTWrapper {
|
||||
}
|
||||
LOGGER.debug("GET JWT validator token not worked response code {} from {} ", responseCode, obj);
|
||||
}
|
||||
|
||||
|
||||
public static void initLocalToken(final String baseUUID) throws Exception {
|
||||
// RSA signatures require a public and private RSA key pair, the public key
|
||||
// must be made known to the JWS recipient in order to verify the signatures
|
||||
@ -139,7 +139,7 @@ public class JWTWrapper {
|
||||
rsaPublicJWK = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void initValidateToken(final String publicKey) {
|
||||
try {
|
||||
rsaPublicJWK = RSAKey.parse(publicKey);
|
||||
@ -147,16 +147,16 @@ public class JWTWrapper {
|
||||
e.printStackTrace();
|
||||
LOGGER.debug("Can not retrieve public Key !!!!!!!! RSAKey='{}'", publicKey);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String getPublicKeyJson() {
|
||||
if (rsaPublicJWK == null) {
|
||||
return null;
|
||||
}
|
||||
return rsaPublicJWK.toJSONString();
|
||||
}
|
||||
|
||||
|
||||
public static java.security.interfaces.RSAPublicKey getPublicKeyJava() throws JOSEException {
|
||||
if (rsaPublicJWK == null) {
|
||||
return null;
|
||||
@ -164,7 +164,7 @@ public class JWTWrapper {
|
||||
// Convert back to std Java interface
|
||||
return rsaPublicJWK.toRSAPublicKey();
|
||||
}
|
||||
|
||||
|
||||
/** Create a token with the provided elements
|
||||
* @param userID UniqueId of the USER (global unique ID)
|
||||
* @param userLogin Login of the user (never change)
|
||||
@ -187,12 +187,12 @@ public class JWTWrapper {
|
||||
try {
|
||||
// Create RSA-signer with the private key
|
||||
final JWSSigner signer = new RSASSASigner(rsaJWK);
|
||||
|
||||
|
||||
LOGGER.warn("timeOutInMunites= {}", timeOutInMunites);
|
||||
final Date now = new Date();
|
||||
LOGGER.warn("now = {}", now);
|
||||
final Date expiration = new Date(new Date().getTime() - 60 * timeOutInMunites * 1000 /* millisecond */);
|
||||
|
||||
|
||||
LOGGER.warn("expiration= {}", expiration);
|
||||
final JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder().subject(Long.toString(userID))
|
||||
.claim("login", userLogin).claim("application", application).issuer(isuer).issueTime(now)
|
||||
@ -205,7 +205,7 @@ public class JWTWrapper {
|
||||
final JWTClaimsSet claimsSet = builder.build();
|
||||
final SignedJWT signedJWT = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).type(JOSEObjectType.JWT)
|
||||
/* .keyID(rsaJWK.getKeyID()) */.build(), claimsSet);
|
||||
|
||||
|
||||
// Compute the RSA signature
|
||||
signedJWT.sign(signer);
|
||||
// serialize the output...
|
||||
@ -215,7 +215,7 @@ public class JWTWrapper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static JWTClaimsSet validateToken(final String signedToken, final String isuer, final String application) {
|
||||
try {
|
||||
// On the consumer side, parse the JWS and verify its RSA signature
|
||||
@ -267,7 +267,7 @@ public class JWTWrapper {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static String createJwtTestToken(
|
||||
final long userID,
|
||||
final String userLogin,
|
||||
@ -280,10 +280,10 @@ public class JWTWrapper {
|
||||
}
|
||||
try {
|
||||
final int timeOutInMunites = 3600;
|
||||
|
||||
|
||||
final Date now = new Date();
|
||||
final Date expiration = new Date(new Date().getTime() + timeOutInMunites * 1000 /* ms */);
|
||||
|
||||
|
||||
final JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder().subject(Long.toString(userID))
|
||||
.claim("login", userLogin).claim("application", application).issuer(isuer).issueTime(now)
|
||||
.expirationTime(expiration); // Do not ask why we need a "-" here ... this have no meaning
|
||||
@ -295,10 +295,10 @@ public class JWTWrapper {
|
||||
final JWTClaimsSet claimsSet = builder.build();
|
||||
final SignedJWT signedJWT = new SignedJWT(new JWSHeader.Builder(JWSAlgorithm.RS256).type(JOSEObjectType.JWT)
|
||||
/* .keyID(rsaJWK.getKeyID()) */.build(), claimsSet);
|
||||
|
||||
|
||||
// Compute the RSA signature
|
||||
signedJWT.sign(new TestSigner());
|
||||
|
||||
|
||||
// serialize the output...
|
||||
return signedJWT.serialize();
|
||||
} catch (final Exception ex) {
|
||||
|
40
test/src/test/kar/archidata/ConfigureDb.java
Normal file
40
test/src/test/kar/archidata/ConfigureDb.java
Normal file
@ -0,0 +1,40 @@
|
||||
package test.kar.archidata;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ConfigureDb {
|
||||
final static private Logger LOGGER = LoggerFactory.getLogger(ConfigureDb.class);
|
||||
|
||||
public static void configure() throws IOException {
|
||||
if (true) {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
} else {
|
||||
// Enable this if you want to access to a local MySQL base to test with an adminer
|
||||
ConfigBaseVariable.bdDatabase = "test_db";
|
||||
ConfigBaseVariable.dbPort = "3906";
|
||||
ConfigBaseVariable.dbUser = "root";
|
||||
//ConfigBaseVariable.dbPassword = "password";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
}
|
||||
|
||||
public static void clear() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
|
||||
}
|
||||
}
|
@ -11,11 +11,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -29,22 +26,12 @@ public class TestJson {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -12,11 +12,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -29,22 +26,12 @@ public class TestListJson {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -11,12 +11,9 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.dataAccess.addOn.AddOnManyToMany;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -31,22 +28,12 @@ public class TestManyToMany {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
@ -129,7 +116,7 @@ public class TestManyToMany {
|
||||
Assertions.assertNotNull(retrieve.otherData);
|
||||
Assertions.assertEquals(insertedData.otherData, retrieve.otherData);
|
||||
Assertions.assertNotNull(retrieve.remote);
|
||||
Assertions.assertEquals(retrieve.remote.size(), 2);
|
||||
Assertions.assertEquals(2, retrieve.remote.size());
|
||||
Assertions.assertEquals(retrieve.remote.get(0), insertedRemote1.id);
|
||||
Assertions.assertEquals(retrieve.remote.get(1), insertedRemote2.id);
|
||||
|
||||
@ -141,7 +128,7 @@ public class TestManyToMany {
|
||||
Assertions.assertNotNull(retrieveExpand.otherData);
|
||||
Assertions.assertEquals(insertedData.otherData, retrieveExpand.otherData);
|
||||
Assertions.assertNotNull(retrieveExpand.remote);
|
||||
Assertions.assertEquals(retrieveExpand.remote.size(), 2);
|
||||
Assertions.assertEquals(2, retrieveExpand.remote.size());
|
||||
Assertions.assertEquals(retrieveExpand.remote.get(0).id, insertedRemote1.id);
|
||||
Assertions.assertEquals(retrieveExpand.remote.get(1).id, insertedRemote2.id);
|
||||
|
||||
|
@ -11,11 +11,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -33,22 +30,12 @@ public class TestManyToOne {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -11,11 +11,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -33,22 +30,12 @@ public class TestOneToMany {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -11,11 +11,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -28,22 +25,12 @@ public class TestRawQuery {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
@ -83,13 +70,13 @@ public class TestRawQuery {
|
||||
test.floatData = 7.0F;
|
||||
DataAccess.insert(test);
|
||||
{
|
||||
String query = """
|
||||
final String query = """
|
||||
SELECT *
|
||||
FROM TypesTable
|
||||
WHERE `intData` = ?
|
||||
ORDER BY id DESC
|
||||
""";
|
||||
List<Object> parameters = List.of(Integer.valueOf(99));
|
||||
final List<Object> parameters = List.of(Integer.valueOf(99));
|
||||
// Try to retrieve all the data:
|
||||
final List<TypesTable> retrieve = DataAccess.query(TypesTable.class, query, parameters);
|
||||
|
||||
@ -102,13 +89,13 @@ public class TestRawQuery {
|
||||
}
|
||||
{
|
||||
|
||||
String query = """
|
||||
final String query = """
|
||||
SELECT DISTINCT intData
|
||||
FROM TypesTable
|
||||
WHERE `intData` = ?
|
||||
ORDER BY id DESC
|
||||
""";
|
||||
List<Object> parameters = List.of(Integer.valueOf(99));
|
||||
final List<Object> parameters = List.of(Integer.valueOf(99));
|
||||
// Try to retrieve all the data:
|
||||
final List<TypesTable> retrieve = DataAccess.query(TypesTable.class, query, parameters);
|
||||
|
||||
|
@ -14,12 +14,9 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.dataAccess.QueryOptions;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -36,26 +33,15 @@ public class TestSimpleTable {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Clear the static test:
|
||||
idOfTheObject = null;
|
||||
startAction = null;
|
||||
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -14,11 +14,9 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.dataAccess.QueryOptions;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -36,26 +34,16 @@ public class TestSimpleTableSoftDelete {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Clear the static test:
|
||||
idOfTheObject = null;
|
||||
startAction = null;
|
||||
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -11,11 +11,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -29,22 +26,12 @@ public class TestTypeEnum1 {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -11,11 +11,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -29,22 +26,12 @@ public class TestTypeEnum2 {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -16,11 +16,8 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
import org.kar.archidata.dataAccess.DataAccess;
|
||||
import org.kar.archidata.dataAccess.DataFactory;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.tools.ConfigBaseVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -33,22 +30,12 @@ public class TestTypes {
|
||||
|
||||
@BeforeAll
|
||||
public static void configureWebServer() throws Exception {
|
||||
if (!"true".equalsIgnoreCase(System.getenv("TEST_E2E_MODE"))) {
|
||||
ConfigBaseVariable.dbType = "sqlite";
|
||||
ConfigBaseVariable.dbHost = "memory";
|
||||
// for test we need to connect all time the DB
|
||||
ConfigBaseVariable.dbKeepConnected = "true";
|
||||
}
|
||||
// Connect the dataBase...
|
||||
final DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
|
||||
entry.connect();
|
||||
ConfigureDb.configure();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void removeDataBase() throws IOException {
|
||||
LOGGER.info("Remove the test db");
|
||||
DBEntry.closeAllForceMode();
|
||||
ConfigBaseVariable.clearAllValue();
|
||||
ConfigureDb.clear();
|
||||
}
|
||||
|
||||
@Order(1)
|
||||
|
@ -1,8 +1,15 @@
|
||||
package test.kar.archidata.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.kar.archidata.model.GenericData;
|
||||
|
||||
public class TypeManyToManyRemote extends GenericData {
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
|
||||
public class TypeManyToManyRemote extends GenericData {
|
||||
@ManyToMany(fetch = FetchType.LAZY, targetEntity = TypeManyToManyRoot.class, mappedBy = "remote")
|
||||
public List<Long> remoteToParent;
|
||||
public String data;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user