Package org.sonar.home.cache

Examples of org.sonar.home.cache.FileCache$Downloader


  @Rule
  public ExpectedException thrown = ExpectedException.none();

  @Test
  public void should_request_list_of_plugins() {
    FileCache cache = mock(FileCache.class);
    ServerClient server = mock(ServerClient.class);
    when(server.request("/deploy/plugins/index.txt")).thenReturn("checkstyle,true\nsqale,false");
    DefaultPluginsReferential downloader = new DefaultPluginsReferential(cache, server);

    List<RemotePlugin> plugins = downloader.pluginList();
View Full Code Here


    assertThat(plugins.get(1).isCore()).isFalse();
  }

  @Test
  public void should_download_plugin() throws Exception {
    FileCache cache = mock(FileCache.class);

    File pluginJar = temp.newFile();
    when(cache.get(eq("checkstyle-plugin.jar"), eq("fakemd5_1"), any(FileCache.Downloader.class))).thenReturn(pluginJar);

    ServerClient server = mock(ServerClient.class);
    DefaultPluginsReferential downloader = new DefaultPluginsReferential(cache, server);

    RemotePlugin plugin = new RemotePlugin("checkstyle", true)
View Full Code Here

public class FileCacheProviderTest {
  @Test
  public void provide() {
    FileCacheProvider provider = new FileCacheProvider();
    FileCache cache = provider.provide(new Settings());

    assertThat(cache).isNotNull();
    assertThat(cache.getDir()).isNotNull().exists();
  }
View Full Code Here

  @Test
  public void keep_singleton_instance() {
    FileCacheProvider provider = new FileCacheProvider();
    Settings settings = new Settings();
    FileCache cache1 = provider.provide(settings);
    FileCache cache2 = provider.provide(settings);

    assertThat(cache1).isSameAs(cache2);
  }
View Full Code Here

    Thread.currentThread().setContextClassLoader(initialThreadClassloader);
  }

  @Test
  public void extend_classloader_with_jdbc_driver() throws Exception {
    FileCache cache = mock(FileCache.class);

    File fakeDriver = new File(Resources.getResource(JdbcDriverHolderTest.class, "JdbcDriverHolderTest/jdbc-driver.jar").getFile());
    when(cache.get(eq("ojdbc14.jar"), eq("fakemd5"), any(FileCache.Downloader.class))).thenReturn(fakeDriver);

    /* jdbc-driver.jar has just one file /foo/foo.txt */
    assertThat(Thread.currentThread().getContextClassLoader().getResource("foo/foo.txt")).isNull();

    ServerClient server = mock(ServerClient.class);
View Full Code Here

    assertThat(holder.getClassLoader()).isNull();
  }

  @Test
  public void do_nothing_when_jdbc_driver_file_is_empty() throws Exception {
    FileCache cache = mock(FileCache.class);

    ServerClient server = mock(ServerClient.class);
    when(server.request("/deploy/jdbc-driver.txt")).thenReturn("");

    JdbcDriverHolder holder = new JdbcDriverHolder(cache, mode, server);
View Full Code Here

    assertThat(holder.getClassLoader()).isNull();
  }

  @Test
  public void be_disabled_if_preview() {
    FileCache cache = mock(FileCache.class);
    when(mode.isPreview()).thenReturn(true);
    ServerClient server = mock(ServerClient.class);
    JdbcDriverHolder holder = new JdbcDriverHolder(cache, mode, server);

    holder.start();
View Full Code Here

TOP

Related Classes of org.sonar.home.cache.FileCache$Downloader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.