diff options
Diffstat (limited to 'bpmn/MSORESTClient/src/test/java')
11 files changed, 2374 insertions, 0 deletions
diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTest.java new file mode 100644 index 0000000000..87a3f47cfe --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTest.java @@ -0,0 +1,217 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:46:25 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.MockitoExtension.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import java.util.Locale; +import org.apache.http.HttpResponse; +import org.apache.http.ProtocolVersion; +import org.apache.http.ReasonPhraseCatalog; +import org.apache.http.StatusLine; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.EnglishReasonPhraseCatalog; +import org.apache.http.message.BasicHttpResponse; +import org.apache.http.message.BasicStatusLine; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class APIResponseESTest extends APIResponseESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, "Uc"); + basicHttpResponse0.addHeader("Uc", "org.apache.http.entity.ContentType"); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + assertEquals(0, aPIResponse0.getStatusCode()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 1471, "0fVXWr>"); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + int int0 = aPIResponse0.getStatusCode(); + assertEquals(1471, int0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + ProtocolVersion protocolVersion0 = mock(ProtocolVersion.class, new ViolatedAssumptionAnswer()); + StatusLine statusLine0 = mock(StatusLine.class, new ViolatedAssumptionAnswer()); + doReturn(protocolVersion0).when(statusLine0).getProtocolVersion(); + doReturn("Gi|Heay:?O.-PvSJFp").when(statusLine0).getReasonPhrase(); + doReturn((-1730834464), (-1730834464)).when(statusLine0).getStatusCode(); + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse(statusLine0); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + int int0 = aPIResponse0.getStatusCode(); + assertEquals((-1730834464), int0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 1471, "0fVXWr>"); + byte[] byteArray0 = new byte[3]; + ByteArrayEntity byteArrayEntity0 = new ByteArrayEntity(byteArray0); + basicHttpResponse0.setEntity(byteArrayEntity0); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + byte[] byteArray1 = aPIResponse0.getResponseBodyAsByteArray(); + assertFalse(byteArray1.equals((Object)byteArray0)); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + ProtocolVersion protocolVersion0 = new ProtocolVersion("", 548, 548); + BasicStatusLine basicStatusLine0 = new BasicStatusLine(protocolVersion0, 1196, " len: "); + EnglishReasonPhraseCatalog englishReasonPhraseCatalog0 = EnglishReasonPhraseCatalog.INSTANCE; + Locale locale0 = Locale.ITALY; + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((StatusLine) basicStatusLine0, (ReasonPhraseCatalog) englishReasonPhraseCatalog0, locale0); + StringEntity stringEntity0 = new StringEntity(""); + basicHttpResponse0.setEntity(stringEntity0); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + byte[] byteArray0 = aPIResponse0.getResponseBodyAsByteArray(); + assertArrayEquals(new byte[] {}, byteArray0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, "'"); + basicHttpResponse0.addHeader("'", "'"); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + String string0 = aPIResponse0.getFirstHeader("'"); + assertEquals("'", string0); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + APIResponse aPIResponse0 = null; + try { + aPIResponse0 = new APIResponse((HttpResponse) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.rest.APIResponse", e); + } + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + ProtocolVersion protocolVersion0 = new ProtocolVersion("=", 1, 2); + BasicStatusLine basicStatusLine0 = new BasicStatusLine(protocolVersion0, 1, "="); + EnglishReasonPhraseCatalog englishReasonPhraseCatalog0 = EnglishReasonPhraseCatalog.INSTANCE; + Locale locale0 = Locale.UK; + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((StatusLine) basicStatusLine0, (ReasonPhraseCatalog) englishReasonPhraseCatalog0, locale0); + basicHttpResponse0.setStatusLine(protocolVersion0, 1); + APIResponse aPIResponse0 = null; + try { + aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Unknown category for status code 1 + // + verifyException("org.apache.http.util.Args", e); + } + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, ""); + basicHttpResponse0.addHeader("", ""); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + String string0 = aPIResponse0.getFirstHeader(",n6_`^Oyzn6YprnX"); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, ""); + basicHttpResponse0.addHeader("", ""); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + String string0 = aPIResponse0.getFirstHeader(""); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, ""); + basicHttpResponse0.addHeader("", ""); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + HttpHeader[] httpHeaderArray0 = aPIResponse0.getAllHeaders(); + assertNotNull(httpHeaderArray0); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 1471, "0fVXWr>"); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + HttpHeader[] httpHeaderArray0 = aPIResponse0.getAllHeaders(); + assertNotNull(httpHeaderArray0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, "c"); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + String string0 = aPIResponse0.getResponseBodyAsString(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 1471, "0fVXWr>"); + byte[] byteArray0 = new byte[3]; + ByteArrayEntity byteArrayEntity0 = new ByteArrayEntity(byteArray0); + basicHttpResponse0.setEntity(byteArrayEntity0); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + String string0 = aPIResponse0.getResponseBodyAsString(); + assertEquals("\u0000\u0000\u0000", string0); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 0, "c"); + basicHttpResponse0.addHeader("c", "c"); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + aPIResponse0.getResponseBodyAsString(); + basicHttpResponse0.getStatusLine(); + aPIResponse0.getStatusCode(); + HttpHeader[] httpHeaderArray0 = new HttpHeader[2]; + HttpHeader httpHeader0 = mock(HttpHeader.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(httpHeader0).getName(); + httpHeaderArray0[0] = httpHeader0; + HttpHeader httpHeader1 = mock(HttpHeader.class, new ViolatedAssumptionAnswer()); + httpHeaderArray0[1] = httpHeader1; + PrivateAccess.setVariable((Class<APIResponse>) APIResponse.class, aPIResponse0, "headers", (Object) httpHeaderArray0); + // Undeclared exception! + try { + aPIResponse0.getFirstHeader(""); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + } + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + BasicHttpResponse basicHttpResponse0 = new BasicHttpResponse((ProtocolVersion) null, 1471, "0fVXWr>"); + APIResponse aPIResponse0 = new APIResponse((HttpResponse) basicHttpResponse0); + byte[] byteArray0 = aPIResponse0.getResponseBodyAsByteArray(); + assertNull(byteArray0); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTestscaffolding.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTestscaffolding.java new file mode 100644 index 0000000000..59f09a0bc9 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/APIResponseESTestscaffolding.java @@ -0,0 +1,140 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:46:25 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class APIResponseESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.rest.APIResponse"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(APIResponseESTestscaffolding.class.getClassLoader() , + "org.apache.http.HttpVersion", + "org.apache.http.message.BasicNameValuePair", + "org.apache.http.message.HeaderGroup", + "org.apache.http.message.HeaderValueParser", + "org.apache.http.message.BasicStatusLine", + "org.apache.http.message.BasicHeaderValueParser", + "org.apache.http.message.BasicLineFormatter", + "org.apache.http.entity.ByteArrayEntity", + "org.apache.http.Header", + "org.apache.http.StatusLine", + "org.apache.http.util.EntityUtils", + "org.apache.http.message.BasicHttpResponse", + "org.apache.http.FormattedHeader", + "org.apache.http.RequestLine", + "org.apache.http.HttpMessage", + "org.apache.http.message.AbstractHttpMessage", + "org.apache.http.Consts", + "org.apache.http.protocol.HTTP", + "org.apache.http.util.ByteArrayBuffer", + "org.apache.http.ParseException", + "org.apache.http.HeaderIterator", + "org.apache.http.entity.AbstractHttpEntity", + "org.openecomp.mso.rest.RESTException", + "org.apache.http.util.Args", + "org.apache.http.ReasonPhraseCatalog", + "org.apache.http.HttpEntity", + "org.apache.http.entity.ContentType", + "org.apache.http.message.LineFormatter", + "org.apache.http.entity.StringEntity", + "org.openecomp.mso.rest.HttpHeader", + "org.apache.http.HeaderElement", + "org.apache.http.message.BufferedHeader", + "org.openecomp.mso.rest.APIResponse", + "org.apache.http.util.CharArrayBuffer", + "org.apache.http.ProtocolVersion", + "org.apache.http.util.TextUtils", + "org.apache.http.impl.EnglishReasonPhraseCatalog", + "org.apache.http.params.HttpParams", + "org.apache.http.message.BasicHeader", + "org.apache.http.HttpResponse", + "org.apache.http.NameValuePair", + "org.apache.http.message.ParserCursor" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(APIResponseESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.apache.http.message.HeaderGroup", + "org.apache.http.ProtocolVersion", + "org.apache.http.message.BasicStatusLine", + "org.apache.http.message.BasicLineFormatter", + "org.apache.http.util.CharArrayBuffer", + "org.apache.http.HttpVersion", + "org.apache.http.impl.EnglishReasonPhraseCatalog", + "org.apache.http.message.BasicHeader", + "org.apache.http.message.BasicHeaderValueParser", + "org.apache.http.Consts", + "org.apache.http.protocol.HTTP", + "org.apache.http.message.BasicNameValuePair", + "org.apache.http.message.BufferedHeader", + "org.apache.http.ParseException", + "org.apache.http.entity.AbstractHttpEntity", + "org.apache.http.util.ByteArrayBuffer", + "org.apache.http.entity.ContentType" + ); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTest.java new file mode 100644 index 0000000000..21043496db --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTest.java @@ -0,0 +1,79 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:47:07 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class HttpHeaderESTest extends HttpHeaderESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("Fw", "WD#>QF/v6_|_A"); + String string0 = httpHeader0.getValue(); + assertEquals("WD#>QF/v6_|_A", string0); + assertEquals("Fw", httpHeader0.getName()); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("", ""); + String string0 = httpHeader0.getValue(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("Nae may no be null.", "Nae may no be null."); + PrivateAccess.setVariable((Class<HttpHeader>) HttpHeader.class, httpHeader0, "name", (Object) null); + String string0 = httpHeader0.getName(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("", "EIqJp"); + String string0 = httpHeader0.getName(); + assertEquals("EIqJp", httpHeader0.getValue()); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + HttpHeader httpHeader0 = null; + try { + httpHeader0 = new HttpHeader((String) null, (String) null); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Name may not be null. + // + verifyException("org.openecomp.mso.rest.HttpHeader", e); + } + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("Nae may no be null.", "Nae may no be null."); + String string0 = httpHeader0.getName(); + assertEquals("Nae may no be null.", string0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + HttpHeader httpHeader0 = new HttpHeader("|SJ`pSz:BCB1o8~", (String) null); + String string0 = httpHeader0.getValue(); + assertNull(string0); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTestscaffolding.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTestscaffolding.java new file mode 100644 index 0000000000..e59f7da9fb --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/HttpHeaderESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:47:07 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class HttpHeaderESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.rest.HttpHeader"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(HttpHeaderESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.rest.HttpHeader" + ); + } + + private static void resetClasses() { + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientESTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientESTest.java new file mode 100644 index 0000000000..1a9e05abd0 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientESTest.java @@ -0,0 +1,1068 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:49:09 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.MockitoExtension.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import java.io.InputStream; +import java.util.LinkedHashMap; +import java.util.List; +import org.apache.http.Header; +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.http.StatusLine; +import org.apache.http.client.HttpClient; +import org.apache.http.entity.InputStreamEntity; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RESTClientESTest extends RESTClientESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + RESTClient rESTClient0 = new RESTClient("org.apache.http.ParseException"); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(httpClient0).toString(); + doReturn((HttpResponse) null).when(httpClient0).execute(any(org.apache.http.client.methods.HttpUriRequest.class)); + rESTClient0.setUnitTestClient(httpClient0); + // Undeclared exception! + try { + rESTClient0.patch("<;xR"); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.rest.APIResponse", e); + } + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + RESTConfig rESTConfig0 = mock(RESTConfig.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(rESTConfig0).getProxyHost(); + doReturn(0).when(rESTConfig0).getProxyPort(); + doReturn((String) null).when(rESTConfig0).getURL(); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(httpClient0).toString(); + rESTClient0.setUnitTestClient(httpClient0); + HttpClient httpClient1 = rESTClient0.getUnitTestClient(); + assertSame(httpClient1, httpClient0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + RESTClient rESTClient0 = new RESTClient((String) null, "Jhhlq!Y8o>CaA", (-3767)); + String string0 = rESTClient0.getURL(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("", "=&http.request_sent=http.request_sent", 783, true); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + String string0 = rESTClient0.getURL(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + RESTClient rESTClient0 = new RESTClient("http"); + RESTClient rESTClient1 = rESTClient0.setParameter("http", "http"); + LinkedHashMap<String, List<String>> linkedHashMap0 = rESTClient1.getParameters(); + assertEquals(1, linkedHashMap0.size()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + RESTClient rESTClient0 = new RESTClient(",%LX:SC+'3!nt"); + RESTClient rESTClient1 = rESTClient0.setHeader(",%LX:SC+'3!nt", ",[o<:aGQK"); + LinkedHashMap<String, List<String>> linkedHashMap0 = rESTClient1.getHeaders(); + assertEquals(1, linkedHashMap0.size()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + InputStream inputStream0 = mock(InputStream.class, new ViolatedAssumptionAnswer()); + InputStreamEntity inputStreamEntity0 = new InputStreamEntity(inputStream0); + StatusLine statusLine0 = mock(StatusLine.class, new ViolatedAssumptionAnswer()); + doReturn(0).when(statusLine0).getStatusCode(); + HttpResponse httpResponse0 = mock(HttpResponse.class, new ViolatedAssumptionAnswer()); + doReturn(inputStreamEntity0, (HttpEntity) null, (HttpEntity) null).when(httpResponse0).getEntity(); + doReturn(statusLine0).when(httpResponse0).getStatusLine(); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn("Q[z^W").when(httpClient0).toString(); + doReturn(httpResponse0).when(httpClient0).execute(any(org.apache.http.client.methods.HttpUriRequest.class)); + rESTClient0.setUnitTestClient(httpClient0); + HttpClient httpClient1 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + // Undeclared exception! + try { + rESTClient0.post(); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Entity may not be null + // + verifyException("org.apache.http.util.Args", e); + } + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + RESTClient rESTClient1 = rESTClient0.setParameter((String) null, "7%d/ia+s(I~@<PK"); + // Undeclared exception! + try { + rESTClient1.post(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + RESTConfig rESTConfig0 = mock(RESTConfig.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(rESTConfig0).getProxyHost(); + doReturn(0).when(rESTConfig0).getProxyPort(); + doReturn((String) null).when(rESTConfig0).getURL(); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + // Undeclared exception! + try { + rESTClient0.post(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + } + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("UTF-8"); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + RESTClient rESTClient1 = rESTClient0.addParameter((String) null, ""); + // Undeclared exception! + try { + rESTClient1.patch("DELETE"); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + RESTClient rESTClient0 = new RESTClient("!{usNmLQ_Gt.C_98"); + // Undeclared exception! + try { + rESTClient0.patch("https"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 1: !{usNmLQ_Gt.C_98 + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + rESTClient0.addParameter("", (String) null); + // Undeclared exception! + try { + rESTClient0.httpPut(""); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + RESTClient rESTClient0 = new RESTClient("szM4DVVoiAs`]T/", "szM4DVVoiAs`]T/", (-697)); + // Undeclared exception! + try { + rESTClient0.httpPut(""); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 11: szM4DVVoiAs`]T/ + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + RESTClient rESTClient0 = new RESTClient((String) null); + // Undeclared exception! + try { + rESTClient0.httpPost(" I3^~h5yoFuif"); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + } + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("&", false); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + rESTClient0.setHeader((String) null, "/G$0vW$R4vUaL)*tz"); + // Undeclared exception! + try { + rESTClient0.httpPost("/G$0vW$R4vUaL)*tz"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Header name may not be null + // + verifyException("org.apache.http.util.Args", e); + } + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + RESTClient rESTClient0 = new RESTClient("oO!CF58JhSCm6t"); + rESTClient0.addParameter((String) null, "oO!CF58JhSCm6t"); + // Undeclared exception! + try { + rESTClient0.httpPost(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + RESTClient rESTClient0 = new RESTClient((String) null, "F(Oy=<SOmNE9", (-1932735280)); + // Undeclared exception! + try { + rESTClient0.httpPost(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + } + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("JAl/&Uq6mM8Kf8", false); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + // Undeclared exception! + try { + rESTClient0.httpPost(); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + RESTClient rESTClient0 = new RESTClient("&8jW\"", "&8jW\"", (-1)); + // Undeclared exception! + try { + rESTClient0.httpPost(); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 0: &8jW\" + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + RESTClient rESTClient0 = new RESTClient(")7l9={q>0E4sV]T"); + RESTClient rESTClient1 = rESTClient0.addParameter((String) null, ")7l9={q>0E4sV]T"); + // Undeclared exception! + try { + rESTClient1.httpPatch((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + RESTClient rESTClient0 = new RESTClient("[59t(J)"); + // Undeclared exception! + try { + rESTClient0.httpPatch("[59t(J)"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 0: [59t(J) + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + RESTClient rESTClient0 = new RESTClient("A29%23fZqv%7F*%405=%7F%7Frdbt-X%22DB%2FhCrUn", "=", (-1)); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(httpClient0).toString(); + doReturn((HttpResponse) null).when(httpClient0).execute(any(org.apache.http.client.methods.HttpUriRequest.class)); + rESTClient0.setUnitTestClient(httpClient0); + // Undeclared exception! + try { + rESTClient0.httpGet(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.rest.APIResponse", e); + } + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + RESTClient rESTClient0 = new RESTClient("*;R"); + // Undeclared exception! + try { + rESTClient0.httpGet(); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 0: *;R + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + RESTClient rESTClient0 = new RESTClient("compatibility"); + RESTClient rESTClient1 = rESTClient0.addParameter("https", "https"); + RESTClient rESTClient2 = rESTClient1.setHeader("compatibility", "https"); + RESTClient rESTClient3 = rESTClient2.setParameter("4#'mD<\"jNh?>_vfI:]", "Char array buffer"); + InputStream inputStream0 = mock(InputStream.class, new ViolatedAssumptionAnswer()); + InputStreamEntity inputStreamEntity0 = new InputStreamEntity(inputStream0); + StatusLine statusLine0 = mock(StatusLine.class, new ViolatedAssumptionAnswer()); + doReturn(0).when(statusLine0).getStatusCode(); + rESTClient3.addHeader("2b?N", "https"); + HttpResponse httpResponse0 = mock(HttpResponse.class, new ViolatedAssumptionAnswer()); + doReturn(inputStreamEntity0, (HttpEntity) null, (HttpEntity) null).when(httpResponse0).getEntity(); + doReturn(statusLine0).when(httpResponse0).getStatusLine(); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn("GiQ=eHBwH9zA4COa").when(httpClient0).toString(); + doReturn(httpResponse0).when(httpClient0).execute(any(org.apache.http.client.methods.HttpUriRequest.class)); + rESTClient2.setUnitTestClient(httpClient0); + // Undeclared exception! + try { + rESTClient3.httpDelete(""); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Entity may not be null + // + verifyException("org.apache.http.util.Args", e); + } + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + RESTClient rESTClient0 = new RESTClient(")TZ;T]b%B[FkT4", "%y@{Wz}c3J-!m", 1772); + RESTClient rESTClient1 = rESTClient0.addParameter("$y*O^k0", (String) null); + // Undeclared exception! + try { + rESTClient1.httpDelete((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + RESTClient rESTClient0 = new RESTClient("Length Required"); + // Undeclared exception! + try { + rESTClient0.httpDelete("Length Required"); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 6: Length Required + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("yhPl=c#;<s`V", false); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + rESTClient0.addParameter("yhPl=c#;<s`V", (String) null); + // Undeclared exception! + try { + rESTClient0.httpDelete(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test27() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("2cSq'/FF]W'K.S^k=<=", "2cSq'/FF]W'K.S^k=<=", 2605); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + // Undeclared exception! + try { + rESTClient0.httpDelete(); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 8: 2cSq'/FF]W'K.S^k=<= + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test28() throws Throwable { + RESTClient rESTClient0 = new RESTClient(")7l9={q>0E4sV]T"); + RESTClient rESTClient1 = rESTClient0.addParameter((String) null, ")7l9={q>0E4sV]T"); + // Undeclared exception! + try { + rESTClient1.get(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test29() throws Throwable { + RESTClient rESTClient0 = new RESTClient("z8UR?=)5pTtS]*"); + // Undeclared exception! + try { + rESTClient0.get(); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test30() throws Throwable { + RESTClient rESTClient0 = new RESTClient("JB<TRwDR@k.-C$=w3", "|N", 0); + // Undeclared exception! + try { + rESTClient0.get(); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in path at index 2: JB<TRwDR@k.-C$=w3 + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test31() throws Throwable { + RESTClient rESTClient0 = new RESTClient("YoeLljo%3A%5C%3D=http", "http.protocol.element-charset", (-1908874351)); + RESTClient rESTClient1 = rESTClient0.setParameter("I/O exception (", (String) null); + // Undeclared exception! + try { + rESTClient1.delete(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.net.URLEncoder", e); + } + } + + @Test(timeout = 4000) + public void test32() throws Throwable { + RESTClient rESTClient0 = new RESTClient("\":VYxeR;PP]jO_[f'"); + // Undeclared exception! + try { + rESTClient0.delete(); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal character in scheme name at index 0: \":VYxeR;PP]jO_[f' + // + verifyException("java.net.URI", e); + } + } + + @Test(timeout = 4000) + public void test33() throws Throwable { + RESTClient rESTClient0 = null; + try { + rESTClient0 = new RESTClient((RESTConfig) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.rest.RESTClient", e); + } + } + + @Test(timeout = 4000) + public void test34() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + rESTClient0.addParameter("", ""); + // Undeclared exception! + try { + rESTClient0.httpPatch("lr"); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test35() throws Throwable { + RESTClient rESTClient0 = new RESTClient("", "netscape", 1); + // Undeclared exception! + try { + rESTClient0.httpPost(""); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test36() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig((String) null); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + // Undeclared exception! + try { + rESTClient0.httpGet(); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test37() throws Throwable { + RESTClient rESTClient0 = new RESTClient("K.7:dc=", "K.7:dc=", 0); + try { + rESTClient0.httpPost(); + fail("Expecting exception: Exception"); + + } catch(Exception e) { + // + // org.evosuite.runtime.mock.java.lang.MockThrowable: URI does not specify a valid host name: K.7:dc= + // + verifyException("org.openecomp.mso.rest.RESTClient", e); + } + } + + @Test(timeout = 4000) + public void test38() throws Throwable { + RESTClient rESTClient0 = new RESTClient("org.apache.http.ParseException=", "EWh2BZ[]:q+%4S#7K", (-1847)); + // Undeclared exception! + try { + rESTClient0.httpDelete(); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test39() throws Throwable { + RESTClient rESTClient0 = new RESTClient(",%LX:SC+'3!nt"); + String string0 = rESTClient0.getURL(); + assertEquals(",%LX:SC+'3!nt", string0); + } + + @Test(timeout = 4000) + public void test40() throws Throwable { + RESTClient rESTClient0 = new RESTClient("compatibility"); + InputStream inputStream0 = mock(InputStream.class, new ViolatedAssumptionAnswer()); + doReturn((-3113)).when(inputStream0).read(any(byte[].class)); + HttpEntity httpEntity0 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + StatusLine statusLine0 = mock(StatusLine.class, new ViolatedAssumptionAnswer()); + doReturn(201).when(statusLine0).getStatusCode(); + HttpEntity httpEntity1 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + doReturn(inputStream0).when(httpEntity1).getContent(); + doReturn(0L, (long)(-2116360694)).when(httpEntity1).getContentLength(); + HttpEntity httpEntity2 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + doReturn(false).when(httpEntity2).isStreaming(); + HttpResponse httpResponse0 = mock(HttpResponse.class, new ViolatedAssumptionAnswer()); + doReturn(httpEntity0, httpEntity1, httpEntity2).when(httpResponse0).getEntity(); + doReturn(statusLine0).when(httpResponse0).getStatusLine(); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn("GiQ=eHBwH9zA4COa").when(httpClient0).toString(); + doReturn(httpResponse0).when(httpClient0).execute(any(org.apache.http.client.methods.HttpUriRequest.class)); + rESTClient0.setUnitTestClient(httpClient0); + // Undeclared exception! + try { + rESTClient0.httpDelete(""); + fail("Expecting exception: IndexOutOfBoundsException"); + + } catch(IndexOutOfBoundsException e) { + // + // off: 0 len: -3113 b.length: 4096 + // + verifyException("org.apache.http.util.ByteArrayBuffer", e); + } + } + + @Test(timeout = 4000) + public void test41() throws Throwable { + RESTClient rESTClient0 = new RESTClient("compatibility"); + HttpEntity httpEntity0 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + StatusLine statusLine0 = mock(StatusLine.class, new ViolatedAssumptionAnswer()); + doReturn(201).when(statusLine0).getStatusCode(); + Header[] headerArray0 = new Header[0]; + HttpEntity httpEntity1 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + doReturn((InputStream) null).when(httpEntity1).getContent(); + HttpEntity httpEntity2 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + doReturn(false).when(httpEntity2).isStreaming(); + HttpResponse httpResponse0 = mock(HttpResponse.class, new ViolatedAssumptionAnswer()); + doReturn(headerArray0).when(httpResponse0).getAllHeaders(); + doReturn(httpEntity0, httpEntity1, httpEntity2).when(httpResponse0).getEntity(); + doReturn(statusLine0).when(httpResponse0).getStatusLine(); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn("GiQ=eHBwH9zA4COa").when(httpClient0).toString(); + doReturn(httpResponse0).when(httpClient0).execute(any(org.apache.http.client.methods.HttpUriRequest.class)); + rESTClient0.setUnitTestClient(httpClient0); + APIResponse aPIResponse0 = rESTClient0.httpDelete(""); + assertEquals(201, aPIResponse0.getStatusCode()); + } + + @Test(timeout = 4000) + public void test42() throws Throwable { + RESTClient rESTClient0 = new RESTClient("wlq:6r"); + try { + rESTClient0.httpDelete("E"); + fail("Expecting exception: Exception"); + + } catch(Exception e) { + // + // org.evosuite.runtime.mock.java.lang.MockThrowable: URI does not specify a valid host name: wlq:6r + // + verifyException("org.openecomp.mso.rest.RESTClient", e); + } + } + + @Test(timeout = 4000) + public void test43() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + // Undeclared exception! + try { + rESTClient0.httpPatch(""); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test44() throws Throwable { + RESTClient rESTClient0 = new RESTClient("DELETE"); + // Undeclared exception! + try { + rESTClient0.httpPatch((String) null); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test45() throws Throwable { + RESTClient rESTClient0 = new RESTClient("org.apache.http.ParseException"); + RESTClient rESTClient1 = rESTClient0.addParameter("DELETE", ""); + // Undeclared exception! + try { + rESTClient1.patch("<;xR"); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test46() throws Throwable { + RESTClient rESTClient0 = new RESTClient("compatibility"); + HttpEntity httpEntity0 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + StatusLine statusLine0 = mock(StatusLine.class, new ViolatedAssumptionAnswer()); + doReturn(201).when(statusLine0).getStatusCode(); + Header[] headerArray0 = new Header[0]; + HttpEntity httpEntity1 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + doReturn((InputStream) null).when(httpEntity1).getContent(); + HttpEntity httpEntity2 = mock(HttpEntity.class, new ViolatedAssumptionAnswer()); + doReturn(false).when(httpEntity2).isStreaming(); + HttpResponse httpResponse0 = mock(HttpResponse.class, new ViolatedAssumptionAnswer()); + doReturn(headerArray0).when(httpResponse0).getAllHeaders(); + doReturn(httpEntity0, httpEntity1, httpEntity2).when(httpResponse0).getEntity(); + doReturn(statusLine0).when(httpResponse0).getStatusLine(); + HttpClient httpClient0 = mock(HttpClient.class, new ViolatedAssumptionAnswer()); + doReturn("GiQ=eHBwH9zA4COa").when(httpClient0).toString(); + doReturn(httpResponse0).when(httpClient0).execute(any(org.apache.http.client.methods.HttpUriRequest.class)); + rESTClient0.setUnitTestClient(httpClient0); + APIResponse aPIResponse0 = rESTClient0.httpPut("compatibility"); + assertEquals(201, aPIResponse0.getStatusCode()); + } + + @Test(timeout = 4000) + public void test47() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + // Undeclared exception! + try { + rESTClient0.httpPut(""); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test48() throws Throwable { + RESTClient rESTClient0 = new RESTClient("compatibility"); + rESTClient0.addParameter("https", "https"); + // Undeclared exception! + try { + rESTClient0.httpPut("compatibility"); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test49() throws Throwable { + RESTClient rESTClient0 = new RESTClient("", "(", 307); + // Undeclared exception! + try { + rESTClient0.httpPut((String) null); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test50() throws Throwable { + RESTClient rESTClient0 = new RESTClient("@0*Eu-=Fa"); + // Undeclared exception! + try { + rESTClient0.httpPost("@0*Eu-=Fa"); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test51() throws Throwable { + RESTClient rESTClient0 = new RESTClient("x"); + // Undeclared exception! + try { + rESTClient0.httpPost((String) null); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test52() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("2cSq'/FF]W'K.S^k=<=", "2cSq'/FF]W'K.S^k=<=", 2605); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + RESTClient rESTClient1 = rESTClient0.setHeader("WkI<", "http"); + RESTClient rESTClient2 = rESTClient1.setHeader("WkI<", ""); + assertEquals("2cSq'/FF]W'K.S^k=<=", rESTClient2.getURL()); + } + + @Test(timeout = 4000) + public void test53() throws Throwable { + RESTClient rESTClient0 = new RESTClient("szM4DVVoiAs`]T/", "szM4DVVoiAs`]T/", (-697)); + RESTClient rESTClient1 = rESTClient0.setHeader("szM4DVVoiAs`]T/", "szM4DVVoiAs`]T/"); + RESTClient rESTClient2 = rESTClient1.addHeader("szM4DVVoiAs`]T/", "szM4DVVoiAs`]T/"); + assertSame(rESTClient0, rESTClient2); + } + + @Test(timeout = 4000) + public void test54() throws Throwable { + RESTClient rESTClient0 = new RESTClient("E U(~h|zVLWi", "http", 0); + rESTClient0.setParameter("E U(~h|zVLWi", "http"); + RESTClient rESTClient1 = rESTClient0.setParameter("E U(~h|zVLWi", "k@(}4U05'$}yl)W"); + assertSame(rESTClient1, rESTClient0); + } + + @Test(timeout = 4000) + public void test55() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + RESTClient rESTClient1 = rESTClient0.addParameter("", ""); + RESTClient rESTClient2 = rESTClient0.addParameter("", (String) null); + assertSame(rESTClient2, rESTClient1); + } + + @Test(timeout = 4000) + public void test56() throws Throwable { + RESTClient rESTClient0 = new RESTClient("compatibility"); + rESTClient0.addParameter("https", "https"); + RESTClient rESTClient1 = rESTClient0.setParameter("4#'mD<\"jNh?>_vfI:]", "Char array buffer"); + // Undeclared exception! + try { + rESTClient1.httpDelete(""); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test57() throws Throwable { + RESTClient rESTClient0 = new RESTClient("K.7:dc="); + try { + rESTClient0.get(); + fail("Expecting exception: Exception"); + + } catch(Exception e) { + // + // org.evosuite.runtime.mock.java.lang.MockThrowable: URI does not specify a valid host name: K.7:dc= + // + verifyException("org.openecomp.mso.rest.RESTClient", e); + } + } + + @Test(timeout = 4000) + public void test58() throws Throwable { + RESTClient rESTClient0 = new RESTClient("http.virtual-host"); + RESTClient rESTClient1 = rESTClient0.addAuthorizationHeader("EWh2BZ[]:q+%4S#7K"); + assertSame(rESTClient0, rESTClient1); + } + + @Test(timeout = 4000) + public void test59() throws Throwable { + RESTClient rESTClient0 = new RESTClient("YoeLljo%3A%5C%3D=http", "http.protocol.element-charset", (-1908874351)); + // Undeclared exception! + try { + rESTClient0.delete(); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test60() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("UTF-8"); + RESTClient rESTClient0 = new RESTClient(rESTConfig0); + HttpEntity httpEntity0 = rESTClient0.getHttpEntity(); + assertNull(httpEntity0); + } + + @Test(timeout = 4000) + public void test61() throws Throwable { + RESTClient rESTClient0 = new RESTClient(",%LX:SC+'3!nt"); + LinkedHashMap<String, List<String>> linkedHashMap0 = rESTClient0.getHeaders(); + assertEquals(0, linkedHashMap0.size()); + } + + @Test(timeout = 4000) + public void test62() throws Throwable { + RESTClient rESTClient0 = new RESTClient("DELETE"); + HttpClient httpClient0 = rESTClient0.getUnitTestClient(); + assertNull(httpClient0); + } + + @Test(timeout = 4000) + public void test63() throws Throwable { + RESTClient rESTClient0 = new RESTClient("A29%23fZqv%7F*%405=%7F%7Frdbt-X%22DB%2FhCrUn", "=", (-1)); + RESTClient rESTClient1 = rESTClient0.addParameter("o", "o"); + // Undeclared exception! + try { + rESTClient1.httpGet(); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test64() throws Throwable { + RESTClient rESTClient0 = new RESTClient("DELETE"); + LinkedHashMap<String, List<String>> linkedHashMap0 = rESTClient0.getParameters(); + assertTrue(linkedHashMap0.isEmpty()); + } + + @Test(timeout = 4000) + public void test65() throws Throwable { + RESTClient rESTClient0 = new RESTClient(""); + // Undeclared exception! + try { + rESTClient0.post(); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } + + @Test(timeout = 4000) + public void test66() throws Throwable { + RESTClient rESTClient0 = new RESTClient("DELETE"); + // Undeclared exception! + try { + rESTClient0.httpDelete((String) null); + fail("Expecting exception: IllegalStateException"); + + } catch(IllegalStateException e) { + // + // Target host is null + // + verifyException("org.apache.http.util.Asserts", e); + } + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientESTestscaffolding.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientESTestscaffolding.java new file mode 100644 index 0000000000..2761b252fd --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientESTestscaffolding.java @@ -0,0 +1,366 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:49:09 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RESTClientESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.rest.RESTClient"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RESTClientESTestscaffolding.class.getClassLoader() , + "org.apache.http.client.methods.HttpPatch", + "org.apache.http.io.HttpMessageParserFactory", + "org.apache.http.impl.conn.DefaultHttpResponseParserFactory", + "org.apache.http.impl.execchain.RequestAbortedException", + "org.apache.http.impl.execchain.ProtocolExec", + "org.apache.http.config.Registry", + "org.apache.http.cookie.MalformedCookieException", + "org.apache.http.impl.conn.SystemDefaultDnsResolver", + "org.apache.http.client.protocol.RequestClientConnControl", + "org.apache.http.conn.ConnectionRequest", + "org.apache.http.impl.client.DefaultUserTokenHandler", + "org.apache.http.impl.conn.DefaultManagedHttpClientConnection", + "org.apache.http.conn.HttpClientConnectionManager", + "org.apache.http.client.protocol.RequestAcceptEncoding", + "org.apache.http.HttpException", + "org.apache.http.cookie.CookieSpec", + "org.apache.http.impl.cookie.RFC2965SpecFactory", + "org.apache.http.pool.AbstractConnPool$1", + "org.apache.http.conn.ssl.AllowAllHostnameVerifier", + "org.apache.http.client.CredentialsProvider", + "org.apache.http.client.ClientProtocolException", + "org.apache.http.pool.RouteSpecificPool", + "org.apache.http.client.methods.Configurable", + "org.apache.http.config.RegistryBuilder", + "org.apache.http.params.AbstractHttpParams", + "org.apache.http.io.HttpTransportMetrics", + "org.apache.http.conn.ssl.AbstractVerifier", + "org.openecomp.mso.rest.RESTConfig", + "org.apache.http.auth.Credentials", + "org.apache.http.io.HttpMessageParser", + "org.apache.http.client.methods.AbstractExecutionAwareRequest", + "org.apache.http.impl.BHttpConnectionBase", + "org.apache.http.HttpConnectionMetrics", + "org.apache.http.io.HttpMessageWriter", + "org.apache.http.HttpClientConnection", + "org.apache.http.conn.ConnectionPoolTimeoutException", + "org.apache.http.conn.routing.HttpRouteDirector", + "org.apache.http.pool.ConnPool", + "org.apache.http.protocol.HttpProcessor", + "org.apache.http.auth.AuthProtocolState", + "org.apache.http.client.RedirectStrategy", + "org.apache.http.impl.client.BasicCookieStore", + "org.apache.http.conn.routing.BasicRouteDirector", + "org.apache.http.protocol.HttpContext", + "org.apache.http.params.HttpParams", + "org.apache.http.client.NonRepeatableRequestException", + "org.apache.http.HttpResponse", + "org.apache.http.impl.client.AuthenticationStrategyImpl", + "org.apache.http.impl.client.HttpClientBuilder", + "org.apache.http.message.HeaderGroup", + "org.apache.http.impl.io.DefaultHttpRequestWriterFactory", + "org.apache.http.client.protocol.RequestAuthCache", + "org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory", + "org.apache.http.impl.conn.DefaultSchemePortResolver", + "org.apache.http.config.MessageConstraints", + "org.apache.http.Header", + "org.apache.http.conn.HttpHostConnectException", + "org.apache.http.util.EntityUtils", + "org.apache.http.impl.NoConnectionReuseStrategy", + "org.apache.http.impl.client.BasicCredentialsProvider", + "org.apache.http.conn.ConnectionKeepAliveStrategy", + "org.apache.http.cookie.CookieSpecFactory", + "org.apache.http.conn.ssl.X509HostnameVerifier", + "org.apache.http.protocol.ChainBuilder", + "org.apache.http.impl.client.DefaultHttpRequestRetryHandler", + "org.apache.http.impl.conn.PoolingHttpClientConnectionManager", + "org.apache.http.impl.conn.DefaultProxyRoutePlanner", + "org.apache.http.impl.auth.KerberosSchemeFactory", + "org.apache.http.util.ByteArrayBuffer", + "org.apache.http.cookie.CookieOrigin", + "org.apache.http.client.methods.HttpRequestBase", + "org.apache.http.HttpEntity", + "org.apache.http.pool.PoolEntryCallback", + "org.apache.http.entity.StringEntity", + "org.apache.http.impl.DefaultConnectionReuseStrategy", + "org.apache.http.pool.ConnFactory", + "org.apache.http.client.methods.HttpGet", + "org.apache.http.protocol.BasicHttpContext", + "org.apache.commons.logging.impl.Jdk14Logger", + "org.apache.http.impl.execchain.ClientExecChain", + "org.apache.http.HttpVersion", + "org.apache.http.conn.SchemePortResolver", + "org.apache.http.message.BasicStatusLine", + "org.apache.http.conn.DnsResolver", + "org.apache.http.impl.client.TargetAuthenticationStrategy", + "org.apache.http.params.CoreProtocolPNames", + "org.apache.http.auth.AuthScheme", + "org.apache.http.message.AbstractHttpMessage", + "org.apache.http.auth.MalformedChallengeException", + "org.apache.http.HttpEntityEnclosingRequest", + "org.apache.http.entity.AbstractHttpEntity", + "org.apache.http.ReasonPhraseCatalog", + "org.apache.http.impl.cookie.BrowserCompatSpecFactory$SecurityLevel", + "org.apache.http.client.UserTokenHandler", + "org.apache.http.impl.auth.DigestSchemeFactory", + "org.apache.http.impl.conn.HttpClientConnectionOperator", + "org.apache.http.HttpResponseFactory", + "org.apache.http.client.methods.HttpPut", + "org.openecomp.mso.rest.RESTClient", + "org.apache.http.ConnectionReuseStrategy", + "org.apache.http.client.protocol.RequestDefaultHeaders", + "org.apache.http.message.BasicHeader", + "org.apache.http.impl.conn.ConnectionShutdownException", + "org.apache.http.conn.ManagedHttpClientConnection", + "org.apache.http.client.protocol.ResponseContentEncoding", + "org.apache.http.message.BasicLineParser", + "org.apache.http.client.methods.HttpPost", + "org.apache.http.auth.AuthSchemeProvider", + "org.apache.http.config.SocketConfig", + "org.apache.http.util.Asserts", + "org.apache.http.client.config.RequestConfig", + "org.apache.http.StatusLine", + "org.apache.http.impl.DefaultBHttpClientConnection", + "org.apache.http.impl.DefaultHttpResponseFactory", + "org.apache.http.io.SessionOutputBuffer", + "org.apache.http.RequestLine", + "org.apache.http.conn.HttpConnectionFactory", + "org.apache.http.protocol.RequestContent", + "org.apache.http.cookie.CookieIdentityComparator", + "org.apache.http.config.Lookup", + "org.apache.http.HttpMessage", + "org.apache.http.impl.cookie.NetscapeDraftSpecFactory", + "org.apache.http.HttpRequestInterceptor", + "org.apache.http.HeaderElementIterator", + "org.apache.http.client.AuthCache", + "org.apache.http.pool.AbstractConnPool", + "org.apache.http.HeaderIterator", + "org.apache.http.conn.ClientConnectionManager", + "org.apache.http.HttpInetConnection", + "org.apache.http.entity.ContentType", + "org.apache.http.message.LineFormatter", + "org.apache.http.cookie.CookieSpecProvider", + "org.apache.http.HttpRequest", + "org.apache.http.pool.ConnPoolControl", + "org.openecomp.mso.rest.APIResponse", + "org.apache.http.client.BackoffManager", + "org.openecomp.mso.rest.HostNameVerifier", + "org.apache.http.client.AuthenticationStrategy", + "org.apache.http.conn.socket.ConnectionSocketFactory", + "org.apache.http.protocol.RequestTargetHost", + "org.apache.http.pool.PoolEntry", + "org.apache.http.message.BasicLineFormatter", + "org.apache.http.client.methods.HttpUriRequest", + "org.apache.http.protocol.HttpRequestExecutor", + "org.apache.http.client.methods.HttpRequestWrapper", + "org.apache.http.io.SessionInputBuffer", + "org.apache.http.impl.cookie.IgnoreSpecFactory", + "org.apache.http.impl.auth.HttpAuthenticator", + "org.apache.http.impl.conn.ManagedHttpClientConnectionFactory", + "org.apache.http.conn.ConnectTimeoutException", + "org.apache.http.client.methods.AbortableHttpRequest", + "org.apache.http.client.HttpClient", + "org.apache.http.auth.AuthSchemeFactory", + "org.apache.http.cookie.Cookie", + "org.apache.http.protocol.ImmutableHttpProcessor", + "org.apache.http.impl.auth.SPNegoSchemeFactory", + "org.apache.http.protocol.HTTP", + "org.apache.http.impl.conn.PoolingHttpClientConnectionManager$ConfigData", + "org.openecomp.mso.rest.RESTClient$HttpDeleteWithBody", + "org.apache.http.TokenIterator", + "org.openecomp.mso.rest.HttpHeader", + "org.apache.http.client.methods.HttpRequestWrapper$HttpEntityEnclosingRequestWrapper", + "org.apache.http.protocol.HttpCoreContext", + "org.apache.http.impl.conn.CPool", + "org.apache.http.impl.auth.NTLMSchemeFactory", + "org.apache.http.client.utils.URIUtils", + "org.apache.http.ProtocolVersion", + "org.apache.http.client.protocol.RequestExpectContinue", + "org.apache.http.util.VersionInfo", + "org.apache.http.impl.cookie.RFC2109SpecFactory", + "org.apache.http.entity.InputStreamEntity", + "org.apache.http.HttpHost", + "org.apache.http.conn.UnsupportedSchemeException", + "org.apache.http.ProtocolException", + "org.apache.http.impl.cookie.BrowserCompatSpecFactory", + "org.apache.http.client.methods.HttpEntityEnclosingRequestBase", + "org.apache.http.params.BasicHttpParams", + "org.apache.http.client.protocol.HttpClientContext", + "org.apache.http.impl.client.ProxyAuthenticationStrategy", + "org.apache.http.conn.ssl.StrictHostnameVerifier", + "org.apache.http.io.HttpMessageWriterFactory", + "org.apache.http.concurrent.Cancellable", + "org.apache.http.impl.execchain.MainClientExec", + "org.apache.http.protocol.HttpProcessorBuilder", + "org.apache.http.entity.ContentLengthStrategy", + "org.apache.http.impl.execchain.TunnelRefusedException", + "org.apache.http.conn.routing.HttpRoutePlanner", + "org.apache.http.Consts", + "org.apache.http.conn.ssl.SSLConnectionSocketFactory", + "org.apache.http.message.LineParser", + "org.apache.http.impl.cookie.BestMatchSpecFactory", + "org.apache.http.params.HttpParamsNames", + "org.apache.http.conn.ssl.SSLInitializationException", + "org.openecomp.mso.rest.RESTException", + "org.apache.http.util.Args", + "org.apache.http.params.HttpProtocolParams", + "org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy", + "org.apache.http.protocol.RequestUserAgent", + "org.apache.http.config.ConnectionConfig", + "org.apache.http.conn.socket.LayeredConnectionSocketFactory", + "org.apache.http.conn.ssl.BrowserCompatHostnameVerifier", + "org.apache.http.util.TextUtils", + "org.apache.http.HttpResponseInterceptor", + "org.apache.http.impl.EnglishReasonPhraseCatalog", + "org.apache.http.client.config.RequestConfig$Builder", + "org.apache.http.auth.AuthenticationException", + "org.apache.http.auth.AuthState", + "org.apache.http.client.protocol.RequestAddCookies", + "org.apache.http.impl.conn.DefaultRoutePlanner", + "org.apache.http.conn.routing.HttpRoute", + "org.apache.http.impl.conn.CPoolEntry", + "org.apache.http.client.CookieStore", + "org.apache.http.impl.auth.BasicSchemeFactory", + "org.apache.http.conn.socket.PlainConnectionSocketFactory", + "org.apache.http.client.HttpRequestRetryHandler", + "org.apache.http.ParseException", + "org.apache.http.impl.client.CloseableHttpClient", + "org.apache.http.client.protocol.ResponseProcessCookies", + "org.apache.http.message.BasicRequestLine", + "org.apache.http.client.ServiceUnavailableRetryStrategy", + "org.apache.http.client.methods.HttpExecutionAware", + "org.apache.http.impl.client.InternalHttpClient", + "org.apache.http.HeaderElement", + "org.apache.http.client.ConnectionBackoffStrategy", + "org.apache.http.util.CharArrayBuffer", + "org.apache.http.impl.execchain.RetryExec", + "org.apache.http.conn.routing.RouteInfo", + "org.apache.http.client.ResponseHandler", + "org.apache.http.HttpConnection", + "org.apache.http.message.ParserCursor" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RESTClientESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.rest.RESTClient$HttpDeleteWithBody", + "org.apache.http.conn.socket.PlainConnectionSocketFactory", + "org.apache.http.conn.ssl.AbstractVerifier", + "org.apache.commons.logging.impl.Jdk14Logger", + "org.apache.http.conn.ssl.SSLConnectionSocketFactory", + "org.apache.http.impl.conn.CPool", + "org.apache.http.message.BasicLineFormatter", + "org.apache.http.impl.io.DefaultHttpRequestWriterFactory", + "org.apache.http.ProtocolVersion", + "org.apache.http.HttpVersion", + "org.apache.http.message.BasicLineParser", + "org.apache.http.impl.EnglishReasonPhraseCatalog", + "org.apache.http.impl.DefaultHttpResponseFactory", + "org.apache.http.impl.conn.DefaultHttpResponseParserFactory", + "org.apache.http.impl.conn.ManagedHttpClientConnectionFactory", + "org.apache.http.impl.conn.HttpClientConnectionOperator", + "org.apache.http.impl.conn.DefaultSchemePortResolver", + "org.apache.http.impl.conn.SystemDefaultDnsResolver", + "org.apache.http.util.VersionInfo", + "org.apache.http.impl.client.HttpClientBuilder", + "org.apache.http.protocol.HttpRequestExecutor", + "org.apache.http.impl.DefaultConnectionReuseStrategy", + "org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy", + "org.apache.http.impl.client.AuthenticationStrategyImpl", + "org.apache.http.impl.client.TargetAuthenticationStrategy", + "org.apache.http.impl.client.ProxyAuthenticationStrategy", + "org.apache.http.impl.client.DefaultUserTokenHandler", + "org.apache.http.client.protocol.RequestClientConnControl", + "org.apache.http.client.protocol.ResponseContentEncoding", + "org.apache.http.impl.client.DefaultHttpRequestRetryHandler", + "org.apache.http.impl.cookie.BrowserCompatSpecFactory$SecurityLevel", + "org.apache.http.impl.client.BasicCookieStore", + "org.apache.http.cookie.CookieIdentityComparator", + "org.apache.http.client.config.RequestConfig", + "org.apache.http.client.methods.HttpPut", + "org.apache.http.message.HeaderGroup", + "org.apache.http.message.BasicHeader", + "org.apache.http.entity.AbstractHttpEntity", + "org.apache.http.Consts", + "org.apache.http.entity.ContentType", + "org.apache.http.util.CharArrayBuffer", + "org.apache.http.params.BasicHttpParams", + "org.apache.http.message.BasicRequestLine", + "org.apache.http.protocol.HttpCoreContext", + "org.apache.http.client.protocol.HttpClientContext", + "org.apache.http.auth.AuthProtocolState", + "org.apache.http.client.methods.HttpPost", + "org.apache.http.HttpHost", + "org.apache.http.client.methods.HttpGet", + "org.apache.http.client.methods.HttpPatch", + "org.openecomp.mso.rest.RESTException", + "org.apache.http.client.ClientProtocolException", + "org.apache.http.protocol.HTTP", + "org.apache.http.message.BasicStatusLine", + "org.apache.http.util.ByteArrayBuffer" + ); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientTest.java new file mode 100644 index 0000000000..a1c83ba70e --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTClientTest.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.rest; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.IOException; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpVersion; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpUriRequest; +import org.apache.http.entity.StringEntity; +import org.apache.http.message.BasicHttpResponse; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +import org.openecomp.mso.rest.APIResponse; +import org.openecomp.mso.rest.RESTClient; +import org.openecomp.mso.rest.RESTException; + +/** + * @version 1.0 + * + */ +public class RESTClientTest { + + @Test + public void testSimpleHTTP() throws RESTException, ClientProtocolException, IOException { + HttpClient mockHttpClient = mock(HttpClient.class); + HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); + response.setEntity(new StringEntity("test","UTF-8")); + when(mockHttpClient.execute(Mockito.<HttpUriRequest>any())).thenReturn(response); + + RESTClient restClient = new RESTClient("http://localhost"); + restClient.setUnitTestClient(mockHttpClient); + APIResponse apiResponse = restClient.get(); + Assert.assertEquals(200, apiResponse.getStatusCode()); + Assert.assertEquals("test", apiResponse.getResponseBodyAsString()); + } + + @Test + public void testSimpleHTTPS() throws RESTException, ClientProtocolException, IOException { + HttpClient mockHttpClient = mock(HttpClient.class); + HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK"); + response.setEntity(new StringEntity("test","UTF-8")); + when(mockHttpClient.execute(Mockito.<HttpUriRequest>any())).thenReturn(response); + + RESTClient restClient = new RESTClient("https://localhost"); + restClient.setUnitTestClient(mockHttpClient); + APIResponse apiResponse = restClient.get(); + Assert.assertEquals(200, apiResponse.getStatusCode()); + Assert.assertEquals("test", apiResponse.getResponseBodyAsString()); + } + +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigESTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigESTest.java new file mode 100644 index 0000000000..0a46cebf29 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigESTest.java @@ -0,0 +1,110 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:47:42 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RESTConfigESTest extends RESTConfigESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig((String) null, "", (-3449)); + String string0 = rESTConfig0.getURL(); + assertEquals(-3449, rESTConfig0.getProxyPort()); + assertNull(string0); + assertFalse(rESTConfig0.trustAllCerts()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig(";A,GC~!-_.>+R=>rIO", "", (-3449), false); + String string0 = rESTConfig0.getURL(); + assertEquals("", rESTConfig0.getProxyHost()); + assertEquals(-3449, rESTConfig0.getProxyPort()); + assertFalse(rESTConfig0.trustAllCerts()); + assertEquals(";A,GC~!-_.>+R=>rIO", string0); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("", "", 0); + int int0 = rESTConfig0.getProxyPort(); + assertFalse(rESTConfig0.trustAllCerts()); + assertEquals(0, int0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig((String) null); + int int0 = rESTConfig0.getProxyPort(); + assertEquals((-1), int0); + assertFalse(rESTConfig0.trustAllCerts()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig((String) null, "zZu8", (-1933), true); + String string0 = rESTConfig0.getProxyHost(); + assertEquals(-1933, rESTConfig0.getProxyPort()); + assertTrue(rESTConfig0.trustAllCerts()); + assertNotNull(string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("", "", 2708, true); + boolean boolean0 = rESTConfig0.trustAllCerts(); + assertTrue(boolean0); + assertEquals(2708, rESTConfig0.getProxyPort()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("", "", 2708, true); + rESTConfig0.getURL(); + assertTrue(rESTConfig0.trustAllCerts()); + assertEquals(2708, rESTConfig0.getProxyPort()); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("", true); + String string0 = rESTConfig0.getProxyHost(); + assertTrue(rESTConfig0.trustAllCerts()); + assertNull(string0); + assertEquals(-1, rESTConfig0.getProxyPort()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("", "", 2708, true); + int int0 = rESTConfig0.getProxyPort(); + assertEquals(2708, int0); + assertTrue(rESTConfig0.trustAllCerts()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig("", "", 2708, true); + rESTConfig0.getProxyHost(); + assertEquals(2708, rESTConfig0.getProxyPort()); + assertTrue(rESTConfig0.trustAllCerts()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + RESTConfig rESTConfig0 = new RESTConfig(""); + boolean boolean0 = rESTConfig0.trustAllCerts(); + assertEquals(-1, rESTConfig0.getProxyPort()); + assertFalse(boolean0); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigESTestscaffolding.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigESTestscaffolding.java new file mode 100644 index 0000000000..1eb33ddd80 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTConfigESTestscaffolding.java @@ -0,0 +1,78 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:47:42 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RESTConfigESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.rest.RESTConfig"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RESTConfigESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.rest.RESTConfig" + ); + } + + private static void resetClasses() { + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionESTest.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionESTest.java new file mode 100644 index 0000000000..aff908ee98 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionESTest.java @@ -0,0 +1,78 @@ +/* + * This file was automatically generated by EvoSuite + * Mon Nov 14 11:47:59 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.mock.java.lang.MockThrowable; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class RESTExceptionESTest extends RESTExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + RESTException rESTException0 = new RESTException(0, (String) null); + int int0 = rESTException0.getStatusCode(); + assertEquals(0, int0); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + RESTException rESTException0 = new RESTException(1619, ""); + int int0 = rESTException0.getStatusCode(); + assertEquals(1619, int0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + RESTException rESTException0 = new RESTException(""); + String string0 = rESTException0.getErrorMessage(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + RESTException rESTException0 = null; + try { + rESTException0 = new RESTException((Throwable) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.rest.RESTException", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + RESTException rESTException0 = new RESTException((-489), "org.evosuite.runtime.mock.java.lang.MockThrowable: org.evosuite.runtime.mock.java.lang.MockThrowable"); + String string0 = rESTException0.getErrorMessage(); + assertEquals("org.evosuite.runtime.mock.java.lang.MockThrowable: org.evosuite.runtime.mock.java.lang.MockThrowable", string0); + } + + @Test(timeout = 4000) + public void test5() throws Throwable { + MockThrowable mockThrowable0 = new MockThrowable(); + RESTException rESTException0 = new RESTException((Throwable) mockThrowable0); + int int0 = rESTException0.getStatusCode(); + assertEquals((-1), int0); + } + + @Test(timeout = 4000) + public void test6() throws Throwable { + MockThrowable mockThrowable0 = new MockThrowable(); + RESTException rESTException0 = new RESTException((Throwable) mockThrowable0); + String string0 = rESTException0.getErrorMessage(); + assertNull(string0); + } +} diff --git a/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionESTestscaffolding.java b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionESTestscaffolding.java new file mode 100644 index 0000000000..13d4dcc026 --- /dev/null +++ b/bpmn/MSORESTClient/src/test/java/org/openecomp/mso/rest/RESTExceptionESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Mon Nov 14 11:47:59 GMT 2016 + */ + +package org.openecomp.mso.rest; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class RESTExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.rest.RESTException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(RESTExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.rest.RESTException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(RESTExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.rest.RESTException" + ); + } +} |