/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 4091757 6652379
@summary Basic test for setLastModified method
*/
public class SetLastModified {
+ ", rounded down by filesystem to " + rt);
return;
}
+ ", rounded up by filesystem to " + rt);
return;
}
+ ", then read as " + rt);
}
long ot, t;
/* New time: One week ago */
}
boolean threw = false;
try {
} catch (IllegalArgumentException x) {
threw = true;
}
if (!threw)
throw new Exception("setLastModified succeeded with a negative time");
if (ot != 0) {
} else {
+ "not supported");
}
}
if (f.exists()) {
if (!f.delete())
throw new Exception("Can't delete test file " + f);
}
if (f.setLastModified(nt))
throw new Exception("Succeeded on non-existent file: " + f);
// On Windows we only test with a tiny file as that platform doesn't
// support sparse files by default and so the test takes too long.
final long G = 1024L * 1024L * 1024L;
final long MAX_POSITION =
long pos = 0L;
while (pos <= MAX_POSITION) {
}
ot = f.lastModified();
if (!f.setLastModified(nt))
throw new Exception("setLastModified failed on file: " + f);
pos += G;
}
}
}