Skip to content

Commit

Permalink
fix values in xml files
Browse files Browse the repository at this point in the history
  • Loading branch information
SerayaEryn committed Nov 1, 2018
1 parent 022799c commit 5a1a633
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/revane/loaders/XmlFileLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,16 @@ function getProperties (ref) {
if (Array.isArray(ref)) {
properties = ref.map(toReference)
} else {
properties = [{ ref: ref.attr.bean }]
properties = [toReference(ref)]
}
}
return properties
}

function toReference (ref) {
return { ref: ref.attr.bean }
if (ref.attr.bean) {
return { ref: ref.attr.bean }
} else {
return { value: ref.attr.value }
}
}
19 changes: 19 additions & 0 deletions test/revane.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ test('should create bean for module', (t) => {
})
})

test('should create bean for module with value', (t) => {
t.plan(2)

const options = {
basePackage: path.join(__dirname, '../../testdata'),
configurationFiles: [
path.join(__dirname, '../../testdata/xml/config4.xml')
],
componentScan: false
}
const revane = new Revane(options)
return revane.initialize()
.then(() => {
const bean = revane.get('xml2')
t.ok(bean)
t.equals(bean.xml1, 'xml1')
})
})

test('should read not reject on missing paths', (t) => {
t.plan(1)

Expand Down
7 changes: 7 additions & 0 deletions testdata/xml/config4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1" encoding="utf-8">

<beans>
<bean id="xml2" class="./xml/xml2">
<ref value="xml1"/>
</bean>
</beans>

0 comments on commit 5a1a633

Please sign in to comment.