Skip to content

Commit

Permalink
GitHub actions added (#506)
Browse files Browse the repository at this point in the history
GitHub actions added 

Signed-off-by: David Kral <[email protected]>
  • Loading branch information
Verdent authored Jul 29, 2021
1 parent 2fc86dd commit 4e3f67a
Show file tree
Hide file tree
Showing 6 changed files with 377 additions and 43 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v. 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0,
# or the Eclipse Distribution License v. 1.0 which is available at
# http://www.eclipse.org/org/documents/edl-v10.php.
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#

name: Yasson

on: [push, pull_request]

jobs:
build:
name: Test on JDK ${{ matrix.java_version }}
runs-on: ubuntu-latest

strategy:
matrix:
java_version: [ 11, 16 ]

steps:
- name: Checkout for build
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up compile JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 16
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Checkstyle
run: mvn -B -Pstaging checkstyle:checkstyle
- name: Copyright
run: bash etc/copyright.sh
- name: Yasson install
run: mvn -U -C -Pstaging clean install -DskipTests
- name: Set up JDK for tests
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java_version }}
- name: Yasson tests
run: mvn -U -C -Pstaging test
- name: JSONB-API TCK
run: cd yasson-tck && mvn -U -B test
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.eclipse/yasson.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/eclipse/yasson/)
[![Gitter](https://badges.gitter.im/eclipse/yasson.svg)](https://gitter.im/eclipse/yasson)
[![Javadocs](https://www.javadoc.io/badge/org.eclipse/yasson.svg)](https://www.javadoc.io/doc/org.eclipse/yasson)
[![Build Status](https://travis-ci.org/eclipse-ee4j/yasson.svg?branch=master)](https://travis-ci.org/eclipse-ee4j/yasson)
[![Build Status](https://github.com/eclipse-ee4j/yasson/actions/workflows/maven.yml/badge.svg?branch=master)](https://github.com/eclipse-ee4j/yasson/actions/workflows/maven.yml?branch=master)
[![License](https://img.shields.io/badge/License-EPL%201.0-green.svg)](https://opensource.org/licenses/EPL-1.0)

Yasson is a Java framework which provides a standard binding layer between Java classes and JSON documents. This is similar to what JAXB is doing in the XML world. Yasson is an official reference implementation of JSON Binding ([JSR-367](https://jcp.org/en/jsr/detail?id=367)).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -13,8 +13,10 @@
package org.eclipse.yasson.internal.serializer;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
import java.util.Optional;

import jakarta.json.bind.JsonbException;
Expand Down Expand Up @@ -56,14 +58,24 @@ protected final Optional<Number> deserializeFormatted(String jsonValue, boolean

final JsonbNumberFormatter numberFormat = getCustomization().getDeserializeNumberFormatter();
//consider synchronizing on format instance or per thread cache.
final NumberFormat format = NumberFormat
.getInstance(jsonbContext.getConfigProperties().getLocale(numberFormat.getLocale()));
Locale locale = jsonbContext.getConfigProperties().getLocale(numberFormat.getLocale());
final NumberFormat format = NumberFormat.getInstance(locale);
((DecimalFormat) format).applyPattern(numberFormat.getFormat());
format.setParseIntegerOnly(integerOnly);
try {
return Optional.of(format.parse(jsonValue));
return Optional.of(format.parse(compatibilityChanger(jsonValue, locale)));
} catch (ParseException e) {
throw new JsonbException(Messages.getMessage(MessageKeys.PARSING_NUMBER, jsonValue, numberFormat.getFormat()));
}
}

private String compatibilityChanger(String value, Locale locale) {
char beforeJdk13GroupSeparator = '\u00A0';
char frenchGroupingSeparator = DecimalFormatSymbols.getInstance(Locale.FRENCH).getGroupingSeparator();
if (locale.getLanguage().equals(Locale.FRENCH.getLanguage()) && beforeJdk13GroupSeparator != frenchGroupingSeparator) {
//JDK-8225245
return value.replace(beforeJdk13GroupSeparator, frenchGroupingSeparator);
}
return value;
}
}
12 changes: 9 additions & 3 deletions yasson-tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<properties>
<jsonb.tck.version>2.0.0-SNAPSHOT</jsonb.tck.version>
<yasson.version>2.0.1-SNAPSHOT</yasson.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<!-- TODO: Temporarily enable snapshot repository -->
Expand All @@ -28,13 +30,17 @@
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-tck</artifactId>
<version>${jsonb.tck.version}</version>
<scope>test</scope>
<!-- Limitation to the test scope has been temporarily removed due to NumberFormatCustomizationTest, once it is removed,
test scope will be enabled again-->
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>${yasson.version}</version>
<scope>test</scope>
<!-- Limitation to the test scope has been temporarily removed due to NumberFormatCustomizationTest, once it is removed,
test scope will be enabled again-->
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
Expand All @@ -45,7 +51,7 @@
<dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>4.0.0.Beta1</version>
<version>4.0.2.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Loading

0 comments on commit 4e3f67a

Please sign in to comment.