PageRenderTime 56ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/org.codefaces.web.googlecode.tests/src/org/codefaces/web/urls/googlecode/GoogleCodeSvnPageParsingStrategyTest.java

https://github.com/jingweno/codefaces
Java | 51 lines | 41 code | 10 blank | 0 comment | 0 complexity | 2020b449246c870f18fb75b5f8674b5b MD5 | raw file
  1. package org.codefaces.web.urls.googlecode;
  2. import static org.junit.Assert.*;
  3. import org.codefaces.ui.SCMConfigurableElement;
  4. import org.codefaces.ui.SCMURLConfiguration;
  5. import org.codefaces.web.urls.googlecode.GoogleCodeSvnPageParsingStrategy;
  6. import org.junit.Before;
  7. import org.junit.Test;
  8. public class GoogleCodeSvnPageParsingStrategyTest {
  9. private static final String TEST_REPO_URL = "http://aurorasdk.googlecode.com/svn";
  10. private static final String TEST_SCM_KIND = "Subversion";
  11. private static final String TEST_SVN_MAIN_PAGE_URL = "http://aurorasdk.googlecode.com/svn";
  12. private static final String TEST_SVN_MAIN_PAGE_URL_WITH_TRAILING_SLASH = TEST_SVN_MAIN_PAGE_URL + "/";
  13. private static final String TEST_SVN_OTHER_PAGE_URL = "http://aurorasdk.googlecode.com/svn/trunk/%20aurorasdk%20--username%20jingweno/";
  14. private GoogleCodeSvnPageParsingStrategy strategy;
  15. @Before
  16. public void setUp(){
  17. strategy = new GoogleCodeSvnPageParsingStrategy();
  18. }
  19. @Test
  20. public void urlShouldBeCorrectlyParsedWhenMainPageSVNUrlIsGiven(){
  21. SCMURLConfiguration config = strategy.buildConfigurations(TEST_SVN_MAIN_PAGE_URL);
  22. assertEquals(TEST_REPO_URL, config.get(SCMConfigurableElement.REPO_URL));
  23. assertEquals(TEST_SCM_KIND, config.get(SCMConfigurableElement.SCM_KIND));
  24. assertNull(config.get(SCMConfigurableElement.USER));
  25. }
  26. @Test
  27. public void urlShouldBeCorrectlyParsedWhenMainPageWithTrailingSlashSVNUrlIsGiven(){
  28. SCMURLConfiguration config = strategy
  29. .buildConfigurations(TEST_SVN_MAIN_PAGE_URL_WITH_TRAILING_SLASH);
  30. assertEquals(TEST_REPO_URL, config.get(SCMConfigurableElement.REPO_URL));
  31. assertEquals(TEST_SCM_KIND, config.get(SCMConfigurableElement.SCM_KIND));
  32. assertNull(config.get(SCMConfigurableElement.USER));
  33. }
  34. @Test
  35. public void urlShouldBeCorrectlyParsedWhenOtherPageSVNUrlIsGiven(){
  36. SCMURLConfiguration config = strategy.buildConfigurations(TEST_SVN_OTHER_PAGE_URL);
  37. assertEquals(TEST_REPO_URL, config.get(SCMConfigurableElement.REPO_URL));
  38. assertEquals(TEST_SCM_KIND, config.get(SCMConfigurableElement.SCM_KIND));
  39. assertNull(config.get(SCMConfigurableElement.USER));
  40. }
  41. }