/*
 * Copyright (c) 2008. All rights reserved.
 */
package ro.isdc.wro.model.resource.locator;

import java.io.IOException;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import ro.isdc.wro.util.WroTestUtils;

/**
 * Tests if {@link ClasspathUriLocator} works properly.
 *
 * @author Alex Objelean
 * @created Created on Nov 3, 2008
 */
public class TestClasspathUriLocator {
  /**
   * UriLocator to test.
   */
  private UriLocator uriLocator;

  @Before
  public void init() {
    uriLocator = new ClasspathUriLocator();
  }

  private String createUri(final String location) {
    return ClasspathUriLocator.PREFIX + location;
  }

  @Test
  public void resourceAvailable() throws IOException {
    Assert.assertNotNull(uriLocator.locate(createUri("test.css")));
  }

  @Test
  public void resourceAvailableWithTrailingSpaces() throws IOException {
    Assert.assertNotNull(uriLocator.locate(createUri(" test.css ")));
  }

  @Test
  public void testWildcardInexistentResources() throws IOException {
    uriLocator.locate(createUri("*.NOTEXIST"));
  }

  @Test
  public void testWildcard1Resources() throws IOException {
    WroTestUtils.compare(uriLocator.locate(createUri("ro/isdc/wro/http/*.merged")), uriLocator.locate(createUri("ro/isdc/wro/http/*.css")));
  }

  @Test
  public void testWildcard2Resources() throws IOException {
    uriLocator.locate(createUri("*.cs?"));
  }

  @Test
  public void testWildcard3Resources() throws IOException {
    uriLocator.locate(createUri("*.???"));
  }

  @Test
  public void testRecursiveWildcardResources() throws IOException {
    uriLocator.locate(createUri("**.css"));
  }


  @Test
  public void resourceUnavailable() {
    try {
      uriLocator.locate(createUri("123123.css"));
      Assert.fail("Should throw exception");
    } catch (final IOException e) {
      // TODO: handle exception
    }
  }
}

@@ -195,24 +195,59 @@
 unit.Test;%0A%0A
+import ro.isdc.wro.config.Context;%0A
 import ro.is
@@ -539,24 +539,70 @@
 id init() %7B%0A
+    Context.set(Context.standaloneContext());%0A
     uriLocat

fix failing test