Package ro.isdc.wro.model.resource.factory

Source Code of ro.isdc.wro.model.resource.factory.TestUriLocatorFactory

/**
* Copyright Alex Objelean
*/
package ro.isdc.wro.model.resource.factory;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import ro.isdc.wro.WroRuntimeException;
import ro.isdc.wro.config.Context;
import ro.isdc.wro.model.resource.locator.ClasspathUriLocator;
import ro.isdc.wro.model.resource.locator.factory.SimpleUriLocatorFactory;
import ro.isdc.wro.util.WroUtil;


/**
* Test class for {@link SimpleUriLocatorFactory}.
*
* @author Alex Objelean
*/
public class TestUriLocatorFactory {
  private SimpleUriLocatorFactory factory;
 
  @BeforeClass
  public static void onBeforeClass() {
    assertEquals(0, Context.countActive());
  }
 
  @AfterClass
  public static void onAfterClass() {
    assertEquals(0, Context.countActive());
  }
 
  @Before
  public void setUp() {
    factory = new SimpleUriLocatorFactory();
  }
 
  @Test(expected = WroRuntimeException.class)
  public void cannotLocateNullUri()
      throws Exception {
    factory.locate(null);
  }
 
  @Test(expected = WroRuntimeException.class)
  public void shouldFailWhenNoCapableLocatorAvailable()
      throws Exception {
    factory.addLocator(new ClasspathUriLocator());
    factory.locate("http://www.google.com");
  }
 
  @Test
  public void testValidUri()
      throws Exception {
    factory.addLocator(new ClasspathUriLocator());
    assertNotNull(factory.locate("classpath:" + WroUtil.toPackageAsFolder(TestUriLocatorFactory.class)));
  }
}
TOP

Related Classes of ro.isdc.wro.model.resource.factory.TestUriLocatorFactory

TOP
Copyright © 2018 www.massapi.com. 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.