hudson.util.XStream2 Java Examples
The following examples show how to use
hudson.util.XStream2.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DescriptorImpl.java From zulip-plugin with MIT License | 6 votes |
public DescriptorImpl() { super(ZulipNotifier.class); XmlFile newConfig = getConfigFile(); if (newConfig.exists()) { load(); } else { XStream2 xstream = new XStream2(); xstream.alias("hudson.plugins.humbug.DescriptorImpl", DescriptorImpl.class); XmlFile oldConfig = new XmlFile(xstream, new File(Jenkins.getInstance().getRootDir(), OLD_CONFIG_FILE_NAME)); if (oldConfig.exists()) { try { oldConfig.unmarshal(this); } catch (IOException e) { logger.log(Level.WARNING, "Failed to load " + oldConfig, e); } } } }
Example #2
Source File: RestartSurvivabilityTest.java From folder-auth-plugin with MIT License | 5 votes |
@Test @Issue("JENKINS-58485") public void shouldHaveSameConfigurationAfterRestart() { rule.addStep(new Statement() { @Override public void evaluate() throws Exception { rule.j.createProject(Folder.class, "folder"); rule.j.jenkins.setSecurityRealm(rule.j.createDummySecurityRealm()); rule.j.jenkins.setAuthorizationStrategy(createNewFolderBasedAuthorizationStrategy()); rule.j.jenkins.addNode(rule.j.createSlave("foo", null, null)); checkConfiguration(); } }); rule.addStep(new Statement() { @Override public void evaluate() { rule.j.jenkins.setSecurityRealm(rule.j.createDummySecurityRealm()); checkConfiguration(); // JENKINS-58485 XStream2 xStream = new XStream2(); String xml = xStream.toXML(rule.j.jenkins.getAuthorizationStrategy()); assertFalse(xml.contains("ConcurrentHashMap$KeySetView")); } }); }
Example #3
Source File: ReportXmlStream.java From warnings-ng-plugin with MIT License | 5 votes |
@Override protected void configureXStream(final XStream2 xStream) { xStream.registerConverter(new LineRangeListConverter(xStream)); xStream.registerConverter(new SeverityConverter()); xStream.alias("lineRange", LineRange.class); xStream.alias("edu.hm.hafner.analysis.parser.dry.DuplicationGroup", DuplicationGroup.class); xStream.alias("treeString", TreeString.class); xStream.alias("issue", Issue.class); xStream.alias("analysisReport", Report.class); }
Example #4
Source File: AnalysisResultTest.java From warnings-ng-plugin with MIT License | 5 votes |
@Test void shouldRestoreResultBeforeIssuesStatisticsField() throws IOException { XStream2 reportXmlStream = new XStream2(); Path xml = getResourceAsFile("result.xml"); XmlFile xmlFile = new XmlFile(reportXmlStream, xml.toFile()); AnalysisResult restored = (AnalysisResult) xmlFile.read(); assertThat(restored).hasTotalSize(14).hasNewSize(9).hasFixedSize(0); assertThat(restored.getTotals()).hasTotalSize(14).hasNewSize(9).hasFixedSize(0); }
Example #5
Source File: BlueOceanUrlActionTest.java From blueocean-plugin with MIT License | 5 votes |
@Test public void testMigration() { BlueOceanUrlObject mock = mock(BlueOceanUrlObject.class); BlueOceanUrlAction original = new BlueOceanUrlAction(mock); XStream2 xs = new XStream2(); String s = xs.toXML(original); Object result = xs.fromXML(s); assertThat(result, instanceOf(BlueOceanUrlAction.DoNotShowPersistedBlueOceanUrlActions.class)); }
Example #6
Source File: GlobalConfig.java From docker-workflow-plugin with MIT License | 5 votes |
public GlobalConfig() { String oldId = "org.jenkinsci.plugins.pipeline.modeldefinition.config.GlobalConfig"; File oldConfigFile = new File(Jenkins.get().getRootDir(), oldId + ".xml"); File newConfigFile = new File(Jenkins.get().getRootDir(), getId() + ".xml"); if (oldConfigFile.exists() && !newConfigFile.exists()) { try { FileUtils.moveFile(oldConfigFile, newConfigFile); LOGGER.info("migrated " + oldConfigFile + " to " + newConfigFile); } catch (IOException x) { LOGGER.log(Level.WARNING, null, x); } } ((XStream2) getConfigFile().getXStream()).addCompatibilityAlias(oldId, GlobalConfig.class); load(); }
Example #7
Source File: KubernetesCloud.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
/** * Copy constructor. * Allows to create copies of the original kubernetes cloud. Since it's a singleton * by design, this method also allows specifying a new name. * @param name Name of the cloud to be created * @param source Source Kubernetes cloud implementation * @since 0.13 */ public KubernetesCloud(@NonNull String name, @NonNull KubernetesCloud source) { super(name); XStream2 xs = new XStream2(); xs.omitField(Cloud.class, "name"); xs.omitField(KubernetesCloud.class, "templates"); // TODO PodTemplate and fields needs to implement equals xs.unmarshal(XStream2.getDefaultDriver().createReader(new StringReader(xs.toXML(source))), this); this.templates.addAll(source.templates); }
Example #8
Source File: PodTemplateTest.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
@Test public void copyConstructor() throws Exception { XStream2 xs = new XStream2(); PodTemplate pt = new PodTemplate(); assertEquals(xs.toXML(pt), xs.toXML(new PodTemplate(pt))); pt.setActiveDeadlineSeconds(99); assertEquals(xs.toXML(pt), xs.toXML(new PodTemplate(pt))); pt.setIdleMinutes(99); assertEquals(xs.toXML(pt), xs.toXML(new PodTemplate(pt))); }
Example #9
Source File: ForkPullRequestDiscoveryTraitTest.java From github-branch-source-plugin with MIT License | 4 votes |
@Test public void xstream() throws Exception { System.out.println(new XStream2().toXML(new ForkPullRequestDiscoveryTrait(3, new ForkPullRequestDiscoveryTrait.TrustContributors()))); }
Example #10
Source File: PodTemplate.java From kubernetes-plugin with Apache License 2.0 | 4 votes |
public PodTemplate(PodTemplate from) { XStream2 xs = new XStream2(); xs.unmarshal(XStream2.getDefaultDriver().createReader(new StringReader(xs.toXML(from))), this); this.yamls = from.yamls; this.listener = from.listener; }