Package org.jboss.shrinkwrap.api

Examples of org.jboss.shrinkwrap.api.GenericArchive


               CreateContainerOptions.NONE);
         if (!created) {
            deleteAllObjectsInContainer(regionId, containerName);
         }
      }
      GenericArchive files = ShrinkWrap.create(GenericArchive.class, "files.tar.gz");
      StringAsset content = new StringAsset("foo");
      for (int i = 0; i < OBJECT_COUNT; i++) {
         paths.add(containerName + "/file" + i);
         files.add(content, "/file" + i);
      }
      try {
         tarGz = ByteStreams.toByteArray(files.as(TarGzExporter.class).exportAsInputStream());
      } catch (IOException e) {
         throw Throwables.propagate(e);
      }
   }
View Full Code Here


// TODO: cannot yet test bulk delete offline
@Test
public class BulkApiMockTest extends BaseOpenStackMockTest<SwiftApi> {

   public void extractArchive() throws Exception {
      GenericArchive files = ShrinkWrap.create(GenericArchive.class, "files.tar.gz");
      StringAsset content = new StringAsset("foo");
      for (int i = 0; i < 10; i++) {
         files.add(content, "/file" + i);
      }
      byte[] tarGz = ByteStreams.toByteArray(files.as(TarGzExporter.class).exportAsInputStream());

      MockWebServer server = mockOpenStackServer();
      server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json"))));
      server.enqueue(addCommonHeaders(new MockResponse().setResponseCode(201).setBody("{\"Number Files Created\": 10, \"Errors\": []}")));
View Full Code Here

               new CreateContainerOptions());
         if (!created) {
            deleteAllObjectsInContainer(regionId, containerName);
         }
      }
      GenericArchive files = ShrinkWrap.create(GenericArchive.class, "files.tar.gz");
      StringAsset content = new StringAsset("foo");
      for (int i = 0; i < OBJECT_COUNT; i++) {
         paths.add(containerName + "/file" + i);
         files.add(content, "/file" + i);
      }
      try {
         tarGz = ByteStreams.toByteArray(files.as(TarGzExporter.class).exportAsInputStream());
      } catch (IOException e) {
         throw Throwables.propagate(e);
      }
   }
View Full Code Here

// TODO: cannot yet test bulk delete offline
@Test
public class BulkApiMockTest extends BaseOpenStackMockTest<SwiftApi> {

   public void extractArchive() throws Exception {
      GenericArchive files = ShrinkWrap.create(GenericArchive.class, "files.tar.gz");
      StringAsset content = new StringAsset("foo");
      for (int i = 0; i < 10; i++) {
         files.add(content, "/file" + i);
      }
      byte[] tarGz = ByteStreams.toByteArray(files.as(TarGzExporter.class).exportAsInputStream());

      MockWebServer server = mockOpenStackServer();
      server.enqueue(new MockResponse().setBody(accessRackspace));
      server.enqueue(new MockResponse().setResponseCode(201).setBody("{\"Number Files Created\": 10, \"Errors\": []}"));
View Full Code Here

        webArchive.addClass(SimpleServlet.class);

        final JavaArchive moduleArchive = ShrinkWrap.create(JavaArchive.class, MODULE_ARCHIVE);
        moduleArchive.addClass(DeploymentArchiveTestCase.class);

        final GenericArchive cliArchive = ShrinkWrap.create(GenericArchive.class, "deploymentarchive.cli");
        cliArchive.add(new StringAsset(DEPLOY_SCR), "deploy.scr");
        cliArchive.add(new StringAsset(UNDEPLOY_SCR), "undeploy.scr");
        cliArchive.add(webArchive, "/", ZipExporter.class);
        cliArchive.add(moduleArchive, "/", ZipExporter.class);
        cliArchive.add(new StringAsset(MODULE_XML), "/", "module.xml");

        System.out.println(cliArchive.toString(true));

        final String tempDir = TestSuiteEnvironment.getTmpDir();
        final File file = new File(tempDir, "deploymentarchive.cli");
        cliArchive.as(ZipExporter.class).exportTo(file, true);
        return file;
    }
View Full Code Here

