summaryrefslogtreecommitdiffstats
path: root/cadi/client/src/test/java
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-10-15 08:19:50 -0500
committerInstrumental <jonathan.gathman@att.com>2019-10-15 08:35:35 -0500
commit1296352d8eafee57f982a4342ad79ada4aa56d28 (patch)
tree355cdb89d85530a861319f892b0f24236e6adc50 /cadi/client/src/test/java
parentbdce7667a6e272e2fa32e298d957a0d9090c5bc9 (diff)
Sonar Fixes, Formatting
Issue-ID: AAF-1019 Change-Id: Ica49d9e7323aad9622ff9d95cc21b87430c22c54 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/client/src/test/java')
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsAuthentication.java22
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsTransferSS.java16
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Future.java12
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java6
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Rcli.java66
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Result.java10
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Retryable.java8
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HAuthorizationHeader.java10
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HBasicAuthSS.java22
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HClient.java4
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java18
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HNoAuthSS.java12
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HRcli.java24
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTokenSS.java6
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTransferSS.java16
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HX509SS.java26
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java26
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java8
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java8
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java4
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/client/test/JU_ResultTest.java10
21 files changed, 167 insertions, 167 deletions
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsAuthentication.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsAuthentication.java
index 65daa7b6..9c293c92 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsAuthentication.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsAuthentication.java
@@ -7,9 +7,9 @@
* 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.
@@ -34,20 +34,20 @@ import java.io.PrintStream;
import java.net.HttpURLConnection;
public class JU_AbsAuthentication {
-
+
private final static String ID = "id";
private final static String PASSWORD = "password";
private final static String WARNING = "Your service has 1000 consecutive bad service " +
"logins to AAF. AAF Access will be disabled after 10000\n";
-
+
private static ByteArrayOutputStream errStream;
-
+
@Before
public void setup() {
errStream = new ByteArrayOutputStream();
System.setErr(new PrintStream(errStream));
}
-
+
@After
public void tearDown() {
System.setErr(System.err);
@@ -59,7 +59,7 @@ public class JU_AbsAuthentication {
assertThat(stub.getID(), is(nullValue()));
assertThat(stub.headValue(), is(""));
assertThat(stub.count(), is(0));
-
+
stub.setUser(ID);
assertThat(stub.getID(), is(ID));
@@ -67,7 +67,7 @@ public class JU_AbsAuthentication {
assertThat(stub.getID(), is(ID));
assertThat(stub.headValue(), is(PASSWORD));
assertThat(stub.count(), is(0));
-
+
assertThat(stub.setLastResponse(200), is(0));
assertThat(stub.isDenied(), is(false));
@@ -81,12 +81,12 @@ public class JU_AbsAuthentication {
stub.setCount(999);
assertThat(stub.setLastResponse(401), is(1000));
assertThat(errStream.toString(), is(WARNING));
-
+
// coverage...
stub.setLastMiss(1);
assertThat(stub.isDenied(), is(false));
}
-
+
private class AuthStub extends AbsAuthentication<HttpURLConnection> {
public AuthStub(SecurityInfoC<HttpURLConnection> securityInfo, String user, byte[] headValue)
@@ -95,7 +95,7 @@ public class JU_AbsAuthentication {
@Override public void setSecurity(HttpURLConnection client) throws CadiException { }
@Override public void setUser(String id) { super.setUser(id); }
@Override public String headValue() throws IOException { return super.headValue(); }
-
+
public void setLastMiss(long lastMiss) { this.lastMiss = lastMiss; }
public void setCount(int count) { this.count = count; }
}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsTransferSS.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsTransferSS.java
index c7720775..6d09b379 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsTransferSS.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsTransferSS.java
@@ -7,9 +7,9 @@
* 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.
@@ -34,18 +34,18 @@ import org.onap.aaf.cadi.principal.TaggedPrincipal;
import java.net.HttpURLConnection;
public class JU_AbsTransferSS {
-
+
@Mock TaggedPrincipal princMock;
@Mock SecurityInfoC<HttpURLConnection> siMock;
-
+
private static final String princName = "name";
private static final String princTag = "tag";
private static final String app = "app";
-
+
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
-
+
when(princMock.getName()).thenReturn(princName);
when(princMock.tag()).thenReturn(princTag);
}
@@ -55,12 +55,12 @@ public class JU_AbsTransferSS {
TransferSSStub stub = new TransferSSStub(princMock, app);
assertThat(stub.getID(), is(princName));
assertThat(stub.getValue(), is(princName + ':' + app + ':' + princTag + ':' + "AS"));
-
+
stub = new TransferSSStub(null, app, siMock);
assertThat(stub.getID(), is(""));
assertThat(stub.getValue(), is(nullValue()));
}
-
+
private class TransferSSStub extends AbsTransferSS<HttpURLConnection> {
public TransferSSStub(TaggedPrincipal principal, String app) { super(principal, app); }
public TransferSSStub(TaggedPrincipal principal, String app, SecurityInfoC<HttpURLConnection> si) { super(principal, app, si); }
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Future.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Future.java
index 97fa9d21..a631dfbc 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Future.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Future.java
@@ -7,9 +7,9 @@
* 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.
@@ -34,11 +34,11 @@ public class JU_Future {
@SuppressWarnings("unused")
Future<Integer> f = new FutureStub();
}
-
+
private class FutureStub extends Future<Integer> {
- @Override public boolean get(int timeout) throws CadiException { return false; }
- @Override public int code() { return 0; }
- @Override public String body() { return null; }
+ @Override public boolean get(int timeout) throws CadiException { return false; }
+ @Override public int code() { return 0; }
+ @Override public String body() { return null; }
@Override public String header(String tag) { return null; }
}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java
index 6412d243..d8c5a598 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java
@@ -7,9 +7,9 @@
* * 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.
@@ -37,7 +37,7 @@ public class JU_Holder {
Holder<String> holder = new Holder<String>(str1);
assertThat(holder.get(), is(str1));
assertThat(holder.toString(), is(str1));
-
+
holder.set(str2);
assertThat(holder.get(), is(str2));
assertThat(holder.toString(), is(str2));
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Rcli.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Rcli.java
index d33811e3..8fe0190c 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Rcli.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Rcli.java
@@ -7,9 +7,9 @@
* 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.
@@ -61,24 +61,24 @@ public class JU_Rcli {
@Mock HttpServletRequest reqMock;
@Mock HttpServletResponse respMock;
@Mock ServletInputStream isMock;
-
+
private final static String uriString = "example.com";
private final static String apiVersion = "v1.0";
private final static String contentType = "contentType";
-
+
private static URI uri;
private static Enumeration<String> enumeration;
private Client client;
-
+
@Before
public void setup() throws URISyntaxException, IOException {
MockitoAnnotations.initMocks(this);
-
+
when(dfMock.getTypeClass()).thenReturn(HttpURLConnection.class);
when(dfMock.newData()).thenReturn(dataMock);
when(dataMock.out((TYPE) any())).thenReturn(dataMock);
-
+
when(reqMock.getInputStream()).thenReturn(isMock);
when(isMock.read((byte[]) any())).thenReturn(-1);
@@ -86,7 +86,7 @@ public class JU_Rcli {
enumeration = new CustomEnumeration();
client = new Client();
}
-
+
@Test
public void createTest() throws APIException, CadiException {
RcliStub rcli = new RcliStub(uri);
@@ -112,7 +112,7 @@ public class JU_Rcli {
rcli.create("No question mark", contentType);
rcli.create("question?mark", contentType);
}
-
+
@Test
public void postFormTest() throws APIException, CadiException {
RcliStub rcli = new RcliStub(uri);
@@ -121,7 +121,7 @@ public class JU_Rcli {
rcli.postForm(null, dfMock);
rcli.postForm("No question mark", dfMock);
rcli.postForm("question?mark", dfMock);
-
+
rcli.type(Data.TYPE.JSON);
rcli.postForm("question?mark", dfMock);
@@ -145,7 +145,7 @@ public class JU_Rcli {
rcli.readPost("First string", "Second string");
}
-
+
@Test
public void readTest() throws APIException, CadiException {
RcliStub rcli = new RcliStub(uri);
@@ -189,7 +189,7 @@ public class JU_Rcli {
when(reqMock.getRequestURI()).thenReturn(uriString);
when(reqMock.getHeaderNames()).thenReturn(enumeration);
rcli.transfer(reqMock, respMock, "string", 200);
-
+
// coverage...
when(reqMock.getMethod()).thenReturn("GET");
rcli.transfer(reqMock, respMock, "string", 200);
@@ -207,13 +207,13 @@ public class JU_Rcli {
public void accessorMutatorTest() throws URISyntaxException {
RcliStub rcli = new RcliStub();
Rcli<?> rcliClone = rcli.forUser(null);
-
+
rcli = new RcliStub(uri);
assertThat(rcli.toString(), is(uriString));
assertThat(rcli.getURI(), is(uri));
assertThat(rcli.getReadTimeout(), is(5000));
assertThat(rcli.getConnectionTimeout(), is(3000));
-
+
rcli.connectionTimeout(3001);
assertThat(rcli.getConnectionTimeout(), is(3001));
rcli.readTimeout(5001);
@@ -224,7 +224,7 @@ public class JU_Rcli {
assertThat(rcli.typeString(HttpURLConnection.class), is("application/HttpURLConnection+xml;version=" + apiVersion));
rcli.apiVersion(null);
assertThat(rcli.typeString(HttpURLConnection.class), is("application/HttpURLConnection+xml"));
-
+
rcliClone = rcli.forUser(null);
assertThat(rcliClone.toString(), is(uriString));
}
@@ -232,15 +232,15 @@ public class JU_Rcli {
private class RcliStub extends Rcli<HttpURLConnection> {
public RcliStub() { super(); }
public RcliStub(URI uri) { this.uri = uri; }
- @Override public void setSecuritySetter(SecuritySetter<HttpURLConnection> ss) { }
- @Override public SecuritySetter<HttpURLConnection> getSecuritySetter() { return null; }
- @Override protected Rcli<HttpURLConnection> clone(URI uri, SecuritySetter<HttpURLConnection> ss) { return this; }
- @Override public void invalidate() throws CadiException { }
- @Override protected EClient<HttpURLConnection> client() throws CadiException { return client; }
+ @Override public void setSecuritySetter(SecuritySetter<HttpURLConnection> ss) { }
+ @Override public SecuritySetter<HttpURLConnection> getSecuritySetter() { return null; }
+ @Override protected Rcli<HttpURLConnection> clone(URI uri, SecuritySetter<HttpURLConnection> ss) { return this; }
+ @Override public void invalidate() throws CadiException { }
+ @Override protected EClient<HttpURLConnection> client() throws CadiException { return client; }
public int getReadTimeout() { return readTimeout; }
public int getConnectionTimeout() { return connectionTimeout; }
}
-
+
private class CustomEnumeration implements Enumeration<String> {
private int idx = 0;
private final String[] elements = {"This", "is", "a", "test"};
@@ -257,11 +257,11 @@ public class JU_Rcli {
private class Client implements EClient<HttpURLConnection> {
private Transfer transfer;
@Override public void setPayload(Transfer transfer) { this.transfer = transfer; }
- @Override public void setMethod(String meth) { }
- @Override public void setPathInfo(String pathinfo) { }
- @Override public void addHeader(String tag, String value) { }
- @Override public void setQueryParams(String q) { }
- @Override public void setFragment(String f) { }
+ @Override public void setMethod(String meth) { }
+ @Override public void setPathInfo(String pathinfo) { }
+ @Override public void addHeader(String tag, String value) { }
+ @Override public void setQueryParams(String q) { }
+ @Override public void setFragment(String f) { }
@Override public void send() throws APIException {
try {
if (transfer != null) {
@@ -269,14 +269,14 @@ public class JU_Rcli {
}
} catch (IOException e) {
}
- }
- @Override public <T> Future<T> futureCreate(Class<T> t) { return null; }
- @Override public Future<String> futureReadString() { return null; }
- @Override public <T> Future<T> futureRead(RosettaDF<T> df, TYPE type) { return null; }
- @Override public <T> Future<T> future(T t) { return null; }
- @Override public Future<Void> future(HttpServletResponse resp, int expected) throws APIException { return null; }
+ }
+ @Override public <T> Future<T> futureCreate(Class<T> t) { return null; }
+ @Override public Future<String> futureReadString() { return null; }
+ @Override public <T> Future<T> futureRead(RosettaDF<T> df, TYPE type) { return null; }
+ @Override public <T> Future<T> future(T t) { return null; }
+ @Override public Future<Void> future(HttpServletResponse resp, int expected) throws APIException { return null; }
}
-
+
//private class FutureStub implements Future<String> {
//}
}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Result.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Result.java
index 41570980..1da04064 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Result.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Result.java
@@ -7,9 +7,9 @@
* 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.
@@ -28,7 +28,7 @@ import org.junit.*;
import org.onap.aaf.cadi.client.Result;
public class JU_Result {
-
+
private static final int OK = 200;
private static final int NOT_FOUND = 404;
@@ -38,7 +38,7 @@ public class JU_Result {
result = Result.ok(OK, 10);
assertThat(result.toString(), is("Code: 200"));
assertThat(result.isOK(), is(true));
-
+
result = Result.err(NOT_FOUND, "File not found");
assertThat(result.toString(), is("Code: 404 = File not found"));
assertThat(result.isOK(), is(false));
@@ -47,5 +47,5 @@ public class JU_Result {
assertThat(result.toString(), is("Code: 404 = File not found"));
assertThat(result.isOK(), is(false));
}
-
+
}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Retryable.java b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Retryable.java
index 200b393d..b876710d 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Retryable.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Retryable.java
@@ -7,9 +7,9 @@
* 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.
@@ -40,10 +40,10 @@ public class JU_Retryable {
RetryableStub retry = new RetryableStub();
assertThat(retry.item(), is(nullValue()));
assertThat(retry.lastClient(), is(nullValue()));
-
+
Locator.Item item = null;
assertThat(retry.item(item), is(item));
-
+
retry = new RetryableStub(retry);
assertThat(retry.item(), is(nullValue()));
assertThat(retry.lastClient(), is(nullValue()));
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HAuthorizationHeader.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HAuthorizationHeader.java
index 4bb44e10..c2f75002 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HAuthorizationHeader.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HAuthorizationHeader.java
@@ -7,9 +7,9 @@
* 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.
@@ -41,10 +41,10 @@ public class JU_HAuthorizationHeader {
@Mock
HttpsURLConnection hucsMock;
-
+
@Mock
HttpURLConnection hucMock;
-
+
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
@@ -59,7 +59,7 @@ public class JU_HAuthorizationHeader {
header = new HAuthorizationHeader(null, null, null);
header.setSecurity(hucsMock);
}
-
+
@Test(expected = CadiException.class)
public void throwsWhenDeniedTest() throws CadiException, IOException {
HAuthorizationHeader header = new HAuthorizationHeader(siMock, "string1", "string2") {
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HBasicAuthSS.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HBasicAuthSS.java
index d0655979..9d3b5a4e 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HBasicAuthSS.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HBasicAuthSS.java
@@ -7,9 +7,9 @@
* 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.
@@ -39,23 +39,23 @@ import org.onap.aaf.cadi.http.HSecurityInfoInit;
import org.onap.aaf.cadi.principal.BasicPrincipal;
public class JU_HBasicAuthSS {
-
+
@Mock
BasicPrincipal bpMock;
-
+
private SecurityInfoC<HttpURLConnection> si;
private PropAccess access;
-
+
private final static String id = "id";
private final static String password = "password";
-
+
@Before
public void setup() throws CadiException, IOException {
MockitoAnnotations.initMocks(this);
-
+
when(bpMock.getName()).thenReturn(id);
when(bpMock.getCred()).thenReturn(password.getBytes());
-
+
access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
access.setProperty(Config.AAF_APPID, id);
access.setProperty(Config.AAF_APPPASS, access.encrypt(password));
@@ -68,7 +68,7 @@ public class JU_HBasicAuthSS {
// All the constructors accomplish the same thing
@SuppressWarnings("unused")
HBasicAuthSS auth = new HBasicAuthSS(si);
-
+
// TODO: While these test _should_ pass, and they _do_ pass on my local machine, they won't
// pass when then onap jobbuilder runs them. Good luck!
// assertThat(auth.getID(), is(id));
@@ -84,10 +84,10 @@ public class JU_HBasicAuthSS {
auth = new HBasicAuthSS(bpMock, si);
// assertThat(auth.getID(), is(id));
-
+
auth = new HBasicAuthSS(bpMock, si, false);
// assertThat(auth.getID(), is(id));
-
+
auth = new HBasicAuthSS(bpMock, si, true);
// assertThat(auth.getID(), is(id));
}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HClient.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HClient.java
index c32abe43..c224676c 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HClient.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HClient.java
@@ -99,7 +99,7 @@ public class JU_HClient {
HClientStub client;
client = new HClientStub(ssMock, uri, 0, null);
client.send();
-
+
client.setPathInfo("/pathinfo");
client.send();
@@ -116,7 +116,7 @@ public class JU_HClient {
client.setPayload(transferMock);
client.send();
}
-
+
@Test(expected = APIException.class)
public void sendThrows1Test() throws APIException, LocatorException, URISyntaxException {
HClientStub client = new HClientStub(ssMock, new URI("mailto:me@domain.com"), 0, null);
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java
index 10eb8184..98070d6b 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java
@@ -7,9 +7,9 @@
* 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.
@@ -58,14 +58,14 @@ import org.onap.aaf.misc.env.APIException;
import junit.framework.Assert;
public class JU_HMangr {
-
+
@Mock Locator<URI> locMock;
@Mock SecuritySetter<HttpURLConnection> ssMock;
@Mock Retryable<Void> retryableMock;
@Mock Retryable<Integer> goodRetry;
@Mock Locator.Item itemMock;
@Mock Rcli<Object> clientMock;
-
+
private PropAccess access;
private URI uri;
private final static String uriString = "http://example.com";
@@ -84,11 +84,11 @@ public class JU_HMangr {
when(retryableMock.item()).thenReturn(itemMock);
when(locMock.get(itemMock)).thenReturn(uri);
assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
-
+
//coverage...
when(retryableMock.lastClient()).thenReturn(clientMock);
assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
-
+
CadiException cadiException;
ConnectException connectException = new ConnectException();
@@ -210,7 +210,7 @@ public class JU_HMangr {
assertThat(hman.oneOf(ssMock, retryableMock, false, "host"), is(nullValue()));
assertThat(hman.oneOf(ssMock, retryableMock, false, uriString.substring(7)), is(nullValue()));
-
+
CadiException cadiException;
cadiException = new CadiException(new ConnectException());
@@ -244,7 +244,7 @@ public class JU_HMangr {
fail("Should've thrown an exception");
} catch (CadiException e) {
}
-
+
doThrow(new ConnectException()).when(retryableMock).code((Rcli<?>) any());
assertThat(hman.oneOf(ssMock, retryableMock, false, uriString.substring(7)), is(nullValue()));
@@ -274,5 +274,5 @@ public class JU_HMangr {
return null;
}
}
-
+
} \ No newline at end of file
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HNoAuthSS.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HNoAuthSS.java
index 923dd1a0..e1a1e70b 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HNoAuthSS.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HNoAuthSS.java
@@ -7,9 +7,9 @@
* 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.
@@ -33,21 +33,21 @@ import org.onap.aaf.cadi.config.SecurityInfoC;
import org.onap.aaf.cadi.http.HNoAuthSS;
public class JU_HNoAuthSS {
-
+
@Mock
SecurityInfoC<HttpURLConnection> siMock;
-
+
@Mock
HttpURLConnection httpMock;
@Mock
HttpsURLConnection httpsMock;
-
+
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
-
+
@Test
public void test() throws IOException, CadiException {
HNoAuthSS noAuth = new HNoAuthSS(null);
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HRcli.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HRcli.java
index ab6a39c0..92f7dd63 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HRcli.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HRcli.java
@@ -7,9 +7,9 @@
* 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.
@@ -44,22 +44,22 @@ import org.onap.aaf.cadi.http.HMangr;
import org.onap.aaf.cadi.http.HRcli;
public class JU_HRcli {
-
+
@Mock
SecuritySetter<HttpURLConnection> ssMock;
-
+
@Mock
Locator<URI> locMock;
-
+
@Mock
Locator.Item itemMock;
-
+
private HMangr hman;
private PropAccess access;
private static URI uri;
-
+
private static final String uriString = "example.com";
-
+
@Before
public void setup() throws LocatorException, URISyntaxException {
MockitoAnnotations.initMocks(this);
@@ -79,20 +79,20 @@ public class JU_HRcli {
hrcli.setSecuritySetter(ssMock);
assertThat(hrcli.getSecuritySetter(), is(ssMock));
-
+
// No throw
hrcli.invalidate();
// Throw
doThrow(CadiException.class).when(locMock).invalidate(itemMock);
hrcli.invalidate();
}
-
+
@Test(expected = CadiException.class)
public void protectedInterfaceTest() throws CadiException, LocatorException {
HRcliStub hrcli = new HRcliStub(hman, uri, itemMock, ssMock);
HRcli clone = hrcli.clone(uri, ssMock);
assertThat(clone.toString(), is(hrcli.toString()));
-
+
EClient<HttpURLConnection> eclient = hrcli.client();
assertThat(eclient, is(not(nullValue())));
@@ -105,7 +105,7 @@ public class JU_HRcli {
when(locMock.best()).thenReturn(null);
eclient = hrcli.client();
}
-
+
private class HRcliStub extends HRcli {
public HRcliStub(HMangr hman, URI uri, Item locItem, SecuritySetter<HttpURLConnection> secSet) {
super(hman, uri, locItem, secSet);
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTokenSS.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTokenSS.java
index 9f2c9a71..eaf668e0 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTokenSS.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTokenSS.java
@@ -7,9 +7,9 @@
* 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.
@@ -36,7 +36,7 @@ public class JU_HTokenSS {
@Mock
SecurityInfoC<HttpURLConnection> siMock;
-
+
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTransferSS.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTransferSS.java
index 77fac567..809863e4 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTransferSS.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTransferSS.java
@@ -7,9 +7,9 @@
* 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.
@@ -41,10 +41,10 @@ import org.onap.aaf.cadi.http.HTransferSS;
import org.onap.aaf.cadi.principal.TaggedPrincipal;
public class JU_HTransferSS {
-
+
@Mock
TaggedPrincipal princMock;
-
+
@Mock
HttpURLConnection hucMock;
@@ -53,15 +53,15 @@ public class JU_HTransferSS {
@Mock
SecurityInfoC<HttpURLConnection> siMock;
-
+
@Mock
SecurityInfoC<HttpURLConnection> siMockNoDefSS;
@Mock
SecuritySetter<HttpURLConnection> ssMock;
-
+
private static final String princName = "name";
-
+
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
@@ -73,7 +73,7 @@ public class JU_HTransferSS {
public void test() throws IOException, CadiException {
HTransferSS transfer = new HTransferSS(princMock, "string1");
assertThat(transfer.setLastResponse(0), is(0));
-
+
transfer = new HTransferSS(princMock, "string1", siMock);
transfer.setSecurity(hucsMock);
assertThat(transfer.getID(), is(princName));
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HX509SS.java b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HX509SS.java
index fd102a95..f85697ae 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HX509SS.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HX509SS.java
@@ -7,9 +7,9 @@
* 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.
@@ -48,33 +48,33 @@ import org.onap.aaf.cadi.http.HX509SS;
import org.onap.aaf.misc.env.APIException;
public class JU_HX509SS {
-
+
@Mock X509Certificate x509Mock;
@Mock X509KeyManager keyManagerMock;
@Mock PrivateKey privateKeyMock;
@Mock SecurityInfoC<HttpURLConnection> siMock;
@Mock HttpURLConnection hucMock;
@Mock HttpsURLConnection hucsMock;
-
+
private final static String alias = "Some alias";
private final static String algName = "Some algName";
private final static byte[] publicKeyBytes = "a public key".getBytes();
-
+
private PropAccess access;
private SecurityInfoC<HttpURLConnection> si;
-
+
@Before
public void setup() throws IOException, CadiException, CertificateEncodingException {
MockitoAnnotations.initMocks(this);
-
+
when(x509Mock.getSigAlgName()).thenReturn(algName);
when(x509Mock.getEncoded()).thenReturn(publicKeyBytes);
-
+
when(keyManagerMock.getCertificateChain(alias)).thenReturn(new X509Certificate[] {x509Mock});
when(keyManagerMock.getPrivateKey(alias)).thenReturn(privateKeyMock);
when(siMock.getKeyManagers()).thenReturn(new X509KeyManager[] {keyManagerMock});
-
+
access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
access.setProperty(Config.CADI_ALIAS, alias);
// si = SecurityInfoC.instance(access, HttpURLConnectionStub.class);
@@ -87,12 +87,12 @@ public class JU_HX509SS {
assertThat(x509.setLastResponse(0), is(0));
assertThat(x509.setLastResponse(1), is(0));
assertThat(x509.setLastResponse(2), is(0));
-
+
// coverage...
x509.setSecurity(hucMock);
x509.setSecurity(hucsMock);
}
-
+
// TODO: Test the setSecurity method - Ian
// @Test
// public void test2() throws APIException, CadiException {
@@ -100,7 +100,7 @@ public class JU_HX509SS {
// x509.setSecurity(hucMock);
// x509.setSecurity(hucsMock);
// }
-
+
@Test(expected = APIException.class)
public void throws1Test() throws APIException, CadiException {
@SuppressWarnings("unused")
@@ -113,5 +113,5 @@ public class JU_HX509SS {
@SuppressWarnings("unused")
HX509SS x509 = new HX509SS(alias, siMock);
}
-
+
}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java
index b786cf68..e2c8f828 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java
@@ -7,9 +7,9 @@
* 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.
@@ -38,9 +38,9 @@ import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.locator.DNSLocator;
public class JU_DNSLocator {
-
+
private PropAccess access;
-
+
@Before
public void setup() {
access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
@@ -53,7 +53,7 @@ public class JU_DNSLocator {
URI uri;
dl = new DNSLocator(access, "https", "localhost", "8100-8101");
-
+
item = dl.best();
uri = dl.get(item);
assertThat(uri.toString(), is("https://localhost:8100"));
@@ -66,10 +66,10 @@ public class JU_DNSLocator {
}
assertThat(dl.hasItems(), is(false));
- // This doesn't actually do anything besides increase coverage
+ // This doesn't actually do anything besides increase coverage
dl.destroy();
}
-
+
@Test
public void constructorTest() throws LocatorException {
// For coverage
@@ -84,20 +84,20 @@ public class JU_DNSLocator {
new DNSLocator(access, "https://localhost:8000/");
new DNSLocator(access, "https://aaf-locatexx.onapxxx:8095/locate");
try {
- new DNSLocator(access, "https:localhost:8000");
- fail("Invalid URL should not pass");
+ new DNSLocator(access, "https:localhost:8000");
+ fail("Invalid URL should not pass");
} catch (LocatorException e) {
- access.log(Level.DEBUG, "Valid Exception");
-
+ access.log(Level.DEBUG, "Valid Exception");
+
}
}
-
+
@Test
public void refreshTest() throws LocatorException {
DNSLocator dl = new DNSLocator(access, "https", "bogushost", "8100-8101");
assertThat(dl.refresh(), is(false));
}
-
+
@Test(expected = LocatorException.class)
public void throws1Test() throws LocatorException {
new DNSLocator(access, null);
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java
index d85a84a2..496017a8 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java
@@ -86,7 +86,7 @@ public class JU_HClientHotPeerLocator {
item = loc.first();
loc.invalidate(item);
-
+
loc.invalidate(loc.bestClient());
loc.invalidate(loc.get(loc.next(item)));
loc.destroy();
@@ -106,13 +106,13 @@ public class JU_HClientHotPeerLocator {
assertThat(alternate2, is("Alternate Client is " + goodURL2));
outStream.reset();
-
+
loc.invalidate(loc.first());
loc.destroy();
loc.best();
}
-
+
@Test
public void hasNoItemTest() throws LocatorException {
HClientHotPeerLocator loc;
@@ -134,7 +134,7 @@ public class JU_HClientHotPeerLocator {
loc = new CoverageLocator(access, urlStr, 0, "38.627", "-90.199", ssMock);
assertThat(loc._invalidate(null), is(nullValue()));
loc._destroy(null);
-
+
loc._newClient("bad string");
}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java
index 0eae1198..26673dd5 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java
@@ -7,9 +7,9 @@
* 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.
@@ -85,7 +85,7 @@ public class JU_PropertyLocator {
pl.refresh();
assertThat(pl.hasItems(), is(true));
-
+
assertThat(pl.next(null), is(nullValue()));
// coverage...
@@ -97,7 +97,7 @@ public class JU_PropertyLocator {
pl.destroy();
pl = new PropertyLocator(uris);
-
+
}
@Test(expected=LocatorException.class)
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java b/cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java
index 31fda501..1cc74e56 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java
@@ -7,9 +7,9 @@
* 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.
diff --git a/cadi/client/src/test/java/org/onap/aaf/client/test/JU_ResultTest.java b/cadi/client/src/test/java/org/onap/aaf/client/test/JU_ResultTest.java
index 575bc2ee..ef26f475 100644
--- a/cadi/client/src/test/java/org/onap/aaf/client/test/JU_ResultTest.java
+++ b/cadi/client/src/test/java/org/onap/aaf/client/test/JU_ResultTest.java
@@ -7,9 +7,9 @@
* * 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.
@@ -52,7 +52,7 @@ public class JU_ResultTest {
assertFalse(t.isOK());
assertThat(t.toString(), is("Code: 1 = Error Body"));
}
-
+
@Test
public void testOk1() {
Result<String> t = Result.ok(1, "Ok");
@@ -70,7 +70,7 @@ public class JU_ResultTest {
assertFalse(t.isOK());
assertThat(t.toString(), is("Code: 1 = Error Body"));
}
-
+
@Test
public void testOk2() {
Result<String> t = Result.ok(1, "Ok");
@@ -88,7 +88,7 @@ public class JU_ResultTest {
assertFalse(t.isOK());
assertThat(t.toString(), is("Code: 1 = Error Body"));
}
-
+
@Test
public void testOk3() {
Result<String> t = Result.ok(1, "Ok");