Example #1
0
  public static void testBumpSubBuilders() throws Exception {
    File tmp = new File("tmp-ws");
    if (tmp.exists()) IO.deleteWithException(tmp);
    tmp.mkdir();
    assertTrue(tmp.isDirectory());

    try {
      IO.copy(new File("test/ws"), tmp);
      Workspace ws = Workspace.getWorkspace(tmp);
      Project project = ws.getProject("bump-sub");
      project.setTrace(true);

      assertNull(project.getProperty("Bundle-Version"));

      project.bump("=+0");

      assertNull(project.getProperty("Bundle-Version"));

      for (Builder b : project.getSubBuilders()) {
        assertEquals(new Version(1, 1, 0), new Version(b.getVersion()));
      }
    } finally {
      IO.deleteWithException(tmp);
    }
  }
Example #2
0
  public static void testBumpIncludeFile() throws Exception {
    File tmp = new File("tmp-ws");
    if (tmp.exists()) IO.deleteWithException(tmp);
    tmp.mkdir();
    assertTrue(tmp.isDirectory());

    try {
      IO.copy(new File("test/ws"), tmp);
      Workspace ws = Workspace.getWorkspace(tmp);
      Project project = ws.getProject("bump-included");
      project.setTrace(true);
      Version old = new Version(project.getProperty("Bundle-Version"));
      assertEquals(new Version(1, 0, 0), old);
      project.bump("=+0");

      Processor processor = new Processor();
      processor.setProperties(project.getFile("include.txt"));

      Version newv = new Version(processor.getProperty("Bundle-Version"));
      System.err.println("New version " + newv);
      assertEquals(1, newv.getMajor());
      assertEquals(1, newv.getMinor());
      assertEquals(0, newv.getMicro());
    } finally {
      IO.deleteWithException(tmp);
    }
  }
Example #3
0
  /** Check isStale */
  public static void testIsStale() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("test/ws"));
    ws.setOffline(false);
    Project top = ws.getProject("p-stale");
    assertNotNull(top);
    top.build();
    Project bottom = ws.getProject("p-stale-dep");
    assertNotNull(bottom);
    bottom.build();

    long lastModified = bottom.lastModified();
    top.getPropertiesFile().setLastModified(lastModified + 1000);

    stale(top, true);
    stale(bottom, true);
    assertTrue(top.isStale());
    assertTrue(bottom.isStale());

    stale(top, false);
    stale(bottom, true);
    assertTrue(top.isStale());
    assertTrue(bottom.isStale());

    stale(top, true);
    stale(bottom, false);
    assertTrue(top.isStale());
    assertFalse(bottom.isStale());

    // Thread.sleep(1000);
    // stale(top, false);
    // stale(bottom, false);
    // assertFalse(top.isStale());
    // assertFalse(bottom.isStale());
  }
Example #4
0
  /** Check if the getSubBuilders properly predicts the output. */
  public static void testSubBuilders() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("test/ws"));
    Project project = ws.getProject("p4-sub");

    Collection<? extends Builder> bs = project.getSubBuilders();
    assertNotNull(bs);
    assertEquals(3, bs.size());
    Set<String> names = new HashSet<String>();
    for (Builder b : bs) {
      names.add(b.getBsn());
    }
    assertTrue(names.contains("p4-sub.a"));
    assertTrue(names.contains("p4-sub.b"));
    assertTrue(names.contains("p4-sub.c"));

    File[] files = project.build();
    assertTrue(project.check());

    System.err.println(Processor.join(project.getErrors(), "\n"));
    System.err.println(Processor.join(project.getWarnings(), "\n"));
    assertEquals(0, project.getErrors().size());
    assertEquals(0, project.getWarnings().size());
    assertNotNull(files);
    assertEquals(3, files.length);
    for (File file : files) {
      Jar jar = new Jar(file);
      Manifest m = jar.getManifest();
      assertTrue(names.contains(m.getMainAttributes().getValue("Bundle-SymbolicName")));
    }
  }
