Skip to content

Commit

Permalink
Add unit test for INI parsing with an enum
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemers committed Jan 28, 2020
1 parent b006f3f commit c105a4d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,26 @@ class ReflectionBuilderTest {
assertDestroyedEvents("listenerTwo", objects, 3); //2 beans defined after it + its own destroyed event
}

/**
* SHIRO-739
*/
@Test
void testEnum() {
def ini = new Ini()
ini.load '''
simpleBean = org.apache.shiro.config.SimpleBean
simpleBean.name = testEnum
simpleBean.simpleEnum = FOO
'''

ReflectionBuilder builder = new ReflectionBuilder();
Map<String, ?> objects = builder.buildObjects(ini.getSections().iterator().next());
assertThat(objects, aMapWithSize(greaterThan(0)))

SimpleBean bean = objects.get("simpleBean")
assertThat(bean.name, is("testEnum"))
assertThat(bean.simpleEnum, is(SimpleEnum.FOO))
}

/**
* @since 1.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class SimpleBean {
List<SimpleBean> simpleBeans;
List<String> stringList;
Map<String,Object> mapProp = new LinkedHashMap<String,Object>();
SimpleEnum simpleEnum;

public SimpleBean(){}
public SimpleBean(String name) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.shiro.config

enum SimpleEnum {
FOO,
BAR
}

0 comments on commit c105a4d

Please sign in to comment.