summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-10 15:45:17 +0200
committerhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-10 15:54:38 +0200
commit1ff1a1d0853e63978cea54fea79da0db6f35097e (patch)
tree31b439ac93af7fad29c4d0c4adfa70dc4fbec6e6
parent23c27ddcd79913d11eac16eb42c5a43899de97a1 (diff)
Reformat sdnr helpserver to ONAP code style
Reformat to ONAP code style Issue-ID: SDNC-1273 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com> Change-Id: I1904961694fad3b8ba03d6e452ffa579b803bac6 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java32
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java22
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java4
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java12
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java26
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java6
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java43
7 files changed, 72 insertions, 73 deletions
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
index f91e96b79..683311e8a 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver;
import java.io.BufferedReader;
@@ -65,7 +65,7 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
resp.addHeader("Access-Control-Allow-Methods", "OPTIONS, HEAD, GET, POST, PUT, DELETE");
resp.addHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Content-Length");
if (query != null && query.contains("meta")) {
-
+
File f = new File(HelpInfrastructureObject.KARAFHELPDIRECTORY, "meta.json");
if (f.exists()) {
LOG.debug("found local meta file");
@@ -114,19 +114,19 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
LOG.debug("delivering file");
OutputStream out = resp.getOutputStream();
-// if (this.isTextFile(f) && REDIRECT_LINKS) {
-// String line;
-// try (BufferedReader br = new BufferedReader(new FileReader(f))) {
-// line = br.readLine();
-// while (line != null) {
-// out.write((line + "\n").getBytes());
-// line = br.readLine();
-// }
-// out.flush();
-// out.close();
-// br.close();
-// }
-// } else
+ // if (this.isTextFile(f) && REDIRECT_LINKS) {
+ // String line;
+ // try (BufferedReader br = new BufferedReader(new FileReader(f))) {
+ // line = br.readLine();
+ // while (line != null) {
+ // out.write((line + "\n").getBytes());
+ // line = br.readLine();
+ // }
+ // out.flush();
+ // out.close();
+ // br.close();
+ // }
+ // } else
{
try (FileInputStream in = new FileInputStream(f)) {
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java
index 975f8985b..ca3a40043 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.data;
import java.io.File;
@@ -29,16 +29,15 @@ import org.osgi.framework.Bundle;
* Extract subtree with resources from Opendaylight/Karaf/OSGi bundle into Karaf directory<br>
*
* Reference: Eclipsezone @see
- * <a href="https://www.eclipsezone.com/eclipse/forums/t101557.html">https://www.eclipszone.com</a>
- * <br>
+ * <a href="https://www.eclipsezone.com/eclipse/forums/t101557.html">https://www.eclipszone.com</a> <br>
* <br>
- * Example for resource and directory path from karaf log. write resource: help/FAQ/0.4.0/README.md
- * Create directories for: data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Open
- * the file: data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Problem: Binary,
- * JPG files => do not use buffer related functions
+ * Example for resource and directory path from karaf log. write resource: help/FAQ/0.4.0/README.md Create directories
+ * for: data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Open the file:
+ * data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Problem: Binary, JPG files => do not use buffer
+ * related functions
*
- * Hint: Verify with file manager the content of the bundle.jar file to see the location of the
- * resources. There is no need to mark them via the classpath.
+ * Hint: Verify with file manager the content of the bundle.jar file to see the location of the resources. There is no
+ * need to mark them via the classpath.
*/
public class ExtactBundleResource {
@@ -47,8 +46,7 @@ public class ExtactBundleResource {
* Extract resources from Karaf/OSGi bundle into karaf directory structure.
*
* @param bundle Karaf/OSGi bundle with resources
- * @param filePrefix prefix in karaf file system for destination e.g.
- * "data/cache/com.highstreet.technologies."
+ * @param filePrefix prefix in karaf file system for destination e.g. "data/cache/com.highstreet.technologies."
* @param ressoureRoot root name of ressources, with leading "/". e.g. "/help"
* @throws IOException In case of problems.
*/
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
index 2c79645f1..ebf11b6af 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.data;
import java.io.File;
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java
index 5f8558270..87d33f32f 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
import static org.junit.Assert.assertFalse;
@@ -62,7 +62,7 @@ public class TestExtract extends Mockito {
});
when(myBundle.getEntry(anyString())).thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
- System.out.println("GetEntrye input: "+args[0]);
+ System.out.println("GetEntrye input: " + args[0]);
return new URL(testFile = (String) args[0]);
});
@@ -70,11 +70,11 @@ public class TestExtract extends Mockito {
ExtactBundleResource.copyBundleResoucesRecursively(myBundle, TMPDATAFOLDER, "help/meta.json");
- assertTrue("Test file not found: "+testFile, new File(TMPDATAFOLDER+testFile).exists());
+ assertTrue("Test file not found: " + testFile, new File(TMPDATAFOLDER + testFile).exists());
- ExtactBundleResource.deleteRecursively(new File(TMPDATAFOLDER+"file:"));
+ ExtactBundleResource.deleteRecursively(new File(TMPDATAFOLDER + "file:"));
- assertFalse("Test not deleted: "+testFile, new File(TMPDATAFOLDER+"file:").exists());
+ assertFalse("Test not deleted: " + testFile, new File(TMPDATAFOLDER + "file:").exists());
} catch (Exception e) {
e.printStackTrace();
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java
index 9d63da500..3e2472822 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -6,23 +6,21 @@
* =================================================================================================
* Licensed 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.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -43,18 +41,20 @@ public class TestHelpInfObject {
e.printStackTrace();
}
}
+
@After
public void deinit() {
this.init();
}
+
@Test
public void test() {
- File root=new File(HelpInfrastructureObject.getHelpDirectoryBase()+"/"+ROOT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test2/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test3/abc/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test3/abc1/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test5/0.4.0/README.md", CONTENT);
+ File root = new File(HelpInfrastructureObject.getHelpDirectoryBase() + "/" + ROOT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test2/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test3/abc/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test3/abc1/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test5/0.4.0/README.md", CONTENT);
try {
new HelpInfrastructureObject(root.toPath());
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java
index dfe649a87..60add4be7 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
import static org.junit.Assert.fail;
@@ -36,7 +36,7 @@ public class TestHelpInfrastructure {
try {
path = Paths.get(url.toURI());
HelpInfrastructureObject helpInfrastuctureObject = new HelpInfrastructureObject(path);
- System.out.println("Help: "+helpInfrastuctureObject);
+ System.out.println("Help: " + helpInfrastuctureObject);
} catch (URISyntaxException e) {
fail(e.getMessage());
}
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java
index 2e4f987be..cd40e122b 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -6,20 +6,23 @@
* =================================================================================================
* Licensed 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.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
+import static java.nio.file.StandardOpenOption.CREATE;
+import static java.nio.file.StandardOpenOption.CREATE_NEW;
+import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
+import static java.nio.file.StandardOpenOption.WRITE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
@@ -36,27 +39,24 @@ import org.mockito.Mockito;
import org.onap.ccsdk.features.sdnr.wt.helpserver.HelpServlet;
import org.onap.ccsdk.features.sdnr.wt.helpserver.data.ExtactBundleResource;
import org.onap.ccsdk.features.sdnr.wt.helpserver.data.HelpInfrastructureObject;
-import static java.nio.file.StandardOpenOption.CREATE_NEW;
-import static java.nio.file.StandardOpenOption.WRITE;
-import static java.nio.file.StandardOpenOption.CREATE;
-import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
public class TestMyServlet extends Mockito {
private static final String GETHELPDIRECTORYBASE = "data";
private static final String CONTENT = "abbccdfkamaosie aksdmais";
- public static void createHelpFile(String filename,String content) {
- File file=new File(HelpInfrastructureObject.getHelpDirectoryBase() + filename);
+ public static void createHelpFile(String filename, String content) {
+ File file = new File(HelpInfrastructureObject.getHelpDirectoryBase() + filename);
File folder = file.getParentFile();
- if(!folder.exists()) {
+ if (!folder.exists()) {
folder.mkdirs();
}
try {
- if(file.exists()) {
+ if (file.exists()) {
file.delete();
}
- Files.write( file.toPath(),content.getBytes(),new OpenOption[] { WRITE, CREATE_NEW , CREATE, TRUNCATE_EXISTING});
+ Files.write(file.toPath(), content.getBytes(),
+ new OpenOption[] {WRITE, CREATE_NEW, CREATE, TRUNCATE_EXISTING});
} catch (IOException e1) {
fail(e1.getMessage());
}
@@ -70,6 +70,7 @@ public class TestMyServlet extends Mockito {
e.printStackTrace();
}
}
+
@After
public void deinit() {
this.init();
@@ -87,7 +88,7 @@ public class TestMyServlet extends Mockito {
when(request.getQueryString()).thenReturn("?meta");
StringWriter stringWriter = new StringWriter();
- ServletOutputStream out=new ServletOutputStream() {
+ ServletOutputStream out = new ServletOutputStream() {
@Override
public void write(int arg0) throws IOException {
@@ -96,11 +97,11 @@ public class TestMyServlet extends Mockito {
};
when(response.getOutputStream()).thenReturn(out);
- HelpServlet helpServlet=null;
+ HelpServlet helpServlet = null;
try {
helpServlet = new HelpServlet();
System.out.println("Server created");
- createHelpFile("/meta.json",CONTENT);
+ createHelpFile("/meta.json", CONTENT);
helpServlet.doOptions(request, response);
System.out.println("Get calling");
@@ -115,7 +116,7 @@ public class TestMyServlet extends Mockito {
String result = stringWriter.toString().trim();
System.out.println("Result: '" + result + "'");
- assertEquals(CONTENT,result);
+ assertEquals(CONTENT, result);
}
@Test
@@ -128,11 +129,11 @@ public class TestMyServlet extends Mockito {
private void testGetRequest(String fn) {
HelpServlet helpServlet = new HelpServlet();
- createHelpFile("/"+fn,CONTENT);
+ createHelpFile("/" + fn, CONTENT);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
- when(request.getRequestURI()).thenReturn("help/"+fn);
+ when(request.getRequestURI()).thenReturn("help/" + fn);
StringWriter sw = new StringWriter();
ServletOutputStream out = new ServletOutputStream() {
@@ -156,6 +157,6 @@ public class TestMyServlet extends Mockito {
} catch (Exception e) {
}
- assertEquals("compare content for "+fn,CONTENT,sw.toString().trim());
+ assertEquals("compare content for " + fn, CONTENT, sw.toString().trim());
}
}