コード例 #1
0
  @Test
  public void testGetRecsPerImage() throws DatabaseException {
    Project census = new Project("census", 2, 3, 4, 5);
    dbProjects.add(census);

    assertEquals(dbProjects.getRecsPerImage(census.getId()), 2);
  }
コード例 #2
0
ファイル: BlueJ.java プロジェクト: tordf/Greenfoot
  /**
   * Opens a project.
   *
   * @param directory Where the project is stored.
   * @return the BProject that describes the newly opened project or null if it cannot be opened.
   */
  public final BProject openProject(File directory) {
    if (!myWrapper.isValid()) throw new ExtensionUnloadedException();

    // Yes somebody may just call it with null, for fun..
    if (directory == null) return null;

    Project openProj = Project.openProject(directory.getAbsolutePath(), null);
    if (openProj == null) return null;

    // a hack, since bluej does not handle "opening" of projects correctly.
    // this code should really be into openProject or it should not be possible to open
    // a project is the initial package name is not there.
    Package pkg = openProj.getCachedPackage(openProj.getInitialPackageName());
    if (pkg == null) return null;

    // I make a new identifier out of this
    Identifier aProject = new Identifier(openProj, pkg);

    // This will make the frame if not already there. should not be needed...
    try {
      aProject.getPackageFrame();
    } catch (ExtensionException exc) {
    }

    // Note: the previous Identifier is not used here.
    return openProj.getBProject();
  }
コード例 #3
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);
    }
  }
コード例 #4
0
  @Test
  public void testGetNumFields() throws DatabaseException {
    Project census = new Project("census", 2, 3, 4, 5);
    dbProjects.add(census);

    assertEquals(dbProjects.getNumFields(census.getId()), 5);
  }
コード例 #5
0
  @Test
  public void testAdd() throws DatabaseException {

    Project census = new Project("census", 2, 3, 4, 5);
    Project births = new Project("births", 6, 7, 8, 9);

    dbProjects.add(census);
    dbProjects.add(births);

    List<Project> all = dbProjects.getAll();
    assertEquals(2, all.size());

    boolean foundAge = false;
    boolean foundPlace = false;

    for (Project p : all) {

      assertFalse(p.getId() == -1);

      if (!foundAge) {
        foundAge = areEqual(p, census, false);
      }
      if (!foundPlace) {
        foundPlace = areEqual(p, births, false);
      }
    }

    assertTrue(foundAge && foundPlace);
  }
コード例 #6
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();
  }
コード例 #7
0
  // Get details of Task/Card/Story
  @RequestMapping(value = "/{userId}/edit/{type}/{typeId}", method = RequestMethod.GET)
  public String getTypeDetails(
      @ModelAttribute("project") Project project,
      @PathVariable Long userId,
      @PathVariable String type,
      @PathVariable Long typeId,
      ModelMap model) {

    if (type.contentEquals("story")) {
      List ls = userDao.getStoryById(typeId);
      Story s = (Story) ls.get(0);
      model.addAttribute("story", s);
    } else if (type.contentEquals("cards")) {
      List lc = userDao.getCardById(typeId);
      Card c = (Card) lc.get(0);
      model.addAttribute("cards", c);
    } else if (type.contentEquals("tasks")) {
      List lt = userDao.getTaskById(typeId);
      Task t = (Task) lt.get(0);
      model.addAttribute("tasks", t);
    }

    List p = userDao.getProjectById(userId);
    Project ps = (Project) p.get(0);
    model.addAttribute("project", ps.getProjectname());
    model.addAttribute("type", type);
    model.addAttribute("userid", userId);
    return "Details";
  }
コード例 #8
0
ファイル: JPABinding.java プロジェクト: keepcleargas/yalp
 public static void save(Project project) {
   System.out.println("---> " + project.isPersistent());
   Logger.warn("Next warning is intended!");
   project.save();
   validation.keep();
   show(project.id);
 }
コード例 #9
0
 /**
  * Extracts the module name from the specified project. If empty then the provided default name is
  * used.
  *
  * @param defaultName the default module name to use
  * @param project the maven 2 project
  * @return the module name to use
  */
 private String extractModuleName(final String defaultName, final Project project) {
   if (StringUtils.isBlank(project.getProjectName())) {
     return defaultName;
   } else {
     return project.getProjectName();
   }
 }
コード例 #10
0
 private static void checkPackageInfoFiles(
     Project project, String packageName, boolean expectPackageInfo, boolean expectPackageInfoJava)
     throws Exception {
   File pkgInfo = IO.getFile(project.getSrc(), packageName + "/packageinfo");
   File pkgInfoJava = IO.getFile(project.getSrc(), packageName + "/package-info.java");
   assertEquals(expectPackageInfo, pkgInfo.exists());
   assertEquals(expectPackageInfoJava, pkgInfoJava.exists());
 }
