forked from EsotericSoftware/kryo
-
Notifications
You must be signed in to change notification settings - Fork 0
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 EsotericSoftware#396 from magro/issue-364-charset-…
…serializer Adds Charset serializer
- Loading branch information
Showing
15 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
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
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
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 |
---|---|---|
|
@@ -15,22 +15,25 @@ | |
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
|
||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | ||
|
||
package com.esotericsoftware.kryo; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.nio.charset.Charset; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Calendar; | ||
import java.util.Collections; | ||
import java.util.Date; | ||
import java.util.EnumSet; | ||
import java.util.List; | ||
import java.util.Locale; | ||
import java.util.TimeZone; | ||
|
||
import com.esotericsoftware.kryo.io.Input; | ||
import com.esotericsoftware.kryo.io.Output; | ||
import java.util.Locale; | ||
|
||
/** @author Nathan Sweet <[email protected]> */ | ||
public class DefaultSerializersTest extends KryoTestCase { | ||
|
@@ -342,6 +345,26 @@ public void testLocaleSerializer () { | |
roundTrip(16, 16, new Locale("es", "ES", "áéíóú")); | ||
} | ||
|
||
public void testCharset() { | ||
List<String> css = Arrays.asList("ISO-8859-1", "US-ASCII", "UTF-8", "UTF-16", "UTF-16BE", "UTF-16LE"); | ||
|
||
for(String cs : css) { | ||
Charset charset = Charset.forName(cs); | ||
kryo.register(charset.getClass()); | ||
int expectedLength = 1 + cs.length(); | ||
roundTrip(expectedLength, expectedLength, charset); | ||
} | ||
|
||
kryo = new Kryo(); | ||
kryo.setRegistrationRequired(false); | ||
|
||
for(String cs : css) { | ||
Charset charset = Charset.forName(cs); | ||
int expectedLength = 3 + charset.getClass().getName().length() + cs.length(); | ||
roundTrip(expectedLength, expectedLength, charset); | ||
} | ||
} | ||
|
||
public enum TestEnum { | ||
a, b, c | ||
} | ||
|
@@ -373,4 +396,4 @@ public BigIntegerSubclass(String val) { | |
} | ||
} | ||
|
||
} | ||
} |
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.