@@ -63,19 +63,20 @@ public class InitialRegistrationImplTest {
6363 public void setUp () throws NoSuchFieldException , IOException {
6464 this .initialRegistration = new InitialRegistrationImpl ();
6565 this .serviceSettings = mock (ServiceSettingsImpl .class );
66-
66+
6767 PrivateAccessor .setField (this .initialRegistration , "serviceSettings" , this .serviceSettings );
68-
68+
6969 this .baseDir = File .createTempFile (getClass ().getName (), "_tmp" );
7070 this .baseDir .delete ();
7171 this .baseDir .mkdir ();
7272 this .baseDir .deleteOnExit ();
7373 new File (this .baseDir , DEFAULT_FILTER_FN ).delete ();
7474
7575 this .generatedConfigFile = new File (this .baseDir , SYNC_CONFIG_FN );
76- this .generatedFilterFile = new File (this .baseDir , SYNC_FILTER_FN );
76+ this .generatedFilterFile = new File (this .baseDir , SYNC_FILTER_FN );
7777
7878 this .props = new LinkedHashMap <String , Object >();
79+ this .props .put (InitialRegistrationImpl .PROP_SYNC_ONCE_TYPE , InitialRegistrationImpl .SYNC_ONCE_AUTO );
7980 this .props .put (InitialRegistrationImpl .PROP_LOCAL_PATH , this .baseDir .getAbsolutePath ());
8081 this .props .put (InitialRegistrationImpl .PROP_FILTER_ROOTS ,
8182 new String [] { "/content/my-app" , "/etc/designs/my-app" });
@@ -109,6 +110,41 @@ public void testActivateEmptyDir() throws URISyntaxException {
109110 FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
110111 verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
111112 }
113+
114+
115+ @ Test
116+ public void testActivateEmptyDirDisabled1 () throws URISyntaxException {
117+ /* Prepare data. */
118+ this .baseDir .delete ();
119+ assertEquals (false , this .baseDir .exists ());
120+ this .props .remove (InitialRegistrationImpl .PROP_SYNC_ONCE_TYPE );
121+
122+ /* Invoke method. */
123+ this .initialRegistration .activate (this .props );
124+
125+ /* Check its results. */
126+ FileAssert .assertEquals (getResource ("data3-config.properties" ), this .generatedConfigFile );
127+ FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
128+ verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
129+ }
130+
131+
132+ @ Test
133+ public void testActivateEmptyDirDisabled2 () throws URISyntaxException {
134+ /* Prepare data. */
135+ this .baseDir .delete ();
136+ assertEquals (false , this .baseDir .exists ());
137+ this .props .put (InitialRegistrationImpl .PROP_SYNC_ONCE_TYPE , InitialRegistrationImpl .SYNC_ONCE_DISABLED );
138+
139+ /* Invoke method. */
140+ this .initialRegistration .activate (this .props );
141+
142+ /* Check its results. */
143+ FileAssert .assertEquals (getResource ("data3-config.properties" ), this .generatedConfigFile );
144+ FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
145+ verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
146+ }
147+
112148
113149 @ Test
114150 public void testActivateTrimPathProperty () throws URISyntaxException {
@@ -141,6 +177,23 @@ public void testActivateDirWithIgnorableContent() throws URISyntaxException, IOE
141177 FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
142178 verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
143179 }
180+
181+
182+ @ Test
183+ public void testActivateDirWithIgnorableContentDisabled () throws URISyntaxException , IOException {
184+ /* Prepare data. */
185+ assertEquals (0 , this .baseDir .list ().length );
186+ createTempFiles (".vlt-sync.log" );
187+ this .props .remove (InitialRegistrationImpl .PROP_SYNC_ONCE_TYPE );
188+
189+ /* Invoke method. */
190+ this .initialRegistration .activate (this .props );
191+
192+ /* Check its results. */
193+ FileAssert .assertEquals (getResource ("data3-config.properties" ), this .generatedConfigFile );
194+ FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
195+ verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
196+ }
144197
145198 @ Test
146199 public void testActivateDirWithIgnorableContentOverwrite () throws URISyntaxException , IOException {
@@ -173,6 +226,22 @@ public void testActivateDirWithContents() throws IOException, URISyntaxException
173226 verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
174227 }
175228
229+
230+ @ Test
231+ public void testActivateDirWithContentsDisabled () throws IOException , URISyntaxException {
232+ /* Prepare data. */
233+ assertEquals (0 , this .baseDir .list ().length );
234+ createTempFiles ("readme.txt" , "LICENSE" );
235+ this .props .remove (InitialRegistrationImpl .PROP_SYNC_ONCE_TYPE );
236+
237+ /* Invoke method. */
238+ this .initialRegistration .activate (this .props );
239+
240+ /* Check its results. */
241+ FileAssert .assertEquals (getResource ("data3-config.properties" ), this .generatedConfigFile );
242+ FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
243+ verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
244+ }
176245
177246 @ Test
178247 public void testActivateDirWithContentsJcr2Fs () throws IOException , URISyntaxException {
@@ -236,6 +305,24 @@ public void testActivatePropertyFileExistsOverwrite() throws IOException, URISyn
236305 FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
237306 verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
238307 }
308+
309+
310+ @ Test
311+ public void testActivatePropertyFileExistsOverwriteDisabled () throws IOException , URISyntaxException {
312+ /* Prepare data. */
313+ assertEquals (0 , this .baseDir .list ().length );
314+ createTempFiles (SYNC_CONFIG_FN );
315+ this .props .remove (InitialRegistrationImpl .PROP_SYNC_ONCE_TYPE );
316+ this .props .put (InitialRegistrationImpl .PROP_OVERWRITE_CONFIG_FILES , true );
317+
318+ /* Invoke method. */
319+ this .initialRegistration .activate (this .props );
320+
321+ /* Check its results. */
322+ FileAssert .assertEquals (getResource ("data3-config.properties" ), this .generatedConfigFile );
323+ FileAssert .assertEquals (getResource ("data1-filter.xml" ), this .generatedFilterFile );
324+ verify (this .serviceSettings , times (1 )).addSyncRoot (this .baseDir , 3000l );
325+ }
239326
240327 @ Test
241328 public void testActivatePropertyFileExistsDirWithContentsOverwrite () throws IOException , URISyntaxException {
0 commit comments