diff test/org/tmatesoft/hg/test/TestAuxUtilities.java @ 331:a37ce7145c3f

Access to repository configuration
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 05 Nov 2011 04:21:18 +0100
parents 3f09b8c19142
children 5f9073eabf06
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestAuxUtilities.java	Tue Oct 25 03:30:02 2011 +0200
+++ b/test/org/tmatesoft/hg/test/TestAuxUtilities.java	Sat Nov 05 04:21:18 2011 +0100
@@ -22,6 +22,7 @@
 import java.nio.ByteBuffer;
 
 import org.junit.Assert;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.tmatesoft.hg.core.HgCatCommand;
 import org.tmatesoft.hg.core.Nodeid;
@@ -31,11 +32,15 @@
 import org.tmatesoft.hg.repo.HgDataFile;
 import org.tmatesoft.hg.repo.HgManifest;
 import org.tmatesoft.hg.repo.HgManifest.Flags;
+import org.tmatesoft.hg.repo.HgRepoConfig;
+import org.tmatesoft.hg.repo.HgRepoConfig.PathsSection;
+import org.tmatesoft.hg.repo.HgRepoConfig.Section;
 import org.tmatesoft.hg.repo.HgRepository;
 import org.tmatesoft.hg.util.Adaptable;
 import org.tmatesoft.hg.util.ByteChannel;
 import org.tmatesoft.hg.util.CancelSupport;
 import org.tmatesoft.hg.util.CancelledException;
+import org.tmatesoft.hg.util.Pair;
 import org.tmatesoft.hg.util.Path;
 
 /**
@@ -256,4 +261,30 @@
 			}
 		});
 	}
+
+	@Test
+	@Ignore("just a dump for now, to compare values visually")
+	public void testRepositoryConfig() throws Exception {
+		HgRepository repo = Configuration.get().own();
+		final HgRepoConfig cfg = repo.getConfiguration();
+		Assert.assertNotNull(cfg.getPaths());
+		Assert.assertNotNull(cfg.getExtensions());
+		final Section dne = cfg.getSection("does-not-exist");
+		Assert.assertNotNull(dne);
+		Assert.assertFalse(dne.exists());
+		for (Pair<String, String> p : cfg.getSection("ui")) {
+			System.out.printf("%s = %s\n", p.first(), p.second());
+		}
+		final PathsSection p = cfg.getPaths();
+		System.out.printf("Known paths: %d. default: %s(%s), default-push: %s(%s)\n", p.getKeys().size(), p.getDefault(), p.hasDefault(), p.getDefaultPush(), p.hasDefaultPush());
+		for (String k : cfg.getPaths().getKeys()) {
+			System.out.println(k);
+		}
+		Assert.assertFalse(p.hasDefault() ^ p.getDefault() != null);
+		Assert.assertFalse(p.hasDefaultPush() ^ p.getDefaultPush() != null);
+	}
+	
+	public static void main(String[] args) throws Exception {
+		new TestAuxUtilities().testRepositoryConfig();
+	}
 }