Package com.github.dandelion.core.storage

Examples of com.github.dandelion.core.storage.AssetStorageUnit


    assertThat(location).isEqualTo("/context" + CONTEXT_RELATIVE_URL);
  }

  @Test
  public void should_return_the_processed_context_relative_url() {
    AssetStorageUnit asu = new AssetStorageUnit("my.js", singletonMap("webapp", CONTEXT_ABSOLUTE_URL));
    String location = locator.getLocation(asu, request);
    assertThat(location).isEqualTo(CONTEXT_ABSOLUTE_URL);
  }
View Full Code Here


  public void should_throw_an_exception_when_the_asset_has_no_location() {
    exception.expect(DandelionException.class);
    exception
        .expectMessage("No location is configured for the asset 'asset-name' (js, v1.0.0). Please add at least one location in the corresponding JSON file.");

    AssetStorageUnit asu = new AssetStorageUnit();
    asu.setName("asset-name");
    asu.setType(AssetType.js);
    asu.setVersion("1.0.0");
    assetMapper.mapToAsset(asu);
  }
View Full Code Here

  public void should_throw_an_exception_when_the_asset_has_empty_locations() {
    exception.expect(DandelionException.class);
    exception
        .expectMessage("No location is configured for the asset 'asset-name' (js, v1.0.0). Please add at least one location in the corresponding JSON file.");

    AssetStorageUnit asu = new AssetStorageUnit();
    asu.setName("asset-name");
    asu.setType(AssetType.js);
    asu.setVersion("1.0.0");
    asu.setLocations(Collections.<String, String>emptyMap());
    assetMapper.mapToAsset(asu);
  }
View Full Code Here

  public void should_throw_an_exception_when_the_asset_has_an_unknown_location() {
    exception.expect(DandelionException.class);
    exception.expectMessage("The location key 'foo' is not valid. Please choose a valid one among "
        + context.getAssetLocatorsMap().keySet() + ".");

    AssetStorageUnit asu = new AssetStorageUnit();
    asu.setName("asset-name");
    asu.setType(AssetType.js);
    asu.setVersion("1.0.0");
    asu.setLocations(singletonMap("foo", "/assets/js/asset-name.js"));
    assetMapper.mapToAsset(asu);
  }
View Full Code Here

  }

  @Test
  public void should_select_webapp_as_a_first_authorized_location() {

    AssetStorageUnit asu = new AssetStorageUnit();
    asu.setName("asset-name");
    asu.setType(AssetType.js);
    asu.setVersion("1.0.0");

    Map<String, String> locations = new HashMap<String, String>();
    locations.put("cdn", "//asset-name.js");
    locations.put("webapp", "/assets/js/asset-name.js");
    locations.put("classpath", "/foo/bar/asset-name.js");
    asu.setLocations(locations);
    Asset asset = assetMapper.mapToAsset(asu);
    assertThat(asset.getConfigLocation()).isEqualTo("/assets/js/asset-name.js");
    assertThat(asset.getConfigLocationKey()).isEqualTo("webapp");
    assertThat(asset.getFinalLocation()).isEqualTo("/context/assets/js/asset-name.js");
  }
View Full Code Here

  public void should_throw_an_exception_when_using_an_empty_location(){
    exception.expect(DandelionException.class);
    exception
        .expectMessage("The asset 'my.js' (js, v1.0.0) configured with a 'cdn' location key has a blank location. Please correct this location in the corresponding JSON file.");
   
    AssetStorageUnit asu = new AssetStorageUnit("my.js", "1.0.0", AssetType.js, singletonMap("cdn", ""));
    locator.getLocation(asu, request);
  }
View Full Code Here

    locator.getLocation(asu, request);
  }
 
  @Test
  public void should_return_the_same_absolute_url() {
    AssetStorageUnit asu = new AssetStorageUnit("my.js", singletonMap("cdn", absolute_url));
    String location = locator.getLocation(asu, request);
    assertThat(location).isEqualTo(absolute_url);
  }
View Full Code Here

  }

  @Test
  public void should_select_cdn_as_a_second_authorized_location() {

    AssetStorageUnit asu = new AssetStorageUnit();
    asu.setName("asset-name");
    asu.setType(AssetType.js);
    asu.setVersion("1.0.0");

    Map<String, String> locations = new HashMap<String, String>();
    locations.put("classpath", "foo/bar/asset-name.js");
    locations.put("cdn", "//my.domain/asset-name.js");
    asu.setLocations(locations);
    Asset asset = assetMapper.mapToAsset(asu);
    assertThat(asset.getConfigLocation()).isEqualTo("//my.domain/asset-name.js");
    assertThat(asset.getConfigLocationKey()).isEqualTo("cdn");
    assertThat(asset.getFinalLocation()).isEqualTo("//my.domain/asset-name.js");
  }
View Full Code Here

    assertThat(location).isEqualTo(absolute_url);
  }

  @Test
  public void should_return_the_same_protocol_relative_url() {
    AssetStorageUnit asu = new AssetStorageUnit("my.js", singletonMap("cdn", protocol_relative_url));
    String location = locator.getLocation(asu, request);
    assertThat(location).isEqualTo(protocol_relative_url);
  }
View Full Code Here

  }

  @Test
  public void should_return_the_content() {
    String filePath = new File("src/test/resources/locator/asset.js").toURI().toString();
    AssetStorageUnit asu = new AssetStorageUnit("my.js", singletonMap("cdn", filePath));
    String content = locator.getContent(asu, request);
    assertThat(content).isEqualTo("/* content */");
  }
 
View Full Code Here

TOP

Related Classes of com.github.dandelion.core.storage.AssetStorageUnit

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.