aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/container/xml/bind/JAXBContextFactoryTest.java
blob: 670b69516bf1afec14be2bab4199ed437b926e06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.xml.bind;

import org.junit.Test;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

/**
 * @author einarmr
 * @author gjoranv
 * @since 5.3
 */
@SuppressWarnings("deprecation")
public class JAXBContextFactoryTest {
    @Test
    public void testInstantiationAndDestruction() {

        com.yahoo.container.xml.providers.JAXBContextFactoryProvider provider = new com.yahoo.container.xml.providers.JAXBContextFactoryProvider();
        JAXBContextFactory factory = provider.get();
        assertThat(factory.getClass().getName(), equalTo(com.yahoo.container.xml.providers.JAXBContextFactoryProvider.FACTORY_CLASS));

        try {
            JAXBContextFactory.getContextPath((Class) null);
            fail("Should have failed with null classes.");
        } catch (Exception e) { }

        try {
            JAXBContextFactory.getContextPath();
            fail("Should have failed with empty list.");
        } catch (Exception e) { }

        assertThat(JAXBContextFactory.getContextPath(this.getClass()),
                equalTo(this.getClass().getPackage().getName()));

        assertThat(JAXBContextFactory.getContextPath(this.getClass(),
                String.class),
                equalTo(this.getClass().getPackage().getName() + ":" +
                        String.class.getPackage().getName()));

        provider.deconstruct();

    }
}