Integration tests and the Atlassian Spring Scanner

KPSA July 21, 2016

Hi!

I'm trying to develop a JIRA plugin and having a hard time with the Spring-Scanner. I've managed to export the component I need now, I guess. It's showing up as an exported service in the OSGI console.

However, I wrote a integration test using this component, but it seems, that the test-plugin isn't using the spring scanner at all. There's no META-INF/plugin-components directory in its jar, for instance.

Isn't this supported? Am I on the wrong track here? Has anybody wrote an integration test using autowiring in the spring scanner?

Thanks.

Kind regards

Dennis

 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
KPSA August 22, 2016

Yes, it seems, that the spring scanner currently isn't supported for integration tests. I've used the old "component-import" plugin module as a fallback. That works. The setup is like this:

 

<atlassian-plugin key="${project.groupId}.${project.artifactId}-tests" name="${project.name}" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}" />
    </plugin-info>
    <component-import key="myComponent"
                      interface="com.example.MyComponentInterface"/>
</atlassian-plugin>
(...)
@Scanned
@RunWith(AtlassianPluginsTestRunner.class)
public class MyIntegrationTest {
 
  private final MyComponentInterface myComponent;
 
  public MyIntegrationTest(final MyComponentInterface myComponent) {
    this.myComponent = myComponent;
  }
 
(...)
 
}
0 votes
Marthinus Engelbrecht August 22, 2016

I'm having similar issues. I've used `@InjectMocks` from Mockito to mock out dependencies, but I'm having trouble injecting the real component.  

 

TAGS
AUG Leaders

Atlassian Community Events