/* * Copyright 2003 Federal Chancellery Austria * MOA-SPSS has been developed in a cooperation between BRZ, the Federal * Chancellery Austria - ICT staff unit, and Graz University of Technology. * * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * http://www.osor.eu/eupl/ * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works * that you distribute must include a readable copy of the "NOTICE" text file. */ package test.at.gv.egovernment.moa.spss.api.xmlbind; import java.util.List; import org.junit.Assert; import org.w3c.dom.Element; import test.at.gv.egovernment.moa.spss.SPSSTestCase; import at.gv.egovernment.moa.spss.api.common.CanonicalizationTransform; import at.gv.egovernment.moa.spss.api.common.EnvelopedSignatureTransform; import at.gv.egovernment.moa.spss.api.common.ExclusiveCanonicalizationTransform; import at.gv.egovernment.moa.spss.api.common.XPathFilter2Transform; import at.gv.egovernment.moa.spss.api.common.XPathTransform; import at.gv.egovernment.moa.spss.api.common.XSLTTransform; import at.gv.egovernment.moa.spss.api.xmlbind.TransformParser; /** * Test the TransformParser. * * @author Patrick Peck * @version $Id$ */ public class TransformParserTest extends SPSSTestCase { private static String TESTDATA_BASE = TESTDATA_ROOT + "xml/dsigTransform/"; private TransformParser transformParser; public TransformParserTest(String name) { super(name); } protected void setUp() { transformParser = new TransformParser(); } public void testParseTransforms() throws Exception { Element transformsElem = parseXml(TESTDATA_BASE + "transforms.xml").getDocumentElement(); List transforms = transformParser.parseTransforms(transformsElem); Assert.assertNotNull(transforms); Assert.assertEquals(3, transforms.size()); } public void testParseCanonicalizationTransform() throws Exception { Element transformElem = parseXml(TESTDATA_BASE + "canonicalization.xml").getDocumentElement(); CanonicalizationTransform transform = (CanonicalizationTransform) transformParser.parseTransform(transformElem); Assert.assertNotNull(transform); Assert.assertEquals( CanonicalizationTransform.CANONICAL_XML, transform.getAlgorithmURI()); } public void testParseExclCanonicalizationTransform() throws Exception { Element transformElem = parseXml(TESTDATA_BASE + "exclusiveCanonicalization.xml") .getDocumentElement(); ExclusiveCanonicalizationTransform transform = (ExclusiveCanonicalizationTransform) transformParser.parseTransform( transformElem); Assert.assertNotNull(transform); Assert.assertEquals( ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML, transform.getAlgorithmURI()); Assert.assertEquals(3, transform.getInclusiveNamespacePrefixes().size()); } public void testParseEnvelopedTransform() throws Exception { Element transformElem = parseXml(TESTDATA_BASE + "enveloped.xml").getDocumentElement(); EnvelopedSignatureTransform transform = (EnvelopedSignatureTransform) transformParser.parseTransform( transformElem); Assert.assertNotNull(transform); } public void testParseXPathTransform() throws Exception { Element transformElem = parseXml(TESTDATA_BASE + "xpath.xml").getDocumentElement(); XPathTransform transform = (XPathTransform) transformParser.parseTransform(transformElem); Assert.assertNotNull(transform); Assert.assertEquals("//ToBeSigned/Data", transform.getXPathExpression()); Assert.assertEquals(1, transform.getNamespaceDeclarations().size()); } public void testParseXPathFilter2Transform() throws Exception { Element transformElem = parseXml(TESTDATA_BASE + "xpath2.xml").getDocumentElement(); XPathFilter2Transform transform = (XPathFilter2Transform) transformParser.parseTransform(transformElem); Assert.assertNotNull(transform); Assert.assertEquals(3, transform.getFilters().size()); } public void testParseXSLTTransform() throws Exception { Element transformElem = parseXml(TESTDATA_BASE + "xslt.xml").getDocumentElement(); XSLTTransform transform = (XSLTTransform) transformParser.parseTransform(transformElem); Assert.assertNotNull(transform); } }