     * @return
     * @throws IllegalStateException
     */
    protected final Serializable executeTest(final String archiveId, final String testClassName, final String methodName)
        throws IllegalStateException {
        final GenericArchive archive = this.getDeployedArchives().get(archiveId);
        if (archive == null) {
            throw new IllegalStateException("Archive with ID " + archiveId + " is not deployed");
        }

        // Use a ClassLoader with explicitly null parent to achieve isolation from --classpath
        final ShrinkWrapClassLoader isolatedArchiveCL = new ShrinkWrapClassLoader((ClassLoader) null, archive);

        final ClassLoader oldCl = SecurityActions.getTccl();
        ObjectOutputStream objectOutstream = null;
        try {
            // We have to set the TCCL here due to ARQ-1181; if that's resolved we can remove all TCCL mucking
            SecurityActions.setTccl(isolatedArchiveCL);
            /*
             * All reflection in this section is to avoid CCE when we load these classes from the isolated ClassLoader,
             * we can't have them assignable to the ClassLoader which loaded this class.
             */
            final Class<?> testClass;
            try {
                testClass = isolatedArchiveCL.loadClass(testClassName);
            } catch (final ClassNotFoundException cnfe) {
                throw new IllegalStateException("Could not load class " + testClassName + " from deployed archive: "
                    + archive.toString());
            }
            final Class<?> testRunnersClass;
            try {
                testRunnersClass = isolatedArchiveCL.loadClass(CLASS_NAME_ARQ_TEST_RUNNERS);
            } catch (final ClassNotFoundException cnfe) {
                throw new IllegalStateException("Could not load class " + CLASS_NAME_ARQ_TEST_RUNNERS
                    + " from deployed archive: " + archive.toString());
            }
            final Method getTestRunnerMethod = testRunnersClass.getMethod(METHOD_NAME_GET_TEST_RUNNER,
                ClassLoader.class);
            final Object testRunner = getTestRunnerMethod.invoke(null, isolatedArchiveCL);
            final Class<?> testRunnerClass = testRunner.getClass();
View Full Code Here

                    final String deploymentName = message.substring(WireProtocol.COMMAND_UNDEPLOY_PREFIX.length())
                        .trim();
                    if (log.isLoggable(Level.FINEST)) {
                        log.finest("Requesting undeployment of: " + deploymentName);
                    }
                    final GenericArchive removedArchive = NettyServer.this.getDeployedArchives().remove(deploymentName);

                    // Check that we resulted in undeployment
                    if (removedArchive == null) {
                        if (log.isLoggable(Level.FINEST)) {
                            log.finest("Not current deployment: " + deploymentName);
View Full Code Here

            }

            try {
                // Read in the archive using the isolated CL context of this domain
                final InputStream instream = new ByteBufInputStream(in);
                final GenericArchive archive = NettyServer.this.getShrinkwrapDomain().getArchiveFactory()
                    .create(ZipImporter.class).importFrom(instream).as(GenericArchive.class);
                instream.close();
                if (log.isLoggable(Level.FINEST)) {
                    log.finest("Got archive: " + archive.toString(true));
                }

                // Store the archive
                final String id = archive.getId();
                NettyServer.this.getDeployedArchives().put(id, archive);

                // Tell the client OK, and let it know the ID of the archive (so it may be undeployed)
                final ByteBuf out = ctx.nextOutboundByteBuffer();
                NettyServer.sendResponse(ctx, out, WireProtocol.RESPONSE_OK_PREFIX + WireProtocol.COMMAND_DEPLOY_PREFIX
View Full Code Here

      {
         for (ArchivePath path : nestedArchives.keySet())
         {
            try
            {
               GenericArchive genericArchive = archive.getAsType(GenericArchive.class, path);
               if (Testable.isArchiveToTest(genericArchive))
               {
                  return genericArchive;
               }
            }
View Full Code Here

      {
         for (ArchivePath path : nestedArchives.keySet())
         {
            try
            {
               GenericArchive genericArchive = archive.getAsType(GenericArchive.class, path);
               if (Testable.isArchiveToTest(genericArchive))
               {
                  return genericArchive;
               }
            }
View Full Code Here

TOP

Related Classes of org.jboss.shrinkwrap.api.GenericArchive

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.