< prev index next >

test/javax/xml/jaxp/functional/test/astro/AstroTest.java

Print this page


   1 /*
   2  * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package test.astro;
  25 
  26 import static java.lang.String.valueOf;
  27 import static org.testng.Assert.assertEquals;
  28 import static test.astro.AstroConstants.ASTROCAT;
  29 import static test.astro.AstroConstants.GOLDEN_DIR;
  30 
  31 import java.io.IOException;
  32 import java.nio.file.Files;
  33 import java.nio.file.Paths;
  34 import java.util.List;
  35 
  36 import javax.xml.transform.sax.TransformerHandler;
  37 
  38 import jaxp.library.JAXPFileBaseTest;
  39 
  40 import org.testng.annotations.BeforeClass;
  41 import org.testng.annotations.DataProvider;

  42 import org.testng.annotations.Test;
  43 
  44 /*
  45  * @summary run astro application, test xslt
  46  *
  47  * There are vast amounts of textual astronomical data, typically user is
  48  * interested in a small subset, which is the result from carrying out a query.
  49  * A query can be composed of one or more filters, for example, the user could
  50  * query the database for all stars of visual magnitude down to 6.5 that lie
  51  * between right ascensions 0 h to 2 h, and between declinations of 45 to 90 degrees.
  52  *
  53  * Astro application uses JAXP to query astronomical data saved in an XML dataset.
  54  * A FilterFactory implementation creates filter(A filter is an instance of a JAXP
  55  * TransformerHandler) from an XSL stylesheet.
  56  * A InputSourceFactory implementation creates a new sax input source from an XML file.
  57  * AstroProcessor leverages InputSourceFactory to parse catalog.xml, which saves
  58  * textual astronomical data, and then creates filters with specified parameters
  59  * from FilterFactory, all of the filters are chained together, AstroProcessor
  60  * appends the HTML filter at the end of filter chain, and hooks up the chain to
  61  * the input source, finally processes and outputs to the user specified output file.
  62  *
  63  * AstroTest drives AstroProcessor to run the specified queries(total 4 in setup),
  64  * and then compares the output with the golden files to determine PASS or FAIL.
  65  * It provides variant implementations of FilterFactory and InputSourceFactory to
  66  * AstroProcessor to test different JAXP classes and features.
  67  *
  68  */
  69 public class AstroTest extends JAXPFileBaseTest {

  70     private FiltersAndGolden[] data;
  71 
  72     @BeforeClass
  73     public void setup() throws Exception {
  74         data = new FiltersAndGolden[4];
  75         data[0] = new FiltersAndGolden(getGoldenFileContent(1), astro -> astro.getRAFilter(0.106, 0.108));
  76         data[1] = new FiltersAndGolden(getGoldenFileContent(2), astro -> astro.getStellarTypeFilter("K0IIIbCN-0.5"));
  77         data[2] = new FiltersAndGolden(getGoldenFileContent(3), astro -> astro.getStellarTypeFilter("G"), astro -> astro.getDecFilter(-5.0, 60.0));
  78         data[3] = new FiltersAndGolden(getGoldenFileContent(4), astro -> astro.getRADECFilter(0.084, 0.096, -5.75, 14.0));
  79     }
  80 
  81     /*
  82      * Provide permutations of InputSourceFactory and FilterFactory for test.
  83      */
  84     @DataProvider(name = "factories")
  85     public Object[][] getQueryFactories() {
  86         return new Object[][] {
  87                 { StreamFilterFactoryImpl.class, InputSourceFactoryImpl.class },
  88                 { SAXFilterFactoryImpl.class, InputSourceFactoryImpl.class },
  89                 { DOMFilterFactoryImpl.class, InputSourceFactoryImpl.class },


   1 /*
   2  * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package test.astro;
  25 
  26 import static java.lang.String.valueOf;
  27 import static org.testng.Assert.assertEquals;
  28 import static test.astro.AstroConstants.ASTROCAT;
  29 import static test.astro.AstroConstants.GOLDEN_DIR;
  30 
  31 import java.io.IOException;
  32 import java.nio.file.Files;
  33 import java.nio.file.Paths;
  34 import java.util.List;
  35 
  36 import javax.xml.transform.sax.TransformerHandler;
  37 


  38 import org.testng.annotations.BeforeClass;
  39 import org.testng.annotations.DataProvider;
  40 import org.testng.annotations.Listeners;
  41 import org.testng.annotations.Test;
  42 
  43 /*
  44  * @summary run astro application, test xslt
  45  *
  46  * There are vast amounts of textual astronomical data, typically user is
  47  * interested in a small subset, which is the result from carrying out a query.
  48  * A query can be composed of one or more filters, for example, the user could
  49  * query the database for all stars of visual magnitude down to 6.5 that lie
  50  * between right ascensions 0 h to 2 h, and between declinations of 45 to 90 degrees.
  51  *
  52  * Astro application uses JAXP to query astronomical data saved in an XML dataset.
  53  * A FilterFactory implementation creates filter(A filter is an instance of a JAXP
  54  * TransformerHandler) from an XSL stylesheet.
  55  * A InputSourceFactory implementation creates a new sax input source from an XML file.
  56  * AstroProcessor leverages InputSourceFactory to parse catalog.xml, which saves
  57  * textual astronomical data, and then creates filters with specified parameters
  58  * from FilterFactory, all of the filters are chained together, AstroProcessor
  59  * appends the HTML filter at the end of filter chain, and hooks up the chain to
  60  * the input source, finally processes and outputs to the user specified output file.
  61  *
  62  * AstroTest drives AstroProcessor to run the specified queries(total 4 in setup),
  63  * and then compares the output with the golden files to determine PASS or FAIL.
  64  * It provides variant implementations of FilterFactory and InputSourceFactory to
  65  * AstroProcessor to test different JAXP classes and features.
  66  *
  67  */
  68 @Listeners({jaxp.library.FilePolicy.class})
  69 public class AstroTest {
  70     private FiltersAndGolden[] data;
  71 
  72     @BeforeClass
  73     public void setup() throws Exception {
  74         data = new FiltersAndGolden[4];
  75         data[0] = new FiltersAndGolden(getGoldenFileContent(1), astro -> astro.getRAFilter(0.106, 0.108));
  76         data[1] = new FiltersAndGolden(getGoldenFileContent(2), astro -> astro.getStellarTypeFilter("K0IIIbCN-0.5"));
  77         data[2] = new FiltersAndGolden(getGoldenFileContent(3), astro -> astro.getStellarTypeFilter("G"), astro -> astro.getDecFilter(-5.0, 60.0));
  78         data[3] = new FiltersAndGolden(getGoldenFileContent(4), astro -> astro.getRADECFilter(0.084, 0.096, -5.75, 14.0));
  79     }
  80 
  81     /*
  82      * Provide permutations of InputSourceFactory and FilterFactory for test.
  83      */
  84     @DataProvider(name = "factories")
  85     public Object[][] getQueryFactories() {
  86         return new Object[][] {
  87                 { StreamFilterFactoryImpl.class, InputSourceFactoryImpl.class },
  88                 { SAXFilterFactoryImpl.class, InputSourceFactoryImpl.class },
  89                 { DOMFilterFactoryImpl.class, InputSourceFactoryImpl.class },


< prev index next >