@@ -53,11 +53,11 @@ public void testExists() {
5353 public void testCreateFile () {
5454 final String temp = StringUtils .removeEnd (System .getProperty ("java.io.tmpdir" ), File .separator );
5555 final String s = System .getProperty ("file.separator" );
56- assertEquals (String .format ("%s%su%sf-887503681 " , temp , s , s ),
56+ assertEquals (String .format ("%s%su%s887503681-f " , temp , s , s ),
5757 new FlatTemporaryFileService ().create ("u" , new Path ("/p/f" , EnumSet .of (Path .Type .file ))).getAbsolute ());
5858 final Path file = new Path ("/p/f" , EnumSet .of (Path .Type .file ));
5959 file .attributes ().setRegion ("region" );
60- assertEquals (String .format ("%s%su%sf-887503681 " , temp , s , s ),
60+ assertEquals (String .format ("%s%su%s887503681-f " , temp , s , s ),
6161 new FlatTemporaryFileService ().create ("u" , file ).getAbsolute ());
6262 }
6363
@@ -67,7 +67,7 @@ public void testCreateContainer() {
6767 final String s = System .getProperty ("file.separator" );
6868 final Path file = new Path ("/container" , EnumSet .of (Path .Type .directory ));
6969 file .attributes ().setRegion ("region" );
70- assertEquals (String .format ("%s%su%scontainer-887503681 " , temp , s , s ),
70+ assertEquals (String .format ("%s%su%s887503681-container " , temp , s , s ),
7171 new FlatTemporaryFileService ().create ("u" , file ).getAbsolute ());
7272 }
7373
@@ -99,8 +99,8 @@ public void testPathNotTooLong() {
9999 final Local local = new FlatTemporaryFileService ().create ("UID" , file );
100100 assertTrue (local .getParent ().exists ());
101101 final String localFile = local .getAbsolute ();
102- assertEquals (String .format ("%s/%s/%s-887551731 " , temp , "UID" , testPathFile ).replace ('/' , File .separatorChar ), localFile );
103- assertNotEquals (String .format ("%s/%s%s/2/%s-887551731 " , temp , "UID" , testPathMD5 , testPathFile ).replace ('/' , File .separatorChar ), localFile );
102+ assertEquals (String .format ("%s/%s/887551731-%s " , temp , "UID" , testPathFile ).replace ('/' , File .separatorChar ), localFile );
103+ assertNotEquals (String .format ("%s/%s%s/2/887551731-%s " , temp , "UID" , testPathMD5 , testPathFile ).replace ('/' , File .separatorChar ), localFile );
104104 }
105105
106106 @ Test
@@ -112,6 +112,19 @@ public void testTemporaryPath() {
112112 assertTrue (local .getParent ().exists ());
113113 assertEquals ("t.txt" , file .getName ());
114114 assertNotEquals ("t.txt" , local .getName ());
115+ assertTrue (local .getName ().endsWith ("-t.txt" ));
115116 assertEquals (LocalFactory .get (PreferencesFactory .get ().getProperty ("tmp.dir" )), LocalFactory .get (local .getParent ().getAbsolute ()));
116117 }
118+
119+ @ Test
120+ public void testTemporaryPathCustomPrefix () {
121+ final Path file = new Path ("/f1/f2/t.txt" , EnumSet .of (Path .Type .file ));
122+ file .attributes ().setDuplicate (true );
123+ file .attributes ().setVersionId ("1" );
124+ final Local local = new FlatTemporaryFileService ().create ("u" , file );
125+ assertTrue (local .getParent ().exists ());
126+ assertEquals ("t.txt" , file .getName ());
127+ assertTrue (local .getName ().endsWith ("-t.txt" ));
128+ assertEquals (LocalFactory .get (PreferencesFactory .get ().getProperty ("tmp.dir" ), "u" ), LocalFactory .get (local .getParent ().getAbsolute ()));
129+ }
117130}
0 commit comments