コード例 #11
0
ファイル: JPABinding.java プロジェクト: keepcleargas/yalp
 public static void withMap(String companyId) {
   Company company = Company.findById(companyId);
   Project project = new Project();
   project.companies = new HashMap();
   project.companies.put(company.name, company);
   project.create();
   render("@show", project);
 }
コード例 #12
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;
 }
コード例 #13
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());
 }
コード例 #14
0
ファイル: EventLoader.java プロジェクト: singhindresh/ometa
  private Project feedProjectData(Project project) throws Exception {
    project.setParentProjectName(projectName);

    Project parentProject = readPersister.getProject(projectName);
    project.setParentProjectId(parentProject.getProjectId());
    project.setProjectLevel(parentProject.getProjectLevel() + 1);
    project.setEditGroup(parentProject.getEditGroup());
    project.setViewGroup(parentProject.getViewGroup());
    return project;
  }
コード例 #15
0
  public static JMenu getJMenu() {
    JMenu menu = new JMenu("copy to DeploymentDiagram as ComponentInstance");
    Project p = ProjectBrowser.TheInstance.getProject();
    for (Iterator it = p.getDiagrams().iterator(); it.hasNext(); ) {
      Object d = it.next();
      if (d instanceof UMLDeploymentDiagram) menu.add(new CopyAction((UMLDeploymentDiagram) d));
    }

    return menu;
  }
コード例 #16
0
 private void jMenuItemViewDocumentsActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemViewDocumentsActionPerformed
   if (this.docFrameTableModel == null) {
     this.docFrameTableModel = new DocumentFrameTableModel(theProject.getDocumentCollection());
   }
   DocumentFrame d =
       new DocumentFrame(this.docFrameTableModel, theDesktop, theProject.getDocumentCollection());
   d.setVisible(true);
   theDesktop.add(d);
 } // GEN-LAST:event_jMenuItemViewDocumentsActionPerformed
コード例 #17
0
 private void jMenuItemPerformLSAActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jMenuItemPerformLSAActionPerformed
   Thread t =
       new LSAThread(
           theProject.getDocumentCollection(),
           theProject.getDocumentClassCollection(),
           thePrefs.get("lsa-regex"),
           this);
   t.start();
 } // GEN-LAST:event_jMenuItemPerformLSAActionPerformed
コード例 #18
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));
 }
コード例 #19
0
ファイル: ClientController.java プロジェクト: piopawlu/ols
  /**
   * Opens the project denoted by the given file.
   *
   * @param aFile the project file to open, cannot be <code>null</code>.
   * @throws IOException in case of I/O problems.
   */
  public void openProjectFile(final File aFile) throws IOException {
    FileInputStream fis = new FileInputStream(aFile);

    this.projectManager.loadProject(fis);

    final Project project = this.projectManager.getCurrentProject();
    project.setFilename(aFile);

    zoomToFit();
  }
コード例 #20
0
ファイル: DefaultIndex.java プロジェクト: eSh3m4/sonarqube
 private void addModule(Project parent, Project module) {
   ProjectDefinition parentDefinition = projectTree.getProjectDefinition(parent);
   java.io.File parentBaseDir = parentDefinition.getBaseDir();
   ProjectDefinition moduleDefinition = projectTree.getProjectDefinition(module);
   java.io.File moduleBaseDir = moduleDefinition.getBaseDir();
   module.setPath(new PathResolver().relativePath(parentBaseDir, moduleBaseDir));
   addResource(module);
   for (Project submodule : module.getModules()) {
     addModule(module, submodule);
   }
 }
コード例 #21
0
ファイル: CocoMoDB.java プロジェクト: erikw/etsf01_project
 public double getMaxAttrib(Project.Attribute attr) {
   double max = 0;
   double value;
   for (Project p : refProjects) {
     value = p.getAttribute(attr);
     if (value > max) {
       max = value;
     }
   }
   return max;
 }
コード例 #22
0
ファイル: CocoMoDB.java プロジェクト: erikw/etsf01_project
 public List<Result> similarProjects(Project inputProject) {
   // LinkedList<Project> projects = new LinkedList<Project>();
   ArrayList<Result> projects = new ArrayList<Result>();
   double tmpSim;
   for (Project p : refProjects) {
     if ((tmpSim = p.calculateSimilarity(inputProject, this)) >= threshold) {
       projects.add(new Result(tmpSim, p));
     }
   }
   return projects;
 }
コード例 #23
0
ファイル: CocoMoDB.java プロジェクト: erikw/etsf01_project
 public double getMinAttrib(Project.Attribute attr) {
   double min = Double.MAX_VALUE;
   double value;
   for (Project p : refProjects) {
     value = p.getAttribute(attr);
     if (value < min) {
       min = value;
     }
   }
   return min;
 }
コード例 #24
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());
 }
コード例 #25
0
  public static void project(Long id) {
    Project project = Project.findById(id);

    Long UID = Long.parseLong(Session.current().get("user_id"));
    User u = User.findById(UID);

    if (project.canBeSeenBy(u)) {
      render(project);
    } else {
      projects();
    }
  }
コード例 #26
0
ファイル: ClientController.java プロジェクト: piopawlu/ols
  /**
   * Saves an OLS data file to the given file.
   *
   * @param aFile the file to save the OLS data to, cannot be <code>null</code>.
   * @throws IOException in case of I/O problems.
   */
  public void saveDataFile(final File aFile) throws IOException {
    final FileWriter writer = new FileWriter(aFile);
    try {
      final Project tempProject = this.projectManager.createTemporaryProject();
      tempProject.setCapturedData(this.dataContainer);

      OlsDataHelper.write(tempProject, writer);
    } finally {
      writer.flush();
      writer.close();
    }
  }
コード例 #27
0
  public static void createproject(String projectname, String projectdescription) {
    if (projectname != null && projectdescription != null) {
      Long id = Long.parseLong(Session.current().get("user_id"));
      User u = User.findById(id);

      Project p = new Project(projectname, projectdescription, u);
      p.save();

      projects();
    } else {
      render();
    }
  }
コード例 #28
0
ファイル: ClientController.java プロジェクト: piopawlu/ols
  /**
   * Saves the current project to the given file.
   *
   * @param aFile the file to save the project information to, cannot be <code>null</code>.
   * @throws IOException in case of I/O problems.
   */
  public void saveProjectFile(final String aName, final File aFile) throws IOException {
    FileOutputStream out = null;
    try {
      final Project project = this.projectManager.getCurrentProject();
      project.setFilename(aFile);
      project.setName(aName);

      out = new FileOutputStream(aFile);
      this.projectManager.saveProject(out);
    } finally {
      HostUtils.closeResource(out);
    }
  }
コード例 #29
0
  @Override
  public OntrackSVNRevisionInfo getOntrackRevisionInfo(SVNRepository repository, long revision) {

    // Gets information about the revision
    SVNRevisionInfo basicInfo = svnService.getRevisionInfo(repository, revision);
    SVNChangeLogRevision changeLogRevision =
        svnService.createChangeLogRevision(repository, basicInfo);

    // Gets the first copy event on this path after this revision
    SVNLocation firstCopy = svnService.getFirstCopyAfter(repository, basicInfo.toLocation());

    // Data to collect
    Collection<BuildView> buildViews = new ArrayList<>();
    Collection<BranchStatusView> branchStatusViews = new ArrayList<>();
    // Loops over all authorised branches
    for (Project project : structureService.getProjectList()) {
      // Filter on SVN configuration: must be present and equal to the one the revision info is
      // looked into
      Property<SVNProjectConfigurationProperty> projectSvnConfig =
          propertyService.getProperty(project, SVNProjectConfigurationPropertyType.class);
      if (!projectSvnConfig.isEmpty()
          && repository
              .getConfiguration()
              .getName()
              .equals(projectSvnConfig.getValue().getConfiguration().getName())) {
        for (Branch branch : structureService.getBranchesForProject(project.getId())) {
          // Filter on branch type
          // Filter on SVN configuration: must be present
          if (branch.getType() != BranchType.TEMPLATE_DEFINITION
              && propertyService.hasProperty(branch, SVNBranchConfigurationPropertyType.class)) {
            // Identifies a possible build given the path/revision and the first copy
            Optional<Build> build = lookupBuild(basicInfo.toLocation(), firstCopy, branch);
            // Build found
            if (build.isPresent()) {
              // Gets the build view
              BuildView buildView = structureService.getBuildView(build.get());
              // Adds it to the list
              buildViews.add(buildView);
              // Collects the promotions for the branch
              branchStatusViews.add(structureService.getEarliestPromotionsAfterBuild(build.get()));
            }
          }
        }
      }
    }

    // OK
    return new OntrackSVNRevisionInfo(
        repository.getConfiguration(), changeLogRevision, buildViews, branchStatusViews);
  }
コード例 #30
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")));
    }
  }