Example #5
0
  public static void testBump() throws Exception {
    File tmp = new File("tmp-ws");
    if (tmp.exists()) IO.deleteWithException(tmp);
    tmp.mkdir();
    assertTrue(tmp.isDirectory());

    try {
      IO.copy(new File("test/ws"), tmp);
      Workspace ws = Workspace.getWorkspace(tmp);
      Project project = ws.getProject("p1");
      int size = project.getProperties().size();
      Version old = new Version(project.getProperty("Bundle-Version"));
      System.err.println("Old version " + old);
      project.bump("=+0");
      Version newv = new Version(project.getProperty("Bundle-Version"));
      System.err.println("New version " + newv);
      assertEquals(old.getMajor(), newv.getMajor());
      assertEquals(old.getMinor() + 1, newv.getMinor());
      assertEquals(0, newv.getMicro());
      assertEquals(size, project.getProperties().size());
      assertEquals("sometime", newv.getQualifier());
    } finally {
      IO.deleteWithException(tmp);
    }
  }
Example #6
0
  @Override
  protected void setUp() throws Exception {
    tmp = IO.getFile("generated/tmp");
    tmp.mkdirs();
    IO.copy(IO.getFile("testdata/ws"), tmp);
    workspace = Workspace.getWorkspace(tmp);
    workspace.refresh();

    InfoRepository repo = workspace.getPlugin(InfoRepository.class);
    t1 = create("bsn-1", new Version(1, 0, 0));
    t2 = create("bsn-2", new Version(1, 0, 0));

    repo.put(new FileInputStream(t1), null);
    repo.put(new FileInputStream(t2), null);
    t1 = repo.get("bsn-1", new Version(1, 0, 0), null);
    t2 = repo.get("bsn-2", new Version(1, 0, 0), null);
    repo.put(new FileInputStream(IO.getFile("generated/biz.aQute.remote.launcher.jar")), null);

    workspace.getPlugins().add(repo);

    File storage = IO.getFile("generated/storage-1");
    storage.mkdirs();

    configuration = new HashMap<String, Object>();
    configuration.put(
        Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
    configuration.put(Constants.FRAMEWORK_STORAGE, storage.getAbsolutePath());

    configuration.put(
        Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "org.osgi.framework.launch;version=1.2");

    framework = new org.apache.felix.framework.FrameworkFactory().newFramework(configuration);
    framework.init();
    framework.start();
    context = framework.getBundleContext();
    location = "reference:" + IO.getFile("generated/biz.aQute.remote.agent.jar").toURI().toString();
    agent = context.installBundle(location);
    agent.start();

    thread =
        new Thread() {
          @Override
          public void run() {
            try {
              Main.main(
                  new String[] {
                    "-s", "generated/storage", "-c", "generated/cache", "-p", "1090", "-et"
                  });
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        };
    thread.setDaemon(true);
    thread.start();

    super.setUp();
  }
Example #7
0
 private static Project testBuildAll(String dependsOn, int count) throws Exception {
   Workspace ws = new Workspace(new File("test/ws"));
   Project all = ws.getProject("build-all");
   all.setProperty("-dependson", dependsOn);
   all.prepare();
   Collection<Project> dependson = all.getDependson();
   assertEquals(count, dependson.size());
   return all;
 }
Example #8
0
 /* to maintain hashCode contract */
 public int hashCode() {
   if (id == -1) {
     if (isPersistant()) {
       id = Workspace.makeGuid();
     } else {
       id = Workspace.nextId();
     }
   }
   return id;
 }
Example #9
0
 /**
  * Check multiple repos
  *
  * @throws Exception
  */
 public static void testMultipleRepos() throws Exception {
   Workspace ws = Workspace.getWorkspace(new File("test/ws"));
   Project project = ws.getProject("p1");
   System.err.println(
       project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.EXACT, null));
   System.err.println(
       project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.HIGHEST, null));
   System.err.println(
       project.getBundle("org.apache.felix.configadmin", "1.1.0", Strategy.LOWEST, null));
 }
Example #10
0
 /** Duplicates in runbundles gave a bad error, should be ignored */
 public static void testRunbundleDuplicates() throws Exception {
   Workspace ws = new Workspace(new File("test/ws"));
   Project top = ws.getProject("p1");
   top.clear();
   top.setProperty("-runbundles", "org.apache.felix.configadmin,org.apache.felix.configadmin");
   Collection<Container> runbundles = top.getRunbundles();
   assertTrue(top.check("Multiple bundles with the same final URL"));
   assertNotNull(runbundles);
   assertEquals(1, runbundles.size());
 }
Example #11
0
 /** Test 2 equal bsns but diff. versions */
 public static void testSameBsnRunBundles() throws Exception {
   Workspace ws = new Workspace(new File("test/ws"));
   Project top = ws.getProject("p1");
   top.setProperty(
       "-runbundles",
       "org.apache.felix.configadmin;version='[1.0.1,1.0.1]',org.apache.felix.configadmin;version='[1.1.0,1.1.0]'");
   Collection<Container> runbundles = top.getRunbundles();
   assertTrue(top.check());
   assertNotNull(runbundles);
   assertEquals(2, runbundles.size());
 }
Example #12
0
 /** Test bnd.bnd of project `foo`: `-runbundles: foo;version=latest` */
 public static void testRunBundlesContainsSelf() throws Exception {
   Workspace ws = new Workspace(new File("test/ws"));
   Project top = ws.getProject("p1");
   top.setProperty("-runbundles", "p1;version=latest");
   top.setChanged();
   top.isStale();
   Collection<Container> runbundles = top.getRunbundles();
   assertTrue(top.check("Circular dependency"));
   assertNotNull(runbundles);
   assertEquals(0, runbundles.size());
 }
  public static void testParseSystemCapabilities() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("src/test/ws"));
    Project project = ws.getProject("p1");

    ProjectLauncherImpl launcher = new ProjectLauncherImpl(project);
    launcher.prepare();

    String systemCaps = launcher.getSystemCapabilities();
    assertEquals(
        "osgi.native;osgi.native.osname:List<String>=\"Win7,Windows7,Windows 7\";osgi.native.osversion:Version=6.1",
        systemCaps);
  }
