Created
March 16, 2015 16:56
-
-
Save stoicflame/57252b7b04daa65195bf to your computer and use it in GitHub Desktop.
Test Illustrating http://jira.codehaus.org/browse/ENUNCIATE-801
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.codehaus.enunciate.domain.login; | |
import javax.xml.bind.JAXBContext; | |
import javax.xml.bind.annotation.XmlRootElement; | |
import java.io.StringReader; | |
/** | |
* @author Ryan Heaton | |
*/ | |
@XmlRootElement | |
public class LoginRequest { | |
public String organizationName; | |
public String password; | |
public String username; | |
public static void main(String[] args) throws Exception { | |
LoginRequest sampleRequest = new LoginRequest(); | |
sampleRequest.organizationName = "organization"; | |
sampleRequest.password = "password"; | |
sampleRequest.username = "username"; | |
//outputs: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns2:loginRequest xmlns:ns2="http://www.ncr.com/app1/ns1"><organizationName>organization</organizationName><password>password</password><username>username</username></ns2:loginRequest> | |
JAXBContext context = JAXBContext.newInstance(LoginRequest.class); | |
context.createMarshaller().marshal(sampleRequest, System.out); | |
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><loginRequest xmlns=\"http://www.ncr.com/app1/ns1\"><organizationName xmlns=\"\">organization</organizationName><password xmlns=\"\">password</password><username xmlns=\"\">username</username></loginRequest>"; | |
sampleRequest = (LoginRequest) context.createUnmarshaller().unmarshal(new StringReader(xml)); | |
assert sampleRequest.username.equals("username"); | |
assert sampleRequest.password.equals("password"); | |
assert sampleRequest.organizationName.equals("organization"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@XmlSchema ( | |
namespace = "http://www.ncr.com/app1/ns1" | |
) | |
package org.codehaus.enunciate.domain.login; | |
import javax.xml.bind.annotation.XmlSchema; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment