@Test
 public void getLocalRepositoryAsFilePathWithoutSlash()
     throws MalformedURLException, FileNotFoundException {
   PropertyResolver propertyResolver = createMock(PropertyResolver.class);
   File valid = FileUtils.getFileFromClasspath("configuration/localrepository");
   File validWithSlash = FileUtils.getFileFromClasspath("configuration/localrepository/");
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.settings")).andReturn(null);
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.useFallbackRepositories")).andReturn(null);
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.localRepository"))
       .andReturn(valid.getAbsolutePath())
       .atLeastOnce();
   replay(propertyResolver);
   MavenConfiguration config = new MavenConfigurationImpl(propertyResolver, PID);
   assertEquals(
       "Local repository", validWithSlash.toURI().toURL(), config.getLocalRepository().getURL());
   verify(propertyResolver);
 }
  @Test
  public void getLocalRepositoryFromSettingsWithSpace() throws FileNotFoundException {
    PropertyResolver propertyResolver = createMock(PropertyResolver.class);
    File validSettings = FileUtils.getFileFromClasspath("user settings/maven_user_settings.xml");
    expect(propertyResolver.get("org.ops4j.pax.url.mvn.localRepository")).andReturn(null);
    expect(propertyResolver.get("org.ops4j.pax.url.mvn.useFallbackRepositories")).andReturn(null);
    expect(propertyResolver.get("org.ops4j.pax.url.mvn.settings"))
        .andReturn(validSettings.getAbsolutePath());
    replay(propertyResolver);

    MavenConfiguration config = new MavenConfigurationImpl(propertyResolver, PID);
    String localRepository = config.getSettings().getLocalRepository();
    assertNotNull(localRepository);
    assertEquals("My path/.m2/repository", localRepository);
    verify(propertyResolver);
  }
  public TestContainer start() throws TestContainerException {
    ClassLoader parent = null;
    try {
      final Map<String, String> p = new HashMap<String, String>(m_properties);
      String folder = p.get("org.osgi.framework.storage");
      if (folder == null) {
        folder = System.getProperty("org.osgi.framework.storage");
      }
      if (folder == null) {
        // folder = System.getProperty( "user.home" ) + File.separator + "osgi";
        folder = getCache();
      }
      LOG.debug("Cache folder set to " + folder);
      FileUtils.delete(new File(folder));
      // load default stuff

      p.put("org.osgi.framework.storage", folder);
      //  System.setProperty( "org.osgi.vendor.framework", "org.ops4j.pax.exam" );

      p.put(
          "org.osgi.framework.system.packages.extra",
          "org.ops4j.pax.exam;version=" + skipSnapshotFlag(Info.getPaxExamVersion()));

      parent = Thread.currentThread().getContextClassLoader();
      // Thread.currentThread().setContextClassLoader( null );

      m_framework = m_frameworkFactory.newFramework(p);
      m_framework.init();

      installAndStartBundles(m_framework.getBundleContext());

      Thread.currentThread().setContextClassLoader(parent);

    } catch (Exception e) {
      throw new TestContainerException("Problem starting test container.", e);
    } finally {
      if (parent != null) {
        Thread.currentThread().setContextClassLoader(parent);
      }
    }
    return this;
  }
 @Test
 public void getRepossitoryPoliciesFromSettings()
     throws MalformedURLException, FileNotFoundException {
   PropertyResolver propertyResolver = createMock(PropertyResolver.class);
   File validSettings = FileUtils.getFileFromClasspath("settings-policies.xml");
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.repositories")).andReturn(null);
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote")).andReturn(null);
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.localRepository")).andReturn(null);
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.useFallbackRepositories"))
       .andReturn("false");
   expect(propertyResolver.get("org.ops4j.pax.url.mvn.settings"))
       .andReturn(validSettings.getAbsolutePath());
   replay(propertyResolver);
   MavenConfiguration config = new MavenConfigurationImpl(propertyResolver, PID);
   List<MavenRepositoryURL> repositories = config.getRepositories();
   assertEquals(1, repositories.size());
   MavenRepositoryURL mavenRepositoryURL = repositories.get(0);
   assertEquals("always", mavenRepositoryURL.getReleasesUpdatePolicy());
   assertEquals("never", mavenRepositoryURL.getSnapshotsUpdatePolicy());
   assertEquals("fail", mavenRepositoryURL.getReleasesChecksumPolicy());
   assertEquals("warn", mavenRepositoryURL.getSnapshotsChecksumPolicy());
   verify(propertyResolver);
 }