Skip to content
Snippets Groups Projects
Commit d7969707 authored by felmer's avatar felmer
Browse files

SE-21 implemented and unit tested

SVN: 5802
parent fe38e865
No related branches found
No related tags found
No related merge requests found
......@@ -58,11 +58,13 @@ class SVNUtilities
/** A project all other projects depend on implicitely. */
static final String BUILD_RESOURCES_PROJECT = "build_resources";
private static final String RELEASE_PATTERN_PREFIX = "((S|[0-9]+\\.)[0-9]+)\\.";
/** The regular expression that a release tag has to match. */
static final String RELEASE_TAG_PATTERN_STRING = "([0-9]+)\\.([0-9]+)\\.([0-9]+)";
static final String RELEASE_TAG_PATTERN_STRING = RELEASE_PATTERN_PREFIX + "[0-9]+";
/** The regular expression that a release branch has to match. */
static final String RELEASE_BRANCH_PATTERN_STRING = "([0-9]+)\\.([0-9]+)\\.x";
static final String RELEASE_BRANCH_PATTERN_STRING = RELEASE_PATTERN_PREFIX + "x";
/**
* A class that holds the information about an operating system process when it is finished.
......@@ -371,7 +373,7 @@ class SVNUtilities
final Matcher tagMatcher = Pattern.compile(RELEASE_TAG_PATTERN_STRING).matcher(tagName);
boolean matches = tagMatcher.matches();
assert matches;
return String.format("%s.%s.x", tagMatcher.group(1), tagMatcher.group(2));
return String.format("%s.x", tagMatcher.group(1));
}
static String getFirstTagForBranch(String branchName)
......@@ -380,7 +382,7 @@ class SVNUtilities
Pattern.compile(RELEASE_BRANCH_PATTERN_STRING).matcher(branchName);
boolean matches = branchMatcher.matches();
assert matches;
return String.format("%s.%s.0", branchMatcher.group(1), branchMatcher.group(2));
return String.format("%s.0", branchMatcher.group(1));
}
}
......@@ -48,24 +48,36 @@ public class SVNRepositoryProjectContextTest
public void testVersionTypeReleaseBranch()
{
final SVNRepositoryProjectContext def = new SVNRepositoryProjectContext();
def.setReleaseBranch("2.3.x");
assert RELEASE_BRANCH == def.getVersionType();
assertEquals("2.3.x", def.getVersion());
def.setReleaseBranch("0.0.x");
assert RELEASE_BRANCH == def.getVersionType();
assertEquals("0.0.x", def.getVersion());
def.setReleaseBranch("S30.x");
assert RELEASE_BRANCH == def.getVersionType();
assertEquals("S30.x", def.getVersion());
}
@Test
public void testVersionTypeTag()
{
final SVNRepositoryProjectContext def = new SVNRepositoryProjectContext();
def.setReleaseTag("2.3.0");
assert RELEASE_TAG == def.getVersionType();
assertEquals("2.3.0", def.getVersion());
def.setReleaseTag("1.18.100");
assert RELEASE_TAG == def.getVersionType();
assertEquals("1.18.100", def.getVersion());
def.setReleaseTag("S18.100");
assert RELEASE_TAG == def.getVersionType();
assertEquals("S18.100", def.getVersion());
}
@Test
......@@ -142,7 +154,7 @@ public class SVNRepositoryProjectContextTest
final SVNRepositoryProjectContext def = new SVNRepositoryProjectContext();
final String name = "someProject";
final String subName = "someSubProject";
final String branchName = "0.9.x";
final String branchName = "S9.x";
def.setProjectName(name);
def.setReleaseBranch(branchName);
final String branchUrl =
......@@ -299,6 +311,14 @@ public class SVNRepositoryProjectContextTest
final SVNRepositoryProjectContext def = new SVNRepositoryProjectContext();
def.setReleaseTag("1.1.x");
}
@Test(expectedExceptions =
{ UserFailureException.class })
public void testIllegalTag8()
{
final SVNRepositoryProjectContext def = new SVNRepositoryProjectContext();
def.setReleaseTag("s1.x");
}
@Test(expectedExceptions =
{ UserFailureException.class })
......@@ -356,6 +376,14 @@ public class SVNRepositoryProjectContextTest
def.setReleaseBranch("1.1.0");
}
@Test(expectedExceptions =
{ UserFailureException.class })
public void testIllegalBranch8()
{
final SVNRepositoryProjectContext def = new SVNRepositoryProjectContext();
def.setReleaseBranch("s1.0");
}
@Test
public void testMissingName()
{
......
......@@ -97,6 +97,8 @@ public class SVNUtilitiesTest
{
assertEquals("0.9.x", SVNUtilities.getBranchForTag("0.9.0"));
assertEquals("1.0.x", SVNUtilities.getBranchForTag("1.0.10"));
assertEquals("8.04.x", SVNUtilities.getBranchForTag("8.04.10"));
assertEquals("S30.x", SVNUtilities.getBranchForTag("S30.10"));
}
@Test
......@@ -104,6 +106,8 @@ public class SVNUtilitiesTest
{
assertEquals("0.9.0", SVNUtilities.getFirstTagForBranch("0.9.x"));
assertEquals("1.5.0", SVNUtilities.getFirstTagForBranch("1.5.x"));
assertEquals("8.04.0", SVNUtilities.getFirstTagForBranch("8.04.x"));
assertEquals("S30.0", SVNUtilities.getFirstTagForBranch("S30.x"));
}
}
......@@ -6,7 +6,7 @@
</run>
</groups>
<packages>
<package name="ch.systemsx.*" />
<package name="ch.systemsx.cisd.ant.*" />
</packages>
</test>
</suite>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment