You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/11/01 09:52:00 UTC

[jira] [Commented] (NETBEANS-109) settings.xml factory generate mirror element instead of server

    [ https://issues.apache.org/jira/browse/NETBEANS-109?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16233861#comment-16233861 ] 

ASF GitHub Bot commented on NETBEANS-109:
-----------------------------------------

asfgit closed pull request #205: NETBEANS-109 fix server generation
URL: https://github.com/apache/incubator-netbeans/pull/205
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 8d7036717..28b8683ee 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 @@ private static BaseDocument getDocument(final DataObject modelSourceDataObject)
      * 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 @@ private static String getPathFromSource(ModelSource source) {
     /**
      * 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 401bc6bfd..a216cccfe 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 ServerImpl(SettingsModel model, Element element) {
     }
     
     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 000000000..12455d569
--- /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"));
+
+    }
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> settings.xml factory generate mirror element instead of server
> --------------------------------------------------------------
>
>                 Key: NETBEANS-109
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-109
>             Project: NetBeans
>          Issue Type: Bug
>          Components: projects - Maven
>    Affects Versions: 8.2
>         Environment: jdk 8 
>            Reporter: Eric Barboni
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 9.0
>
>
> module: maven.model
> Implementation of settings.xml factory contains an issue preventing to generate a well formed xml file. Generating server is in fact generating mirror element in the servers sections.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)