org.evosuite.testcase.statements.environment.AccessedEnvironment Maven / Gradle / Ivy
The newest version!
/**
* Copyright (C) 2010-2018 Gordon Fraser, Andrea Arcuri and EvoSuite
* contributors
*
* This file is part of EvoSuite.
*
* EvoSuite is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* EvoSuite is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with EvoSuite. If not, see .
*/
package org.evosuite.testcase.statements.environment;
import org.evosuite.runtime.javaee.JeeData;
import org.evosuite.runtime.util.Inputs;
import org.evosuite.runtime.vnet.EndPointInfo;
import java.io.Serializable;
import java.util.*;
/**
* Class used to keep track of what environment components (local files, remote URLs, etc)
* a test case has accessed to
*
* Created by arcuri on 12/12/14.
*/
public class AccessedEnvironment implements Serializable {
private static final long serialVersionUID = 2653568611955383431L;
/**
* Paths of accessed local files
*/
private final Set localFiles;
/**
* URL of remote resources
*/
private final Set remoteURLs;
/**
* TCP/UDP sockets opened by the SUT
*/
private final Set localListeningPorts;
/**
* Remote addr/ports the SUT has contacted (ie initialized communication)
* via TCP/UDP
*/
private final Set remoteContactedPorts;
private JeeData jeeData;
public AccessedEnvironment(){
localFiles = new LinkedHashSet<>();
remoteURLs = new LinkedHashSet<>();
localListeningPorts = new LinkedHashSet<>();
remoteContactedPorts = new LinkedHashSet<>();
jeeData = null;
}
public void copyFrom(AccessedEnvironment other){
clear();
this.localFiles.addAll(other.localFiles);
this.remoteURLs.addAll(other.remoteURLs);
this.localListeningPorts.addAll(other.localListeningPorts);
this.remoteContactedPorts.addAll(other.remoteContactedPorts);
this.jeeData = other.jeeData; //it is an immutable object
}
public void clear(){
localFiles.clear();
remoteURLs.clear();
localListeningPorts.clear();
remoteContactedPorts.clear();
jeeData = null;
}
public boolean hasProperty(String property) throws IllegalArgumentException{
Inputs.checkNull(property);
return false; //TODO
}
public JeeData getJeeData() {
return jeeData;
}
public void setJeeData(JeeData jeeData) {
this.jeeData = jeeData;
}
public void addRemoteContactedPorts(Collection ports){
remoteContactedPorts.addAll(ports);
}
public Set getViewOfRemoteContactedPorts(){
return Collections.unmodifiableSet(remoteContactedPorts);
}
public void addLocalListeningPorts(Collection ports){
localListeningPorts.addAll(ports);
}
public Set getViewOfLocalListeningPorts(){
return Collections.unmodifiableSet(localListeningPorts);
}
public void addLocalFiles(Collection files){
localFiles.addAll(files);
}
public Set getViewOfAccessedFiles(){
return Collections.unmodifiableSet(localFiles);
}
public void addRemoteURLs(Collection urls){
remoteURLs.addAll(urls);
}
public Set getViewOfRemoteURLs(){
return Collections.unmodifiableSet(remoteURLs);
}
public boolean isNetworkAccessed() {
return !remoteURLs.isEmpty() || !localListeningPorts.isEmpty() || !remoteContactedPorts.isEmpty();
}
public boolean isFileSystemAccessed() {
return !localFiles.isEmpty();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy