|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2008 the original author or authors. |
| 2 | + * Copyright 2002-2009 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package org.springframework.beans;
|
18 | 18 |
|
19 | 19 | import static org.junit.Assert.*;
|
20 |
| - |
21 | 20 | import org.junit.Test;
|
22 |
| - |
23 | 21 | import test.beans.CustomEnum;
|
24 | 22 | import test.beans.GenericBean;
|
25 | 23 |
|
@@ -53,4 +51,62 @@ public void testCustomEnumWithEmptyString() {
|
53 | 51 | assertEquals(null, gb.getCustomEnum());
|
54 | 52 | }
|
55 | 53 |
|
| 54 | + @Test |
| 55 | + public void testCustomEnumArrayWithSingleValue() { |
| 56 | + GenericBean<?> gb = new GenericBean<Object>(); |
| 57 | + BeanWrapper bw = new BeanWrapperImpl(gb); |
| 58 | + bw.setPropertyValue("customEnumArray", "VALUE_1"); |
| 59 | + assertEquals(1, gb.getCustomEnumArray().length); |
| 60 | + assertEquals(CustomEnum.VALUE_1, gb.getCustomEnumArray()[0]); |
| 61 | + } |
| 62 | + |
| 63 | + @Test |
| 64 | + public void testCustomEnumArrayWithMultipleValues() { |
| 65 | + GenericBean<?> gb = new GenericBean<Object>(); |
| 66 | + BeanWrapper bw = new BeanWrapperImpl(gb); |
| 67 | + bw.setPropertyValue("customEnumArray", new String[] {"VALUE_1", "VALUE_2"}); |
| 68 | + assertEquals(2, gb.getCustomEnumArray().length); |
| 69 | + assertEquals(CustomEnum.VALUE_1, gb.getCustomEnumArray()[0]); |
| 70 | + assertEquals(CustomEnum.VALUE_2, gb.getCustomEnumArray()[1]); |
| 71 | + } |
| 72 | + |
| 73 | + @Test |
| 74 | + public void testCustomEnumArrayWithMultipleValuesAsCsv() { |
| 75 | + GenericBean<?> gb = new GenericBean<Object>(); |
| 76 | + BeanWrapper bw = new BeanWrapperImpl(gb); |
| 77 | + bw.setPropertyValue("customEnumArray", "VALUE_1,VALUE_2"); |
| 78 | + assertEquals(2, gb.getCustomEnumArray().length); |
| 79 | + assertEquals(CustomEnum.VALUE_1, gb.getCustomEnumArray()[0]); |
| 80 | + assertEquals(CustomEnum.VALUE_2, gb.getCustomEnumArray()[1]); |
| 81 | + } |
| 82 | + |
| 83 | + @Test |
| 84 | + public void testCustomEnumSetWithSingleValue() { |
| 85 | + GenericBean<?> gb = new GenericBean<Object>(); |
| 86 | + BeanWrapper bw = new BeanWrapperImpl(gb); |
| 87 | + bw.setPropertyValue("customEnumSet", "VALUE_1"); |
| 88 | + assertEquals(1, gb.getCustomEnumSet().size()); |
| 89 | + assertTrue(gb.getCustomEnumSet().contains(CustomEnum.VALUE_1)); |
| 90 | + } |
| 91 | + |
| 92 | + @Test |
| 93 | + public void testCustomEnumSetWithMultipleValues() { |
| 94 | + GenericBean<?> gb = new GenericBean<Object>(); |
| 95 | + BeanWrapper bw = new BeanWrapperImpl(gb); |
| 96 | + bw.setPropertyValue("customEnumSet", new String[] {"VALUE_1", "VALUE_2"}); |
| 97 | + assertEquals(2, gb.getCustomEnumSet().size()); |
| 98 | + assertTrue(gb.getCustomEnumSet().contains(CustomEnum.VALUE_1)); |
| 99 | + assertTrue(gb.getCustomEnumSet().contains(CustomEnum.VALUE_2)); |
| 100 | + } |
| 101 | + |
| 102 | + @Test |
| 103 | + public void testCustomEnumSetWithMultipleValuesAsCsv() { |
| 104 | + GenericBean<?> gb = new GenericBean<Object>(); |
| 105 | + BeanWrapper bw = new BeanWrapperImpl(gb); |
| 106 | + bw.setPropertyValue("customEnumSet", "VALUE_1,VALUE_2"); |
| 107 | + assertEquals(2, gb.getCustomEnumSet().size()); |
| 108 | + assertTrue(gb.getCustomEnumSet().contains(CustomEnum.VALUE_1)); |
| 109 | + assertTrue(gb.getCustomEnumSet().contains(CustomEnum.VALUE_2)); |
| 110 | + } |
| 111 | + |
56 | 112 | }
|
0 commit comments