Package org.eclipse.jgit.junit

Examples of org.eclipse.jgit.junit.MockSystemReader$MockConfig


      SystemReader.setInstance(instance);
    }
  }

  private static void setWindowsSystemReader() {
    SystemReader.setInstance(new MockSystemReader() {
      {
        setWindows();
      }
    });
  }
View Full Code Here


      }
    });
  }

  private static void setUnixSystemReader() {
    SystemReader.setInstance(new MockSystemReader() {
      {
        setUnix();
      }
    });
  }
View Full Code Here

    assertEquals("", c.getString("foo", null, "bar"));
  }

  @Test
  public void test007_readUserConfig() {
    final MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    final String hostname = mockSystemReader.getHostname();
    final Config userGitConfig = mockSystemReader.openUserConfig(null,
        FS.DETECTED);
    final Config localConfig = new Config(userGitConfig);
    mockSystemReader.clearProperties();

    String authorName;
    String authorEmail;

    // no values defined nowhere
    authorName = localConfig.get(UserConfig.KEY).getAuthorName();
    authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
    assertEquals(Constants.UNKNOWN_USER_DEFAULT, authorName);
    assertEquals(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);
    assertTrue(localConfig.get(UserConfig.KEY).isAuthorNameImplicit());
    assertTrue(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit());

    // the system user name is defined
    mockSystemReader.setProperty(Constants.OS_USER_NAME_KEY, "os user name");
    localConfig.uncache(UserConfig.KEY);
    authorName = localConfig.get(UserConfig.KEY).getAuthorName();
    assertEquals("os user name", authorName);
    assertTrue(localConfig.get(UserConfig.KEY).isAuthorNameImplicit());

    if (hostname != null && hostname.length() != 0) {
      authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
      assertEquals("os user name@" + hostname, authorEmail);
    }
    assertTrue(localConfig.get(UserConfig.KEY).isAuthorEmailImplicit());

    // the git environment variables are defined
    mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
    mockSystemReader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
    localConfig.uncache(UserConfig.KEY);
    authorName = localConfig.get(UserConfig.KEY).getAuthorName();
    authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
    assertEquals("git author name", authorName);
    assertEquals("author@email", authorEmail);
View Full Code Here

    assertFalse(localConfig.get(UserConfig.KEY).isCommitterEmailImplicit());
  }

  @Test
  public void testReadUserConfigWithInvalidCharactersStripped() {
    final MockSystemReader mockSystemReader = new MockSystemReader();
    final Config localConfig = new Config(mockSystemReader.openUserConfig(
        null, FS.DETECTED));

    localConfig.setString("user", null, "name", "foo<bar");
    localConfig.setString("user", null, "email", "baz>\nqux@example.com");
View Full Code Here

  private PersonIdent ident;

  @Before
  public void setUp() {
    mockSystemReader = new MockSystemReader() {
      @Override
      public long getCurrentTime() {
        return 1318125997291L;
      }
    };
View Full Code Here

public class GitDateParserBadlyFormattedTest {
  private String dateStr;

  @Before
  public void setUp() {
    MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
  }
View Full Code Here

import org.junit.Test;

public class GitDateParserTest {
  @Before
  public void setUp() {
    MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
  }
View Full Code Here

public class RelativeDateFormatterTest {

  @Before
  public void setUp() {
    SystemReader.setInstance(new MockSystemReader());
  }
View Full Code Here

    assertEquals(true, c.getBoolean("foo", null, "bar", false));
    assertEquals("", c.getString("foo", null, "bar"));
  }

  public void test007_readUserConfig() {
    final MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    final String hostname = mockSystemReader.getHostname();
    final Config userGitConfig = mockSystemReader.openUserConfig(FS.DETECTED);
    final Config localConfig = new Config(userGitConfig);
    mockSystemReader.clearProperties();

    String authorName;
    String authorEmail;

    // no values defined nowhere
    authorName = localConfig.get(UserConfig.KEY).getAuthorName();
    authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
    assertEquals(Constants.UNKNOWN_USER_DEFAULT, authorName);
    assertEquals(Constants.UNKNOWN_USER_DEFAULT + "@" + hostname, authorEmail);

    // the system user name is defined
    mockSystemReader.setProperty(Constants.OS_USER_NAME_KEY, "os user name");
    localConfig.uncache(UserConfig.KEY);
    authorName = localConfig.get(UserConfig.KEY).getAuthorName();
    assertEquals("os user name", authorName);

    if (hostname != null && hostname.length() != 0) {
      authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
      assertEquals("os user name@" + hostname, authorEmail);
    }

    // the git environment variables are defined
    mockSystemReader.setProperty(Constants.GIT_AUTHOR_NAME_KEY, "git author name");
    mockSystemReader.setProperty(Constants.GIT_AUTHOR_EMAIL_KEY, "author@email");
    localConfig.uncache(UserConfig.KEY);
    authorName = localConfig.get(UserConfig.KEY).getAuthorName();
    authorEmail = localConfig.get(UserConfig.KEY).getAuthorEmail();
    assertEquals("git author name", authorName);
    assertEquals("author@email", authorEmail);
View Full Code Here

  private SharingWizard sharingWizard;

  @BeforeClass
  public static void beforeClass() throws Exception {

    MockSystemReader mockSystemReader = new MockSystemReader();
    SystemReader.setInstance(mockSystemReader);
    mockSystemReader.setProperty(Constants.GIT_CEILING_DIRECTORIES_KEY,
        ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile()
            .getParentFile().getAbsoluteFile().toString());

    TestUtil.showExplorerView();
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.junit.MockSystemReader$MockConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.