Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

TEMP

  • Loading branch information...
commit 0e5a03282315f2b048615e02fa6e5b4c770ea2f8 1 parent 2953354
@aheritier aheritier authored
View
15 acceptance-webapp/pom.xml
@@ -88,6 +88,13 @@
<artifactId>validation-api</artifactId>
</dependency>
<!-- **************************************** -->
+ <!-- JGit -->
+ <!-- **************************************** -->
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ </dependency>
+ <!-- **************************************** -->
<!-- Juzu -->
<!-- **************************************** -->
<dependency>
@@ -222,6 +229,14 @@
<scope>runtime</scope>
</dependency>
<!-- **************************************** -->
+ <!-- JGit -->
+ <!-- **************************************** -->
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit.java7</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <!-- **************************************** -->
<!-- Required by logback for colorized console on windows -->
<!-- **************************************** -->
<dependency>
View
149 acceptance-webapp/src/main/java/org/exoplatform/acceptance/model/vcs/VCSBranch.java
@@ -20,153 +20,24 @@
import org.exoplatform.acceptance.model.StorableObject;
-import com.google.common.base.Objects;
import javax.validation.constraints.NotNull;
+import org.springframework.data.mongodb.core.mapping.Document;
/**
- *
+ * a VCS Branch
*/
-public class VCSBranch {
-
- /**
- * The name to humanly identify the credential
- */
- @NotNull
- protected String name;
-
- public VCSBranch(@NotNull String name) {
- this.name = name;
- }
+@Document(collection = "vcsbranches")
+public class VCSBranch extends StorableObject {
- public String getName() {
- return name;
+ public VCSBranch() {
+ super();
}
- public void setName(@NotNull String name) {
- this.name = name;
- }
-
- /**
- * Returns a string representation of the object. In general, the
- * {@code toString} method returns a string that
- * "textually represents" this object. The result should
- * be a concise but informative representation that is easy for a
- * person to read.
- * It is recommended that all subclasses override this method.
- * <p/>
- * The {@code toString} method for class {@code Object}
- * returns a string consisting of the name of the class of which the
- * object is an instance, the at-sign character `{@code @}', and
- * the unsigned hexadecimal representation of the hash code of the
- * object. In other words, this method returns a string equal to the
- * value of:
- * <blockquote>
- * <pre>
- * getClass().getName() + '@' + Integer.toHexString(hashCode())
- * </pre></blockquote>
- *
- * @return a string representation of the object.
- */
- @Override
- public String toString() {
- return Objects.toStringHelper(this).add("name", getName()).toString();
- }
-
- /**
- * Indicates whether some other object is "equal to" this one.
- * <p/>
- * The {@code equals} method implements an equivalence relation
- * on non-null object references:
- * <ul>
- * <li>It is <i>reflexive</i>: for any non-null reference value
- * {@code x}, {@code x.equals(x)} should return
- * {@code true}.
- * <li>It is <i>symmetric</i>: for any non-null reference values
- * {@code x} and {@code y}, {@code x.equals(y)}
- * should return {@code true} if and only if
- * {@code y.equals(x)} returns {@code true}.
- * <li>It is <i>transitive</i>: for any non-null reference values
- * {@code x}, {@code y}, and {@code z}, if
- * {@code x.equals(y)} returns {@code true} and
- * {@code y.equals(z)} returns {@code true}, then
- * {@code x.equals(z)} should return {@code true}.
- * <li>It is <i>consistent</i>: for any non-null reference values
- * {@code x} and {@code y}, multiple invocations of
- * {@code x.equals(y)} consistently return {@code true}
- * or consistently return {@code false}, provided no
- * information used in {@code equals} comparisons on the
- * objects is modified.
- * <li>For any non-null reference value {@code x},
- * {@code x.equals(null)} should return {@code false}.
- * </ul>
- * <p/>
- * The {@code equals} method for class {@code Object} implements
- * the most discriminating possible equivalence relation on objects;
- * that is, for any non-null reference values {@code x} and
- * {@code y}, this method returns {@code true} if and only
- * if {@code x} and {@code y} refer to the same object
- * ({@code x == y} has the value {@code true}).
- * <p/>
- * Note that it is generally necessary to override the {@code hashCode}
- * method whenever this method is overridden, so as to maintain the
- * general contract for the {@code hashCode} method, which states
- * that equal objects must have equal hash codes.
- *
- * @param obj the reference object with which to compare.
- * @return {@code true} if this object is the same as the obj
- * argument; {@code false} otherwise.
- * @see #hashCode()
- * @see java.util.HashMap
- */
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final StorableObject other = (StorableObject) obj;
- return java.util.Objects.equals(this.getName(), other.getName());
+ public VCSBranch(@NotNull String name) {
+ super(name);
}
- /**
- * Returns a hash code value for the object. This method is
- * supported for the benefit of hash tables such as those provided by
- * {@link java.util.HashMap}.
- * <p/>
- * The general contract of {@code hashCode} is:
- * <ul>
- * <li>Whenever it is invoked on the same object more than once during
- * an execution of a Java application, the {@code hashCode} method
- * must consistently return the same integer, provided no information
- * used in {@code equals} comparisons on the object is modified.
- * This integer need not remain consistent from one execution of an
- * application to another execution of the same application.
- * <li>If two objects are equal according to the {@code equals(Object)}
- * method, then calling the {@code hashCode} method on each of
- * the two objects must produce the same integer result.
- * <li>It is <em>not</em> required that if two objects are unequal
- * according to the {@link Object#equals(Object)}
- * method, then calling the {@code hashCode} method on each of the
- * two objects must produce distinct integer results. However, the
- * programmer should be aware that producing distinct integer results
- * for unequal objects may improve the performance of hash tables.
- * </ul>
- * <p/>
- * As much as is reasonably practical, the hashCode method defined by
- * class {@code Object} does return distinct integers for distinct
- * objects. (This is typically implemented by converting the internal
- * address of the object into an integer, but this implementation
- * technique is not required by the
- * Java<font size="-2"><sup>TM</sup></font> programming language.)
- *
- * @return a hash code value for this object.
- * @see Object#equals(Object)
- * @see System#identityHashCode
- */
- @Override
- public int hashCode() {
- return java.util.Objects.hash(this.getName());
+ public VCSBranch(@NotNull String name, @NotNull String id) {
+ super(name, id);
}
}
View
108 acceptance-webapp/src/main/java/org/exoplatform/acceptance/model/vcs/VCSFileSet.java
@@ -20,40 +20,136 @@
import com.google.common.base.Objects;
import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import javax.validation.constraints.NotNull;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.transport.RefSpec;
+import org.eclipse.jgit.transport.TagOpt;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
*/
public class VCSFileSet {
+ private static final Logger LOGGER = LoggerFactory.getLogger(VCSFileSet.class);
/**
* Local base directory where the clone is created
*/
- @NotNull
private File baseDir;
/**
* Identifier of the VCSRepository from which this local copy was created
*/
- @NotNull
private VCSRepository repository;
+ /**
+ * Offers a "GitPorcelain"-like API to interact with a git repository.
+ */
+ private Git git;
public VCSFileSet(@NotNull File baseDir, @NotNull VCSRepository repository) {
this.baseDir = baseDir;
this.repository = repository;
+ initialize();
}
public File getBaseDir() {
return baseDir;
}
- public void setBaseDir(File baseDir) {
- this.baseDir = baseDir;
- }
-
public VCSRepository getRepository() {
return repository;
}
+ private void initialize() {
+ if (!baseDir.exists()) {
+ if (this.repository.getRemoteRepositories().size() > 0) {
+ LOGGER.debug("Cloning {} into {}", this.repository.getName(), baseDir);
+ // Clone the first remote
+ try {
+ git = Git.cloneRepository()
+ .setURI(this.repository.getRemoteRepositories().iterator().next().getUrl())
+ .setDirectory(baseDir)
+ .setBare(true)
+ .call();
+ } catch (GitAPIException e) {
+ LOGGER.warn("Error while cloning {} : {}", this.repository, e.getMessage());
+ return;
+ }
+ LOGGER.debug("{} cloned into {}", this.repository.getName());
+ }
+ } else {
+ try {
+ git = new Git(new FileRepository(baseDir));
+ } catch (IOException e) {
+ LOGGER.warn("Error while initializing {} : {}", this, e.getMessage());
+ return;
+ }
+ }
+ StoredConfig config = git.getRepository().getConfig();
+ config.unsetSection("remote", "origin");
+ try {
+ config.save();
+ } catch (IOException e) {
+ LOGGER.warn("Error while updating local repository config");
+ }
+ for (VCSCoordinates remote : this.repository.getRemoteRepositories()) {
+ config.setString("remote", remote.getName(), "url", remote.getUrl());
+ try {
+ config.save();
+ } catch (IOException e) {
+ LOGGER.warn("Error while updating local repository config");
+ continue;
+ }
+ // Fetch
+ try {
+ LOGGER.debug("Fetching {} into {}", remote.getName(), this.baseDir);
+ git.fetch()
+ .setRemote(remote.getName())
+ .setRefSpecs(new RefSpec("+refs/heads/*:refs/remotes/" + remote.getName() + "/*"))
+ .setRemoveDeletedRefs(true)
+ .setTagOpt(TagOpt.FETCH_TAGS)
+ .call();
+ LOGGER.debug("{} fetched into {}", remote.getName(), this.baseDir);
+ } catch (Exception e) {
+ LOGGER.warn("Error while fetching changes from remotes : {}", e.getMessage());
+ }
+
+ }
+ }
+
+ public List<VCSBranch> getBranches() {
+ List<VCSBranch> branches = new ArrayList<>();
+ try {
+ for (Ref ref : git.branchList().call()) {
+ branches.add(new VCSBranch(ref.getName().replaceAll("/refs/heads", "")));
+ }
+ } catch (GitAPIException e) {
+ LOGGER.warn("Error while getting branches on {} : {}", this, e.getMessage());
+ return Collections.emptyList();
+ }
+ return branches;
+ }
+
+ public List<VCSTag> getTags() {
+ List<VCSTag> tags = new ArrayList<>();
+ try {
+ for (Ref ref : git.tagList().call()) {
+ tags.add(new VCSTag(ref.getName().replaceAll("/refs/tags/", "")));
+ }
+ } catch (GitAPIException e) {
+ LOGGER.warn("Error while getting tags on {} : {}", this, e.getMessage());
+ return Collections.emptyList();
+ }
+ return tags;
+ }
+
/**
* Returns a string representation of the object. In general, the
* {@code toString} method returns a string that
View
24 acceptance-webapp/src/main/java/org/exoplatform/acceptance/model/vcs/VCSTag.java
@@ -0,0 +1,24 @@
+package org.exoplatform.acceptance.model.vcs;
+
+import org.exoplatform.acceptance.model.StorableObject;
+
+import javax.validation.constraints.NotNull;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * a VCS Tag
+ */
+@Document(collection = "vcstags")
+public class VCSTag extends StorableObject {
+ public VCSTag() {
+ super();
+ }
+
+ public VCSTag(@NotNull String name) {
+ super(name);
+ }
+
+ public VCSTag(@NotNull String name, @NotNull String id) {
+ super(name, id);
+ }
+}
View
14 acceptance-webapp/src/main/java/org/exoplatform/acceptance/service/ConfigurationService.java
@@ -94,8 +94,11 @@ public File getDataDir() {
}
File dataDir = new File(dataDirPath);
if (!dataDir.exists()) {
- boolean result = dataDir.mkdirs();
- LOGGER.info("Data directory {} creation [{}]", dataDirPath, result ? "OK" : "KO");
+ if (dataDir.mkdirs()) {
+ LOGGER.info("Data directory {} creation [OK]");
+ } else {
+ LOGGER.error("Data directory {} creation [KO]");
+ }
}
return dataDir;
}
@@ -106,8 +109,11 @@ public File getTmpDir() {
}
File tmpDir = new File(tmpDirPath);
if (!tmpDir.exists()) {
- boolean result = tmpDir.mkdirs();
- LOGGER.info("Temporary directory {} creation [{}]", tmpDirPath, result ? "OK" : "KO");
+ if (tmpDir.mkdirs()) {
+ LOGGER.info("Temporary directory {} creation [OK]");
+ } else {
+ LOGGER.error("Temporary directory {} creation [KO]");
+ }
}
return tmpDir;
}
View
34 acceptance-webapp/src/main/java/org/exoplatform/acceptance/service/DevDataLoaderService.java
@@ -46,22 +46,28 @@ public void initializeData() {
credentialService.updateOrCreate(new UsernamePasswordCredential("A username/password", "a_username", "a_password"));
credentialService.updateOrCreate(new TokenCredential("A token", "a_token"));
credentialService.updateOrCreate(new KeyPairCredential("A key pair", "a_private_key", "a_public_key"));
- createVCSRepository("Platform-UI");
- createVCSRepository("Commons");
- createVCSRepository("Content");
- createVCSRepository("Calendar");
- createVCSRepository("Social");
- createVCSRepository("Wiki");
- createVCSRepository("Forum");
- createVCSRepository("Integration");
- createVCSRepository("Platform");
+ createVCSRepository("maven-depmgt-pom",false);
+ createVCSRepository("platform-ui",true);
+ createVCSRepository("commons",true);
+ createVCSRepository("ecms",true);
+ createVCSRepository("calendar",true);
+ createVCSRepository("social",true);
+ createVCSRepository("wiki",true);
+ createVCSRepository("forum",true);
+ createVCSRepository("integration",true);
+ createVCSRepository("platform",true);
+ createVCSRepository("platform-public-distributions",false);
+ createVCSRepository("ide",true);
+ createVCSRepository("platform-private-distributions",false);
}
- private VCSRepository createVCSRepository(String name) {
- VCSRepository gitRepository = new VCSRepository(name.toLowerCase());
- gitRepository.addRemoteRepository("development", "https://github.com/exodev/" + name.toLowerCase() + ".git",
- Credential.NONE.getId());
- gitRepository.addRemoteRepository("blessed", "https://github.com/exoplatform/" + name.toLowerCase() + ".git",
+ private VCSRepository createVCSRepository(String repoName, boolean hasDevRepo) {
+ VCSRepository gitRepository = new VCSRepository(repoName);
+ if (hasDevRepo) {
+ gitRepository.addRemoteRepository("development", "https://github.com/exodev/" + repoName + ".git",
+ Credential.NONE.getId());
+ }
+ gitRepository.addRemoteRepository("blessed", "https://github.com/exoplatform/" + repoName + ".git",
Credential.NONE.getId());
return VCSRepositoryService.updateOrCreate(gitRepository);
}
View
37 ...nce-webapp/src/main/java/org/exoplatform/acceptance/service/vcs/VCSRepositoryService.java
@@ -18,18 +18,21 @@
*/
package org.exoplatform.acceptance.service.vcs;
+import org.exoplatform.acceptance.model.vcs.VCSBranch;
import org.exoplatform.acceptance.model.vcs.VCSFileSet;
import org.exoplatform.acceptance.model.vcs.VCSRepository;
+import org.exoplatform.acceptance.model.vcs.VCSTag;
import org.exoplatform.acceptance.service.AbstractMongoCRUDService;
import org.exoplatform.acceptance.service.CRUDService;
import org.exoplatform.acceptance.service.ConfigurationService;
import org.exoplatform.acceptance.service.credential.CredentialService;
+import org.exoplatform.acceptance.storage.vcs.VCSBranchMongoStorage;
import org.exoplatform.acceptance.storage.vcs.VCSRepositoryMongoStorage;
+import org.exoplatform.acceptance.storage.vcs.VCSTagMongoStorage;
import java.io.File;
import javax.inject.Inject;
import javax.inject.Named;
-import javax.validation.constraints.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
@@ -46,6 +49,10 @@
@Inject
private VCSRepositoryMongoStorage vcsRepositoryMongoStorage;
@Inject
+ private VCSBranchMongoStorage vcsBranchMongoStorage;
+ @Inject
+ private VCSTagMongoStorage vcsTagMongoStorage;
+ @Inject
private CredentialService credentialService;
@Override
@@ -57,21 +64,25 @@ public VCSRepository findByName(String name) {
return vcsRepositoryMongoStorage.findByName(name);
}
- public VCSFileSet getFileSet(
- @NotNull File basedir,
- @NotNull VCSRepository repository) {
- return new VCSFileSet(basedir, repository);
- }
-
// Every minute
- @Scheduled(fixedRate = 60000)
+ @Scheduled(fixedRate = 120000)
public void extractSourceStatistics() {
- LOGGER.debug("Starting to process source repositories");
- for (VCSRepository VCSRepository : vcsRepositoryMongoStorage.findAll()) {
- LOGGER.debug("Processing sources repository {}", VCSRepository.getName());
- VCSFileSet localFileSet = getFileSet(new File(getCheckoutDirectory(), VCSRepository.getName()), VCSRepository);
+ for (VCSRepository repository : vcsRepositoryMongoStorage.findAll()) {
+ VCSFileSet localFileSet = new VCSFileSet(new File(getCheckoutDirectory(), repository.getName() + ".git"), repository);
+ for (VCSBranch branch : localFileSet.getBranches()) {
+ if (vcsBranchMongoStorage.findByName(branch.getName()) == null) {
+ vcsBranchMongoStorage.save(branch);
+ LOGGER.debug("Record new branch : {}", branch);
+ }
+ }
+ for (VCSTag tag : localFileSet.getTags()) {
+ if (vcsTagMongoStorage.findByName(tag.getName()) == null) {
+ vcsTagMongoStorage.save(tag);
+ LOGGER.debug("Record new tag : {}", tag);
+ }
+ }
}
- LOGGER.debug("Source repositories processed");
+ LOGGER.info("VCS data updated.");
}
public File getCheckoutDirectory() {
View
32 ...ce-webapp/src/main/java/org/exoplatform/acceptance/storage/vcs/VCSBranchMongoStorage.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-2013 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.acceptance.storage.vcs;
+
+import org.exoplatform.acceptance.model.vcs.VCSBranch;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * CRUD operations managed by Mongo for VCSBranch classes
+ */
+@Repository
+public interface VCSBranchMongoStorage extends MongoRepository<VCSBranch, String> {
+ VCSBranch findByName(String name);
+}
View
32 ...tance-webapp/src/main/java/org/exoplatform/acceptance/storage/vcs/VCSTagMongoStorage.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-2013 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.acceptance.storage.vcs;
+
+import org.exoplatform.acceptance.model.vcs.VCSTag;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * CRUD operations managed by Mongo for VCSTag classes
+ */
+@Repository
+public interface VCSTagMongoStorage extends MongoRepository<VCSTag, String> {
+ VCSTag findByName(String name);
+}
View
80 ...ebapp/src/test/java/org/exoplatform/acceptance/storage/vcs/VCSBranchMongoStorageTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011-2013 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.acceptance.storage.vcs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.exoplatform.acceptance.model.vcs.VCSBranch;
+
+import javax.inject.Inject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:/org/exoplatform/acceptance/storage/spring-test.xml"})
+@ActiveProfiles("test")
+public class VCSBranchMongoStorageTest {
+
+ @Inject
+ private VCSBranchMongoStorage vcsBranchMongoStorage;
+
+ @Before
+ public void setUp() {
+ // cleanup the collection if any Tenant
+ vcsBranchMongoStorage.deleteAll();
+ }
+
+ @After
+ public void tearDown() {
+ // cleanup the collection
+ vcsBranchMongoStorage.deleteAll();
+ }
+
+ @Test
+ public void create() {
+ VCSBranch savedVCSBranch = vcsBranchMongoStorage.save(new VCSBranch("a_branch"));
+ assertNotNull("The reference ID should not be null", savedVCSBranch.getId());
+ assertEquals("We should have exactly 1 reference", 1, vcsBranchMongoStorage.count());
+ }
+
+ @Test
+ public void delete() {
+ VCSBranch savedVCSBranch = vcsBranchMongoStorage.save(new VCSBranch("a_branch"));
+ vcsBranchMongoStorage.delete(savedVCSBranch);
+ assertEquals("We should have exactly 0 reference", 0, vcsBranchMongoStorage.count());
+ }
+
+ @Test
+ public void update() {
+ VCSBranch savedVCSBranch = vcsBranchMongoStorage.save(new VCSBranch("a_branch"));
+ savedVCSBranch.setName("a_branch2");
+ vcsBranchMongoStorage.save(savedVCSBranch);
+ assertEquals("We should have exactly 1 reference", 1, vcsBranchMongoStorage.count());
+ assertEquals("a_branch2", vcsBranchMongoStorage.findOne(savedVCSBranch.getId()).getName());
+ }
+}
View
80 ...e-webapp/src/test/java/org/exoplatform/acceptance/storage/vcs/VCSTagMongoStorageTest.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011-2013 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.exoplatform.acceptance.storage.vcs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.exoplatform.acceptance.model.vcs.VCSTag;
+
+import javax.inject.Inject;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:/org/exoplatform/acceptance/storage/spring-test.xml"})
+@ActiveProfiles("test")
+public class VCSTagMongoStorageTest {
+
+ @Inject
+ private VCSTagMongoStorage vcsTagMongoStorage;
+
+ @Before
+ public void setUp() {
+ // cleanup the collection if any Tenant
+ vcsTagMongoStorage.deleteAll();
+ }
+
+ @After
+ public void tearDown() {
+ // cleanup the collection
+ vcsTagMongoStorage.deleteAll();
+ }
+
+ @Test
+ public void createTag() {
+ VCSTag savedVCSTag = vcsTagMongoStorage.save(new VCSTag("a_tag"));
+ assertNotNull("The reference ID should not be null", savedVCSTag.getId());
+ assertEquals("We should have exactly 1 reference", 1, vcsTagMongoStorage.count());
+ }
+
+ @Test
+ public void deleteTag() {
+ VCSTag savedVCSTag = vcsTagMongoStorage.save(new VCSTag("a_tag"));
+ vcsTagMongoStorage.delete(savedVCSTag);
+ assertEquals("We should have exactly 0 reference", 0, vcsTagMongoStorage.count());
+ }
+
+ @Test
+ public void updateTag() {
+ VCSTag savedVCSTag = vcsTagMongoStorage.save(new VCSTag("a_tag"));
+ savedVCSTag.setName("a_tag2");
+ vcsTagMongoStorage.save(savedVCSTag);
+ assertEquals("We should have exactly 1 reference", 1, vcsTagMongoStorage.count());
+ assertEquals("a_tag2", vcsTagMongoStorage.findOne(savedVCSTag.getId()).getName());
+ }
+}
View
14 pom.xml
@@ -71,6 +71,7 @@
<javax.jsr250.version>1.0</javax.jsr250.version>
<javax.servlet.version>3.0.1</javax.servlet.version>
<javax.validation.version>1.1.0.Final</javax.validation.version>
+ <jgit.version>3.1.0.201310021548-r</jgit.version>
<json-path.version>0.9.1</json-path.version>
<junit.version>4.11</junit.version>
<juzu.version>0.8.0-beta4</juzu.version>
@@ -241,6 +242,19 @@
<version>${tomcat.version}</version>
</dependency>
<!-- **************************************** -->
+ <!-- JGit -->
+ <!-- **************************************** -->
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ <version>${jgit.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit.java7</artifactId>
+ <version>${jgit.version}</version>
+ </dependency>
+ <!-- **************************************** -->
<!-- Build resource used to import license related files -->
<!-- **************************************** -->
<dependency>
Please sign in to comment.
Something went wrong with that request. Please try again.