This is an automated email from the ASF dual-hosted git repository.
matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new e99b66b NETBEANS-109 Maven ServerImpl generates MIRROR instead of
SERVER element
new 5ca23d5 Merge branch 'pr/205'
e99b66b is described below
commit e99b66b0a8ff3aff7bd85301f2035b18e382e763
Author: Eric Barboni <[email protected]>
AuthorDate: Mon Oct 30 13:51:34 2017 +0100
NETBEANS-109 Maven ServerImpl generates MIRROR instead of SERVER element
Creating a new Server entry in the maven settings model should
result in a new server element added to the serialized XML
structure. Instead of this a mirror element is created.
The fix uses the right element and adds a test for it.
---
.../netbeans/modules/maven/model/Utilities.java | 4 +-
.../maven/model/settings/impl/ServerImpl.java | 2 +-
.../maven/model/settings/impl/SettingsTest.java | 92 ++++++++++++++++++++++
3 files changed, 96 insertions(+), 2 deletions(-)
diff --git a/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
b/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
index 8d70367..28b8683 100644
--- a/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
+++ b/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
@@ -155,6 +155,8 @@ public class Utilities {
* This method could be overridden by the Unit testcase to return a special
* ModelSource object for a FileObject with custom impl of classes added
to the lookup.
* This is optional if both getDocument(FO) and createCatalogModel(FO) are
overridden.
+ * @param thisFileObj
+ * @return
*/
public static ModelSource createModelSource(final FileObject thisFileObj) {
return createModelSource(thisFileObj, null, null);
@@ -356,7 +358,7 @@ public class Utilities {
/**
* performs model modifying operations on top of the settings.xml model.
After modifications,
* the model is persisted to file.
- * @param profilesFileObject
+ * @param settingsFileObject
* @param operations
*/
public static void performSettingsModelOperations(FileObject
settingsFileObject, List<? extends ModelOperation<SettingsModel>> operations) {
diff --git
a/maven.model/src/org/netbeans/modules/maven/model/settings/impl/ServerImpl.java
b/maven.model/src/org/netbeans/modules/maven/model/settings/impl/ServerImpl.java
index 401bc6b..a216ccc 100644
---
a/maven.model/src/org/netbeans/modules/maven/model/settings/impl/ServerImpl.java
+++
b/maven.model/src/org/netbeans/modules/maven/model/settings/impl/ServerImpl.java
@@ -40,7 +40,7 @@ public class ServerImpl extends SettingsComponentImpl
implements Server {
}
public ServerImpl(SettingsModel model) {
- this(model, createElementNS(model, model.getSettingsQNames().MIRROR));
+ this(model, createElementNS(model, model.getSettingsQNames().SERVER));
}
// attributes
diff --git
a/maven.model/test/unit/src/org/netbeans/modules/maven/model/settings/impl/SettingsTest.java
b/maven.model/test/unit/src/org/netbeans/modules/maven/model/settings/impl/SettingsTest.java
new file mode 100644
index 0000000..12455d5
--- /dev/null
+++
b/maven.model/test/unit/src/org/netbeans/modules/maven/model/settings/impl/SettingsTest.java
@@ -0,0 +1,92 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.maven.model.settings.impl;
+
+import java.util.Collections;
+import org.junit.Test;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.maven.model.ModelOperation;
+import org.netbeans.modules.maven.model.Utilities;
+import org.netbeans.modules.maven.model.settings.Configuration;
+import org.netbeans.modules.maven.model.settings.Server;
+import org.netbeans.modules.maven.model.settings.SettingsModel;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.test.TestFileUtils;
+
+/**
+ *
+ * @author skygo
+ */
+public class SettingsTest extends NbTestCase {
+
+ public SettingsTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ clearWorkDir();
+ }
+
+ @Test
+ public void testSomeMethod() throws Exception {
+ FileObject settings =
TestFileUtils.writeFile(FileUtil.toFileObject(getWorkDir()), "settings.xml",
+ "<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"\n"
+ + "
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+ + "
xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0\n"
+ + "
https://maven.apache.org/xsd/settings-1.0.0.xsd\"></settings>");
+ Utilities.performSettingsModelOperations(settings,
+ Collections.<ModelOperation<SettingsModel>>singletonList(new
ModelOperation<SettingsModel>() {
+ @Override
+ public void performOperation(SettingsModel model) {
+ Server server1 = model.getFactory().createServer();
+ Server server2 = model.getFactory().createServer();
+ server1.setPassphrase("dummypass");
+ server1.setPrivateKey("dummykey");
+ server1.setUsername("dummyname");
+ Configuration config =
model.getFactory().createConfiguration();
+ config.setSimpleParameter("testparam", "testvalue");
+ server1.setConfiguration(config);
+ model.getSettings().addServer(server1);
+ model.getSettings().addServer(server2);
+
+ }
+ }));
+ assertEquals("<settings
xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"\n"
+ + "
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+ + "
xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0\n"
+ + "
https://maven.apache.org/xsd/settings-1.0.0.xsd\">\n"
+ + " <servers>\n"
+ + " <server>\n"
+ + " <passphrase>dummypass</passphrase>\n"
+ + " <privateKey>dummykey</privateKey>\n"
+ + " <username>dummyname</username>\n"
+ + " <configuration>\n"
+ + " <testparam>testvalue</testparam>\n"
+ + " </configuration>\n"
+ + " </server>\n"
+ + " <server/>\n"
+ + " </servers>\n"
+ + "</settings>",
+ settings.asText().replace("\r\n", "\n"));
+
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].