Example #14
0
  /*
   * Launches against the agent& main
   */
  public void testAgentAndMain() throws Exception {
    Project project = workspace.getProject("p1");
    Run bndrun = new Run(workspace, project.getBase(), project.getFile("one.bndrun"));
    bndrun.setProperty("-runpath", "biz.aQute.remote.launcher");
    bndrun.setProperty("-runbundles", "bsn-1,bsn-2");
    bndrun.setProperty("-runremote", "agent,main;agent=1090");

    final RemoteProjectLauncherPlugin pl =
        (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher();
    pl.prepare();

    List<? extends RunSession> sessions = pl.getRunSessions();
    assertEquals(2, sessions.size());

    RunSession agent = sessions.get(0);
    RunSession main = sessions.get(1);

    CountDownLatch agentLatch = launch(agent);
    CountDownLatch mainLatch = launch(main);

    agent.waitTillStarted(1000);
    main.waitTillStarted(1000);
    Thread.sleep(500);

    agent.cancel();
    main.cancel();

    agentLatch.await();
    mainLatch.await();
    assertEquals(-3, agent.getExitCode());
    assertEquals(-3, main.getExitCode());

    bndrun.close();
  }
 @Override
 public void startup(IProgressMonitor monitor) {
   job = new CharsetManagerJob();
   resourceChangeListener = new ResourceChangeListener();
   workspace.addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
   charsetListener = new CharsetDeltaJob(workspace);
   charsetListener.startup();
 }
  private void bindCheckNeedUpdate(Workspace workspace) {
    doUpdateCityWeather(true);
    workspace.setCheckNeedUpdateListener(
        new com.moji.mjweather.view.Workspace.OnCheckNeedUpdateListener() {

          public void onCheckNeedUpdate(int i) {
            doUpdateCityWeather(true);
          }
        });
  }
Example #17
0
  public static void testRunBuilds() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("test/ws"));

    // Running a .bnd includes built bundles by default
    Project p1 = ws.getProject("p1");
    assertTrue(p1.getRunBuilds());

    // Can override the default by specifying -runbuilds: false
    Project p2 = ws.getProject("p2");
    assertFalse(p2.getRunBuilds());

    // Running a .bndrun DOES NOT include built bundles by default
    Project p1a = new Project(ws, new File("test/ws/p1"), new File("test/ws/p1/p1a.bndrun"));
    assertFalse(p1a.getRunBuilds());

    // ... unless we override the default by specifying -runbuilds: true
    Project p1b = new Project(ws, new File("test/ws/p1"), new File("test/ws/p1/p1b.bndrun"));
    assertTrue(p1b.getRunBuilds());
  }
Example #18
0
  @Override
  public void created(Project p) throws IOException {
    Workspace workspace = p.getWorkspace();

    copy("pom.xml", "pom.xml", p);

    File root = workspace.getFile("pom.xml");

    doRoot(p, root);

    String rootPom = IO.collect(root);
    if (!rootPom.contains(getTag(p))) {
      rootPom =
          rootPom.replaceAll(
              "<!-- DO NOT EDIT MANAGED BY BND MAVEN LIFECYCLE PLUGIN -->\n",
              "$0\n\t\t" + getTag(p) + "\n");
      IO.store(rootPom, root);
    }
  }
  public static void testParseRunProperties() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("src/test/ws"));
    Project project = ws.getProject("p1");

    ProjectLauncherImpl launcher = new ProjectLauncherImpl(project);
    launcher.prepare();

    String arg = launcher.getRunVM().iterator().next();
    String s = "-D" + LauncherConstants.LAUNCHER_PROPERTIES + "=";
    String propertiesPath = arg.substring(s.length());
    Matcher matcher = Pattern.compile("^([\"'])(.*)\\1$").matcher(propertiesPath);
    if (matcher.matches()) {
      propertiesPath = matcher.group(2);
    }

    Properties launchProps = new Properties();
    launchProps.load(new FileInputStream(new File(propertiesPath)));
    assertEquals(
        new File("src/test/ws/p1/generated/p1.jar").getAbsolutePath(),
        launchProps.get("launch.bundles"));
  }
Example #20
0
  public static void testRepoMacro() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("test/ws"));
    Project project = ws.getProject("p2");
    System.err.println(project.getPlugins(FileRepo.class));
    String s = project.getReplacer().process(("${repo;libtest}"));
    System.err.println(s);
    assertTrue(
        s.contains(
            "org.apache.felix.configadmin"
                + File.separator
                + "org.apache.felix.configadmin-1.2.0"));
    assertTrue(
        s.contains("org.apache.felix.ipojo" + File.separator + "org.apache.felix.ipojo-1.0.0.jar"));

    s = project.getReplacer().process(("${repo;libtestxyz}"));
    assertTrue(s.matches("<<[^>]+>>"));

    s = project.getReplacer().process("${repo;org.apache.felix.configadmin;1.0.0;highest}");
    assertTrue(s.endsWith("org.apache.felix.configadmin-1.2.0.jar"));
    s = project.getReplacer().process("${repo;org.apache.felix.configadmin;1.0.0;lowest}");
    assertTrue(s.endsWith("org.apache.felix.configadmin-1.0.1.jar"));
  }
  /**
   * Returns the charset explicitly set by the user for the given resource, or <code>null</code>. If
   * no setting exists for the given resource and <code>recurse</code> is <code>true</code>, every
   * parent up to the workspace root will be checked until a charset setting can be found.
   *
   * @param resourcePath the path for the resource
   * @param recurse whether the parent should be queried
   * @return the charset setting for the given resource
   */
  public String getCharsetFor(IPath resourcePath, boolean recurse) {
    Assert.isLegal(resourcePath.segmentCount() >= 1);
    IProject project = workspace.getRoot().getProject(resourcePath.segment(0));

    Preferences prefs = getPreferences(project, false, false);
    Preferences derivedPrefs = getPreferences(project, false, true);

    if (prefs == null && derivedPrefs == null)
      // no preferences found - for performance reasons, short-circuit
      // lookup by falling back to workspace's default setting
      return recurse ? ResourcesPlugin.getEncoding() : null;

    return internalGetCharsetFor(prefs, derivedPrefs, resourcePath, recurse);
  }
