From 12041a6b3021ad44d194e1336ae924a05983b78a Mon Sep 17 00:00:00 2001 From: "A. J. David Bosschaert" Date: Thu, 8 Feb 2018 15:45:18 +0000 Subject: [PATCH] Add unit test for Version conversion. git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1823573 13f79535-47bb-0310-9956-ffa450edef68 --- .../osgi/util/converter/ConverterTest.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java b/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java index ddb7a73c009..903e65d24bf 100644 --- a/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java +++ b/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java @@ -63,6 +63,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.osgi.framework.Version; import org.osgi.util.converter.MyDTO.Count; import org.osgi.util.converter.MyEmbeddedDTO.Alpha; @@ -89,6 +90,15 @@ public void tearDown() { converter = null; } + @Test + public void testVersion() { + Version v =new Version(1,2,3,"qualifier"); + Converter c = Converters.standardConverter(); + String s = c.convert(v).to(String.class); + Version v2 = c.convert(s).to(Version.class); + assertEquals(v, v2); + } + @Test public void testSimpleConversions() { // Conversions to String @@ -752,9 +762,9 @@ public void testDTOWithGenerics() { @Test public void testMapToDTOWithGenerics() { Map dto = new HashMap<>(); - + dto.put("longList", Arrays.asList((short)999, "1000")); - + Map dtoMap = new LinkedHashMap<>(); dto.put("dtoMap", dtoMap); @@ -798,14 +808,14 @@ public void testMapToDTOWithGenericVariables() { dto.put("set", new HashSet<>(Arrays.asList("foo", (int) 'o', 'o'))); dto.put("raw", "1234"); dto.put("array", Arrays.asList("foo", (int) 'o', 'o')); - - MyGenericDTOWithVariables converted = + + MyGenericDTOWithVariables converted = converter.convert(dto).to(new TypeReference>() {}); assertEquals(Character.valueOf('1'), converted.raw); assertArrayEquals(new Character[] {'f', 'o', 'o'}, converted.array); assertEquals(new HashSet(Arrays.asList('f', 'o')), converted.set); } - + @Test public void testMapToDTOWithSurplusMapFiels() { Map m = new HashMap<>(); @@ -1191,7 +1201,7 @@ public void testLongArrayToLongCollection() { assertEquals(la[i], it.next()); } } - + @Test public void testMapToInterfaceWithGenerics() { Map dto = new HashMap<>(); @@ -1207,8 +1217,8 @@ public void testMapToInterfaceWithGenericVariables() { dto.put("set", new HashSet<>(Arrays.asList("foo", (int) 'o', 'o'))); dto.put("raw", "1234"); dto.put("array", Arrays.asList("foo", (int) 'o', 'o')); - - MyGenericInterfaceWithVariables converted = + + MyGenericInterfaceWithVariables converted = converter.convert(dto).to(new TypeReference>() {}); assertEquals(Character.valueOf('1'), converted.raw()); assertArrayEquals(new Character[] {'f', 'o', 'o'}, converted.array());