Package com.volantis.mps.message.store

Examples of com.volantis.mps.message.store.MessageStoreConfig


     * @throws ServletException If there is a problem in handling the config
     *                          file.
     */
    protected MessageStoreConfig readConfiguration(String configFile)
            throws ServletException {
        MessageStoreConfig config = new MessageStoreConfig();

        try {
            InputStream is = new FileInputStream(configFile);
            if (is != null) {
                SAXBuilder builder = new SAXBuilder();

                // Create a jar file entity resolver on the MPS core jar
                JarFileEntityResolver resolver =
                        new JarFileEntityResolver(this);
                // Add the mapping for the MSS config schema file
                resolver.addSystemIdMapping(MSS_CONFIG_SCHEMA_URI,
                                            MSS_CONFIG_SCHEMA_LOCATION);
                // And tell the builder about it
                builder.setEntityResolver(resolver);

                // Read the config file into an XML document.
                Document configDoc = builder.build(is);

                Element root = configDoc.getRootElement();

                // Ensure an appropriate namesepace is setup
                SimpleNamespaceContext nsContext = new SimpleNamespaceContext();
                nsContext.addNamespace(NAMESPACE_PREFIX,
                                       root.getNamespaceURI());

                // Grab the message-store element to allow extraction of the
                // various attributes
                XPath xpath = new JDOMXPath("//" +
                                            NAMESPACE_PREFIX + ":" +
                                            MSS_CONFIG_MESSAGESTORE_ELEMENT);
                xpath.setNamespaceContext(nsContext);

                Element element = (Element) xpath.selectSingleNode(root);

                // Location
                config.setLocation(element.getAttributeValue(
                        MSS_CONFIG_LOCATION_ATTRIBUTE));

                // ID Size
                config.setIdSize(Integer.parseInt(element.getAttributeValue(
                        MSS_CONFIG_IDSIZE_ATTRIBUTE)));

                // Timeout
                String timeout = element.getAttributeValue(
                        MSS_CONFIG_TIMEOUT_ATTRIBUTE);
                if (timeout.equalsIgnoreCase(UNLIMITED)) {
                    config.setUnlimitedTimeout(true);
                } else {
                    config.setTimeout(Integer.parseInt(timeout));
                }

                // Validation
                String validate = element.getAttributeValue(
                        MSS_CONFIG_VALIDATE_ATTRIBUTE);
                config.setValidate(validate.equals("true"));

                // Get the environment element and extract the log4j attribute
                xpath = new JDOMXPath("//" +
                                      NAMESPACE_PREFIX + ":" +
                                      MSS_CONFIG_ENVIRONMENT_ELEMENT);
                xpath.setNamespaceContext(nsContext);

                element = (Element) xpath.selectSingleNode(root);
                config.setLog4jConfigurationFile(
                        element.getAttributeValue(MSS_CONFIG_LOG4J_ATTRIBUTE));
            } else {
                handleConfigError(null);
            }
        } catch (IOException ioe) {
View Full Code Here


    public void testGenerateID() throws Exception {
        // Create a test instance
        MessageStoreServlet servlet = new MessageStoreServlet();

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setIdSize(12);

        Set ids = new HashSet();
        boolean success = false;
View Full Code Here

    public void testCheckValidID() throws Exception {
        // Create a test instance
        MessageStoreServlet servlet = new MessageStoreServlet();

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setIdSize(12);
        servlet.globalConfig.setLocation(
                MessageStoreTestHelper.MESSAGE_STORE_LOCATION);
        servlet.messageStoreIDs = new HashMap();
View Full Code Here

        // Create a test instance
        MessageStoreServlet servlet = new MessageStoreServlet();

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setLocation(MessageStoreTestHelper.TMPDIR);
        servlet.globalConfig.setIdSize(12);
        servlet.messageStoreIDs = new HashMap();

        Set ids = new HashSet();
View Full Code Here

    public void testCreateEntryFile() {
        // Create a test instance
        MessageStoreServlet servlet = new MessageStoreServlet();

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setLocation(MessageStoreTestHelper.TMPDIR);

        String id = "abcdef123456";
        String expected = MessageStoreTestHelper.TMPDIR +
                System.getProperty("file.separator") +
View Full Code Here

    public void testGenerateTimeStamp() throws Exception {
        // Create a test instance
        MessageStoreServlet servlet = new MessageStoreServlet();

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setLocation(MessageStoreTestHelper.TMPDIR);

        String id = "abcdef123456";

        // Test with null file
View Full Code Here

    public void testInitializeMessageStore() throws Exception {
        // Create a test instance
        MessageStoreServlet servlet = new MessageStoreServlet();

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setLocation(
                MessageStoreTestHelper.MESSAGE_STORE_LOCATION);

        // Create a test message store directory
        MessageStoreTestHelper.createDir(
View Full Code Here

        writer.write(validContents);
        writer.flush();
        writer.close();

        // Obtain the config object from the config file
        MessageStoreConfig created = servlet.readConfiguration(
                validConfig.getAbsolutePath());

        // Test success...
        assertEquals("Location should be as expected",
                     tempPath,
                     created.getLocation());
        assertEquals("Timeout should be unlimited",
                     true,
                     created.isUnlimitedTimeout());
        assertEquals("ID sizes should be equal", 12, created.getIdSize());
        assertEquals("Validate should be false", false, created.isValidate());

    }
View Full Code Here

    public void testDaemonTidyTask() throws Exception {
        // Create a test instance
        MessageStoreServlet servlet = new MessageStoreServlet();

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setLocation(
                MessageStoreTestHelper.MESSAGE_STORE_LOCATION);
        servlet.globalConfig.setIdSize(12);
        servlet.globalConfig.setTimeout(300);
        servlet.messageStoreIDs = new HashMap();
View Full Code Here

                return retrievedXML;
            }
        };

        // Configure the config object as required (init() will not have run)
        servlet.globalConfig = new MessageStoreConfig();
        servlet.globalConfig.setLocation(
                MessageStoreTestHelper.MESSAGE_STORE_LOCATION);
        servlet.globalConfig.setIdSize(12);
        servlet.messageStoreIDs = new HashMap();
View Full Code Here

TOP

Related Classes of com.volantis.mps.message.store.MessageStoreConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.