You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by da...@apache.org on 2018/02/08 15:45:18 UTC
svn commit: r1823573 -
/felix/trunk/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java
Author: davidb
Date: Thu Feb 8 15:45:18 2018
New Revision: 1823573
URL: http://svn.apache.org/viewvc?rev=1823573&view=rev
Log:
Add unit test for Version conversion.
Modified:
felix/trunk/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java
Modified: felix/trunk/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java?rev=1823573&r1=1823572&r2=1823573&view=diff
==============================================================================
--- felix/trunk/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java (original)
+++ felix/trunk/converter/converter/src/test/java/org/osgi/util/converter/ConverterTest.java Thu Feb 8 15:45:18 2018
@@ -63,6 +63,7 @@ import java.util.stream.Stream;
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;
@@ -90,6 +91,15 @@ public class ConverterTest {
}
@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
assertEquals("abc", converter.convert("abc").to(String.class));
@@ -752,9 +762,9 @@ public class ConverterTest {
@Test
public void testMapToDTOWithGenerics() {
Map<String, Object> dto = new HashMap<>();
-
+
dto.put("longList", Arrays.asList((short)999, "1000"));
-
+
Map<String, Object> dtoMap = new LinkedHashMap<>();
dto.put("dtoMap", dtoMap);
@@ -798,14 +808,14 @@ public class ConverterTest {
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<Character> converted =
+
+ MyGenericDTOWithVariables<Character> converted =
converter.convert(dto).to(new TypeReference<MyGenericDTOWithVariables<Character>>() {});
assertEquals(Character.valueOf('1'), converted.raw);
assertArrayEquals(new Character[] {'f', 'o', 'o'}, converted.array);
assertEquals(new HashSet<Character>(Arrays.asList('f', 'o')), converted.set);
}
-
+
@Test
public void testMapToDTOWithSurplusMapFiels() {
Map<String, String> m = new HashMap<>();
@@ -1191,7 +1201,7 @@ public class ConverterTest {
assertEquals(la[i], it.next());
}
}
-
+
@Test
public void testMapToInterfaceWithGenerics() {
Map<String, Object> dto = new HashMap<>();
@@ -1207,8 +1217,8 @@ public class ConverterTest {
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<Character> converted =
+
+ MyGenericInterfaceWithVariables<Character> converted =
converter.convert(dto).to(new TypeReference<MyGenericInterfaceWithVariables<Character>>() {});
assertEquals(Character.valueOf('1'), converted.raw());
assertArrayEquals(new Character[] {'f', 'o', 'o'}, converted.array());