|
@@ -40,14 +40,15 @@ import javax.crypto.KeyGenerator;
|
|
|
|
|
|
import org.apache.hadoop.io.Text;
|
|
|
import org.apache.hadoop.io.WritableComparator;
|
|
|
-import org.apache.hadoop.security.TokenStorage;
|
|
|
+import org.apache.hadoop.security.Credentials;
|
|
|
import org.apache.hadoop.security.token.Token;
|
|
|
import org.apache.hadoop.security.token.TokenIdentifier;
|
|
|
+import org.junit.After;
|
|
|
import org.junit.Before;
|
|
|
import org.junit.Test;
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
-public class TestTokenStorage {
|
|
|
+public class TestCredentials {
|
|
|
private static final String DEFAULT_HMAC_ALGORITHM = "HmacSHA1";
|
|
|
private static final File tmpDir =
|
|
|
new File(System.getProperty("test.build.data", "/tmp"), "mapred");
|
|
@@ -57,12 +58,17 @@ public class TestTokenStorage {
|
|
|
tmpDir.mkdir();
|
|
|
}
|
|
|
|
|
|
+ @After
|
|
|
+ public void tearDown() {
|
|
|
+ tmpDir.delete();
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressWarnings("unchecked")
|
|
|
@Test
|
|
|
public <T extends TokenIdentifier> void testReadWriteStorage()
|
|
|
throws IOException, NoSuchAlgorithmException{
|
|
|
// create tokenStorage Object
|
|
|
- TokenStorage ts = new TokenStorage();
|
|
|
+ Credentials ts = new Credentials();
|
|
|
|
|
|
Token<T> token1 = new Token();
|
|
|
Token<T> token2 = new Token();
|
|
@@ -98,7 +104,7 @@ public class TestTokenStorage {
|
|
|
// open and read it back
|
|
|
DataInputStream dis =
|
|
|
new DataInputStream(new FileInputStream(tmpFileName));
|
|
|
- ts = new TokenStorage();
|
|
|
+ ts = new Credentials();
|
|
|
ts.readFields(dis);
|
|
|
dis.close();
|
|
|
|
|
@@ -129,5 +135,6 @@ public class TestTokenStorage {
|
|
|
WritableComparator.compareBytes(kTS, 0, kTS.length, kLocal,
|
|
|
0, kLocal.length)==0);
|
|
|
}
|
|
|
+ tmpFileName.delete();
|
|
|
}
|
|
|
}
|