LinkageError:在pde环境中使用hamcrest运行junit测试时出现加载程序约束违规

时间:2015-05-07 14:33:27

标签: maven osgi-bundle eclipse-pde hamcrest linkageerror

我正在尝试使用junit和hamcrest来测试一个类。这是我的测试:

 @Test
public void testConvert()
{
    assertNull(converter.convert(null));
    assertNull(converter.convert(CommonentityFactory.eINSTANCE.createOrganization()));

    OrganizationMID organizationMID = OrganizationMID.create(DOMAIN, 1234L);
    String organizationName = "organizationName";

    com.demographics.app.commonentity.Organization fromOrganization = CommonentityFactory.eINSTANCE
            .createOrganization();
    fromOrganization.setMID(organizationMID);
    fromOrganization.setNameFormatted(organizationName);

    com.search.organization.ui.Organization organization = converter
            .convert(fromOrganization);
    assertThat(organization.getOrganizationMID(), is(organizationMID));
    assertThat(organization.getOrganizationName(), is(organizationName));
}

当我作为pde测试运行测试时,我明白了,

java.lang.LinkageError: loader constraint violation: loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) previously initiated loading for a different type with name "org/hamcrest/Matcher"

以下是我的导入:

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;

import org.junit.Test;

我正在使用org.junit v4.8.2-v370mockito-core v1.8.5org.hamcrest.osgi v1.1

我不确定这里有什么问题,但我觉得我没有在我的pom中设置依赖项。 任何人都可以帮我解决这个问题吗?

0 个答案:

没有答案