diff test/org/tmatesoft/hg/test/TestStorePath.java @ 490:b3c16d1aede0

Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 16 Aug 2012 17:08:34 +0200
parents 12f668401613
children 4a0bab2c6da1
line wrap: on
line diff
--- a/test/org/tmatesoft/hg/test/TestStorePath.java	Mon Aug 13 19:24:29 2012 +0200
+++ b/test/org/tmatesoft/hg/test/TestStorePath.java	Thu Aug 16 17:08:34 2012 +0200
@@ -16,6 +16,8 @@
  */
 package org.tmatesoft.hg.test;
 
+import static org.tmatesoft.hg.internal.RequiresFile.*;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -25,8 +27,10 @@
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
+import org.tmatesoft.hg.core.SessionContext;
 import org.tmatesoft.hg.internal.BasicSessionContext;
 import org.tmatesoft.hg.internal.Internals;
+import org.tmatesoft.hg.internal.RepoInitializer;
 import org.tmatesoft.hg.util.PathRewrite;
 
 /**
@@ -42,7 +46,8 @@
 	private PathRewrite storePathHelper;
 	private final Map<String, Object> propertyOverrides = new HashMap<String, Object>();
 
-	private Internals internals;
+	private final SessionContext sessionCtx;
+	private final RepoInitializer repoInit;
 
 	public static void main(String[] args) throws Throwable {
 		final TestStorePath test = new TestStorePath();
@@ -54,9 +59,9 @@
 	
 	public TestStorePath() {
 		propertyOverrides.put("hg.consolelog.debug", true);
-		internals = new Internals(new BasicSessionContext(propertyOverrides, null));
-		internals.setStorageConfig(1, 0x7);
-		storePathHelper = internals.buildDataFilesHelper();
+		sessionCtx = new BasicSessionContext(propertyOverrides, null);
+		repoInit = new RepoInitializer().setRequires(STORE + FNCACHE + DOTENCODE);
+		storePathHelper = repoInit.buildDataFilesHelper(sessionCtx);
 	}
 	
 	@Before
@@ -120,11 +125,11 @@
 		String s = "Привет.txt";
 		//
 		propertyOverrides.put(Internals.CFG_PROPERTY_FS_FILENAME_ENCODING, "cp1251");
-		PathRewrite sph = internals.buildDataFilesHelper();
+		PathRewrite sph = repoInit.buildDataFilesHelper(sessionCtx);
 		errorCollector.checkThat(sph.rewrite(s), CoreMatchers.<CharSequence>equalTo("store/data/~cf~f0~e8~e2~e5~f2.txt.i"));
 		//
 		propertyOverrides.put(Internals.CFG_PROPERTY_FS_FILENAME_ENCODING, "UTF8");
-		sph = internals.buildDataFilesHelper();
+		sph = repoInit.buildDataFilesHelper(sessionCtx);
 		errorCollector.checkThat(sph.rewrite(s), CoreMatchers.<CharSequence>equalTo("store/data/~d0~9f~d1~80~d0~b8~d0~b2~d0~b5~d1~82.txt.i"));
 	}
 }