Example #22
0
  /*
   * Launches against the agent
   */
  public void testSimpleLauncher() throws Exception {
    Project project = workspace.getProject("p1");
    Run bndrun = new Run(workspace, project.getBase(), project.getFile("one.bndrun"));
    bndrun.setProperty("-runpath", "biz.aQute.remote.launcher");
    bndrun.setProperty("-runbundles", "bsn-1,bsn-2");
    bndrun.setProperty("-runremote", "test");

    final RemoteProjectLauncherPlugin pl =
        (RemoteProjectLauncherPlugin) bndrun.getProjectLauncher();
    pl.prepare();
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicInteger exitCode = new AtomicInteger(-1);

    List<? extends RunSession> sessions = pl.getRunSessions();
    assertEquals(1, sessions.size());

    final RunSession session = sessions.get(0);

    Thread t =
        new Thread("test-launch") {
          public void run() {
            try {
              exitCode.set(session.launch());
            } catch (Exception e) {
              e.printStackTrace();
            } finally {
              latch.countDown();
            }
          }
        };
    t.start();
    Thread.sleep(500);

    for (Bundle b : context.getBundles()) {
      System.out.println(b.getLocation());
    }
    assertEquals(4, context.getBundles().length);
    String p1 = t1.getAbsolutePath();
    System.out.println(p1);

    assertNotNull(context.getBundle(p1));
    assertNotNull(context.getBundle(t2.getAbsolutePath()));

    pl.cancel();
    latch.await();

    assertEquals(-3, exitCode.get());

    bndrun.close();
  }
 public void setCharsetFor(IPath resourcePath, String newCharset) throws CoreException {
   // for the workspace root we just set a preference in the instance scope
   if (resourcePath.segmentCount() == 0) {
     IEclipsePreferences resourcesPreferences =
         InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
     if (newCharset != null) resourcesPreferences.put(ResourcesPlugin.PREF_ENCODING, newCharset);
     else resourcesPreferences.remove(ResourcesPlugin.PREF_ENCODING);
     try {
       resourcesPreferences.flush();
     } catch (BackingStoreException e) {
       IProject project = workspace.getRoot().getProject(resourcePath.segment(0));
       String message = Messages.resources_savingEncoding;
       throw new ResourceException(
           IResourceStatus.FAILED_SETTING_CHARSET, project.getFullPath(), message, e);
     }
     return;
   }
   // for all other cases, we set a property in the corresponding project
   IResource resource = workspace.getRoot().findMember(resourcePath);
   if (resource != null) {
     try {
       // disable the listener so we don't react to changes made by ourselves
       Preferences encodingSettings =
           getPreferences(
               resource.getProject(), true, resource.isDerived(IResource.CHECK_ANCESTORS));
       if (newCharset == null || newCharset.trim().length() == 0)
         encodingSettings.remove(getKeyFor(resourcePath));
       else encodingSettings.put(getKeyFor(resourcePath), newCharset);
       flushPreferences(encodingSettings, true);
     } catch (BackingStoreException e) {
       IProject project = workspace.getRoot().getProject(resourcePath.segment(0));
       String message = Messages.resources_savingEncoding;
       throw new ResourceException(
           IResourceStatus.FAILED_SETTING_CHARSET, project.getFullPath(), message, e);
     }
   }
 }
