Skip to content

Commit 317e4cf

Browse files
authored
Fix MVN build issues (#35)
1. Fix MVN build issue Cause: Failed test case. Fix: CRLF handling in XML transform is corrected to LF 2. Fix MVN package issue during rerun Cause: lombok annotations were not resolved in test cases Fix: lombok uses unnamed classes. So, the compiler flags are updated - General code clean up - Updated README.md for v2.1.1 - Updated .gitignore
1 parent b5acf03 commit 317e4cf

File tree

6 files changed

+94
-50
lines changed

6 files changed

+94
-50
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ libraries/
1919
gradlew
2020
gradlew.bat
2121

22-
logs/
22+
logs/
23+
24+
.DS_Store
25+
.factorypath
26+
settings.json

README.md

Lines changed: 59 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,67 +13,87 @@ REQUIREMENTS
1313
============
1414

1515
[OpenJDK 8](http://openjdk.java.net/projects/jdk8/) or Java 8
16+
[Maven](https://maven.apache.org/download.cgi) if you want to build using `mvn` [Supported from v2.1.1].
1617

1718
Releases
1819
========
19-
Latest .jar file in release section contains netconf-java compiled from Java SE 8u65.
20-
If user wants to use some other java version, then download the source code and compile it with desired version.
20+
Releases contain source code only. Due to changing JDK licensing, jar files are not released.
21+
User may download the source code and compile it with desired JDK version.
22+
23+
* Instructions to build
24+
* Download Source Code for the required release
25+
* Compile the code and build the jar using your chosen JDK version
26+
* Use the jar file
27+
28+
* Instructions to build using `mvn`
29+
* Download Source Code for the required release
30+
* Compile the code and build the jar using `mvn package`
31+
* Use the jar file from (source to netconf-java)/netconf-java/target
32+
33+
v2.1.1
34+
------
35+
36+
* Fixed `mvn` build issues
2137

2238
v2.0.0
2339
------
40+
2441
* Replaced the ssh library with [JSch](http://www.jcraft.com/jsch/)
25-
* Adds support for new ssh crypto algorithms
26-
* More modern ssh implementation
42+
* Adds support for new ssh crypto algorithms
43+
* More modern ssh implementation
2744
* Added support for importing and building the library with maven
2845
* Added FindBugs code testing to maven build
2946

3047
This is a breaking change to the API. New Device objects are now created using a builder.
3148
Example:
32-
```
49+
50+
```Java
3351
Device device = Device.builder().hostName("hostname")
3452
.userName("username")
3553
.password("password")
3654
.hostKeysFileName("hostKeysFileName")
37-
.build();
55+
.build();
3856
```
3957

4058
SYNOPSIS
4159
========
4260

43-
import java.io.IOException;
44-
import javax.xml.parsers.ParserConfigurationException;
45-
import net.juniper.netconf.NetconfException;
46-
import org.xml.sax.SAXException;
47-
48-
import net.juniper.netconf.XML;
49-
import net.juniper.netconf.Device;
50-
51-
public class ShowInterfaces {
52-
public static void main(String args[]) throws NetconfException,
53-
ParserConfigurationException, SAXException, IOException {
54-
55-
//Create device
56-
Device device = Device.builder()
57-
.hostName("hostname")
58-
.userName("username")
59-
.password("password")
60-
.hostKeysFileName("hostKeysFileName")
61-
.build();
62-
device.connect();
63-
64-
//Send RPC and receive RPC Reply as XML
65-
XML rpc_reply = device.executeRPC("get-interface-information");
66-
/* OR
67-
* device.executeRPC("<get-interface-information/>");
68-
* OR
69-
* device.executeRPC("<rpc><get-interface-information/></rpc>");
70-
*/
71-
72-
//Print the RPC-Reply and close the device.
73-
System.out.println(rpc_reply);
74-
device.close();
75-
}
61+
```Java
62+
import java.io.IOException;
63+
import javax.xml.parsers.ParserConfigurationException;
64+
import net.juniper.netconf.NetconfException;
65+
import org.xml.sax.SAXException;
66+
67+
import net.juniper.netconf.XML;
68+
import net.juniper.netconf.Device;
69+
70+
public class ShowInterfaces {
71+
public static void main(String args[]) throws NetconfException,
72+
ParserConfigurationException, SAXException, IOException {
73+
74+
//Create device
75+
Device device = Device.builder()
76+
.hostName("hostname")
77+
.userName("username")
78+
.password("password")
79+
.hostKeysFileName("hostKeysFileName")
80+
.build();
81+
device.connect();
82+
83+
//Send RPC and receive RPC Reply as XML
84+
XML rpc_reply = device.executeRPC("get-interface-information");
85+
/* OR
86+
* device.executeRPC("<get-interface-information/>");
87+
* OR
88+
* device.executeRPC("<rpc><get-interface-information/></rpc>");
89+
*/
90+
91+
//Print the RPC-Reply and close the device.
92+
System.out.println(rpc_reply);
93+
device.close();
7694
}
95+
}
96+
```
7797

7898
LICENSE
7999
=======

pom.xml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>net.juniper.netconf</groupId>
99
<artifactId>netconf-java</artifactId>
10-
<version>2.1</version>
10+
<version>2.1.1</version>
1111
<packaging>jar</packaging>
1212

1313
<properties>
@@ -29,9 +29,9 @@
2929

3030
<developers>
3131
<developer>
32-
<name>Juniper Staff</name>
32+
<name>Juniper Networks</name>
3333
<email>[email protected]</email>
34-
<organization>Juniper</organization>
34+
<organization>Juniper Networks</organization>
3535
<organizationUrl>https://github.com/Juniper</organizationUrl>
3636
</developer>
3737
</developers>
@@ -81,11 +81,24 @@
8181
<configuration>
8282
<source>1.8</source>
8383
<target>1.8</target>
84+
<compilerArgs>
85+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
86+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
87+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
88+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
89+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
90+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
91+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
92+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
93+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
94+
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
95+
</compilerArgs>
8496
</configuration>
8597
</plugin>
8698
<plugin>
8799
<groupId>org.apache.maven.plugins</groupId>
88100
<artifactId>maven-source-plugin</artifactId>
101+
<version>3.2.1</version>
89102
<executions>
90103
<execution>
91104
<id>attach-sources</id>
@@ -98,13 +111,18 @@
98111
<plugin>
99112
<groupId>org.apache.maven.plugins</groupId>
100113
<artifactId>maven-javadoc-plugin</artifactId>
114+
<version>3.2.0</version>
101115
<executions>
102116
<execution>
103117
<id>attach-javadocs</id>
104118
<goals>
105119
<goal>jar</goal>
106120
</goals>
107121
<configuration>
122+
<source>1.8</source>
123+
<additionalOptions>
124+
<additionalOption>-Xdoclint:none</additionalOption>
125+
</additionalOptions>
108126
<stylesheet>java</stylesheet>
109127
<bottom><![CDATA[Copyright 2018, <a href="https://www.juniper.net">Juniper Networks, Inc.<a>]]> </bottom>
110128
</configuration>
@@ -158,7 +176,11 @@
158176
<artifactId>slf4j-log4j12</artifactId>
159177
<version>1.7.12</version>
160178
</dependency>
161-
179+
<dependency>
180+
<groupId>xalan</groupId>
181+
<artifactId>xalan</artifactId>
182+
<version>2.7.1</version>
183+
</dependency>
162184
<dependency>
163185
<groupId>org.hamcrest</groupId>
164186
<artifactId>hamcrest-all</artifactId>

src/main/java/net/juniper/netconf/XML.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package net.juniper.netconf;
1010

1111
import com.google.common.base.Preconditions;
12+
import org.apache.xml.serializer.OutputPropertiesFactory;
1213
import org.w3c.dom.Document;
1314
import org.w3c.dom.Element;
1415
import org.w3c.dom.Node;
@@ -506,6 +507,7 @@ public String toString() {
506507
TransformerFactory transFactory = TransformerFactory.newInstance();
507508
Transformer transformer = transFactory.newTransformer();
508509
StringWriter buffer = new StringWriter();
510+
transformer.setOutputProperty(OutputPropertiesFactory.S_KEY_LINE_SEPARATOR, "\n");
509511
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
510512
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
511513
transformer.setOutputProperty

src/test/java/net/juniper/netconf/NetconfSessionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package net.juniper.netconf;
22

3-
43
import com.jcraft.jsch.Channel;
54
import lombok.extern.slf4j.Slf4j;
65
import org.junit.Before;
@@ -13,6 +12,7 @@
1312
import javax.xml.parsers.DocumentBuilderFactory;
1413
import javax.xml.parsers.ParserConfigurationException;
1514
import java.io.BufferedOutputStream;
15+
import java.io.ByteArrayOutputStream;
1616
import java.io.IOException;
1717
import java.io.PipedInputStream;
1818
import java.io.PipedOutputStream;
@@ -136,7 +136,7 @@ public void GIVEN_executeRPC_WHEN_lldpRequest_THEN_correctResponse() throws Exce
136136

137137
Thread thread = new Thread(() -> {
138138
try {
139-
outPipe.write("Go to HELL".getBytes());
139+
outPipe.write(FAKE_RPC_REPLY.getBytes());
140140
outPipe.write(DEVICE_PROMPT_BYTE);
141141
outPipe.flush();
142142
Thread.sleep(800);

src/test/java/net/juniper/netconf/TestHelper.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
package net.juniper.netconf;
22

3-
import org.apache.commons.io.FileUtils;
4-
53
import java.io.File;
64
import java.io.FileNotFoundException;
7-
import java.io.IOException;
85
import java.net.URL;
96

107
class TestHelper {
118

129
static File getSampleFile(String fileName) throws FileNotFoundException {
1310
URL sampleFileUri = ClassLoader.getSystemClassLoader()
1411
.getResource(fileName);
15-
File sampleFile;
1612
if (sampleFileUri == null) {
1713
throw new FileNotFoundException(String.format("Could not find file %s", fileName));
1814
}

0 commit comments

Comments
 (0)