List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException(Throwable th)
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12213TestCase.java
@Test(groups = { "wso2.greg" }, description = "change registry.xml and restart server") @SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE }) public void editRegistryXML() throws Exception { String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; FileOutputStream fileOutputStream = null; XMLStreamWriter writer = null; File srcFile = new File(registryXmlPath); try {//from ww w .j a v a 2 s . c o m OMElement handlerConfig = AXIOMUtil.stringToOM("<property name=\"useOriginalSchema\">true</property>"); OMElement registryXML = getRegistryXmlOmElement(); OMElement om1; for (Iterator iterator = registryXML.getChildrenWithName(new QName("handler")); iterator.hasNext();) { OMElement om = (OMElement) iterator.next(); if (om.getAttribute(new QName("class")).getAttributeValue() .equals("org.wso2.carbon.registry.extensions.handlers" + ".ZipWSDLMediaTypeHandler")) { om1 = om; om1.addChild(handlerConfig); registryXML.addChild(om1); registryXML.build(); break; } } fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); registryXML.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e); } finally { if (writer != null) { writer.close(); } if (fileOutputStream != null) { fileOutputStream.close(); } } restartServer(); String sessionCookie = getSessionCookie(); //reinitialize environment after server restart resourceAdminServiceClient = new ResourceAdminServiceClient(backendURL, sessionCookie); serverAdminClient = new ServerAdminClient(backendURL, sessionCookie); }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924.java
@Test(groups = { "wso2.greg" }, description = "Restore registry.xml to the previous state", dependsOnMethods = "deleteService") @SetEnvironment(executionEnvironments = { ExecutionEnvironment.integration_user }) public void restoreRegistryXML() throws XMLStreamException, IOException, InterruptedException, RegistryException { String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try {/*from ww w . ja v a 2s .c om*/ OMElement element = getRegistryXmlOmElement(); element.getChildrenWithName(new QName("aspect")).remove(); element.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); element.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e); } catch (IOException e) { throw new IOException("IO exception" + e); } finally { writer.close(); fileOutputStream.close(); } String resourcePath = ProductConstant.SYSTEM_TEST_RESOURCE_LOCATION + "artifacts" + File.separator + "GREG" + File.separator + "xml" + File.separator + "lifeCycleConfig.xml"; Resource lifecycleConfig = governance.newResource(); lifecycleConfig.setMediaType("application/xml"); lifecycleConfig.setContentStream(new FileInputStream(resourcePath)); governance.put("trunk/lifeCycleConfig.xml", lifecycleConfig); }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924.java
@AfterClass(alwaysRun = true) @SetEnvironment(executionEnvironments = { ExecutionEnvironment.integration_user }) public void deleteAndRestore() throws Exception { String workList = "<workList serverURL=\"" + frameworkProperties.getProductVariables().getBackendUrl() + "\" remote=\"false\">\n" + " <username>" + userInfo.getUserName() + "</username>\n" + " <password>" + userInfo.getPassword() + "</password>\n" + " </workList>"; ServiceManager serviceManager = new ServiceManager(governance); GovernanceUtils.loadGovernanceArtifacts((UserRegistry) governance); Service[] services = serviceManager.getAllServices(); for (Service s : services) { if (s.getQName().getLocalPart().equals(serviceName)) { serviceManager.removeService(s.getId()); }/*w ww. jav a2 s . co m*/ } if (governance.resourceExists("trunk/lifeCycleConfig.xml")) { governance.delete("trunk/lifeCycleConfig.xml"); } String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try { OMElement element = getRegistryXmlOmElement(); element.getChildrenWithName(new QName("aspect")).remove(); if (!element.getChildrenWithName(new QName("workList")).hasNext()) { element.addChild(AXIOMUtil.stringToOM(workList)); } element.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); element.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e.getMessage()); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e.getMessage()); } catch (IOException e) { throw new IOException("XML stream exception" + e.getMessage()); } finally { if (fileOutputStream != null) { fileOutputStream.close(); } if (writer != null) { writer.flush(); } } restartServer(); governance = null; registry = null; lifeCycleAdminServiceClient = null; lifeCycleManagementClient = null; serverAdminClient = null; environment = null; builder = null; }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924.java
public static void editRegistryXML() throws XMLStreamException, IOException, InterruptedException { String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try {//w w w.j av a 2 s .c om OMElement handlerConfig = getHandlerOmElement(); OMElement registryXML = getRegistryXmlOmElement(); if (registryXML.getChildrenWithName(new QName("workList")).hasNext()) { registryXML.getChildrenWithName(new QName("workList")).remove(); } registryXML.addChild(handlerConfig); registryXML.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); registryXML.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e.getMessage()); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e.getMessage()); } catch (IOException e) { throw new IOException("XML stream exception" + e.getMessage()); } finally { if (fileOutputStream != null) { fileOutputStream.close(); } if (writer != null) { writer.flush(); } } }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924.java
public static void editRegistryXMLWithNewConfig() throws XMLStreamException, IOException, InterruptedException { String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try {/*from ww w . java 2 s . co m*/ OMElement handlerConfig = getHandlerOmElementNew(); OMElement registryXML = getRegistryXmlOmElement(); registryXML.addChild(handlerConfig); registryXML.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); registryXML.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e.getMessage()); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e.getMessage()); } catch (IOException e) { throw new IOException("XML stream exception" + e.getMessage()); } finally { if (fileOutputStream != null) { fileOutputStream.close(); } if (writer != null) { writer.flush(); } } }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924TestCase.java
@Test(groups = { "wso2.greg" }, description = "Restore registry.xml to the previous state", dependsOnMethods = "deleteService") @SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE }) public void restoreRegistryXML() throws XMLStreamException, IOException, InterruptedException, RegistryException { String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try {//from w w w .j a v a2 s. c o m OMElement element = getRegistryXmlOmElement(); element.getChildrenWithName(new QName("aspect")).remove(); element.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); element.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e); } catch (IOException e) { throw new IOException("IO exception" + e); } finally { writer.close(); fileOutputStream.close(); } String resourcePath = getTestArtifactLocation() + "artifacts" + File.separator + "GREG" + File.separator + "xml" + File.separator + "lifeCycleConfig.xml"; Resource lifecycleConfig = governance.newResource(); lifecycleConfig.setMediaType("application/xml"); lifecycleConfig.setContentStream(new FileInputStream(resourcePath)); governance.put("trunk/lifeCycleConfig.xml", lifecycleConfig); }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924TestCase.java
@AfterClass(alwaysRun = true) @SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE }) public void deleteAndRestore() throws Exception { String workList = "<workList serverURL=\"" + automationContext.getContextUrls().getBackEndUrl() + "\" remote=\"false\">\n" + " <username>" + userNameWithoutDomain + "</username>\n" + " <password>" + automationContext.getContextTenant().getContextUser().getPassword() + "</password>\n" + " </workList>"; ServiceManager serviceManager = new ServiceManager(governance); GovernanceUtils.loadGovernanceArtifacts((UserRegistry) governance); Service[] services = serviceManager.getAllServices(); for (Service s : services) { if (s.getQName().getLocalPart().equals(serviceName)) { serviceManager.removeService(s.getId()); }/* www.j a v a 2 s. c o m*/ } if (governance.resourceExists("trunk/lifeCycleConfig.xml")) { governance.delete("trunk/lifeCycleConfig.xml"); } String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try { OMElement element = getRegistryXmlOmElement(); element.getChildrenWithName(new QName("aspect")).remove(); if (!element.getChildrenWithName(new QName("workList")).hasNext()) { element.addChild(AXIOMUtil.stringToOM(workList)); } element.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); element.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e.getMessage()); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e.getMessage()); } catch (IOException e) { throw new IOException("XML stream exception" + e.getMessage()); } finally { if (fileOutputStream != null) { fileOutputStream.close(); } if (writer != null) { writer.flush(); } } restartServer(); }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924TestCase.java
public void editRegistryXML() throws XMLStreamException, IOException, InterruptedException { String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try {/*from w w w .j ava2s . c o m*/ OMElement handlerConfig = getHandlerOmElement(); OMElement registryXML = getRegistryXmlOmElement(); if (registryXML.getChildrenWithName(new QName("workList")).hasNext()) { registryXML.getChildrenWithName(new QName("workList")).remove(); } registryXML.addChild(handlerConfig); registryXML.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); registryXML.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e.getMessage()); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e.getMessage()); } catch (IOException e) { throw new IOException("XML stream exception" + e.getMessage()); } finally { if (fileOutputStream != null) { fileOutputStream.close(); } if (writer != null) { writer.flush(); } } }
From source file:org.wso2.carbon.registry.jira.issues.test.Carbon12924TestCase.java
public void editRegistryXMLWithNewConfig() throws XMLStreamException, IOException, InterruptedException { String registryXmlPath = CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator + "conf" + File.separator + "registry.xml"; File srcFile = new File(registryXmlPath); try {//w w w . ja va 2s .co m OMElement handlerConfig = getHandlerOmElementNew(); OMElement registryXML = getRegistryXmlOmElement(); registryXML.addChild(handlerConfig); registryXML.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); registryXML.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e.getMessage()); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e.getMessage()); } catch (IOException e) { throw new IOException("XML stream exception" + e.getMessage()); } finally { if (fileOutputStream != null) { fileOutputStream.close(); } if (writer != null) { writer.flush(); } } }
From source file:org.wso2.carbon.registry.jira2.issues.test2.Carbon0102TestCase.java
/** * Update the registry XML file with tasks configurations * * @throws IOException/* w w w. j a va 2 s. c o m*/ * @throws XMLStreamException */ public void updateRegistryXMLConfigurations() throws IOException, XMLStreamException { FileOutputStream fileOutputStream = null; XMLStreamWriter writer = null; File srcFile = new File(registryXmlPath); try { OMElement handlerConfig = AXIOMUtil.stringToOM( "\n<task name=\"MediationTask\" class=\"org.wso2.carbon.governance.platform.extensions.mediation." + "MediationArtifactPopulatorTask\">\n" + " <trigger cron=\"1/10 * * * * ?\"/>\n" + " <property key=\"userName\" value=\"admin\" />\n" + " <property key=\"password\" value=\"admin\" />\n" + " <property key=\"serverUrl\" value=\"https://localhost:9444/services/\"/>\n" + " <property key=\"proxyArtifactKey\" value=\"proxy\" />\n" + " <property key=\"sequenceArtifactKey\" value=\"sequence\" />\n" + " <property key=\"endpointArtifactKey\" value=\"endpoint\" />\n" + "</task>"); OMElement registryXML = getRegistryXmlOmElement(); Iterator iterator = registryXML.getChildrenWithName(new QName("tasks")); OMElement om = (OMElement) iterator.next(); om.addChild(handlerConfig); registryXML.addChild(om); registryXML.build(); fileOutputStream = new FileOutputStream(srcFile); writer = XMLOutputFactory.newInstance().createXMLStreamWriter(fileOutputStream); registryXML.serialize(writer); } catch (FileNotFoundException e) { throw new FileNotFoundException("Registry.xml file not found" + e); } catch (XMLStreamException e) { throw new XMLStreamException("XML stream exception" + e); } finally { if (writer != null) { writer.close(); } if (fileOutputStream != null) { fileOutputStream.close(); } } }