36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
package org.gcube.common.authorization.library.binder;
|
|
|
|
import java.io.StringReader;
|
|
import java.io.StringWriter;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import javax.xml.bind.JAXBContext;
|
|
import javax.xml.bind.JAXBException;
|
|
|
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
|
import org.gcube.common.scope.impl.DefaultServiceMap;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
|
|
public class AuthorizationEntryBinder {
|
|
|
|
public static JAXBContext getContext() throws JAXBException{
|
|
return JAXBContext.newInstance(AuthorizationEntry.class);
|
|
}
|
|
|
|
@Test
|
|
public void bind() throws Exception{
|
|
JAXBContext context = getContext();
|
|
StringWriter sw = new StringWriter();
|
|
AuthorizationEntry ae1 = new AuthorizationEntry("clientId", null, "scope");
|
|
Map<String, String> services = new HashMap<String, String>();
|
|
services.put("service", "endpoint");
|
|
ae1.setMap(new DefaultServiceMap("scope","versione", services ));
|
|
context.createMarshaller().marshal(ae1, sw);
|
|
System.out.println(sw.toString());
|
|
AuthorizationEntry ae2 = (AuthorizationEntry)context.createUnmarshaller().unmarshal(new StringReader(sw.toString()));
|
|
Assert.assertEquals(ae1, ae2);
|
|
}
|
|
}
|