cleanup work
This commit is contained in:
parent
43f407e6e7
commit
e84137bdfc
|
@ -1,68 +0,0 @@
|
||||||
package com.apache.camel.file.processor;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.apache.camel.CamelContext;
|
|
||||||
import org.apache.camel.builder.RouteBuilder;
|
|
||||||
import org.apache.camel.impl.DefaultCamelContext;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
||||||
|
|
||||||
import com.baeldung.camel.file.FileProcessor;
|
|
||||||
|
|
||||||
|
|
||||||
public class FileProcessorTest {
|
|
||||||
|
|
||||||
private static final long DURATION_MILIS = 10000;
|
|
||||||
private static final String SOURCE_FOLDER = "src/test/source-folder";
|
|
||||||
private static final String DESTINATION_FOLDER = "src/test/destination-folder";
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
File sourceFolder = new File(SOURCE_FOLDER);
|
|
||||||
File destinationFolder = new File(DESTINATION_FOLDER);
|
|
||||||
|
|
||||||
cleanFolder(sourceFolder);
|
|
||||||
cleanFolder(destinationFolder);
|
|
||||||
|
|
||||||
sourceFolder.mkdirs();
|
|
||||||
File file1 = new File(SOURCE_FOLDER + "/File1.txt");
|
|
||||||
File file2 = new File(SOURCE_FOLDER + "/File2.txt");
|
|
||||||
file1.createNewFile();
|
|
||||||
file2.createNewFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanFolder(File folder) {
|
|
||||||
File[] files = folder.listFiles();
|
|
||||||
if (files != null) {
|
|
||||||
for (File file : files) {
|
|
||||||
if (file.isFile()) {
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void moveFolderContentJavaDSLTest() throws Exception {
|
|
||||||
final CamelContext camelContext = new DefaultCamelContext();
|
|
||||||
camelContext.addRoutes(new RouteBuilder() {
|
|
||||||
@Override
|
|
||||||
public void configure() throws Exception {
|
|
||||||
from("file://" + SOURCE_FOLDER + "?delete=true").process(new FileProcessor()).to("file://" + DESTINATION_FOLDER);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
camelContext.start();
|
|
||||||
Thread.sleep(DURATION_MILIS);
|
|
||||||
camelContext.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void moveFolderContentSpringDSLTest() throws InterruptedException {
|
|
||||||
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context-test.xml");
|
|
||||||
Thread.sleep(DURATION_MILIS);
|
|
||||||
applicationContext.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,10 +10,6 @@
|
||||||
<name>spring-integration</name>
|
<name>spring-integration</name>
|
||||||
<url>http://www.springsource.org/spring-integration</url>
|
<url>http://www.springsource.org/spring-integration</url>
|
||||||
|
|
||||||
<prerequisites>
|
|
||||||
<maven>2.2.1</maven>
|
|
||||||
</prerequisites>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<spring.integration.version>4.3.5.RELEASE</spring.integration.version>
|
<spring.integration.version>4.3.5.RELEASE</spring.integration.version>
|
||||||
|
@ -132,4 +128,5 @@
|
||||||
<version>${spring.integration.version}</version>
|
<version>${spring.integration.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -15,23 +15,14 @@
|
||||||
*/
|
*/
|
||||||
package com.baeldung.samples;
|
package com.baeldung.samples;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.support.AbstractApplicationContext;
|
import org.springframework.context.support.AbstractApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
||||||
|
public final class FileCopyIntegrationTest {
|
||||||
|
|
||||||
/**
|
//
|
||||||
* Starts the Spring Context and will initialize the Spring Integration routes.
|
|
||||||
*
|
|
||||||
* @author Baeldung
|
|
||||||
* @since 1.0
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public final class FileCopyTest {
|
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(FileCopyTest.class);
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFileCopyConfiguration_thanFileCopiedSuccessfully() throws InterruptedException {
|
public void whenFileCopyConfiguration_thanFileCopiedSuccessfully() throws InterruptedException {
|
||||||
|
@ -42,13 +33,9 @@ public final class FileCopyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void publish() throws InterruptedException {
|
public void publish() throws InterruptedException {
|
||||||
|
final AbstractApplicationContext context = new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-file-publish-context.xml");
|
||||||
|
|
||||||
final AbstractApplicationContext context =
|
|
||||||
new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/spring-integration-file-publish-context.xml");
|
|
||||||
|
|
||||||
Thread.sleep(15000);
|
Thread.sleep(15000);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
|
@ -203,6 +203,7 @@
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>**/*IntegrationTest.java</exclude>
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.baeldung.htmlunit;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.gargoylesoftware.htmlunit.WebClient;
|
||||||
|
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||||
|
|
||||||
|
public class HtmlUnitAndJUnitLiveTest {
|
||||||
|
|
||||||
|
private WebClient webClient;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void init() throws Exception {
|
||||||
|
webClient = new WebClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void close() throws Exception {
|
||||||
|
webClient.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenAClient_whenEnteringBaeldung_thenPageTitleIsOk() throws Exception {
|
||||||
|
webClient.getOptions().setThrowExceptionOnScriptError(false);
|
||||||
|
HtmlPage page = webClient.getPage("http://www.baeldung.com/");
|
||||||
|
Assert.assertEquals("Baeldung | Java, Spring and Web Development tutorials", page.getTitleText());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,34 +0,0 @@
|
||||||
package com.baeldung.htmlunit;
|
|
||||||
|
|
||||||
import com.gargoylesoftware.htmlunit.WebClient;
|
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class HtmlUnitAndJUnitTest {
|
|
||||||
|
|
||||||
private WebClient webClient;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void init() throws Exception {
|
|
||||||
webClient = new WebClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void close() throws Exception {
|
|
||||||
webClient.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void givenAClient_whenEnteringBaeldung_thenPageTitleIsOk()
|
|
||||||
throws Exception {
|
|
||||||
webClient.getOptions().setThrowExceptionOnScriptError(false);
|
|
||||||
HtmlPage page = webClient.getPage("http://www.baeldung.com/");
|
|
||||||
Assert.assertEquals(
|
|
||||||
"Baeldung | Java, Spring and Web Development tutorials",
|
|
||||||
page.getTitleText());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -20,7 +20,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ContextConfiguration(classes = { TestConfig.class })
|
@ContextConfiguration(classes = { TestConfig.class })
|
||||||
public class HtmlUnitAndSpringTest {
|
public class HtmlUnitAndSpringLiveTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WebApplicationContext wac;
|
private WebApplicationContext wac;
|
|
@ -12,7 +12,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlHeading1;
|
import com.gargoylesoftware.htmlunit.html.HtmlHeading1;
|
||||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||||
|
|
||||||
public class HtmlUnitWebScraping {
|
public class HtmlUnitWebLiveScraping {
|
||||||
|
|
||||||
private WebClient webClient;
|
private WebClient webClient;
|
||||||
|
|
Loading…
Reference in New Issue