Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test improvement: removed resource optimism (test smell) #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wiztools.restclient;

import org.junit.*;
import org.wiztools.restclient.util.XMLUtil;
import org.wiztools.restclient.bean.Request;
import org.wiztools.restclient.bean.ReqEntityStringBean;
Expand All @@ -10,11 +11,7 @@
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.*;
import org.wiztools.commons.Charsets;
import org.wiztools.restclient.bean.*;
Expand Down Expand Up @@ -92,6 +89,7 @@ public void testGetDocumentCharset() throws Exception {
// When document complies to standard:
{
File f = new File("src/test/resources/org/wiztools/restclient/xml/charset1.xml");
Assume.assumeTrue(f.exists());
String expResult = "UTF-8";
String result = XMLUtil.getDocumentCharset(f);
System.out.println("encoding attribute: " + result ) ;
Expand All @@ -101,6 +99,7 @@ public void testGetDocumentCharset() throws Exception {
// When document does not have encoding attribute:
{
File f = new File("src/test/resources/org/wiztools/restclient/xml/charset2.xml");
Assume.assumeTrue(f.exists());
String expResult = Charsets.UTF_8.name();
System.out.println("expResult: " + expResult);
String result = XMLUtil.getDocumentCharset(f);
Expand All @@ -111,6 +110,7 @@ public void testGetDocumentCharset() throws Exception {
// When document does not have XML declaration:
{
File f = new File("src/test/resources/org/wiztools/restclient/xml/charset3.xml");
Assume.assumeTrue(f.exists());
String expResult = Charsets.UTF_8.name();
System.out.println("expResult: " + expResult);
String result = XMLUtil.getDocumentCharset(f);
Expand All @@ -128,6 +128,7 @@ public void testWriteRequestXML() throws Exception {
System.out.println("writeRequestXML");
RequestBean bean = getDefaultRequestBean();
File f = File.createTempFile("prefix", ".rcq");
Assume.assumeTrue(f.exists());
pWrite.writeRequest(bean, f);
Request expResult = pRead.getRequestFromFile(f);
assertEquals(expResult, bean);
Expand All @@ -141,6 +142,7 @@ public void testWriteResponseXML() throws Exception {
System.out.println("writeResponseXML");
ResponseBean bean = getDefaultResponseBean();
File f = File.createTempFile("prefix", ".rcs");
Assume.assumeTrue(f.exists());
pWrite.writeResponse(bean, f);
Response expResult = pRead.getResponseFromFile(f);
assertEquals(expResult, bean);
Expand All @@ -153,6 +155,7 @@ public void testWriteResponseXML() throws Exception {
public void testGetRequestFromXMLFile() throws Exception {
System.out.println("getRequestFromXMLFile");
File f = new File("src/test/resources/reqFromXml.rcq");
Assume.assumeTrue(f.exists());

RequestBean expResult = getDefaultRequestBean();

Expand All @@ -167,6 +170,7 @@ public void testGetRequestFromXMLFile() throws Exception {
public void testGetResponseFromXMLFile() throws Exception {
System.out.println("getResponseFromXMLFile");
File f = new File("src/test/resources/resFromXml.rcs");
Assume.assumeTrue(f.exists());

ResponseBean expResult = getDefaultResponseBean();

Expand All @@ -182,6 +186,7 @@ public void testGetResponseFromXMLFile() throws Exception {
@Test
public void testIntegrityOfTestScript() throws Exception{
File f = new File("src/test/resources/resTestScriptIntegrity.rcq");
Assume.assumeTrue(f.exists());
Request req = pRead.getRequestFromFile(f);
File outFile = File.createTempFile("abc", "xyz");
pWrite.writeRequest(req, outFile);
Expand Down