aboutsummaryrefslogtreecommitdiff
path: root/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/ComplexAttributesMarshalling.java
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2014-03-21 14:45:05 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2014-03-21 14:45:05 +0100
commitf3f35663f362ce6722eaa26598fb5aa8c4c6d962 (patch)
treebc9d66ebe1b5b840c6e3bf0087a8dd58040528a1 /id/server/stork2-commons/src/test/java/eu/stork/peps/tests/ComplexAttributesMarshalling.java
parent05212e955f2c44bd3150b47d9d534c5a73eb71d1 (diff)
parent658cb68c445d5b73815c43b66dd717483a425ea5 (diff)
downloadmoa-id-spss-f3f35663f362ce6722eaa26598fb5aa8c4c6d962.tar.gz
moa-id-spss-f3f35663f362ce6722eaa26598fb5aa8c4c6d962.tar.bz2
moa-id-spss-f3f35663f362ce6722eaa26598fb5aa8c4c6d962.zip
Merge remote-tracking branch 'remotes/origin/vidp' into moa2_0_tlenz
Conflicts: id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditOAAction.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationServer.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/PEPSConnectorServlet.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/config/stork/STORKConfig.java id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java id/server/idserverlib/src/main/resources/resources/properties/id_messages_de.properties id/server/moa-id-commons/pom.xml id/server/stork2-saml-engine/pom.xml pom.xml repository/iaik/iaik_tsl/1.0/iaik_tsl-1.0.jar repository/iaik/iaik_tsl/1.0/iaik_tsl-1.0.pom
Diffstat (limited to 'id/server/stork2-commons/src/test/java/eu/stork/peps/tests/ComplexAttributesMarshalling.java')
-rw-r--r--id/server/stork2-commons/src/test/java/eu/stork/peps/tests/ComplexAttributesMarshalling.java187
1 files changed, 187 insertions, 0 deletions
diff --git a/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/ComplexAttributesMarshalling.java b/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/ComplexAttributesMarshalling.java
new file mode 100644
index 000000000..c7e195fa6
--- /dev/null
+++ b/id/server/stork2-commons/src/test/java/eu/stork/peps/tests/ComplexAttributesMarshalling.java
@@ -0,0 +1,187 @@
+/*
+ * This work is Open Source and licensed by the European Commission under the
+ * conditions of the European Public License v1.1
+ *
+ * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1);
+ *
+ * any use of this file implies acceptance of the conditions of this license.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * ---
+ *
+ * Test cases for marshalling complex attributes.
+ *
+ * Implemented are two testcases for marshalling and unmarshalling. These testcases are
+ * for canonical residenc address and has bank account.
+ */
+
+package eu.stork.peps.tests;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+
+import org.junit.Test;
+
+import eu.stork.peps.complex.attributes.CanonicalAddressType;
+import eu.stork.peps.complex.attributes.HasAccountInBankType;
+import eu.stork.peps.complex.attributes.ObjectFactory;
+
+/**
+ * @author Advania
+ *
+ * Examples on how to use the jaxb marshaller.
+ *
+ * The classes are created from the StorkcomplexAttributes.xsd schema located in resources.
+ *
+ * @version $Revision: 1.00 $, $Date: 2014-17-02 11:15:00 $
+ *
+ */
+
+public class ComplexAttributesMarshalling {
+
+ /**
+ * Test marshalling canonical address
+ * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ * <canonicalResidenceAddress xmlns="urn:eu:stork:names:tc:STORK:1.0:assertion">
+ * <countryCodeAddress>IS</countryCodeAddress>
+ * <state>Reykjavik</state>
+ * <municipalityCode>RVK</municipalityCode>
+ * <town>Reykjavik</town>
+ * <postalCode>101</postalCode>
+ * <streetName>Laugavegur</streetName>
+ * <streetNumber>1</streetNumber>
+ * <apartmentNumber>10</apartmentNumber>
+ * </canonicalResidenceAddress>
+ */
+ @Test
+ public void testMarshallCanonicalResidencAddress()
+ {
+ try
+ {
+ final CanonicalAddressType object = new CanonicalAddressType();
+ object.setApartmentNumber("10");
+ object.setCountryCodeAddress("IS");
+ object.setMunicipalityCode("RVK");
+ object.setPostalCode("101");
+ object.setState("Reykjavik");
+ object.setStreetName("Laugavegur");
+ object.setStreetNumber("1");
+ object.setTown("Reykjavik");
+
+ final JAXBContext context = JAXBContext.newInstance(CanonicalAddressType.class);
+ final Marshaller m = context.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+ final ObjectFactory objf = new ObjectFactory();
+
+ m.marshal(objf.createCanonicalResidenceAddress(object), new FileOutputStream("CanonicalAddressType.xml"));
+ m.marshal(objf.createCanonicalResidenceAddress(object), System.out);
+ }
+ catch (JAXBException | FileNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Test unmarshalling canonical address
+ * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ * <canonicalResidenceAddress xmlns="urn:eu:stork:names:tc:STORK:1.0:assertion">
+ * <countryCodeAddress>IS</countryCodeAddress>
+ * <state>Reykjavik</state>
+ * <municipalityCode>RVK</municipalityCode>
+ * <town>Reykjavik</town>
+ * <postalCode>101</postalCode>
+ * <streetName>Laugavegur</streetName>
+ * <streetNumber>1</streetNumber>
+ * <apartmentNumber>10</apartmentNumber>
+ * </canonicalResidenceAddress>
+ */
+ @Test
+ public void testUnmarshallCanonicalAddress()
+ {
+ JAXBContext uContext;
+ try
+ {
+ uContext = JAXBContext.newInstance(CanonicalAddressType.class);
+ final Unmarshaller u = uContext.createUnmarshaller();
+ final File file = new File("CanonicalAddressType.xml");
+
+ final JAXBElement<CanonicalAddressType> root = u.unmarshal(new StreamSource(file), CanonicalAddressType.class);
+ final CanonicalAddressType foo = root.getValue();
+
+ final String A = foo.getStreetName();
+ final String B = foo.getStreetNumber();
+
+ System.out.println("Streetname: " + A);
+ System.out.println("Streetnumber: " + B);
+
+ }
+ catch (final JAXBException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Test marshalling has bank account
+ * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ * <hasAccountInBank xmlns="urn:eu:stork:names:tc:STORK:1.0:assertion">
+ * <bankName>Arion</bankName>
+ * <AQAA>3</AQAA>
+ * </hasAccountInBank>
+ */
+ @Test
+ public void testMarshallHasBankAccount()
+ {
+ try
+ {
+ final HasAccountInBankType object = new HasAccountInBankType();
+ object.setAQAA(3);
+ object.setBankName("Arion Bank");
+ final JAXBContext context = JAXBContext.newInstance(HasAccountInBankType.class);
+ final Marshaller m = context.createMarshaller();
+ final ObjectFactory o = new ObjectFactory();
+ m.marshal(o.createHasAccountInBank(object), new FileOutputStream ("hasbankaccount.xml"));
+ m.marshal(o.createHasAccountInBank(object), System.out);
+
+ } catch (JAXBException | FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * Test unmarshalling has bank account
+ * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ * <hasAccountInBank xmlns="urn:eu:stork:names:tc:STORK:1.0:assertion">
+ * <bankName>Arion</bankName>
+ * <AQAA>3</AQAA>
+ * </hasAccountInBank>
+ */
+ @Test
+ public void testUnmarshallHasBankAccount()
+ {
+ try
+ {
+ final JAXBContext context = JAXBContext.newInstance(HasAccountInBankType.class);
+ final Unmarshaller um = context.createUnmarshaller();
+ final File file = new File("hasbankaccount.xml");
+ final JAXBElement<HasAccountInBankType> root = um.unmarshal(new StreamSource(file), HasAccountInBankType.class);
+ final HasAccountInBankType foo = root.getValue();
+ System.out.println(foo.getBankName());
+ } catch (final JAXBException e) {
+ e.printStackTrace();
+ }
+ }
+
+}