Example #24
0
  /**
   * Tests the handling of the -sub facility
   *
   * @throws Exception
   */
  public static void testSub() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("test/ws"));
    Project project = ws.getProject("p4-sub");
    File[] files = project.build();
    Arrays.sort(files);

    System.err.println(Processor.join(project.getErrors(), "\n"));
    System.err.println(Processor.join(project.getWarnings(), "\n"));

    assertEquals(0, project.getErrors().size());
    assertEquals(0, project.getWarnings().size());
    assertNotNull(files);
    assertEquals(3, files.length);

    Jar a = new Jar(files[0]);
    Jar b = new Jar(files[1]);
    Manifest ma = a.getManifest();
    Manifest mb = b.getManifest();

    assertEquals("base", ma.getMainAttributes().getValue("Base-Header"));
    assertEquals("base", mb.getMainAttributes().getValue("Base-Header"));
    assertEquals("a", ma.getMainAttributes().getValue("Sub-Header"));
    assertEquals("b", mb.getMainAttributes().getValue("Sub-Header"));
  }
Example #25
0
  public static void testOutofDate() throws Exception {
    Workspace ws = Workspace.getWorkspace(new File("test/ws"));
    Project project = ws.getProject("p3");
    File bnd = new File("test/ws/p3/bnd.bnd");
    assertTrue(bnd.exists());

    project.clean();
    File pt = project.getTarget();
    if (!pt.exists() && !pt.mkdirs()) {
      throw new IOException("Could not create directory " + pt);
    }
    try {
      // Now we build it.
      File[] files = project.build();
      System.err.println(project.getErrors());
      System.err.println(project.getWarnings());
      assertTrue(project.isOk());
      assertNotNull(files);
      assertEquals(1, files.length);

      // Now we should not rebuild it
      long lastTime = files[0].lastModified();
      files = project.build();
      assertEquals(1, files.length);
      assertTrue(files[0].lastModified() == lastTime);

      Thread.sleep(2000);

      project.updateModified(System.currentTimeMillis(), "Testing");
      files = project.build();
      assertEquals(1, files.length);
      assertTrue("Must have newer files now", files[0].lastModified() > lastTime);
    } finally {
      project.clean();
    }
  }
Example #26
0
  public static void testSetPackageVersion() throws Exception {
    File tmp = new File("tmp-ws");
    if (tmp.exists()) IO.deleteWithException(tmp);
    tmp.mkdir();
    assertTrue(tmp.isDirectory());

    try {
      IO.copy(new File("test/ws"), tmp);
      Workspace ws = Workspace.getWorkspace(tmp);
      Project project = ws.getProject("p5");
      project.setTrace(true);

      Version newVersion = new Version(2, 0, 0);

      // Package with no package info
      project.setPackageInfo("pkg1", newVersion);
      Version version = project.getPackageInfo("pkg1");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg1", true, false);

      // Package with package-info.java containing @Version("1.0.0")
      project.setPackageInfo("pkg2", newVersion);
      version = project.getPackageInfo("pkg2");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg2", false, true);

      // Package with package-info.java containing @aQute.bnd.annotations.Version("1.0.0")
      project.setPackageInfo("pkg3", newVersion);
      version = project.getPackageInfo("pkg3");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg3", false, true);

      // Package with package-info.java containing @aQute.bnd.annotations.Version(value="1.0.0")
      project.setPackageInfo("pkg4", newVersion);
      version = project.getPackageInfo("pkg4");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg4", false, true);

      // Package with package-info.java containing version + packageinfo
      project.setPackageInfo("pkg5", newVersion);
      version = project.getPackageInfo("pkg5");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg5", true, true);

      // Package with package-info.java NOT containing version + packageinfo
      project.setPackageInfo("pkg6", newVersion);
      version = project.getPackageInfo("pkg6");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg6", true, true);

      // Package with package-info.java NOT containing version
      project.setPackageInfo("pkg7", newVersion);
      version = project.getPackageInfo("pkg7");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg7", true, true);

      newVersion = new Version(2, 2, 0);

      // Update packageinfo file
      project.setPackageInfo("pkg1", newVersion);
      version = project.getPackageInfo("pkg1");
      assertEquals(newVersion, version);
      checkPackageInfoFiles(project, "pkg1", true, false);

    } finally {
      IO.deleteWithException(tmp);
    }
  }
