aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/helpserver/provider/src/test/java
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 /sdnr/wt/helpserver/provider/src/test/java
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>
Diffstat (limited to 'sdnr/wt/helpserver/provider/src/test/java')
-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
4 files changed, 44 insertions, 43 deletions
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());
}
}