Package org.jboss.forge.addon.resource

Examples of org.jboss.forge.addon.resource.DirectoryResource


   }

   @Test
   public void testCreateValidatorInDirectory() throws Exception
   {
      DirectoryResource dir = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      JavaResource validator = operations.newValidator(dir, "SampleValidator", "org.example");

      Assert.assertEquals("SampleValidator.java", validator.getName());
      Assert.assertEquals("SampleValidator", validator.getJavaType().getName());
      Assert.assertEquals("org.example", validator.getJavaType().getPackage());
View Full Code Here


   }

   @Test
   public void testRunScriptSingleLine() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      shellTest.getShell().setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("touch foo.txt");

      Resource<?> child = temp.getChild("foo.txt");
      Assert.assertFalse(child.exists());

      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.SECONDS);
      Assert.assertFalse(result instanceof Failed);
View Full Code Here

   }

   @Test
   public void testRunScriptMultiLine() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      shellTest.getShell().setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("touch foo.txt\n"
               + "touch foo2.txt");

      Resource<?> child = temp.getChild("foo.txt");
      Resource<?> child2 = temp.getChild("foo2.txt");
      Assert.assertFalse(child.exists());
      Assert.assertFalse(child2.exists());

      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.MINUTES);
      Assert.assertFalse(result instanceof Failed);
View Full Code Here

   }

   @Test
   public void testRunScriptMultiLineWithRandomWhitespace() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      shellTest.getShell().setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("\ntouch foo.txt\n\n\n\t\n"
               + "touch foo2.txt\r\n");

      Resource<?> child = temp.getChild("foo.txt");
      Resource<?> child2 = temp.getChild("foo2.txt");
      Assert.assertFalse(child.exists());
      Assert.assertFalse(child2.exists());

      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.SECONDS);
      Assert.assertFalse(result instanceof Failed);
View Full Code Here

   }

   @Test
   public void testRunScriptFailure() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      shellTest.getShell().setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("throw-exception");

      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.SECONDS);
      Assert.assertTrue(result instanceof Failed);
   }
View Full Code Here

   }

   @Test
   public void testRunScriptMultiLineWithComments() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      shellTest.getShell().setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("\ntouch foo.txt\n\n\n\t\n"
               + "#touch foo2.txt\r\n");

      Resource<?> child = temp.getChild("foo.txt");
      Resource<?> child2 = temp.getChild("foo2.txt");
      Assert.assertFalse(child.exists());
      Assert.assertFalse(child2.exists());

      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.SECONDS);
      Assert.assertFalse(result instanceof Failed);
View Full Code Here

   @Test
   public void testRunCommandLinux() throws Exception
   {
      Assume.assumeTrue(OperatingSystemUtils.isLinux());
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      FileResource<?> fileResource = (FileResource<?>) temp.getChild("file.txt");
      fileResource.createNewFile();
      fileResource.deleteOnExit();
      Result result = shellTest.execute("run -c \"ls " + temp.getFullyQualifiedName() + "\"", COMMAND_TIMEOUT,
               TimeUnit.SECONDS);
      Assert.assertFalse(result instanceof Failed);
      Assert.assertThat(shellTest.getStdOut(), CoreMatchers.containsString("file.txt"));
   }
View Full Code Here

   }

   @Test
   public void testKeepShellContext() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      Shell shell = shellTest.getShell();
      shell.setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("mkdir foo\ncd foo");
      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.SECONDS);
      Assert.assertFalse(result instanceof Failed);
      Resource<?> child = temp.getChild("foo");
      Assert.assertTrue(child.exists());
      Assert.assertEquals(child, shell.getCurrentResource());
   }
View Full Code Here

   }

   @Test
   public void testRunScriptFailureWithUnknownCommands() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      shellTest.getShell().setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("touch foo.txt\nblah");

      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.SECONDS);
      Assert.assertTrue(result instanceof Failed);
   }
View Full Code Here

   }

   @Test
   public void testRunScriptMultipleLines() throws Exception
   {
      DirectoryResource temp = (DirectoryResource) resourceFactory.create(OperatingSystemUtils.createTempDir());
      temp.deleteOnExit();
      shellTest.getShell().setCurrentResource(temp);

      FileResource<?> script = (FileResource<?>) temp.getChild("script.fsh");
      script.setContents("touch \\\n\t foo.txt");
      Result result = shellTest.execute("run script.fsh", COMMAND_TIMEOUT, TimeUnit.SECONDS);
      Assert.assertFalse(result instanceof Failed);
      Resource<?> child = temp.getChild("foo.txt");
      Assert.assertTrue(child.exists());

   }
View Full Code Here

TOP

Related Classes of org.jboss.forge.addon.resource.DirectoryResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.