Example #27
0
 /** #194 StackOverflowError when -runbundles in bnd.bnd refers to itself */
 public static void testProjectReferringToItself() throws Exception {
   Workspace ws = new Workspace(new File("test/ws"));
   Project top = ws.getProject("bug194");
   top.addClasspath(top.getOutput());
   assertTrue(top.check("Circular dependency context"));
 }
Example #28
0
 /**
  * Test if you can add directories and files to the classpath. Originally checked only for files
  */
 public static void testAddDirToClasspath() throws Exception {
   Workspace ws = new Workspace(new File("test/ws"));
   Project top = ws.getProject("p1");
   top.addClasspath(top.getOutput());
   assertTrue(top.check());
 }
Example #29
0
  public void _workspace(WorkspaceOptions opts) throws Exception {
    File base = bnd.getBase();

    String name = opts._arguments().get(0);

    File workspaceDir = Processor.getFile(base, name);
    name = workspaceDir.getName();
    base = workspaceDir.getParentFile();

    if (base == null) {
      bnd.error(
          "You cannot create a workspace in the root (%s). The parent of a workspace %n"
              + "must be a valid directory. Recommended is to dedicate a directory to %n"
              + "all (or related) workspaces.",
          workspaceDir);
      return;
    }

    if (!opts.anyname() && !Verifier.isBsn(name)) {
      bnd.error(
          "You specified a workspace name that does not follow the recommended pattern "
              + "(it should be like a Bundle Symbolic name). It is a bit pedantic but it "
              + "really helps hwne you get many workspaces. If you insist on this name, use the -a/--anyname option.");
      return;
    }

    Workspace ws = bnd.getWorkspace((File) null);

    if (ws != null && ws.isValid()) {
      bnd.error(
          "You are currently in a workspace already (%s) in %s. You can only create a new workspace outside an existing workspace",
          ws, base);
      return;
    }

    File eclipseDir = workspaceDir;
    workspaceDir.mkdirs();

    if (!opts.single()) workspaceDir = new File(workspaceDir, "scm");

    workspaceDir.mkdirs();

    if (!base.isDirectory()) {
      bnd.error("Could not create directory for the bnd workspace %s", base);
    } else if (!eclipseDir.isDirectory()) {
      bnd.error("Could not create directory for the Eclipse workspace %s", eclipseDir);
    }

    if (!workspaceDir.isDirectory()) {
      bnd.error("Could not create the workspace directory %s", workspaceDir);
      return;
    }

    if (!opts.update() && !opts.force() && workspaceDir.list().length > 0) {
      bnd.error(
          "The workspace directory %s is not empty, specify -u/--update to update or -f/--force to replace",
          workspaceDir);
    }

    InputStream in = getClass().getResourceAsStream("/templates/enroute.zip");
    if (in == null) {
      bnd.error("Cannot find template in this jar %s", "/templates/enroute.zip");
      return;
    }

    Pattern glob = Pattern.compile("[^/]+|cnf/.*|\\...+/.*");

    copy(workspaceDir, in, glob, opts.force());

    File readme = new File(workspaceDir, "README.md");
    if (readme.isFile()) IO.copy(readme, bnd.out);

    bnd.out.printf(
        "%nWorkspace %s created.%n%n" //
            + " Start Eclipse:%n" //
            + "   1) Select the Eclipse workspace %s%n" //
            + "   2) Package Explorer context menu: Import/General/Existing Projects from %s%n"
            + "%n"
            + "", //
        workspaceDir.getName(), eclipseDir, workspaceDir);
  }
Example #30
0
 private void reportRemove(Test test) {
   Workspace.scheduleTask("testResult", project.getProject(), test, null);
 }