code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static String parseMessagePayload(Element payloadElement) {
if (payloadElement == null) {
return "";
}
try {
Document payload = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
payload.appendChild(payload.importNode(payl... | java |
public ServerCnxnFactory getServerFactory() {
if (serverFactory == null) {
try {
serverFactory = new NIOServerCnxnFactory();
serverFactory.configure(new InetSocketAddress(port), 5000);
} catch (IOException e) {
throw new CitrusRuntimeExcept... | java |
public ZooKeeperServer getZooKeeperServer() {
if (zooKeeperServer == null) {
String dataDirectory = System.getProperty("java.io.tmpdir");
File dir = new File(dataDirectory, "zookeeper").getAbsoluteFile();
try {
zooKeeperServer = new ZooKeeperServer(dir, dir, 2... | java |
public HttpComponentsClientHttpRequestFactory getObject() throws Exception {
Assert.notNull(credentials, "User credentials not set properly!");
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient) {
@Override
prot... | java |
protected T findValidationContext(List<ValidationContext> validationContexts) {
for (ValidationContext validationContext : validationContexts) {
if (getRequiredValidationContextType().isInstance(validationContext)) {
return (T) validationContext;
}
}
retu... | java |
private long getWaitTimeMs(TestContext context) {
if (StringUtils.hasText(seconds)) {
return Long.valueOf(context.replaceDynamicContentInString(seconds)) * 1000;
} else {
return Long.valueOf(context.replaceDynamicContentInString(milliseconds));
}
} | java |
protected void createConnection() throws JMSException {
if (connection == null) {
if (!endpointConfiguration.isPubSubDomain() && endpointConfiguration.getConnectionFactory() instanceof QueueConnectionFactory) {
connection = ((QueueConnectionFactory) endpointConfiguration.getConnectio... | java |
protected void createSession(Connection connection) throws JMSException {
if (session == null) {
if (!endpointConfiguration.isPubSubDomain() && connection instanceof QueueConnection) {
session = ((QueueConnection) connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
... | java |
private void deleteTemporaryDestination(Destination destination) {
log.debug("Delete temporary destination: '{}'", destination);
try {
if (destination instanceof TemporaryQueue) {
((TemporaryQueue) destination).delete();
} else if (destination instanceof Temporar... | java |
private Destination getReplyDestination(Session session, Message message) throws JMSException {
if (message.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL) != null) {
if (message.getHeader(org.springframework.messaging.MessageHeaders.REPLY_CHANNEL) instanceof Destination) {
... | java |
private Destination resolveDestination(String destinationName) throws JMSException {
if (log.isDebugEnabled()) {
log.debug("Sending JMS message to destination: '" + destinationName + "'");
}
return resolveDestinationName(destinationName, session);
} | java |
private Destination resolveDestinationName(String name, Session session) throws JMSException {
if (endpointConfiguration.getDestinationResolver() != null) {
return endpointConfiguration.getDestinationResolver().resolveDestinationName(session, name, endpointConfiguration.isPubSubDomain());
}
... | java |
public void destroy() {
JmsUtils.closeSession(session);
if (connection != null) {
ConnectionFactoryUtils.releaseConnection(connection, endpointConfiguration.getConnectionFactory(), true);
}
} | java |
public CamelRouteActionBuilder context(String camelContext) {
Assert.notNull(applicationContext, "Citrus application context is not initialized!");
this.camelContext = applicationContext.getBean(camelContext, ModelCamelContext.class);
return this;
} | java |
public CamelControlBusActionBuilder controlBus() {
CamelControlBusAction camelControlBusAction = new CamelControlBusAction();
camelControlBusAction.setCamelContext(getCamelContext());
action.setDelegate(camelControlBusAction);
return new CamelControlBusActionBuilder(camelControlBusAction);
} | java |
public CamelRouteActionBuilder create(RouteBuilder routeBuilder) {
CreateCamelRouteAction camelRouteAction = new CreateCamelRouteAction();
try {
if (!routeBuilder.getContext().equals(getCamelContext())) {
routeBuilder.configureRoutes(getCamelContext());
} else {
routeBuilder.configure();
}
cam... | java |
public void start(String ... routes) {
StartCamelRouteAction camelRouteAction = new StartCamelRouteAction();
camelRouteAction.setRouteIds(Arrays.asList(routes));
camelRouteAction.setCamelContext(getCamelContext());
action.setDelegate(camelRouteAction);
} | java |
public void stop(String ... routes) {
StopCamelRouteAction camelRouteAction = new StopCamelRouteAction();
camelRouteAction.setRouteIds(Arrays.asList(routes));
camelRouteAction.setCamelContext(getCamelContext());
action.setDelegate(camelRouteAction);
} | java |
public void remove(String ... routes) {
RemoveCamelRouteAction camelRouteAction = new RemoveCamelRouteAction();
camelRouteAction.setRouteIds(Arrays.asList(routes));
camelRouteAction.setCamelContext(getCamelContext());
action.setDelegate(camelRouteAction);
} | java |
private ModelCamelContext getCamelContext() {
if (camelContext == null) {
Assert.notNull(applicationContext, "Citrus application context is not initialized!");
if (applicationContext.containsBean("citrusCamelContext")) {
camelContext = applicationContext.getBean("citrusCamelContext", M... | java |
private void replaceHeaders(final Message from, final Message to) {
to.getHeaders().clear();
to.getHeaders().putAll(from.getHeaders());
} | java |
protected SoapAttachment findAttachment(SoapMessage soapMessage, SoapAttachment controlAttachment) {
List<SoapAttachment> attachments = soapMessage.getAttachments();
Attachment matching = null;
if (controlAttachment.getContentId() == null) {
if (attachments.size() == 1) {
... | java |
protected void validateAttachmentContentId(SoapAttachment receivedAttachment, SoapAttachment controlAttachment) {
//in case contentId was not set in test case, skip validation
if (!StringUtils.hasText(controlAttachment.getContentId())) { return; }
if (receivedAttachment.getContentId() ... | java |
protected void validateAttachmentContentType(SoapAttachment receivedAttachment, SoapAttachment controlAttachment) {
//in case contentType was not set in test case, skip validation
if (!StringUtils.hasText(controlAttachment.getContentType())) { return; }
if (receivedAttachment.getContent... | java |
public static String replaceDynamicNamespaces(String expression, Map<String, String> namespaces) {
String expressionResult = expression;
for (Entry<String, String> namespaceEntry : namespaces.entrySet()) {
if (expressionResult.contains(DYNAMIC_NS_START + namespaceEntry.getValue() + ... | java |
public static Object evaluate(Node node, String xPathExpression,
NamespaceContext nsContext, XPathExpressionResult resultType) {
if (resultType.equals(XPathExpressionResult.NODE)) {
Node resultNode = evaluateAsNode(node, xPathExpression, nsContext);
if (resultNode.getNodeTyp... | java |
public static Node evaluateAsNode(Node node, String xPathExpression, NamespaceContext nsContext) {
Node result = (Node) evaluateExpression(node, xPathExpression, nsContext, XPathConstants.NODE);
if (result == null) {
throw new CitrusRuntimeException("No result for XPath expression: '" + xPa... | java |
public static NodeList evaluateAsNodeList(Node node, String xPathExpression, NamespaceContext nsContext) {
NodeList result = (NodeList) evaluateExpression(node, xPathExpression, nsContext, XPathConstants.NODESET);
if (result == null) {
throw new CitrusRuntimeException("No result for XPath e... | java |
public static String evaluateAsString(Node node, String xPathExpression, NamespaceContext nsContext) {
String result = (String) evaluateExpression(node, xPathExpression, nsContext, XPathConstants.STRING);
if (!StringUtils.hasText(result)) {
//result is empty so check if the expression node ... | java |
public static Boolean evaluateAsBoolean(Node node, String xPathExpression, NamespaceContext nsContext) {
return (Boolean) evaluateExpression(node, xPathExpression, nsContext, XPathConstants.BOOLEAN);
} | java |
public static Double evaluateAsNumber(Node node, String xPathExpression, NamespaceContext nsContext) {
return (Double) evaluateExpression(node, xPathExpression, nsContext, XPathConstants.NUMBER);
} | java |
public static Object evaluateAsObject(Node node, String xPathExpression, NamespaceContext nsContext, QName resultType) {
return evaluateExpression(node, xPathExpression, nsContext, resultType);
} | java |
private static XPathExpression buildExpression(String xPathExpression, NamespaceContext nsContext)
throws XPathExpressionException {
XPath xpath = createXPathFactory().newXPath();
if (nsContext != null) {
xpath.setNamespaceContext(nsContext);
}
return xp... | java |
public static Object evaluateExpression(Node node, String xPathExpression, NamespaceContext nsContext, QName returnType) {
try {
return buildExpression(xPathExpression, nsContext).evaluate(node, returnType);
} catch (XPathExpressionException e) {
throw new CitrusRuntimeException(... | java |
private synchronized static XPathFactory createXPathFactory() {
XPathFactory factory = null;
// read system property and see if there is a factory set
Properties properties = System.getProperties();
for (Map.Entry<Object, Object> prop : properties.entrySet()) {
String key = ... | java |
public Registry getRegistry() throws RemoteException {
if (registry == null) {
if (StringUtils.hasText(host)) {
registry = LocateRegistry.getRegistry(host, port);
} else {
registry = LocateRegistry.getRegistry(port);
}
}
return... | java |
public File[] build() {
MavenStrategyStage maven = Maven.configureResolver()
.workOffline(offline)
.resolve(artifactCoordinates);
return applyTransitivity(maven).asFile();
} | java |
public CitrusArchiveBuilder all() {
core();
jms();
kafka();
jdbc();
http();
websocket();
ws();
ssh();
ftp();
mail();
camel();
vertx();
docker();
kubernetes();
selenium();
cucumber();
z... | java |
private void createReportFile(String reportFileName, String content) {
File targetDirectory = new File(getReportDirectory());
if (!targetDirectory.exists()) {
if (!targetDirectory.mkdirs()) {
throw new CitrusRuntimeException("Unable to create report output directory: " + getR... | java |
private void verifyPage(String pageId) {
if (!pages.containsKey(pageId)) {
throw new CitrusRuntimeException(String.format("Unknown page '%s' - please introduce page with type information first", pageId));
}
} | java |
public static <T extends CitrusAppConfiguration> T apply(T configuration, String[] arguments) {
LinkedList<String> args = new LinkedList<>(Arrays.asList(arguments));
CitrusAppOptions options = new CitrusAppOptions();
while (!args.isEmpty()) {
String arg = args.removeFirst();
... | java |
private void parseMappingDefinitions(BeanDefinitionBuilder builder, Element element) {
HashMap<String, String> mappings = new HashMap<String, String>();
for (Element matcher : DomUtils.getChildElementsByTagName(element, "mapping")) {
mappings.put(matcher.getAttribute("path"), matcher.getAttr... | java |
private String getJUnitReportsFolder() {
if (ClassUtils.isPresent("org.testng.annotations.Test", getClass().getClassLoader())) {
return "test-output" + File.separator + "junitreports";
} else if (ClassUtils.isPresent("org.junit.Test", getClass().getClassLoader())) {
JUnitReporter... | java |
public io.fabric8.kubernetes.client.KubernetesClient getKubernetesClient() {
if (kubernetesClient == null) {
kubernetesClient = createKubernetesClient();
}
return kubernetesClient;
} | java |
private String getLogoImageData() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
BufferedInputStream reader = null;
try {
reader = new BufferedInputStream(FileUtils.getFileResource(logo).getInputStream());
byte[] contents = new byte[1024];... | java |
private String getCodeSnippetHtml(Throwable cause) {
StringBuilder codeSnippet = new StringBuilder();
BufferedReader reader = null;
try {
if (cause instanceof CitrusRuntimeException) {
CitrusRuntimeException ex = (CitrusRuntimeException) cause;
... | java |
private String getStackTraceHtml(Throwable cause) {
StringBuilder stackTraceBuilder = new StringBuilder();
stackTraceBuilder.append(cause.getClass().getName())
.append(": ")
.append(cause.getMessage())
.append("\n ");
for (i... | java |
protected void validateNamespaces(Map<String, String> expectedNamespaces, Message receivedMessage) {
if (CollectionUtils.isEmpty(expectedNamespaces)) { return; }
if (receivedMessage.getPayload() == null || !StringUtils.hasText(receivedMessage.getPayload(String.class))) {
throw new Validatio... | java |
protected void validateMessageContent(Message receivedMessage, Message controlMessage, XmlMessageValidationContext validationContext,
TestContext context) {
if (controlMessage == null || controlMessage.getPayload() == null) {
log.debug("Skip message payload validation as no control messa... | java |
private void validateXmlHeaderFragment(String receivedHeaderData, String controlHeaderData,
XmlMessageValidationContext validationContext, TestContext context) {
log.debug("Start XML header data validation ...");
Document received = XMLUtils.parseMessagePayload(receivedHeaderData);
... | java |
private void validateXmlTree(Node received, Node source,
XmlMessageValidationContext validationContext, NamespaceContext namespaceContext, TestContext context) {
switch(received.getNodeType()) {
case Node.DOCUMENT_TYPE_NODE:
doDocumentTypeDefinition(received, source, val... | java |
private void doDocumentTypeDefinition(Node received, Node source,
XmlMessageValidationContext validationContext,
NamespaceContext namespaceContext, TestContext context) {
Assert.isTrue(source instanceof DocumentType, "Missing document type definition in expected xml fragment");
... | java |
private void doElement(Node received, Node source,
XmlMessageValidationContext validationContext, NamespaceContext namespaceContext, TestContext context) {
doElementNameValidation(received, source);
doElementNamespaceValidation(received, source);
//check if element is ignored eith... | java |
private void doText(Element received, Element source) {
if (log.isDebugEnabled()) {
log.debug("Validating node value for element: " + received.getLocalName());
}
String receivedText = DomUtils.getTextValue(received);
String sourceText = DomUtils.getTextValue(source);
... | java |
private void doAttribute(Node receivedElement, Node receivedAttribute, Node sourceElement,
XmlMessageValidationContext validationContext, NamespaceContext namespaceContext, TestContext context) {
if (receivedAttribute.getNodeName().startsWith(XMLConstants.XMLNS_ATTRIBUTE)) { return; }
Strin... | java |
private void doNamespaceQualifiedAttributeValidation(Node receivedElement, Node receivedAttribute, Node sourceElement, Node sourceAttribute) {
String receivedValue = receivedAttribute.getNodeValue();
String sourceValue = sourceAttribute.getNodeValue();
if (receivedValue.contains(":") && sourceV... | java |
private void doPI(Node received) {
if (log.isDebugEnabled()) {
log.debug("Ignored processing instruction (" + received.getLocalName() + "=" + received.getNodeValue() + ")");
}
} | java |
private boolean isValidationMatcherExpression(Node node) {
switch (node.getNodeType()) {
case Node.ELEMENT_NODE:
return node.getFirstChild() != null &&
StringUtils.hasText(node.getFirstChild().getNodeValue()) &&
ValidationMatcherUtils.isValidationMatch... | java |
public void addSchemaRepository(XsdSchemaRepository schemaRepository) {
if (schemaRepositories == null) {
schemaRepositories = new ArrayList<XsdSchemaRepository>();
}
schemaRepositories.add(schemaRepository);
} | java |
public SchemaRepositoryModelBuilder addSchema(String id, String location) {
SchemaModel schema = new SchemaModel();
schema.setId(id);
schema.setLocation(location);
if (model.getSchemas() == null) {
model.setSchemas(new SchemaRepositoryModel.Schemas());
}
mod... | java |
public SchemaRepositoryModelBuilder addSchema(SchemaModel schema) {
if (model.getSchemas() == null) {
model.setSchemas(new SchemaRepositoryModel.Schemas());
}
model.getSchemas().getSchemas().add(schema);
return this;
} | java |
public SchemaRepositoryModelBuilder addSchemaReference(String schemaId) {
SchemaRepositoryModel.Schemas.Reference schemaRef = new SchemaRepositoryModel.Schemas.Reference();
schemaRef.setSchema(schemaId);
if (model.getSchemas() == null) {
model.setSchemas(new SchemaRepositoryModel.Sc... | java |
public void execute(StepTemplate stepTemplate, Object[] args) {
Template steps = new Template();
steps.setActions(stepTemplate.getActions());
steps.setActor(stepTemplate.getActor());
TemplateBuilder templateBuilder = new TemplateBuilder(steps)
.name(stepTemplate.getName())
... | java |
protected Map<String,Object> createMessageHeaders(MimeMailMessage msg) throws MessagingException, IOException {
Map<String, Object> headers = new HashMap<>();
headers.put(CitrusMailMessageHeaders.MAIL_MESSAGE_ID, msg.getMimeMessage().getMessageID());
headers.put(CitrusMailMessageHeaders.MAIL_FRO... | java |
protected BodyPart handlePart(MimePart part) throws IOException, MessagingException {
String contentType = parseContentType(part.getContentType());
if (part.isMimeType("multipart/*")) {
return handleMultiPart((Multipart) part.getContent());
} else if (part.isMimeType("text/*")) {
... | java |
private BodyPart handleMultiPart(Multipart body) throws IOException, MessagingException {
BodyPart bodyPart = null;
for (int i = 0; i < body.getCount(); i++) {
MimePart entity = (MimePart) body.getBodyPart(i);
if (bodyPart == null) {
bodyPart = handlePart(entity)... | java |
protected BodyPart handleApplicationContentPart(MimePart applicationData, String contentType) throws IOException, MessagingException {
if (applicationData.isMimeType("application/pdf")) {
return handleImageBinaryPart(applicationData, contentType);
} else if (applicationData.isMimeType("appli... | java |
protected BodyPart handleImageBinaryPart(MimePart image, String contentType) throws IOException, MessagingException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
FileCopyUtils.copy(image.getInputStream(), bos);
String base64 = Base64.encodeBase64String(bos.toByteArray());
re... | java |
protected BodyPart handleBinaryPart(MimePart mediaPart, String contentType) throws IOException, MessagingException {
String contentId = mediaPart.getContentID() != null ? "(" + mediaPart.getContentID() + ")" : "";
return new BodyPart(mediaPart.getFileName() + contentId, contentType);
} | java |
protected BodyPart handleTextPart(MimePart textPart, String contentType) throws IOException, MessagingException {
String content;
if (textPart.getContent() instanceof String) {
content = (String) textPart.getContent();
} else if (textPart.getContent() instanceof InputStream) {
... | java |
private String stripMailBodyEnding(String textBody) throws IOException {
BufferedReader reader = null;
StringBuilder body = new StringBuilder();
try {
reader = new BufferedReader(new StringReader(textBody));
String line = reader.readLine();
while (line != nu... | java |
static String parseContentType(String contentType) throws IOException {
if (contentType.indexOf(System.getProperty("line.separator")) > 0) {
BufferedReader reader = new BufferedReader(new StringReader(contentType));
try {
String plainContentType = reader.readLine();
... | java |
public SoapServerRequestActionBuilder receive() {
SoapServerRequestActionBuilder soapServerRequestActionBuilder = new SoapServerRequestActionBuilder(action, soapServer)
.withApplicationContext(applicationContext);
return soapServerRequestActionBuilder;
} | java |
public SoapServerResponseActionBuilder send() {
SoapServerResponseActionBuilder soapServerResponseActionBuilder = new SoapServerResponseActionBuilder(action, soapServer)
.withApplicationContext(applicationContext);
return soapServerResponseActionBuilder;
} | java |
public SoapServerFaultResponseActionBuilder sendFault() {
SoapServerFaultResponseActionBuilder soapServerResponseActionBuilder = new SoapServerFaultResponseActionBuilder(action, soapServer)
.withApplicationContext(applicationContext);
return soapServerResponseActionBuilder;
} | java |
public static Object evaluate(ReadContext readerContext, String jsonPathExpression) {
String expression = jsonPathExpression;
String jsonPathFunction = null;
for (String name : JsonPathFunctions.getSupportedFunctions()) {
if (expression.endsWith(String.format(".%s()", name))) {
... | java |
public static String evaluateAsString(String payload, String jsonPathExpression) {
try {
JSONParser parser = new JSONParser(JSONParser.MODE_JSON_SIMPLE);
Object receivedJson = parser.parse(payload);
ReadContext readerContext = JsonPath.parse(receivedJson);
return... | java |
public static String evaluateAsString(ReadContext readerContext, String jsonPathExpression) {
Object jsonPathResult = evaluate(readerContext, jsonPathExpression);
if (jsonPathResult instanceof JSONArray) {
return ((JSONArray) jsonPathResult).toJSONString();
} else if (jsonPathResult... | java |
public static void stripWhitespaceNodes(Node element) {
Node node, child;
for (child = element.getFirstChild(); child != null; child = node) {
node = child.getNextSibling();
stripWhitespaceNodes(child);
}
if (element.getNodeType() == Node.TEXT_NODE && element.get... | java |
private static void buildNodeName(Node node, StringBuffer buffer) {
if (node.getParentNode() == null) {
return;
}
buildNodeName(node.getParentNode(), buffer);
if (node.getParentNode() != null
&& node.getParentNode().getParentNode() != null) {
buf... | java |
public static String serialize(Document doc) {
LSSerializer serializer = configurer.createLSSerializer();
LSOutput output = configurer.createLSOutput();
String charset = getTargetCharset(doc).displayName();
output.setEncoding(charset);
StringWriter writer = new StringWriter();
... | java |
public static String prettyPrint(String xml) {
LSParser parser = configurer.createLSParser();
configurer.setParserConfigParameter(parser, VALIDATE_IF_SCHEMA, false);
LSInput input = configurer.createLSInput();
try {
Charset charset = getTargetCharset(xml);
inpu... | java |
public static Map<String, String> lookupNamespaces(Node referenceNode) {
Map<String, String> namespaces = new HashMap<String, String>();
Node node;
if (referenceNode.getNodeType() == Node.DOCUMENT_NODE) {
node = referenceNode.getFirstChild();
} else {
node = refe... | java |
public static Map<String, String> lookupNamespaces(String xml) {
Map<String, String> namespaces = new HashMap<String, String>();
//TODO: handle inner CDATA sections because namespaces they might interfere with real namespaces in xml fragment
if (xml.indexOf(XMLConstants.XMLNS_ATTRIBUTE) != -1) ... | java |
public static Document parseMessagePayload(String messagePayload) {
LSParser parser = configurer.createLSParser();
LSInput receivedInput = configurer.createLSInput();
try {
Charset charset = getTargetCharset(messagePayload);
receivedInput.setByteStream(new ByteArrayInputS... | java |
public static Charset getTargetCharset(Document doc) {
String defaultEncoding = System.getProperty(Citrus.CITRUS_FILE_ENCODING_PROPERTY, System.getenv(Citrus.CITRUS_FILE_ENCODING_ENV));
if (StringUtils.hasText(defaultEncoding)) {
return Charset.forName(defaultEncoding);
}
if... | java |
private static Charset getTargetCharset(String messagePayload) throws UnsupportedEncodingException {
String defaultEncoding = System.getProperty(Citrus.CITRUS_FILE_ENCODING_PROPERTY, System.getenv(Citrus.CITRUS_FILE_ENCODING_ENV));
if (StringUtils.hasText(defaultEncoding)) {
return Charset.f... | java |
public static String omitXmlDeclaration(String xml) {
if (xml.startsWith("<?xml") && xml.contains("?>")) {
return xml.substring(xml.indexOf("?>") + 2).trim();
}
return xml;
} | java |
private Resource loadSchemas(Definition definition) throws WSDLException, IOException, TransformerException, TransformerFactoryConfigurationError {
Types types = definition.getTypes();
Resource targetXsd = null;
Resource firstSchemaInWSDL = null;
if (types != null) {
List<?>... | java |
@SuppressWarnings("unchecked")
private void inheritNamespaces(SchemaImpl schema, Definition wsdl) {
Map<String, String> wsdlNamespaces = wsdl.getNamespaces();
for (Entry<String, String> nsEntry: wsdlNamespaces.entrySet()) {
if (StringUtils.hasText(nsEntry.getKey())) {
... | java |
private Definition getWsdlDefinition(Resource wsdl) {
try {
Definition definition;
if (wsdl.getURI().toString().startsWith("jar:")) {
// Locate WSDL imports in Jar files
definition = WSDLFactory.newInstance().newWSDLReader().readWSDL(new JarWSDLLocator(wsd... | java |
protected FtpMessage listFiles(ListCommand list, TestContext context) {
String remoteFilePath = Optional.ofNullable(list.getTarget())
.map(ListCommand.Target::getPath)
.map(context::replaceDynamicContentInString)
... | java |
protected FtpMessage deleteFile(DeleteCommand delete, TestContext context) {
String remoteFilePath = context.replaceDynamicContentInString(delete.getTarget().getPath());
try {
if (!StringUtils.hasText(remoteFilePath)) {
return null;
}
boolean success... | java |
protected boolean isDirectory(String remoteFilePath) throws IOException {
if (!ftpClient.changeWorkingDirectory(remoteFilePath)) { // not a directory or not accessible
switch (ftpClient.listFiles(remoteFilePath).length) {
case 0:
throw new CitrusRuntimeException(... | java |
protected FtpMessage storeFile(PutCommand command, TestContext context) {
try {
String localFilePath = context.replaceDynamicContentInString(command.getFile().getPath());
String remoteFilePath = addFileNameToTargetPath(localFilePath, context.replaceDynamicContentInString(command.getTarge... | java |
protected InputStream getLocalFileInputStream(String path, String dataType, TestContext context) throws IOException {
if (dataType.equals(DataType.ASCII.name())) {
String content = context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(path)));
return new ... | java |
protected FtpMessage retrieveFile(GetCommand command, TestContext context) {
try {
String remoteFilePath = context.replaceDynamicContentInString(command.getFile().getPath());
String localFilePath = addFileNameToTargetPath(remoteFilePath, context.replaceDynamicContentInString(command.getT... | java |
private int getFileType(String typeInfo) {
switch (typeInfo) {
case "ASCII":
return FTP.ASCII_FILE_TYPE;
case "BINARY":
return FTP.BINARY_FILE_TYPE;
case "EBCDIC":
return FTP.EBCDIC_FILE_TYPE;
case "LOCAL":
... | java |
protected void connectAndLogin() throws IOException {
if (!ftpClient.isConnected()) {
ftpClient.connect(getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort());
if (log.isDebugEnabled()) {
log.debug("Connected to FTP server: " + ftpClient.getReplyStri... | java |
private Source getPayloadSource(Object payload) {
Source source = null;
if (payload instanceof String) {
source = new StringSource((String) payload);
} else if (payload instanceof File) {
source = new StreamSource((File) payload);
} else if (payload insta... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.