org.jboss.arquillian.core.api.annotation.ApplicationScoped Java Examples

The following examples show how to use org.jboss.arquillian.core.api.annotation.ApplicationScoped. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JiraGovernorTestCase.java    From arquillian-governor with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {

    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);

    jiraGovernorConfiguration = new JiraGovernorConfiguration();
    jiraGovernorConfiguration.setServer(JIRA_SERVER_ADDRESS);
    jiraGovernorConfiguration.setUsername(USERNAME);
    jiraGovernorConfiguration.setPassword(PASSWORD);

    bind(ApplicationScoped.class, JiraGovernorConfiguration.class, jiraGovernorConfiguration);

    final JiraGovernorClient jiraGovernorClient = new JiraGovernorClientFactory().build(jiraGovernorConfiguration);
    bind(ApplicationScoped.class, JiraGovernorClient.class, jiraGovernorClient);
}
 
Example #2
Source File: BlurLevelTestCase.java    From arquillian-recorder with Apache License 2.0 6 votes vote down vote up
@Before
public void init() throws Exception {
    bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);
    bind(ApplicationScoped.class, ScreenshooterConfiguration.class, configuration);
    bind(ApplicationScoped.class, Screenshooter.class, screenshooter);
    bind(ApplicationScoped.class, RecorderStrategyRegister.class, recorderStrategyRegister);

    Mockito.when(screenshooter.getScreenshotType()).thenReturn(ScreenshotType.PNG);

    Mockito.doNothing().when(cleaner).clean(configuration);

    Mockito.when(serviceLoader.onlyOne(ScreenshooterEnvironmentCleaner.class, DefaultScreenshooterEnvironmentCleaner.class))
        .thenReturn(cleaner);

    screenshotFile = folder.newFile("screenshot.png");
    URL resource = BlurLevelTestCase.class.getResource("/arquillian_ui_success_256px.png");
    FileUtils.copyURLToFile(resource, screenshotFile);
    originalSize = (int) screenshotFile.length();
    OUTPUT_FILE = screenshotFile.getAbsoluteFile();
}
 
Example #3
Source File: RedmineGovernorTestCase.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {

    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);

    redminebGovernorConfiguration = new RedmineGovernorConfiguration();
    redminebGovernorConfiguration.setApiKey("apikey");
    redminebGovernorConfiguration.setServer("http://localhost");
    redminebGovernorConfiguration.setForce(true);
    redminebGovernorConfiguration.setClosePassed(true);

    bind(ApplicationScoped.class, RedmineGovernorConfiguration.class, redminebGovernorConfiguration);

    final RedmineGovernorClient redmineGovernorClient = new RedmineGovernorClientFactory().build(redminebGovernorConfiguration);
    bind(ApplicationScoped.class, RedmineGovernorClient.class, redmineGovernorClient);
}
 
Example #4
Source File: GitHubGovernorTestCase.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {

    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);

    gitHubGovernorConfiguration = new GitHubGovernorConfiguration();
    gitHubGovernorConfiguration.setRepository(REPOSITORY_NAME);
    gitHubGovernorConfiguration.setRepositoryUser(REPOSITORY_USERNAME);
    gitHubGovernorConfiguration.setForce(true);
    gitHubGovernorConfiguration.setClosePassed(true);

    if (!TOKEN.equals(EMPTY_STRING)) {
        gitHubGovernorConfiguration.setToken(TOKEN);
    }

    gitHubGovernorConfiguration.setUsername(USERNAME);
    gitHubGovernorConfiguration.setPassword(PASSWORD);

    bind(ApplicationScoped.class, GitHubGovernorConfiguration.class, gitHubGovernorConfiguration);

    final GitHubGovernorClient gitHubGovernorClient = new GitHubGovernorClientFactory().build(gitHubGovernorConfiguration);
    bind(ApplicationScoped.class, GitHubGovernorClient.class, gitHubGovernorClient);
}
 
Example #5
Source File: GovernorTestCase.java    From arquillian-governor with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    serviceProducer.set(serviceLoader);

    final List<GovernorProvider> governorProviders = new ArrayList<GovernorProvider>();
    governorProviders.add(governorProvider);

    Mockito.when(serviceLoader.all(GovernorProvider.class)).thenReturn(governorProviders);

    manager = Mockito.spy(getManager());
    Mockito.when(manager.resolve(ServiceLoader.class)).thenReturn(serviceLoader);

    governorConfiguration = new GovernorConfiguration();
    bind(ApplicationScoped.class, GovernorConfiguration.class, governorConfiguration);
}
 
Example #6
Source File: ScreenshooterLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@org.junit.Before
public void setMocks() throws Exception {
    bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);
    bind(ApplicationScoped.class, ScreenshooterConfiguration.class, configuration);
    bind(ApplicationScoped.class, Screenshooter.class, screenshooter);
    bind(ApplicationScoped.class, RecorderStrategyRegister.class, recorderStrategyRegister);

    Mockito.when(screenshooter.getScreenshotType()).thenReturn(ScreenshotType.PNG);

    Mockito.doNothing().when(cleaner).clean(configuration);

    Mockito.when(serviceLoader.onlyOne(ScreenshooterEnvironmentCleaner.class, DefaultScreenshooterEnvironmentCleaner.class))
        .thenReturn(cleaner);
}
 
Example #7
Source File: RecorderLifecycleObserverTestCase.java    From arquillian-recorder with Apache License 2.0 5 votes vote down vote up
@org.junit.Before
    public void setup() throws Exception {
        bind(ApplicationScoped.class, ServiceLoader.class, serviceLoader);
        bind(ApplicationScoped.class, VideoConfiguration.class, configuration);
        bind(ApplicationScoped.class, Recorder.class, recorder);
        bind(ApplicationScoped.class, TakenResourceRegister.class, takenResourceRegister);

        strategy.setConfiguration(configuration);
        bind(ApplicationScoped.class, VideoStrategy.class, strategy);

        Mockito.when(recorder.getVideoType()).thenReturn(VideoType.MP4);

        Mockito.doNothing().when(cleaner).clean(configuration);

        Mockito.when(serviceLoader.onlyOne(VideoRecorderEnvironmentCleaner.class, DefaultVideoRecorderEnvironmentCleaner.class))
            .thenReturn(cleaner);

//        Mockito.when(serviceLoader.onlyOne(VideoStrategy.class, DefaultVideoStrategy.class))
//            .thenReturn(strategy);

        videoFile = File.createTempFile("fakeVideo", recorder.getVideoType().toString().toLowerCase());

        Mockito.when(configuration.getVideoName()).thenReturn("record");

        Mockito.when(video.getResource()).thenReturn(videoFile);
        Mockito.when(video.getResourceType()).thenReturn(VideoType.MP4);
        Mockito.when(video.getWidth()).thenReturn(100);
        Mockito.when(video.getHeight()).thenReturn(100);

        Mockito.when(recorder.stopRecording()).thenReturn(video);
    }