summaryrefslogtreecommitdiffstats
path: root/cadi/client/src/test/java/org
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-09-07 12:21:34 -0500
committerInstrumental <jonathan.gathman@att.com>2018-09-07 12:22:50 -0500
commit4b5a7d721d994a49057e9bfb403c7bff1b376660 (patch)
treea36d03227b63a3e60346d6c3ca87b061087dae85 /cadi/client/src/test/java/org
parent824dc7b5fc0e1ccdf7f460479aff344727f0f01e (diff)
Mass removal of all Tabs (Style Warnings)
Issue-ID: AAF-473 Change-Id: Iaf0ef8120882937959bb0065f2f6ba74a021940f Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/client/src/test/java/org')
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsAuthentication.java118
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_AbsTransferSS.java66
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Future.java24
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Holder.java24
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Rcli.java448
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Result.java36
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/client/test/JU_Retryable.java40
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HAuthorizationHeader.java70
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HBasicAuthSS.java92
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HClient.java530
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HMangr.java424
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HNoAuthSS.java44
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HRcli.java134
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTokenSS.java26
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HTransferSS.java82
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/http/test/JU_HX509SS.java126
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java172
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_HClientHotPeerLocator.java216
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_PropertyLocator.java114
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/routing/test/JU_GreatCircle.java78
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/client/test/JU_ResultTest.java140
21 files changed, 1502 insertions, 1502 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 cc67946e..65daa7b6 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
@@ -34,70 +34,70 @@ 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);
- }
+
+ 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);
+ }
- @Test
- public void test() throws IOException, InterruptedException {
- AuthStub stub = new AuthStub(null, null, null);
- assertThat(stub.getID(), is(nullValue()));
- assertThat(stub.headValue(), is(""));
- assertThat(stub.count(), is(0));
-
- stub.setUser(ID);
- assertThat(stub.getID(), is(ID));
+ @Test
+ public void test() throws IOException, InterruptedException {
+ AuthStub stub = new AuthStub(null, null, null);
+ assertThat(stub.getID(), is(nullValue()));
+ assertThat(stub.headValue(), is(""));
+ assertThat(stub.count(), is(0));
+
+ stub.setUser(ID);
+ assertThat(stub.getID(), is(ID));
- stub = new AuthStub(null, ID, PASSWORD.getBytes());
- 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));
+ stub = new AuthStub(null, ID, PASSWORD.getBytes());
+ 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));
- for (int i = 1; i <= 10; i++) {
- assertThat(stub.setLastResponse(401), is(i));
- assertThat(stub.isDenied(), is(false));
- }
- assertThat(stub.setLastResponse(401), is(11));
- assertThat(stub.isDenied(), is(true));
+ for (int i = 1; i <= 10; i++) {
+ assertThat(stub.setLastResponse(401), is(i));
+ assertThat(stub.isDenied(), is(false));
+ }
+ assertThat(stub.setLastResponse(401), is(11));
+ assertThat(stub.isDenied(), is(true));
- 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> {
+ 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)
- throws IOException { super(securityInfo, user, headValue); }
+ public AuthStub(SecurityInfoC<HttpURLConnection> securityInfo, String user, byte[] headValue)
+ throws IOException { super(securityInfo, user, headValue); }
- @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; }
- }
+ @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 507f90f4..c7720775 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
@@ -34,39 +34,39 @@ 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);
- }
+
+ @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);
+ }
- @Test
- public void test() {
- 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); }
- @Override public void setSecurity(HttpURLConnection client) throws CadiException { }
- @Override public int setLastResponse(int respCode) { return 0; }
- public String getValue() { return value; }
- }
+ @Test
+ public void test() {
+ 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); }
+ @Override public void setSecurity(HttpURLConnection client) throws CadiException { }
+ @Override public int setLastResponse(int respCode) { return 0; }
+ public String getValue() { return value; }
+ }
}
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 ad0bd535..97fa9d21 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
@@ -29,17 +29,17 @@ import org.onap.aaf.cadi.client.Future;
public class JU_Future {
- @Test
- public void test() {
- @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 String header(String tag) { return null; }
- }
+ @Test
+ public void test() {
+ @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 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 079951f5..dd9b0539 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
@@ -29,17 +29,17 @@ import org.onap.aaf.cadi.client.Holder;
public class JU_Holder {
- @Test
- public void test() {
- String str1 = "a string";
- String str2 = "another string";
- 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));
- }
+ @Test
+ public void test() {
+ String str1 = "a string";
+ String str2 = "another string";
+ 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 886c5d84..d33811e3 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
@@ -55,228 +55,228 @@ import org.onap.aaf.misc.rosetta.env.RosettaData;
public class JU_Rcli {
- @Mock RosettaDF<HttpURLConnection> dfMock;
- @Mock RosettaData<HttpURLConnection> dataMock;
- @Mock HttpURLConnection conMock;
- @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);
-
- uri = new URI(uriString);
- enumeration = new CustomEnumeration();
- client = new Client();
- }
-
- @Test
- public void createTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
- rcli.type(Data.TYPE.XML);
-
- rcli.create(null, contentType, dfMock, conMock);
- rcli.create("No question mark", contentType, dfMock, conMock);
- rcli.create("question?mark", contentType, dfMock, conMock);
-
- rcli.create(null, dfMock, conMock);
- rcli.create("No question mark", dfMock, conMock);
- rcli.create("question?mark", dfMock, conMock);
-
- rcli.create(null, HttpURLConnection.class, dfMock, conMock);
- rcli.create("No question mark", HttpURLConnection.class, dfMock, conMock);
- rcli.create("question?mark", HttpURLConnection.class, dfMock, conMock);
-
- rcli.create(null, HttpURLConnection.class);
- rcli.create("No question mark", HttpURLConnection.class);
- rcli.create("question?mark", HttpURLConnection.class);
-
- rcli.create(null, contentType);
- rcli.create("No question mark", contentType);
- rcli.create("question?mark", contentType);
- }
-
- @Test
- public void postFormTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
-
- rcli.type(Data.TYPE.DEFAULT);
- 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);
-
- rcli.type(Data.TYPE.XML);
- rcli.postForm("question?mark", dfMock);
-
- }
-
- @Test
- public void readPostTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
- rcli.type(Data.TYPE.DEFAULT);
-
- rcli.readPost(null, dfMock, conMock);
- rcli.readPost("No question mark", dfMock, conMock);
- rcli.readPost("question?mark", dfMock, conMock);
-
- rcli.readPost(null, dfMock, conMock, dfMock);
- rcli.readPost("No question mark", dfMock, conMock, dfMock);
- rcli.readPost("question?mark", dfMock, conMock, dfMock);
-
- rcli.readPost("First string", "Second string");
- }
-
- @Test
- public void readTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
- rcli.type(Data.TYPE.DEFAULT);
-
- rcli.read("First string", "Second string", "Third string", "Fourth string");
- rcli.read("First string", "Second string", dfMock, "Third string", "Fourth string");
- rcli.read("First string", dfMock, "Third string", "Fourth string");
- rcli.read("First string", HttpURLConnection.class ,dfMock);
- }
-
- @Test
- public void updateTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
- rcli.type(Data.TYPE.DEFAULT);
-
- rcli.update("First string", "Second string", dfMock, conMock);
- rcli.update("First string", dfMock, conMock);
- rcli.update("First string", HttpURLConnection.class, dfMock, conMock);
- rcli.update("First string");
- rcli.updateRespondString("First string", dfMock, conMock);
- }
-
- @Test
- public void deleteTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
- rcli.type(Data.TYPE.DEFAULT);
-
- rcli.delete("First string", "Second string", dfMock, conMock);
- rcli.delete("First string", dfMock, conMock);
- rcli.delete("First string", HttpURLConnection.class, dfMock, conMock);
- rcli.delete("First string", HttpURLConnection.class);
- rcli.delete("First string", "Second string");
- }
-
- @Test
- public void transferTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
- rcli.type(Data.TYPE.DEFAULT);
-
- 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);
- }
-
- @Test(expected = CadiException.class)
- public void transferThrowsTest() throws APIException, CadiException {
- RcliStub rcli = new RcliStub(uri);
- rcli.type(Data.TYPE.DEFAULT);
-
- rcli.transfer(reqMock, respMock, "string", 200);
- }
-
- @Test
- 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);
- assertThat(rcli.getReadTimeout(), is(5001));
- rcli.apiVersion(apiVersion);
- assertThat(rcli.isApiVersion(apiVersion), is(true));
- rcli.type(Data.TYPE.XML);
- 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));
- }
-
- 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; }
- 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"};
- @Override
- public String nextElement() {
- return idx >= elements.length ? null : elements[idx++];
- }
- @Override
- public boolean hasMoreElements() {
- return idx < elements.length;
- }
- }
-
- 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 send() throws APIException {
- try {
- if (transfer != null) {
- transfer.transfer(new PrintStream(new ByteArrayOutputStream()));
- }
- } 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; }
- }
-
- //private class FutureStub implements Future<String> {
- //}
+ @Mock RosettaDF<HttpURLConnection> dfMock;
+ @Mock RosettaData<HttpURLConnection> dataMock;
+ @Mock HttpURLConnection conMock;
+ @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);
+
+ uri = new URI(uriString);
+ enumeration = new CustomEnumeration();
+ client = new Client();
+ }
+
+ @Test
+ public void createTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+ rcli.type(Data.TYPE.XML);
+
+ rcli.create(null, contentType, dfMock, conMock);
+ rcli.create("No question mark", contentType, dfMock, conMock);
+ rcli.create("question?mark", contentType, dfMock, conMock);
+
+ rcli.create(null, dfMock, conMock);
+ rcli.create("No question mark", dfMock, conMock);
+ rcli.create("question?mark", dfMock, conMock);
+
+ rcli.create(null, HttpURLConnection.class, dfMock, conMock);
+ rcli.create("No question mark", HttpURLConnection.class, dfMock, conMock);
+ rcli.create("question?mark", HttpURLConnection.class, dfMock, conMock);
+
+ rcli.create(null, HttpURLConnection.class);
+ rcli.create("No question mark", HttpURLConnection.class);
+ rcli.create("question?mark", HttpURLConnection.class);
+
+ rcli.create(null, contentType);
+ rcli.create("No question mark", contentType);
+ rcli.create("question?mark", contentType);
+ }
+
+ @Test
+ public void postFormTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+
+ rcli.type(Data.TYPE.DEFAULT);
+ 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);
+
+ rcli.type(Data.TYPE.XML);
+ rcli.postForm("question?mark", dfMock);
+
+ }
+
+ @Test
+ public void readPostTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+ rcli.type(Data.TYPE.DEFAULT);
+
+ rcli.readPost(null, dfMock, conMock);
+ rcli.readPost("No question mark", dfMock, conMock);
+ rcli.readPost("question?mark", dfMock, conMock);
+
+ rcli.readPost(null, dfMock, conMock, dfMock);
+ rcli.readPost("No question mark", dfMock, conMock, dfMock);
+ rcli.readPost("question?mark", dfMock, conMock, dfMock);
+
+ rcli.readPost("First string", "Second string");
+ }
+
+ @Test
+ public void readTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+ rcli.type(Data.TYPE.DEFAULT);
+
+ rcli.read("First string", "Second string", "Third string", "Fourth string");
+ rcli.read("First string", "Second string", dfMock, "Third string", "Fourth string");
+ rcli.read("First string", dfMock, "Third string", "Fourth string");
+ rcli.read("First string", HttpURLConnection.class ,dfMock);
+ }
+
+ @Test
+ public void updateTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+ rcli.type(Data.TYPE.DEFAULT);
+
+ rcli.update("First string", "Second string", dfMock, conMock);
+ rcli.update("First string", dfMock, conMock);
+ rcli.update("First string", HttpURLConnection.class, dfMock, conMock);
+ rcli.update("First string");
+ rcli.updateRespondString("First string", dfMock, conMock);
+ }
+
+ @Test
+ public void deleteTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+ rcli.type(Data.TYPE.DEFAULT);
+
+ rcli.delete("First string", "Second string", dfMock, conMock);
+ rcli.delete("First string", dfMock, conMock);
+ rcli.delete("First string", HttpURLConnection.class, dfMock, conMock);
+ rcli.delete("First string", HttpURLConnection.class);
+ rcli.delete("First string", "Second string");
+ }
+
+ @Test
+ public void transferTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+ rcli.type(Data.TYPE.DEFAULT);
+
+ 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);
+ }
+
+ @Test(expected = CadiException.class)
+ public void transferThrowsTest() throws APIException, CadiException {
+ RcliStub rcli = new RcliStub(uri);
+ rcli.type(Data.TYPE.DEFAULT);
+
+ rcli.transfer(reqMock, respMock, "string", 200);
+ }
+
+ @Test
+ 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);
+ assertThat(rcli.getReadTimeout(), is(5001));
+ rcli.apiVersion(apiVersion);
+ assertThat(rcli.isApiVersion(apiVersion), is(true));
+ rcli.type(Data.TYPE.XML);
+ 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));
+ }
+
+ 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; }
+ 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"};
+ @Override
+ public String nextElement() {
+ return idx >= elements.length ? null : elements[idx++];
+ }
+ @Override
+ public boolean hasMoreElements() {
+ return idx < elements.length;
+ }
+ }
+
+ 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 send() throws APIException {
+ try {
+ if (transfer != null) {
+ transfer.transfer(new PrintStream(new ByteArrayOutputStream()));
+ }
+ } 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; }
+ }
+
+ //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 05ca27f3..41570980 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
@@ -28,24 +28,24 @@ 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;
+
+ private static final int OK = 200;
+ private static final int NOT_FOUND = 404;
- @Test
- public void test() {
- Result<Integer> 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));
+ @Test
+ public void test() {
+ Result<Integer> 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));
- result = Result.err(result);
- assertThat(result.toString(), is("Code: 404 = File not found"));
- assertThat(result.isOK(), is(false));
- }
-
+ result = Result.err(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 84863744..200b393d 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
@@ -35,25 +35,25 @@ import org.onap.aaf.misc.env.APIException;
public class JU_Retryable {
- @Test
- public void test() {
- 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()));
- assertThat(retry.item(item), is(item));
- }
-
- private class RetryableStub extends Retryable<Integer> {
- public RetryableStub() { super(); }
- public RetryableStub(Retryable<?> ret) { super(ret); }
- @Override public Integer code(Rcli<?> client) throws CadiException, ConnectException, APIException { return null; }
- }
+ @Test
+ public void test() {
+ 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()));
+ assertThat(retry.item(item), is(item));
+ }
+
+ private class RetryableStub extends Retryable<Integer> {
+ public RetryableStub() { super(); }
+ public RetryableStub(Retryable<?> ret) { super(ret); }
+ @Override public Integer code(Rcli<?> client) throws CadiException, ConnectException, APIException { return null; }
+ }
}
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 be12e7ac..4bb44e10 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
@@ -36,44 +36,44 @@ import org.onap.aaf.cadi.http.HAuthorizationHeader;
public class JU_HAuthorizationHeader {
- @Mock
- SecurityInfoC<HttpURLConnection> siMock;
+ @Mock
+ SecurityInfoC<HttpURLConnection> siMock;
- @Mock
- HttpsURLConnection hucsMock;
-
- @Mock
- HttpURLConnection hucMock;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
+ @Mock
+ HttpsURLConnection hucsMock;
+
+ @Mock
+ HttpURLConnection hucMock;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
- @Test
- public void test() throws IOException, CadiException {
- HAuthorizationHeader header = new HAuthorizationHeader(siMock, null, null);
- header.setSecurity(hucsMock);
- header.setSecurity(hucMock);
+ @Test
+ public void test() throws IOException, CadiException {
+ HAuthorizationHeader header = new HAuthorizationHeader(siMock, null, null);
+ header.setSecurity(hucsMock);
+ header.setSecurity(hucMock);
- 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") {
- @Override public boolean isDenied() { return true; }
- };
- header.setSecurity(null);
- }
+ 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") {
+ @Override public boolean isDenied() { return true; }
+ };
+ header.setSecurity(null);
+ }
- @Test(expected = CadiException.class)
- public void throwsTest() throws CadiException, IOException {
- HAuthorizationHeader header = new HAuthorizationHeader(siMock, "string1", "string2") {
- @Override public String headValue() throws IOException { throw new IOException(); }
- };
- header.setSecurity(null);
- }
+ @Test(expected = CadiException.class)
+ public void throwsTest() throws CadiException, IOException {
+ HAuthorizationHeader header = new HAuthorizationHeader(siMock, "string1", "string2") {
+ @Override public String headValue() throws IOException { throw new IOException(); }
+ };
+ header.setSecurity(null);
+ }
}
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 fa0a673f..d0655979 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
@@ -39,57 +39,57 @@ 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));
+
+ @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));
- si = SecurityInfoC.instance(access, HttpURLConnection.class);
- }
+ si = SecurityInfoC.instance(access, HttpURLConnection.class);
+ }
- @Test
- public void test() throws IOException {
- // 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));
+ @Test
+ public void test() throws IOException {
+ // 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));
- auth = new HBasicAuthSS(si, false);
-// assertThat(auth.getID(), is(id));
+ auth = new HBasicAuthSS(si, false);
+// assertThat(auth.getID(), is(id));
- auth = new HBasicAuthSS(si, id, password, false);
-// assertThat(auth.getID(), is(id));
+ auth = new HBasicAuthSS(si, id, password, false);
+// assertThat(auth.getID(), is(id));
- auth = new HBasicAuthSS(si, id, password, true);
-// assertThat(auth.getID(), is(id));
+ auth = new HBasicAuthSS(si, id, password, true);
+// assertThat(auth.getID(), is(id));
- 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));
- }
+ 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 646d63fa..c32abe43 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
@@ -51,270 +51,270 @@ import org.onap.aaf.misc.rosetta.env.RosettaData;
public class JU_HClient {
- @Mock private SecuritySetter<HttpURLConnection> ssMock;
- @Mock private Transfer transferMock;
- @Mock private HttpURLConnection hucMock;
- @Mock private HttpServletResponse respMock;
- @Mock private RosettaDF<HttpURLConnection> dfMock;
- @Mock private RosettaData<HttpURLConnection> dataMock;
-
- private static final String uriString = "http://example.com:8080/path/to/a/file.txt";
- private static final String fragment = "fragment";
- private static final String method = "method";
- private static final String pathinfo = "pathinfo";
- private static final String queryParams = "queryParams";
-
- private static final String errorString = "error string";
- private static final String successString = "success string";
-
- private static final String tag1 = "tag1";
- private static final String tag2 = "tag2";
- private static final String value1 = "value1";
- private static final String value2 = "value2";
-
- private URI uri;
-
- @Before
- public void setup() throws URISyntaxException {
- MockitoAnnotations.initMocks(this);
-
- uri = new URI(uriString);
- }
-
- @Test
- public void accessorsMutatorsTest() throws LocatorException {
- HClient client = new HClient(ssMock, uri, 0);
- client.setFragment(fragment);
- client.setMethod(method);
- client.setPathInfo(pathinfo);
- client.setPayload(transferMock);
- client.setQueryParams(queryParams);
- assertThat(client.getURI(), is(uri));
- assertThat(client.timeout(), is(0));
- assertThat(client.toString(), is("HttpURLConnection Client configured to " + uri.toString()));
- }
-
- @Test
- public void sendTest() throws LocatorException, APIException, URISyntaxException {
- HClientStub client;
- client = new HClientStub(ssMock, uri, 0, null);
- client.send();
-
- client.setPathInfo("/pathinfo");
- client.send();
-
- client.setPathInfo("pathinfo");
- client.send();
-
- client = new HClientStub(null, uri, 0, null);
- client.send();
-
- client.addHeader(tag1, value1);
- client.addHeader(tag2, value2);
- client.send();
-
- 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);
- client.send();
- }
-
- @Test(expected = APIException.class)
- public void sendThrows2Test() throws APIException, LocatorException, URISyntaxException {
- HClientStub client = new HClientStub(ssMock, new URI("mailto:me@domain.com"), 0, null);
- client.addHeader(tag1, value1);
- client.addHeader(tag2, value2);
- client.send();
- }
-
- @Test
- public void futureCreateTest() throws LocatorException, CadiException, IOException {
- HClient client = new HClientStub(ssMock, uri, 0, hucMock);
- HFuture<HttpURLConnection> future = (HFuture<HttpURLConnection>) client.futureCreate(HttpURLConnection.class);
-
- // Test a bad response code (default 0) without output
- assertThat(future.get(0), is(false));
- assertThat(future.body().length(), is(0));
-
- // Test a bad response code (default 0) with output
- ByteArrayInputStream bais = new ByteArrayInputStream(errorString.getBytes());
- when(hucMock.getInputStream()).thenReturn(bais);
- assertThat(future.get(0), is(false));
- assertThat(future.body(), is(errorString));
-
- // Test a good response code
- when(hucMock.getResponseCode()).thenReturn(201);
- assertThat(future.get(0), is(true));
- }
-
- @Test
- public void futureReadStringTest() throws LocatorException, CadiException, IOException {
- HClient client = new HClientStub(ssMock, uri, 0, hucMock);
- Future<String> future = client.futureReadString();
-
- // Test a bad response code (default 0) without output
- assertThat(future.get(0), is(false));
- assertThat(future.body().length(), is(0));
-
- // Test a bad response code (default 0) with output
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
- assertThat(future.get(0), is(false));
- assertThat(future.body(), is(errorString));
-
- // Test a good response code
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
- when(hucMock.getResponseCode()).thenReturn(200);
- assertThat(future.get(0), is(true));
- assertThat(future.body(), is(successString));
- }
-
- @Test
- public void futureReadTest() throws LocatorException, CadiException, IOException, APIException {
- HClient client = new HClientStub(ssMock, uri, 0, hucMock);
- Future<HttpURLConnection> future = client.futureRead(dfMock, null);
-
- // Test a bad response code (default 0) without output
- assertThat(future.get(0), is(false));
- assertThat(future.body().length(), is(0));
-
- // Test a bad response code (default 0) with output
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
- assertThat(future.get(0), is(false));
- assertThat(future.body(), is(errorString));
-
- // Test a good response code
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
- when(dfMock.newData()).thenReturn(dataMock);
- when(dataMock.in(null)).thenReturn(dataMock);
- when(dataMock.load((InputStream)any())).thenReturn(dataMock);
- when(dataMock.asObject()).thenReturn(hucMock);
- when(dataMock.asString()).thenReturn(successString);
- when(hucMock.getResponseCode()).thenReturn(200);
- assertThat(future.get(0), is(true));
- assertThat(future.body(), is(successString));
- }
-
- @Test
- public void future1Test() throws LocatorException, CadiException, IOException, APIException {
- HClient client = new HClientStub(ssMock, uri, 0, hucMock);
- Future<HttpURLConnection> future = client.future(hucMock);
-
- // Test a good response code
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
- when(hucMock.getResponseCode()).thenReturn(200);
- assertThat(future.get(0), is(true));
- assertThat(future.body(), is("200"));
-
- // Test a bad response code
- when(hucMock.getResponseCode()).thenReturn(0);
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
- assertThat(future.get(0), is(false));
- assertThat(future.body(), is(errorString));
- }
-
- @Test
- public void future2Test() throws LocatorException, CadiException, IOException, APIException {
- HClient client = new HClientStub(ssMock, uri, 0, hucMock);
- Future<Void> future = client.future(respMock, 200);
-
- ServletOutputStream sos = new ServletOutputStream() {
- @Override public void write(int arg0) throws IOException { }
- };
- when(respMock.getOutputStream()).thenReturn(sos);
-
- // Test a good response code
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
- when(hucMock.getResponseCode()).thenReturn(200);
- assertThat(future.get(0), is(true));
- assertThat(future.body(), is(nullValue()));
-
- // Test a bad response code
- when(hucMock.getResponseCode()).thenReturn(0);
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
- assertThat(future.get(0), is(false));
- assertThat(future.body(), is(""));
- }
-
- @Test
- public void hfutureTest() throws CadiException, IOException, LocatorException {
- HClient client = new HClientStub(ssMock, uri, 0, hucMock);
- HFutureStub future = new HFutureStub(client, hucMock);
- assertThat(future.get(0), is(false));
-
- // Test a bad response code (default 0) with output
- when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
- assertThat(future.get(0), is(false));
-
- assertThat(future.get(0), is(false));
-
- when(hucMock.getResponseCode()).thenReturn(200);
- assertThat(future.get(0), is(true));
-
- StringBuilder sb = future.inputStreamToString(new ByteArrayInputStream(errorString.getBytes()));
- assertThat(sb.toString(), is(errorString));
-
- assertThat(future.code(), is(200));
- assertThat(future.huc(), is(hucMock));
-
- assertThat(future.exception(), is(nullValue()));
- assertThat(future.header("string"), is(nullValue()));
-
- // coverage...
- future.setHuc(null);
- future.close();
- }
-
- @Test
- public void headerTest() throws LocatorException {
- HClient client = new HClientStub(ssMock, uri, 0, hucMock);
- String tag1 = "tag1";
- String tag2 = "tag2";
- String value1 = "value1";
- String value2 = "value2";
- client.addHeader(tag1, value1);
- client.addHeader(tag2, value2);
- }
-
- @Test(expected = LocatorException.class)
- public void throws1Test() throws LocatorException {
- @SuppressWarnings("unused")
- HClient client = new HClient(ssMock, null, 0);
- }
-
- private class HClientStub extends HClient {
- public HClientStub(SecuritySetter<HttpURLConnection> ss, URI uri, int connectTimeout, HttpURLConnection huc) throws LocatorException {
- super(ss, uri, connectTimeout);
- setHuc(huc);
- }
- public void setHuc(HttpURLConnection huc) {
- Field field;
- try {
- field = HClient.class.getDeclaredField("huc");
- field.setAccessible(true);
- field.set(this, huc);
- field.setAccessible(false);
- } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
- e.printStackTrace();
- fail("Caught an exception: " + e.getMessage());
- }
- }
- @Override
- public HttpURLConnection getConnection(URI uri, StringBuilder pi) throws IOException {
- return hucMock;
- }
- }
-
- private class HFutureStub extends HFuture<HttpURLConnection> {
- public HFutureStub(HClient hClient, HttpURLConnection huc) {
- hClient.super(huc);
- }
-
- @Override public String body() { return null; }
- public void setHuc(HttpURLConnection huc) { this.huc = huc; }
- }
+ @Mock private SecuritySetter<HttpURLConnection> ssMock;
+ @Mock private Transfer transferMock;
+ @Mock private HttpURLConnection hucMock;
+ @Mock private HttpServletResponse respMock;
+ @Mock private RosettaDF<HttpURLConnection> dfMock;
+ @Mock private RosettaData<HttpURLConnection> dataMock;
+
+ private static final String uriString = "http://example.com:8080/path/to/a/file.txt";
+ private static final String fragment = "fragment";
+ private static final String method = "method";
+ private static final String pathinfo = "pathinfo";
+ private static final String queryParams = "queryParams";
+
+ private static final String errorString = "error string";
+ private static final String successString = "success string";
+
+ private static final String tag1 = "tag1";
+ private static final String tag2 = "tag2";
+ private static final String value1 = "value1";
+ private static final String value2 = "value2";
+
+ private URI uri;
+
+ @Before
+ public void setup() throws URISyntaxException {
+ MockitoAnnotations.initMocks(this);
+
+ uri = new URI(uriString);
+ }
+
+ @Test
+ public void accessorsMutatorsTest() throws LocatorException {
+ HClient client = new HClient(ssMock, uri, 0);
+ client.setFragment(fragment);
+ client.setMethod(method);
+ client.setPathInfo(pathinfo);
+ client.setPayload(transferMock);
+ client.setQueryParams(queryParams);
+ assertThat(client.getURI(), is(uri));
+ assertThat(client.timeout(), is(0));
+ assertThat(client.toString(), is("HttpURLConnection Client configured to " + uri.toString()));
+ }
+
+ @Test
+ public void sendTest() throws LocatorException, APIException, URISyntaxException {
+ HClientStub client;
+ client = new HClientStub(ssMock, uri, 0, null);
+ client.send();
+
+ client.setPathInfo("/pathinfo");
+ client.send();
+
+ client.setPathInfo("pathinfo");
+ client.send();
+
+ client = new HClientStub(null, uri, 0, null);
+ client.send();
+
+ client.addHeader(tag1, value1);
+ client.addHeader(tag2, value2);
+ client.send();
+
+ 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);
+ client.send();
+ }
+
+ @Test(expected = APIException.class)
+ public void sendThrows2Test() throws APIException, LocatorException, URISyntaxException {
+ HClientStub client = new HClientStub(ssMock, new URI("mailto:me@domain.com"), 0, null);
+ client.addHeader(tag1, value1);
+ client.addHeader(tag2, value2);
+ client.send();
+ }
+
+ @Test
+ public void futureCreateTest() throws LocatorException, CadiException, IOException {
+ HClient client = new HClientStub(ssMock, uri, 0, hucMock);
+ HFuture<HttpURLConnection> future = (HFuture<HttpURLConnection>) client.futureCreate(HttpURLConnection.class);
+
+ // Test a bad response code (default 0) without output
+ assertThat(future.get(0), is(false));
+ assertThat(future.body().length(), is(0));
+
+ // Test a bad response code (default 0) with output
+ ByteArrayInputStream bais = new ByteArrayInputStream(errorString.getBytes());
+ when(hucMock.getInputStream()).thenReturn(bais);
+ assertThat(future.get(0), is(false));
+ assertThat(future.body(), is(errorString));
+
+ // Test a good response code
+ when(hucMock.getResponseCode()).thenReturn(201);
+ assertThat(future.get(0), is(true));
+ }
+
+ @Test
+ public void futureReadStringTest() throws LocatorException, CadiException, IOException {
+ HClient client = new HClientStub(ssMock, uri, 0, hucMock);
+ Future<String> future = client.futureReadString();
+
+ // Test a bad response code (default 0) without output
+ assertThat(future.get(0), is(false));
+ assertThat(future.body().length(), is(0));
+
+ // Test a bad response code (default 0) with output
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
+ assertThat(future.get(0), is(false));
+ assertThat(future.body(), is(errorString));
+
+ // Test a good response code
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
+ when(hucMock.getResponseCode()).thenReturn(200);
+ assertThat(future.get(0), is(true));
+ assertThat(future.body(), is(successString));
+ }
+
+ @Test
+ public void futureReadTest() throws LocatorException, CadiException, IOException, APIException {
+ HClient client = new HClientStub(ssMock, uri, 0, hucMock);
+ Future<HttpURLConnection> future = client.futureRead(dfMock, null);
+
+ // Test a bad response code (default 0) without output
+ assertThat(future.get(0), is(false));
+ assertThat(future.body().length(), is(0));
+
+ // Test a bad response code (default 0) with output
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
+ assertThat(future.get(0), is(false));
+ assertThat(future.body(), is(errorString));
+
+ // Test a good response code
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
+ when(dfMock.newData()).thenReturn(dataMock);
+ when(dataMock.in(null)).thenReturn(dataMock);
+ when(dataMock.load((InputStream)any())).thenReturn(dataMock);
+ when(dataMock.asObject()).thenReturn(hucMock);
+ when(dataMock.asString()).thenReturn(successString);
+ when(hucMock.getResponseCode()).thenReturn(200);
+ assertThat(future.get(0), is(true));
+ assertThat(future.body(), is(successString));
+ }
+
+ @Test
+ public void future1Test() throws LocatorException, CadiException, IOException, APIException {
+ HClient client = new HClientStub(ssMock, uri, 0, hucMock);
+ Future<HttpURLConnection> future = client.future(hucMock);
+
+ // Test a good response code
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
+ when(hucMock.getResponseCode()).thenReturn(200);
+ assertThat(future.get(0), is(true));
+ assertThat(future.body(), is("200"));
+
+ // Test a bad response code
+ when(hucMock.getResponseCode()).thenReturn(0);
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
+ assertThat(future.get(0), is(false));
+ assertThat(future.body(), is(errorString));
+ }
+
+ @Test
+ public void future2Test() throws LocatorException, CadiException, IOException, APIException {
+ HClient client = new HClientStub(ssMock, uri, 0, hucMock);
+ Future<Void> future = client.future(respMock, 200);
+
+ ServletOutputStream sos = new ServletOutputStream() {
+ @Override public void write(int arg0) throws IOException { }
+ };
+ when(respMock.getOutputStream()).thenReturn(sos);
+
+ // Test a good response code
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(successString.getBytes()));
+ when(hucMock.getResponseCode()).thenReturn(200);
+ assertThat(future.get(0), is(true));
+ assertThat(future.body(), is(nullValue()));
+
+ // Test a bad response code
+ when(hucMock.getResponseCode()).thenReturn(0);
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
+ assertThat(future.get(0), is(false));
+ assertThat(future.body(), is(""));
+ }
+
+ @Test
+ public void hfutureTest() throws CadiException, IOException, LocatorException {
+ HClient client = new HClientStub(ssMock, uri, 0, hucMock);
+ HFutureStub future = new HFutureStub(client, hucMock);
+ assertThat(future.get(0), is(false));
+
+ // Test a bad response code (default 0) with output
+ when(hucMock.getInputStream()).thenReturn(new ByteArrayInputStream(errorString.getBytes()));
+ assertThat(future.get(0), is(false));
+
+ assertThat(future.get(0), is(false));
+
+ when(hucMock.getResponseCode()).thenReturn(200);
+ assertThat(future.get(0), is(true));
+
+ StringBuilder sb = future.inputStreamToString(new ByteArrayInputStream(errorString.getBytes()));
+ assertThat(sb.toString(), is(errorString));
+
+ assertThat(future.code(), is(200));
+ assertThat(future.huc(), is(hucMock));
+
+ assertThat(future.exception(), is(nullValue()));
+ assertThat(future.header("string"), is(nullValue()));
+
+ // coverage...
+ future.setHuc(null);
+ future.close();
+ }
+
+ @Test
+ public void headerTest() throws LocatorException {
+ HClient client = new HClientStub(ssMock, uri, 0, hucMock);
+ String tag1 = "tag1";
+ String tag2 = "tag2";
+ String value1 = "value1";
+ String value2 = "value2";
+ client.addHeader(tag1, value1);
+ client.addHeader(tag2, value2);
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throws1Test() throws LocatorException {
+ @SuppressWarnings("unused")
+ HClient client = new HClient(ssMock, null, 0);
+ }
+
+ private class HClientStub extends HClient {
+ public HClientStub(SecuritySetter<HttpURLConnection> ss, URI uri, int connectTimeout, HttpURLConnection huc) throws LocatorException {
+ super(ss, uri, connectTimeout);
+ setHuc(huc);
+ }
+ public void setHuc(HttpURLConnection huc) {
+ Field field;
+ try {
+ field = HClient.class.getDeclaredField("huc");
+ field.setAccessible(true);
+ field.set(this, huc);
+ field.setAccessible(false);
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ fail("Caught an exception: " + e.getMessage());
+ }
+ }
+ @Override
+ public HttpURLConnection getConnection(URI uri, StringBuilder pi) throws IOException {
+ return hucMock;
+ }
+ }
+
+ private class HFutureStub extends HFuture<HttpURLConnection> {
+ public HFutureStub(HClient hClient, HttpURLConnection huc) {
+ hClient.super(huc);
+ }
+
+ @Override public String body() { return null; }
+ public void setHuc(HttpURLConnection huc) { this.huc = huc; }
+ }
}
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 b7415a52..9d87d699 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
@@ -50,216 +50,216 @@ import org.onap.aaf.cadi.http.HMangr;
import org.onap.aaf.misc.env.APIException;
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";
-
- @Before
- public void setup() throws URISyntaxException {
- MockitoAnnotations.initMocks(this);
-
- access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
- uri = new URI(uriString);
- }
-
- @Test
- public void sameTest() throws LocatorException, APIException, CadiException, ConnectException {
- HMangr hman = new HMangr(access, locMock);
- 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();
- cadiException = new CadiException(connectException);
- doThrow(cadiException).when(retryableMock).code(clientMock);
- when(locMock.hasItems()).thenReturn(true).thenReturn(false);
- assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
-
- SocketException socketException = new SocketException();
- cadiException = new CadiException(socketException);
- doThrow(cadiException).when(retryableMock).code(clientMock);
- when(locMock.hasItems()).thenReturn(true).thenReturn(false);
- assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
-
- doThrow(connectException).when(retryableMock).code(clientMock);
- assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
-
- }
-
- @Test(expected = LocatorException.class)
- public void throwsLocatorException1Test() throws LocatorException {
- @SuppressWarnings("unused")
- HMangr hman = new HMangr(access, null);
- }
-
- @Test(expected = LocatorException.class)
- public void throwsLocatorException2Test() throws LocatorException, APIException, CadiException {
- HMangr hman = new HMangr(access, locMock);
- hman.same(ssMock, retryableMock);
- }
-
- @Test(expected = LocatorException.class)
- public void throwsLocatorException3Test() throws LocatorException, APIException, CadiException {
- HMangr hman = new HMangr(access, locMock);
- when(locMock.best()).thenReturn(itemMock);
- when(locMock.hasItems()).thenReturn(true).thenReturn(false);
- hman.same(ssMock, retryableMock);
- }
-
- @SuppressWarnings("unchecked")
- @Test(expected = CadiException.class)
- public void throwsCadiException1Test() throws LocatorException, APIException, CadiException, ConnectException {
- HMangr hman = new HMangr(access, locMock);
- when(retryableMock.item()).thenReturn(itemMock);
- when(locMock.get(itemMock)).thenReturn(uri);
- when(retryableMock.lastClient()).thenReturn(clientMock);
- when(retryableMock.code(clientMock)).thenThrow(CadiException.class);
- hman.same(ssMock, retryableMock);
- }
-
- @Test(expected = CadiException.class)
- public void throwsCadiException2Test() throws LocatorException, APIException, CadiException, ConnectException {
- HMangr hman = new HMangr(access, locMock);
- when(retryableMock.item()).thenReturn(itemMock);
- when(locMock.get(itemMock)).thenReturn(uri);
- when(retryableMock.lastClient()).thenReturn(clientMock);
-
- ConnectException connectException = new ConnectException();
- CadiException cadiException = new CadiException(connectException);
- doThrow(cadiException).when(retryableMock).code(clientMock);
- hman.same(ssMock, retryableMock);
- }
-
- @Test(expected = CadiException.class)
- public void throwsCadiException3Test() throws LocatorException, APIException, CadiException, ConnectException {
- HMangr hman = new HMangr(access, locMock);
- when(retryableMock.item()).thenReturn(itemMock);
- when(locMock.get(itemMock)).thenReturn(uri);
- when(retryableMock.lastClient()).thenReturn(clientMock);
-
- SocketException socketException = new SocketException();
- CadiException cadiException = new CadiException(socketException);
- doThrow(cadiException).when(retryableMock).code(clientMock);
- hman.same(ssMock, retryableMock);
- }
-
- @Test(expected = CadiException.class)
- public void throwsCadiException4Test() throws LocatorException, APIException, CadiException, ConnectException {
- HMangr hman = new HMangr(access, locMock);
- when(retryableMock.item()).thenReturn(itemMock);
- when(locMock.get(itemMock)).thenReturn(uri);
- when(retryableMock.lastClient()).thenReturn(clientMock);
-
- Exception e = new Exception();
- CadiException cadiException = new CadiException(e);
- doThrow(cadiException).when(retryableMock).code(clientMock);
- hman.same(ssMock, retryableMock);
- }
-
- @Test
- public void allTest() throws LocatorException, CadiException, APIException {
- HManagerStub hman = new HManagerStub(access, locMock);
- assertThat(hman.best(ssMock, retryableMock), is(nullValue()));
- assertThat(hman.all(ssMock, retryableMock), is(nullValue()));
- assertThat(hman.all(ssMock, retryableMock, true), is(nullValue()));
- }
-
- @Test
- public void oneOfTest() throws LocatorException, CadiException, APIException, ConnectException {
- HMangr hman = new HMangr(access, locMock);
- assertThat(hman.oneOf(ssMock, retryableMock, false, "host"), is(nullValue()));
-
- try {
- hman.oneOf(ssMock, retryableMock, true, "host");
- fail("Should've thrown an exception");
- } catch (LocatorException e) {
- }
-
- when(locMock.first()).thenReturn(itemMock);
- when(locMock.get(itemMock)).thenReturn(uri);
-
- // Branching coverage...
- assertThat(hman.oneOf(ssMock, retryableMock, false, null), is(nullValue()));
- 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());
- doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
- assertThat(hman.oneOf(ssMock, retryableMock, false, uriString.substring(7)), is(nullValue()));
-
- cadiException = new CadiException(new SSLHandshakeException(null));
- doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
- assertThat(hman.oneOf(ssMock, retryableMock, false, uriString.substring(7)), is(nullValue()));
-
- cadiException = new CadiException(new SocketException());
- doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
- try {
- hman.oneOf(ssMock, retryableMock, false, uriString.substring(7));
- fail("Should've thrown an exception");
- } catch (CadiException e) {
- }
-
- cadiException = new CadiException(new SocketException("java.net.SocketException: Connection reset"));
- doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
- try {
- hman.oneOf(ssMock, retryableMock, false, uriString.substring(7));
- fail("Should've thrown an exception");
- } catch (CadiException e) {
- }
-
- cadiException = new CadiException();
- doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
- try {
- hman.oneOf(ssMock, retryableMock, false, uriString.substring(7));
- 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()));
-
- when(goodRetry.code((Rcli<?>) any())).thenReturn(5);
- assertThat(hman.oneOf(ssMock, goodRetry, false, uriString.substring(7)), is(5));
- }
-
- @Test
- public void coverageTest() throws LocatorException {
- HMangr hman = new HMangr(access, locMock);
- hman.readTimeout(5);
- assertThat(hman.readTimeout(), is(5));
- hman.connectionTimeout(5);
- assertThat(hman.connectionTimeout(), is(5));
- hman.apiVersion("v1.0");
- assertThat(hman.apiVersion(), is("v1.0"));
- hman.close();
-
- }
-
- private class HManagerStub extends HMangr {
- public HManagerStub(Access access, Locator<URI> loc) throws LocatorException { super(access, loc); }
- @Override public<RET> RET same(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable) {
- return null;
- }
- @Override public<RET> RET oneOf(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable, boolean notify, String host) {
- return null;
- }
- }
-
+
+ @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";
+
+ @Before
+ public void setup() throws URISyntaxException {
+ MockitoAnnotations.initMocks(this);
+
+ access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
+ uri = new URI(uriString);
+ }
+
+ @Test
+ public void sameTest() throws LocatorException, APIException, CadiException, ConnectException {
+ HMangr hman = new HMangr(access, locMock);
+ 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();
+ cadiException = new CadiException(connectException);
+ doThrow(cadiException).when(retryableMock).code(clientMock);
+ when(locMock.hasItems()).thenReturn(true).thenReturn(false);
+ assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
+
+ SocketException socketException = new SocketException();
+ cadiException = new CadiException(socketException);
+ doThrow(cadiException).when(retryableMock).code(clientMock);
+ when(locMock.hasItems()).thenReturn(true).thenReturn(false);
+ assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
+
+ doThrow(connectException).when(retryableMock).code(clientMock);
+ assertThat(hman.same(ssMock, retryableMock), is(nullValue()));
+
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throwsLocatorException1Test() throws LocatorException {
+ @SuppressWarnings("unused")
+ HMangr hman = new HMangr(access, null);
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throwsLocatorException2Test() throws LocatorException, APIException, CadiException {
+ HMangr hman = new HMangr(access, locMock);
+ hman.same(ssMock, retryableMock);
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throwsLocatorException3Test() throws LocatorException, APIException, CadiException {
+ HMangr hman = new HMangr(access, locMock);
+ when(locMock.best()).thenReturn(itemMock);
+ when(locMock.hasItems()).thenReturn(true).thenReturn(false);
+ hman.same(ssMock, retryableMock);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test(expected = CadiException.class)
+ public void throwsCadiException1Test() throws LocatorException, APIException, CadiException, ConnectException {
+ HMangr hman = new HMangr(access, locMock);
+ when(retryableMock.item()).thenReturn(itemMock);
+ when(locMock.get(itemMock)).thenReturn(uri);
+ when(retryableMock.lastClient()).thenReturn(clientMock);
+ when(retryableMock.code(clientMock)).thenThrow(CadiException.class);
+ hman.same(ssMock, retryableMock);
+ }
+
+ @Test(expected = CadiException.class)
+ public void throwsCadiException2Test() throws LocatorException, APIException, CadiException, ConnectException {
+ HMangr hman = new HMangr(access, locMock);
+ when(retryableMock.item()).thenReturn(itemMock);
+ when(locMock.get(itemMock)).thenReturn(uri);
+ when(retryableMock.lastClient()).thenReturn(clientMock);
+
+ ConnectException connectException = new ConnectException();
+ CadiException cadiException = new CadiException(connectException);
+ doThrow(cadiException).when(retryableMock).code(clientMock);
+ hman.same(ssMock, retryableMock);
+ }
+
+ @Test(expected = CadiException.class)
+ public void throwsCadiException3Test() throws LocatorException, APIException, CadiException, ConnectException {
+ HMangr hman = new HMangr(access, locMock);
+ when(retryableMock.item()).thenReturn(itemMock);
+ when(locMock.get(itemMock)).thenReturn(uri);
+ when(retryableMock.lastClient()).thenReturn(clientMock);
+
+ SocketException socketException = new SocketException();
+ CadiException cadiException = new CadiException(socketException);
+ doThrow(cadiException).when(retryableMock).code(clientMock);
+ hman.same(ssMock, retryableMock);
+ }
+
+ @Test(expected = CadiException.class)
+ public void throwsCadiException4Test() throws LocatorException, APIException, CadiException, ConnectException {
+ HMangr hman = new HMangr(access, locMock);
+ when(retryableMock.item()).thenReturn(itemMock);
+ when(locMock.get(itemMock)).thenReturn(uri);
+ when(retryableMock.lastClient()).thenReturn(clientMock);
+
+ Exception e = new Exception();
+ CadiException cadiException = new CadiException(e);
+ doThrow(cadiException).when(retryableMock).code(clientMock);
+ hman.same(ssMock, retryableMock);
+ }
+
+ @Test
+ public void allTest() throws LocatorException, CadiException, APIException {
+ HManagerStub hman = new HManagerStub(access, locMock);
+ assertThat(hman.best(ssMock, retryableMock), is(nullValue()));
+ assertThat(hman.all(ssMock, retryableMock), is(nullValue()));
+ assertThat(hman.all(ssMock, retryableMock, true), is(nullValue()));
+ }
+
+ @Test
+ public void oneOfTest() throws LocatorException, CadiException, APIException, ConnectException {
+ HMangr hman = new HMangr(access, locMock);
+ assertThat(hman.oneOf(ssMock, retryableMock, false, "host"), is(nullValue()));
+
+ try {
+ hman.oneOf(ssMock, retryableMock, true, "host");
+ fail("Should've thrown an exception");
+ } catch (LocatorException e) {
+ }
+
+ when(locMock.first()).thenReturn(itemMock);
+ when(locMock.get(itemMock)).thenReturn(uri);
+
+ // Branching coverage...
+ assertThat(hman.oneOf(ssMock, retryableMock, false, null), is(nullValue()));
+ 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());
+ doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
+ assertThat(hman.oneOf(ssMock, retryableMock, false, uriString.substring(7)), is(nullValue()));
+
+ cadiException = new CadiException(new SSLHandshakeException(null));
+ doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
+ assertThat(hman.oneOf(ssMock, retryableMock, false, uriString.substring(7)), is(nullValue()));
+
+ cadiException = new CadiException(new SocketException());
+ doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
+ try {
+ hman.oneOf(ssMock, retryableMock, false, uriString.substring(7));
+ fail("Should've thrown an exception");
+ } catch (CadiException e) {
+ }
+
+ cadiException = new CadiException(new SocketException("java.net.SocketException: Connection reset"));
+ doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
+ try {
+ hman.oneOf(ssMock, retryableMock, false, uriString.substring(7));
+ fail("Should've thrown an exception");
+ } catch (CadiException e) {
+ }
+
+ cadiException = new CadiException();
+ doThrow(cadiException).when(retryableMock).code((Rcli<?>) any());
+ try {
+ hman.oneOf(ssMock, retryableMock, false, uriString.substring(7));
+ 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()));
+
+ when(goodRetry.code((Rcli<?>) any())).thenReturn(5);
+ assertThat(hman.oneOf(ssMock, goodRetry, false, uriString.substring(7)), is(5));
+ }
+
+ @Test
+ public void coverageTest() throws LocatorException {
+ HMangr hman = new HMangr(access, locMock);
+ hman.readTimeout(5);
+ assertThat(hman.readTimeout(), is(5));
+ hman.connectionTimeout(5);
+ assertThat(hman.connectionTimeout(), is(5));
+ hman.apiVersion("v1.0");
+ assertThat(hman.apiVersion(), is("v1.0"));
+ hman.close();
+
+ }
+
+ private class HManagerStub extends HMangr {
+ public HManagerStub(Access access, Locator<URI> loc) throws LocatorException { super(access, loc); }
+ @Override public<RET> RET same(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable) {
+ return null;
+ }
+ @Override public<RET> RET oneOf(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable, boolean notify, String host) {
+ 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 9179aa36..923dd1a0 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
@@ -33,28 +33,28 @@ 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
+ 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);
- noAuth.setSecurity(httpMock);
- noAuth = new HNoAuthSS(siMock);
- noAuth.setSecurity(httpMock);
- noAuth.setSecurity(httpsMock);
- }
+ @Mock
+ HttpsURLConnection httpsMock;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test() throws IOException, CadiException {
+ HNoAuthSS noAuth = new HNoAuthSS(null);
+ noAuth.setSecurity(httpMock);
+ noAuth = new HNoAuthSS(siMock);
+ noAuth.setSecurity(httpMock);
+ noAuth.setSecurity(httpsMock);
+ }
}
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 06055ad6..ab6a39c0 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
@@ -44,78 +44,78 @@ 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);
+
+ @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);
- access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
- hman = new HMangr(access, locMock);
- uri = new URI(uriString);
+ access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
+ hman = new HMangr(access, locMock);
+ uri = new URI(uriString);
- when(locMock.get(itemMock)).thenReturn(uri);
- }
+ when(locMock.get(itemMock)).thenReturn(uri);
+ }
- @Test(expected = CadiException.class)
- public void publicInterfaceTest() throws URISyntaxException, LocatorException, CadiException {
- HRcli hrcli = new HRcli(hman, itemMock, ssMock);
- assertThat(hrcli.setManager(hman), is(hrcli));
- assertThat(hrcli.toString(), is(uriString));
+ @Test(expected = CadiException.class)
+ public void publicInterfaceTest() throws URISyntaxException, LocatorException, CadiException {
+ HRcli hrcli = new HRcli(hman, itemMock, ssMock);
+ assertThat(hrcli.setManager(hman), is(hrcli));
+ assertThat(hrcli.toString(), is(uriString));
- 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())));
+ 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())));
- hrcli = new HRcliStub(hman, null, itemMock, ssMock);
- when(locMock.best()).thenReturn(itemMock);
- eclient = hrcli.client();
- assertThat(eclient, is(not(nullValue())));
+ hrcli = new HRcliStub(hman, null, itemMock, ssMock);
+ when(locMock.best()).thenReturn(itemMock);
+ eclient = hrcli.client();
+ assertThat(eclient, is(not(nullValue())));
- hrcli = new HRcliStub(hman, null, itemMock, ssMock);
- 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);
- }
- public HRcli clone(URI uri, SecuritySetter<HttpURLConnection> ss) {
- return super.clone(uri, ss);
- }
- public EClient<HttpURLConnection> client() throws CadiException {
- return super.client();
- }
- }
+ hrcli = new HRcliStub(hman, null, itemMock, ssMock);
+ 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);
+ }
+ public HRcli clone(URI uri, SecuritySetter<HttpURLConnection> ss) {
+ return super.clone(uri, ss);
+ }
+ public EClient<HttpURLConnection> client() throws CadiException {
+ return super.client();
+ }
+ }
}
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 0fb695ec..9f2c9a71 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
@@ -34,18 +34,18 @@ import org.onap.aaf.cadi.http.HTokenSS;
public class JU_HTokenSS {
- @Mock
- SecurityInfoC<HttpURLConnection> siMock;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void test() throws IOException {
- HTokenSS token = new HTokenSS(siMock, "string1", "string2");
- assertThat(token, is(not(nullValue())));
- }
+ @Mock
+ SecurityInfoC<HttpURLConnection> siMock;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void test() throws IOException {
+ HTokenSS token = new HTokenSS(siMock, "string1", "string2");
+ assertThat(token, is(not(nullValue())));
+ }
}
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 fcb25d4e..77fac567 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
@@ -41,52 +41,52 @@ import org.onap.aaf.cadi.http.HTransferSS;
import org.onap.aaf.cadi.principal.TaggedPrincipal;
public class JU_HTransferSS {
-
- @Mock
- TaggedPrincipal princMock;
-
- @Mock
- HttpURLConnection hucMock;
+
+ @Mock
+ TaggedPrincipal princMock;
+
+ @Mock
+ HttpURLConnection hucMock;
- @Mock
- HttpsURLConnection hucsMock;
+ @Mock
+ HttpsURLConnection hucsMock;
- @Mock
- SecurityInfoC<HttpURLConnection> siMock;
-
- @Mock
- SecurityInfoC<HttpURLConnection> siMockNoDefSS;
+ @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);
- when(princMock.getName()).thenReturn(princName);
- siMock.defSS = ssMock;
- }
+ @Mock
+ SecuritySetter<HttpURLConnection> ssMock;
+
+ private static final String princName = "name";
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ when(princMock.getName()).thenReturn(princName);
+ siMock.defSS = ssMock;
+ }
- @Test
- 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));
+ @Test
+ 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));
- transfer = new HTransferSS(null, "string1", siMock);
- transfer.setSecurity(hucsMock);
- assertThat(transfer.getID(), is(""));
- }
+ transfer = new HTransferSS(null, "string1", siMock);
+ transfer.setSecurity(hucsMock);
+ assertThat(transfer.getID(), is(""));
+ }
- @Test(expected = CadiException.class)
- public void testThrows() throws CadiException {
- HTransferSS transfer = new HTransferSS(princMock, "string1", siMockNoDefSS);
- transfer.setSecurity(hucMock);
- }
+ @Test(expected = CadiException.class)
+ public void testThrows() throws CadiException {
+ HTransferSS transfer = new HTransferSS(princMock, "string1", siMockNoDefSS);
+ transfer.setSecurity(hucMock);
+ }
}
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 b57f29e0..fd102a95 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
@@ -48,70 +48,70 @@ 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);
+
+ @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);
- }
+ 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);
+ }
- @Test
- public void test() throws APIException, CadiException {
- HX509SS x509 = new HX509SS(alias, siMock);
- assertThat(x509.getID(), is(alias));
- 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 {
- // HX509SS x509 = new HX509SS(si, false);
- // x509.setSecurity(hucMock);
- // x509.setSecurity(hucsMock);
- // }
-
- @Test(expected = APIException.class)
- public void throws1Test() throws APIException, CadiException {
- @SuppressWarnings("unused")
- HX509SS x509 = new HX509SS(siMock);
- }
+ @Test
+ public void test() throws APIException, CadiException {
+ HX509SS x509 = new HX509SS(alias, siMock);
+ assertThat(x509.getID(), is(alias));
+ 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 {
+ // HX509SS x509 = new HX509SS(si, false);
+ // x509.setSecurity(hucMock);
+ // x509.setSecurity(hucsMock);
+ // }
+
+ @Test(expected = APIException.class)
+ public void throws1Test() throws APIException, CadiException {
+ @SuppressWarnings("unused")
+ HX509SS x509 = new HX509SS(siMock);
+ }
- @Test(expected = APIException.class)
- public void throws3Test() throws APIException, CadiException {
- when(keyManagerMock.getCertificateChain(alias)).thenReturn(new X509Certificate[0]);
- @SuppressWarnings("unused")
- HX509SS x509 = new HX509SS(alias, siMock);
- }
-
+ @Test(expected = APIException.class)
+ public void throws3Test() throws APIException, CadiException {
+ when(keyManagerMock.getCertificateChain(alias)).thenReturn(new X509Certificate[0]);
+ @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 a80e52f7..9b5bbafe 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
@@ -35,91 +35,91 @@ import org.onap.aaf.cadi.Locator.Item;
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]);
- }
-
- @Test
- public void test() throws LocatorException {
- DNSLocator dl;
- Item item;
- URI uri;
-
- dl = new DNSLocator(access, "https", "localhost", "8100-8101");
-
- item = dl.best();
- uri = dl.get(item);
- assertThat(uri.toString(), is("https://127.0.0.1:8100"));
- item = dl.best();
- assertThat(uri.toString(), is("https://127.0.0.1:8100"));
-
- assertThat(dl.hasItems(), is(true));
- for (item = dl.first(); item != null; item = dl.next(item)) {
- dl.invalidate(item);
- }
- assertThat(dl.hasItems(), is(false));
-
- // This doesn't actually do anything besides increase coverage
- dl.destroy();
- }
-
- @Test
- public void constructorTest() throws LocatorException {
- // For coverage
- new DNSLocator(access, "https", "localhost", "8100");
- new DNSLocator(access, "https", "localhost", "8100-8101");
-
- new DNSLocator(access, "http:localhost");
- new DNSLocator(access, "https:localhost");
- new DNSLocator(access, "https:localhost:8100");
- new DNSLocator(access, "https:localhost:[8100]");
- new DNSLocator(access, "https:localhost:[8100-8101]");
- new DNSLocator(access, "https:localhost:8000/");
- }
-
- @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);
- }
-
- @Test(expected = LocatorException.class)
- public void throws2Test() throws LocatorException {
- new DNSLocator(access, "ftp:invalid");
- }
-
- @Test(expected = LocatorException.class)
- public void throws3Test() throws LocatorException {
- new DNSLocator(access, "https:localhost:[8100");
- }
-
- @Test(expected = LocatorException.class)
- public void throws4Test() throws LocatorException {
- new DNSLocator(access, "https:localhost:[]");
- }
-
- @Test(expected = LocatorException.class)
- public void throws5Test() throws LocatorException {
- new DNSLocator(access, "https:localhost:[8100-]");
- }
-
- @Test(expected = LocatorException.class)
- public void throws6Test() throws LocatorException {
- new DNSLocator(access, "https:localhost:[-8101]");
- }
-
- @Test(expected = LocatorException.class)
- public void throws7Test() throws LocatorException {
- new DNSLocator(access, "https:localhost:/");
- }
+
+ private PropAccess access;
+
+ @Before
+ public void setup() {
+ access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
+ }
+
+ @Test
+ public void test() throws LocatorException {
+ DNSLocator dl;
+ Item item;
+ URI uri;
+
+ dl = new DNSLocator(access, "https", "localhost", "8100-8101");
+
+ item = dl.best();
+ uri = dl.get(item);
+ assertThat(uri.toString(), is("https://127.0.0.1:8100"));
+ item = dl.best();
+ assertThat(uri.toString(), is("https://127.0.0.1:8100"));
+
+ assertThat(dl.hasItems(), is(true));
+ for (item = dl.first(); item != null; item = dl.next(item)) {
+ dl.invalidate(item);
+ }
+ assertThat(dl.hasItems(), is(false));
+
+ // This doesn't actually do anything besides increase coverage
+ dl.destroy();
+ }
+
+ @Test
+ public void constructorTest() throws LocatorException {
+ // For coverage
+ new DNSLocator(access, "https", "localhost", "8100");
+ new DNSLocator(access, "https", "localhost", "8100-8101");
+
+ new DNSLocator(access, "http:localhost");
+ new DNSLocator(access, "https:localhost");
+ new DNSLocator(access, "https:localhost:8100");
+ new DNSLocator(access, "https:localhost:[8100]");
+ new DNSLocator(access, "https:localhost:[8100-8101]");
+ new DNSLocator(access, "https:localhost:8000/");
+ }
+
+ @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);
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throws2Test() throws LocatorException {
+ new DNSLocator(access, "ftp:invalid");
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throws3Test() throws LocatorException {
+ new DNSLocator(access, "https:localhost:[8100");
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throws4Test() throws LocatorException {
+ new DNSLocator(access, "https:localhost:[]");
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throws5Test() throws LocatorException {
+ new DNSLocator(access, "https:localhost:[8100-]");
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throws6Test() throws LocatorException {
+ new DNSLocator(access, "https:localhost:[-8101]");
+ }
+
+ @Test(expected = LocatorException.class)
+ public void throws7Test() throws LocatorException {
+ new DNSLocator(access, "https:localhost:/");
+ }
}
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 81140d23..e40ecb6e 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
@@ -39,112 +39,112 @@ import org.onap.aaf.cadi.locator.HClientHotPeerLocator;
public class JU_HClientHotPeerLocator {
- @Mock private HX509SS ssMock;
-
- private PropAccess access;
- private ByteArrayOutputStream outStream;
-
- // Note: - The IP and port are irrelevant for these tests
- private static final String goodURL1 = "fakeIP1:fakePort1/38/-90"; // Approx St Louis
- private static final String goodURL2 = "fakeIP2:fakePort2/33/-96"; // Approx Dallas
- private static final String badURL = "~%$!@#$//";
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
-
- outStream = new ByteArrayOutputStream();
- access = new PropAccess(new PrintStream(outStream), new String[0]);
- }
-
- @Test
- public void test() throws LocatorException {
- HClientHotPeerLocator loc;
- String urlStr = goodURL1 + ',' + goodURL2;
- loc = new HClientHotPeerLocator(access, urlStr, 0, "38.627", "-90.199", ssMock);
- assertThat(loc.hasItems(), is(true));
-
- String[] messages = outStream.toString().split(System.lineSeparator());
- String preffered = messages[0].split(" ", 4)[3];
- String alternate = messages[1].split(" ", 4)[3];
- assertThat(preffered, is("Preferred Client is " + goodURL1));
- assertThat(alternate, is("Alternate Client is " + goodURL2));
-
- HClient firstClient = loc.get(loc.first());
- HClient bestClient = loc.bestClient();
- assertThat(bestClient, is(firstClient));
-
- Locator.Item item = loc.first();
- assertThat(loc.info(item), is(goodURL1));
-
- item = loc.next(item);
- assertThat(loc.info(item), is(goodURL2));
-
- item = loc.next(item);
- assertThat(item, is(nullValue()));
- assertThat(loc.info(item), is("Invalid Item"));
-
- item = loc.first();
- loc.invalidate(item);
-
- loc.invalidate(loc.bestClient());
- loc.invalidate(loc.get(loc.next(item)));
- loc.destroy();
- }
-
- @Test(expected = LocatorException.class)
- public void failuresTest() throws LocatorException {
- HClientHotPeerLocator loc;
- String urlStr = goodURL1 + ',' + goodURL2 + ',' + badURL;
- loc = new HClientHotPeerLocator(access, urlStr, 1000000, "38.627", "-90.199", ssMock);
- String[] messages = outStream.toString().split(System.lineSeparator());
- String preffered = messages[0].split(" ", 4)[3];
- String alternate1 = messages[1].split(" ", 4)[3];
- String alternate2 = messages[2].split(" ", 4)[3];
- assertThat(preffered, is("Preferred Client is " + badURL));
- assertThat(alternate1, is("Alternate Client is " + goodURL1));
- 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;
- loc = new HClientHotPeerLocator(access, badURL, 0, "38.627", "-90.199", ssMock);
- assertThat(loc.hasItems(), is(false));
- loc.invalidate(loc.first());
- }
-
- @Test(expected = LocatorException.class)
- public void invalidClientTest() throws LocatorException {
- @SuppressWarnings("unused")
- HClientHotPeerLocator loc = new HClientHotPeerLocator(access, "InvalidClient", 0, "38.627", "-90.199", ssMock);
- }
-
- @Test(expected = LocatorException.class)
- public void coverageTest() throws LocatorException {
- CoverageLocator loc;
- String urlStr = goodURL1 + ',' + goodURL2;
- loc = new CoverageLocator(access, urlStr, 0, "38.627", "-90.199", ssMock);
- assertThat(loc._invalidate(null), is(nullValue()));
- loc._destroy(null);
-
- loc._newClient("bad string");
- }
-
- private class CoverageLocator extends HClientHotPeerLocator {
- public CoverageLocator(Access access, String urlstr, long invalidateTime, String localLatitude,
- String localLongitude, HX509SS ss) throws LocatorException {
- super(access, urlstr, invalidateTime, localLatitude, localLongitude, ss);
- }
- public HClient _newClient(String clientInfo) throws LocatorException { return super._newClient(clientInfo); }
- public HClient _invalidate(HClient client) { return super._invalidate(client); }
- public void _destroy(HClient client) { super._destroy(client); }
- }
+ @Mock private HX509SS ssMock;
+
+ private PropAccess access;
+ private ByteArrayOutputStream outStream;
+
+ // Note: - The IP and port are irrelevant for these tests
+ private static final String goodURL1 = "fakeIP1:fakePort1/38/-90"; // Approx St Louis
+ private static final String goodURL2 = "fakeIP2:fakePort2/33/-96"; // Approx Dallas
+ private static final String badURL = "~%$!@#$//";
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ outStream = new ByteArrayOutputStream();
+ access = new PropAccess(new PrintStream(outStream), new String[0]);
+ }
+
+ @Test
+ public void test() throws LocatorException {
+ HClientHotPeerLocator loc;
+ String urlStr = goodURL1 + ',' + goodURL2;
+ loc = new HClientHotPeerLocator(access, urlStr, 0, "38.627", "-90.199", ssMock);
+ assertThat(loc.hasItems(), is(true));
+
+ String[] messages = outStream.toString().split(System.lineSeparator());
+ String preffered = messages[0].split(" ", 4)[3];
+ String alternate = messages[1].split(" ", 4)[3];
+ assertThat(preffered, is("Preferred Client is " + goodURL1));
+ assertThat(alternate, is("Alternate Client is " + goodURL2));
+
+ HClient firstClient = loc.get(loc.first());
+ HClient bestClient = loc.bestClient();
+ assertThat(bestClient, is(firstClient));
+
+ Locator.Item item = loc.first();
+ assertThat(loc.info(item), is(goodURL1));
+
+ item = loc.next(item);
+ assertThat(loc.info(item), is(goodURL2));
+
+ item = loc.next(item);
+ assertThat(item, is(nullValue()));
+ assertThat(loc.info(item), is("Invalid Item"));
+
+ item = loc.first();
+ loc.invalidate(item);
+
+ loc.invalidate(loc.bestClient());
+ loc.invalidate(loc.get(loc.next(item)));
+ loc.destroy();
+ }
+
+ @Test(expected = LocatorException.class)
+ public void failuresTest() throws LocatorException {
+ HClientHotPeerLocator loc;
+ String urlStr = goodURL1 + ',' + goodURL2 + ',' + badURL;
+ loc = new HClientHotPeerLocator(access, urlStr, 1000000, "38.627", "-90.199", ssMock);
+ String[] messages = outStream.toString().split(System.lineSeparator());
+ String preffered = messages[0].split(" ", 4)[3];
+ String alternate1 = messages[1].split(" ", 4)[3];
+ String alternate2 = messages[2].split(" ", 4)[3];
+ assertThat(preffered, is("Preferred Client is " + badURL));
+ assertThat(alternate1, is("Alternate Client is " + goodURL1));
+ 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;
+ loc = new HClientHotPeerLocator(access, badURL, 0, "38.627", "-90.199", ssMock);
+ assertThat(loc.hasItems(), is(false));
+ loc.invalidate(loc.first());
+ }
+
+ @Test(expected = LocatorException.class)
+ public void invalidClientTest() throws LocatorException {
+ @SuppressWarnings("unused")
+ HClientHotPeerLocator loc = new HClientHotPeerLocator(access, "InvalidClient", 0, "38.627", "-90.199", ssMock);
+ }
+
+ @Test(expected = LocatorException.class)
+ public void coverageTest() throws LocatorException {
+ CoverageLocator loc;
+ String urlStr = goodURL1 + ',' + goodURL2;
+ loc = new CoverageLocator(access, urlStr, 0, "38.627", "-90.199", ssMock);
+ assertThat(loc._invalidate(null), is(nullValue()));
+ loc._destroy(null);
+
+ loc._newClient("bad string");
+ }
+
+ private class CoverageLocator extends HClientHotPeerLocator {
+ public CoverageLocator(Access access, String urlstr, long invalidateTime, String localLatitude,
+ String localLongitude, HX509SS ss) throws LocatorException {
+ super(access, urlstr, invalidateTime, localLatitude, localLongitude, ss);
+ }
+ public HClient _newClient(String clientInfo) throws LocatorException { return super._newClient(clientInfo); }
+ public HClient _invalidate(HClient client) { return super._invalidate(client); }
+ public void _destroy(HClient client) { super._destroy(client); }
+ }
}
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 024deff7..7b61e398 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
@@ -36,81 +36,81 @@ import org.onap.aaf.cadi.locator.PropertyLocator;
public class JU_PropertyLocator {
- @Mock
- Socket socketMock;
+ @Mock
+ Socket socketMock;
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
- when(socketMock.isConnected()).thenReturn(true);
- when(socketMock.isClosed()).thenReturn(true).thenReturn(false);
- }
+ when(socketMock.isConnected()).thenReturn(true);
+ when(socketMock.isClosed()).thenReturn(true).thenReturn(false);
+ }
- @Test
- public void test() throws Exception {
- String uris = "https://fred.wilma.com:26444,https://tom.jerry.com:[534-535]";
- PropertyLocator pl = new PropertyLocator(uris, 0L, 1000*60*20L) {
- @Override protected Socket createSocket() { return socketMock; }
- };
- String str = pl.toString();
- assertThat(str.contains("https://fred.wilma.com:26444"), is(true));
- assertThat(str.contains("https://tom.jerry.com:534"), is(true));
- assertThat(str.contains("https://tom.jerry.com:535"), is(true));
+ @Test
+ public void test() throws Exception {
+ String uris = "https://fred.wilma.com:26444,https://tom.jerry.com:[534-535]";
+ PropertyLocator pl = new PropertyLocator(uris, 0L, 1000*60*20L) {
+ @Override protected Socket createSocket() { return socketMock; }
+ };
+ String str = pl.toString();
+ assertThat(str.contains("https://fred.wilma.com:26444"), is(true));
+ assertThat(str.contains("https://tom.jerry.com:534"), is(true));
+ assertThat(str.contains("https://tom.jerry.com:535"), is(true));
- Item item = pl.first();
- assertThat(item.toString(), is("Item: 0 order: 0"));
+ Item item = pl.first();
+ assertThat(item.toString(), is("Item: 0 order: 0"));
- URI uri = pl.get(item);
- assertThat(uri.toString(), is("https://fred.wilma.com:26444"));
+ URI uri = pl.get(item);
+ assertThat(uri.toString(), is("https://fred.wilma.com:26444"));
- assertThat(pl.get(null), is(nullValue()));
+ assertThat(pl.get(null), is(nullValue()));
- assertThat(pl.hasItems(), is(true));
+ assertThat(pl.hasItems(), is(true));
- assertThat(countItems(pl), is(3));
- pl.invalidate(pl.best());
+ assertThat(countItems(pl), is(3));
+ pl.invalidate(pl.best());
- assertThat(countItems(pl), is(2));
- pl.invalidate(pl.best());
+ assertThat(countItems(pl), is(2));
+ pl.invalidate(pl.best());
- assertThat(countItems(pl), is(1));
+ assertThat(countItems(pl), is(1));
- pl.invalidate(pl.best());
+ pl.invalidate(pl.best());
- assertThat(pl.hasItems(), is(false));
- assertThat(countItems(pl), is(0));
+ assertThat(pl.hasItems(), is(false));
+ assertThat(countItems(pl), is(0));
- Thread.sleep(20L); // PL checks same milli...
- pl.refresh();
+ Thread.sleep(20L); // PL checks same milli...
+ pl.refresh();
- assertThat(pl.hasItems(), is(true));
-
- assertThat(pl.next(null), is(nullValue()));
+ assertThat(pl.hasItems(), is(true));
+
+ assertThat(pl.next(null), is(nullValue()));
- // coverage...
- pl.invalidate(null);
- pl.invalidate(null);
- pl.invalidate(null);
- pl.invalidate(null);
+ // coverage...
+ pl.invalidate(null);
+ pl.invalidate(null);
+ pl.invalidate(null);
+ pl.invalidate(null);
- pl.destroy();
+ pl.destroy();
- pl = new PropertyLocator(uris);
-
- }
+ pl = new PropertyLocator(uris);
+
+ }
- @Test(expected=LocatorException.class)
- public void exceptionTest() throws LocatorException {
- new PropertyLocator(null);
- }
+ @Test(expected=LocatorException.class)
+ public void exceptionTest() throws LocatorException {
+ new PropertyLocator(null);
+ }
- private int countItems(PropertyLocator pl) throws LocatorException {
- int count = 0;
- for(Item i = pl.first(); i != null; i = pl.next(i)) {
- ++count;
- }
- return count;
- }
+ private int countItems(PropertyLocator pl) throws LocatorException {
+ int count = 0;
+ for(Item i = pl.first(); i != null; i = pl.next(i)) {
+ ++count;
+ }
+ return count;
+ }
}
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 f492d4a2..31fda501 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
@@ -28,52 +28,52 @@ import org.onap.aaf.cadi.routing.GreatCircle;
public class JU_GreatCircle {
- @BeforeClass
- public static void setUpBeforeClass() throws Exception {
- }
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ }
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- }
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @After
- public void tearDown() throws Exception {
- }
+ @After
+ public void tearDown() throws Exception {
+ }
- @Test
- public void calc1Test() {
- assertEquals(7.803062505568182, GreatCircle.calc(38.627345, -90.193774, 35.252234, -81.384929), 0.000000001);
- assertEquals(0.0, GreatCircle.calc(38.627345, -90.193774, 38.627345, -90.193774), 0.000000001);
- assertEquals(7.803062505568182, GreatCircle.calc(35.252234, -81.384929, 38.627345, -90.193774), 0.000000001);
- assertEquals(7.803062505568182, GreatCircle.calc(38.627345, -90.193774, 35.252234, -81.384929), 0.000000001);
- assertEquals(7.803062505568182, GreatCircle.calc(-38.627345, 90.193774, -35.252234, 81.384929), 0.000000001);
- assertEquals(105.71060033936052, GreatCircle.calc(-38.627345, 90.193774, -35.252234, -81.384929), 0.000000001);
- assertEquals(105.71060033936052, GreatCircle.calc(38.627345, -90.193774, 35.252234, 81.384929), 0.000000001);
- assertEquals(74.32786874922931, GreatCircle.calc(-38.627345, 90.193774, 35.252234, 81.384929), 0.000000001);
- }
+ @Test
+ public void calc1Test() {
+ assertEquals(7.803062505568182, GreatCircle.calc(38.627345, -90.193774, 35.252234, -81.384929), 0.000000001);
+ assertEquals(0.0, GreatCircle.calc(38.627345, -90.193774, 38.627345, -90.193774), 0.000000001);
+ assertEquals(7.803062505568182, GreatCircle.calc(35.252234, -81.384929, 38.627345, -90.193774), 0.000000001);
+ assertEquals(7.803062505568182, GreatCircle.calc(38.627345, -90.193774, 35.252234, -81.384929), 0.000000001);
+ assertEquals(7.803062505568182, GreatCircle.calc(-38.627345, 90.193774, -35.252234, 81.384929), 0.000000001);
+ assertEquals(105.71060033936052, GreatCircle.calc(-38.627345, 90.193774, -35.252234, -81.384929), 0.000000001);
+ assertEquals(105.71060033936052, GreatCircle.calc(38.627345, -90.193774, 35.252234, 81.384929), 0.000000001);
+ assertEquals(74.32786874922931, GreatCircle.calc(-38.627345, 90.193774, 35.252234, 81.384929), 0.000000001);
+ }
- @Test
- public void calc2Test() {
- assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345", "-90.193774", "35.252234", "-81.384929"}), 0.000000001);
- assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345,-90.193774", "35.252234,-81.384929"}), 0.000000001);
- assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345,-90.193774,35.252234,-81.384929"}), 0.000000001);
+ @Test
+ public void calc2Test() {
+ assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345", "-90.193774", "35.252234", "-81.384929"}), 0.000000001);
+ assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345,-90.193774", "35.252234,-81.384929"}), 0.000000001);
+ assertEquals(7.803062505568182, GreatCircle.calc(new String[] {"38.627345,-90.193774,35.252234,-81.384929"}), 0.000000001);
- assertEquals(-1, GreatCircle.calc(new String[0]), 0.000000001);
- assertEquals(-1, GreatCircle.calc(new String[] {"38.627345;-90.193774", "35.252234,-81.384929"}), 0.000000001);
- assertEquals(-1, GreatCircle.calc(new String[] {"38.627345,-90.193774", "35.252234;-81.384929"}), 0.000000001);
- assertEquals(-1, GreatCircle.calc(new String[] {"38.627345,-90.193774;35.252234,-81.384929"}), 0.000000001);
+ assertEquals(-1, GreatCircle.calc(new String[0]), 0.000000001);
+ assertEquals(-1, GreatCircle.calc(new String[] {"38.627345;-90.193774", "35.252234,-81.384929"}), 0.000000001);
+ assertEquals(-1, GreatCircle.calc(new String[] {"38.627345,-90.193774", "35.252234;-81.384929"}), 0.000000001);
+ assertEquals(-1, GreatCircle.calc(new String[] {"38.627345,-90.193774;35.252234,-81.384929"}), 0.000000001);
- assertEquals(-1, GreatCircle.calc(new String[] {"Invalid input", "Invalid input", "Invalid input", "Invalid input"}), 0.000000001);
- }
+ assertEquals(-1, GreatCircle.calc(new String[] {"Invalid input", "Invalid input", "Invalid input", "Invalid input"}), 0.000000001);
+ }
- @Test
- public void coverageTest() {
- @SuppressWarnings("unused")
- GreatCircle gc = new GreatCircle();
- }
+ @Test
+ public void coverageTest() {
+ @SuppressWarnings("unused")
+ GreatCircle gc = new GreatCircle();
+ }
}
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 b0ac5a0c..5b47faab 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
@@ -30,79 +30,79 @@ import org.onap.aaf.cadi.client.Result;
public class JU_ResultTest {
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void testOk() {
- Result<String> t = Result.ok(1, "Ok");
- assertNotNull(t);
- assertThat(t.code, is(1));
- assertTrue(t.isOK());
- assertThat(t.toString(), is("Code: 1"));
- }
+ @Test
+ public void testOk() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
- @Test
- public void testErr() {
- Result<String> t = Result.err(1, "Error Body");
- assertNotNull(t);
- assertThat(t.error, is("Error Body"));
- assertFalse(t.isOK());
- assertThat(t.toString(), is("Code: 1 = Error Body"));
- }
-
- @Test
- public void testOk1() {
- Result<String> t = Result.ok(1, "Ok");
- assertNotNull(t);
- assertThat(t.code, is(1));
- assertTrue(t.isOK());
- assertThat(t.toString(), is("Code: 1"));
- }
+ @Test
+ public void testErr() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
+
+ @Test
+ public void testOk1() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
- @Test
- public void testErr1() {
- Result<String> t = Result.err(1, "Error Body");
- assertNotNull(t);
- assertThat(t.error, is("Error Body"));
- assertFalse(t.isOK());
- assertThat(t.toString(), is("Code: 1 = Error Body"));
- }
-
- @Test
- public void testOk2() {
- Result<String> t = Result.ok(1, "Ok");
- assertNotNull(t);
- assertThat(t.code, is(1));
- assertTrue(t.isOK());
- assertThat(t.toString(), is("Code: 1"));
- }
+ @Test
+ public void testErr1() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
+
+ @Test
+ public void testOk2() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
- @Test
- public void testErr2() {
- Result<String> t = Result.err(1, "Error Body");
- assertNotNull(t);
- assertThat(t.error, is("Error Body"));
- assertFalse(t.isOK());
- assertThat(t.toString(), is("Code: 1 = Error Body"));
- }
-
- @Test
- public void testOk3() {
- Result<String> t = Result.ok(1, "Ok");
- assertNotNull(t);
- assertThat(t.code, is(1));
- assertTrue(t.isOK());
- assertThat(t.toString(), is("Code: 1"));
- }
+ @Test
+ public void testErr2() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
+
+ @Test
+ public void testOk3() {
+ Result<String> t = Result.ok(1, "Ok");
+ assertNotNull(t);
+ assertThat(t.code, is(1));
+ assertTrue(t.isOK());
+ assertThat(t.toString(), is("Code: 1"));
+ }
- @Test
- public void testErr3() {
- Result<String> t = Result.err(1, "Error Body");
- assertNotNull(t);
- assertThat(t.error, is("Error Body"));
- assertFalse(t.isOK());
- assertThat(t.toString(), is("Code: 1 = Error Body"));
- }
+ @Test
+ public void testErr3() {
+ Result<String> t = Result.err(1, "Error Body");
+ assertNotNull(t);
+ assertThat(t.error, is("Error Body"));
+ assertFalse(t.isOK());
+ assertThat(t.toString(), is("Code: 1 = Error Body"));
+ }
}