Package org.jboss.errai.ioc.client

Examples of org.jboss.errai.ioc.client.IOCClientTestCase


            return Description.createTestDescription(getTestClass().getJavaClass(), method.getName());
          }

          @Override
          public void run(final RunNotifier notifier) {
            final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

            final Description description = getDescription();

            notifier.fireTestStarted(description);

            final TestResult result = new TestResult();

            try {
              if (SIMULATED) {
                System.setProperty("errai.simulatedClient", "true");
                try {
                  iocClientTestCase.gwtSetUp();
                  method.invoke(getInstance());
                }
                finally {
                  System.setProperty("errai.simulatedClient", "false");
                }
              }
              else {
                iocClientTestCase.setName(method.getName());
                JUnitShell.runTest(iocClientTestCase, result);
              }
            }
            catch (GenerationException e) {
              notifier.fireTestFailure(new Failure(description, e));
View Full Code Here


    child.run(notifier);
  }

  @Override
  public void run(final RunNotifier notifier) {
    final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

    if (SIMULATED) {
      QualifierUtil.initFromFactoryProvider(new QualifierEqualityFactoryProvider() {
        @Override
        public QualifierEqualityFactory provide() {
          return new QualifierEqualityFactory() {
            @Override
            public boolean isEqual(final Annotation a1, final Annotation a2) {
              return a1.equals(a2);
            }

            @Override
            public int hashCodeOf(final Annotation a1) {
              return a1.hashCode();
            }
          };
        }
      });

      TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(1);

        @Override
        public TaskManager get() {
          return new TaskManager() {
            @Override
            public void execute(final Runnable task) {
              service.execute(task);
            }

            @Override
            public AsyncTask scheduleRepeating(final TimeUnit unit, final int interval, final Runnable task) {
              final ScheduledFuture<?> future =
                      service.scheduleAtFixedRate(task, unit.toMillis(interval), 0,
                              java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(final boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(final Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public AsyncTask schedule(final TimeUnit unit, final int interval, final Runnable task) {
              final ScheduledFuture<?> future =
                      service.schedule(task, unit.toMillis(interval), java.util.concurrent.TimeUnit.MILLISECONDS);

              return new AsyncTask() {
                @Override
                public void cancel(final boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(final Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public void requestStop() {
            }
          };
        }
      });

      if (instance instanceof IOCClientTestCase) {
        iocClientTestCase.setInitializer(new IOCClientTestCase.ContainerBootstrapper() {
          @Override
          public void bootstrap() {
            try {
              final String rootPackage = iocClientTestCase.getModulePackage();
              final Set<String> packages = new HashSet<String>();
              for (final Package p : Package.getPackages()) {
                final String packageName = p.getName();
                if (packageName.startsWith(rootPackage)) {
                  packages.add(packageName);
                }
              }

              packages.add("org.jboss.errai.ioc.client.api.builtin");

              final MockIOCGenerator mockIOCGenerator = new MockIOCGenerator(packages);

              final Class<? extends Bootstrapper> cls = mockIOCGenerator.generate();
              final Bootstrapper bs = cls.newInstance();

              final long tm = System.currentTimeMillis();
              new IOCBeanManagerLifecycle().resetBeanManager();
              final BootstrapInjectionContext ctx = bs.bootstrapContainer();
              ((SimpleCreationalContext)ctx.getRootContext()).finish();

              System.out.println("bootstrapped simulated container in " + (System.currentTimeMillis() - tm) + "ms");
            }
            catch (GenerationException e) {
              throw e;
            }
            catch (Exception e) {
              throw new RuntimeException("failed to run in emulated mode", e);
            }
          }
        });

        iocClientTestCase.setForcePureJava(true);
      }

      super.run(notifier);
    }
    else {
View Full Code Here

            return Description.createTestDescription(getTestClass().getJavaClass(), method.getName());
          }

          @Override
          public void run(RunNotifier notifier) {
            final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

            Description description = getDescription();

            notifier.fireTestStarted(description);

            TestResult result = new TestResult();

            try {
              if (SIMULATED) {
                System.setProperty("errai.simulatedClient", "true");
                try {
                  iocClientTestCase.gwtSetUp();
                  method.invoke(getInstance());
                }
                finally {
                  System.setProperty("errai.simulatedClient", "false");
                }
              }
              else {
                iocClientTestCase.setName(method.getName());
                JUnitShell.runTest(iocClientTestCase, result);
              }
            }
            catch (GenerationException e) {
              notifier.fireTestFailure(new Failure(description, e));
View Full Code Here

    child.run(notifier);
  }

  @Override
  public void run(RunNotifier notifier) {
    final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

    if (SIMULATED) {
      QualifierUtil.initFromFactoryProvider(new QualifierEqualityFactoryProvider() {
        @Override
        public QualifierEqualityFactory provide() {
          return new QualifierEqualityFactory() {
            @Override
            public boolean isEqual(Annotation a1, Annotation a2) {
              return a1.equals(a2);
            }

            @Override
            public int hashCodeOf(Annotation a1) {
              return a1.hashCode();
            }
          };
        }
      });

      TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(1);

        @Override
        public TaskManager get() {
          return new TaskManager() {
            @Override
            public void execute(Runnable task) {
              service.execute(task);
            }

            @Override
            public AsyncTask scheduleRepeating(TimeUnit unit, int interval, Runnable task) {
              final ScheduledFuture<?> future =
                      service.scheduleAtFixedRate(task, unit.toMillis(interval), 0,
                              java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public AsyncTask schedule(TimeUnit unit, int interval, Runnable task) {
              final ScheduledFuture<?> future =
                      service.schedule(task, unit.toMillis(interval), java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public void requestStop() {
            }
          };
        }
      });

      if (instance instanceof IOCClientTestCase) {
        iocClientTestCase.setInitializer(new IOCClientTestCase.ContainerBootstrapper() {
          @Override
          public void bootstrap() {
            try {
              String rootPackage = iocClientTestCase.getModulePackage();
              Set<String> packages = new HashSet<String>();
              for (Package p : Package.getPackages()) {
                String packageName = p.getName();
                if (packageName.startsWith(rootPackage)) {
                  packages.add(packageName);
                }
              }

              packages.add("org.jboss.errai.ioc.client.api.builtin");

              MockIOCGenerator mockIOCGenerator = new MockIOCGenerator(packages);

              Class<? extends Bootstrapper> cls = mockIOCGenerator.generate();
              Bootstrapper bs = cls.newInstance();

              long tm = System.currentTimeMillis();
              new IOCBeanManagerLifecycle().resetBeanManager();
              BootstrapperInjectionContext ctx = bs.bootstrapContainer();
              ctx.getRootContext().finish();

              System.out.println("bootstrapped simulated container in " + (System.currentTimeMillis() - tm) + "ms");
            }
            catch (GenerationException e) {
              throw e;
            }
            catch (Exception e) {
              throw new RuntimeException("failed to run in emulated mode", e);
            }
          }
        });

        iocClientTestCase.setForcePureJava(true);
      }

      super.run(notifier);
    }
    else {
View Full Code Here

            return Description.createTestDescription(getTestClass().getJavaClass(), method.getName());
          }

          @Override
          public void run(final RunNotifier notifier) {
            final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

            final Description description = getDescription();

            notifier.fireTestStarted(description);

            final TestResult result = new TestResult();

            try {
              if (SIMULATED) {
                System.setProperty("errai.simulatedClient", "true");
                try {
                  iocClientTestCase.gwtSetUp();
                  method.invoke(getInstance());
                }
                finally {
                  System.setProperty("errai.simulatedClient", "false");
                }
              }
              else {
                iocClientTestCase.setName(method.getName());
                JUnitShell.runTest(iocClientTestCase, result);
              }
            }
            catch (GenerationException e) {
              notifier.fireTestFailure(new Failure(description, e));
View Full Code Here

    child.run(notifier);
  }

  @Override
  public void run(final RunNotifier notifier) {
    final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

    if (SIMULATED) {
      QualifierUtil.initFromFactoryProvider(new QualifierEqualityFactoryProvider() {
        @Override
        public QualifierEqualityFactory provide() {
          return new QualifierEqualityFactory() {
            @Override
            public boolean isEqual(final Annotation a1, final Annotation a2) {
              return a1.equals(a2);
            }

            @Override
            public int hashCodeOf(final Annotation a1) {
              return a1.hashCode();
            }
          };
        }
      });

      TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(1);

        @Override
        public TaskManager get() {
          return new TaskManager() {
            @Override
            public void execute(final Runnable task) {
              service.execute(task);
            }

            @Override
            public AsyncTask scheduleRepeating(final TimeUnit unit, final int interval, final Runnable task) {
              final ScheduledFuture<?> future =
                      service.scheduleAtFixedRate(task, unit.toMillis(interval), 0,
                              java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(final boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(final Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }

                @Override
                public boolean isFinished() {
                  return future.isDone();
                }
              };
            }

            @Override
            public AsyncTask schedule(final TimeUnit unit, final int interval, final Runnable task) {
              final ScheduledFuture<?> future =
                      service.schedule(task, unit.toMillis(interval), java.util.concurrent.TimeUnit.MILLISECONDS);

              return new AsyncTask() {
                @Override
                public void cancel(final boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(final Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }

                @Override
                public boolean isFinished() {
                  return future.isDone();
                }
              };
            }

            @Override
            public void requestStop() {
            }
          };
        }
      });

      if (instance instanceof IOCClientTestCase) {
        iocClientTestCase.setInitializer(new IOCClientTestCase.ContainerBootstrapper() {
          @Override
          public void bootstrap() {
            try {
              final String rootPackage = iocClientTestCase.getModulePackage();
              final Set<String> packages = new HashSet<String>();
              for (final Package p : Package.getPackages()) {
                final String packageName = p.getName();
                if (packageName.startsWith(rootPackage)) {
                  packages.add(packageName);
                }
              }

              packages.add("org.jboss.errai.ioc.client.api.builtin");

              final MockIOCGenerator mockIOCGenerator = new MockIOCGenerator(packages);

              final Class<? extends Bootstrapper> cls = mockIOCGenerator.generate();
              final Bootstrapper bs = cls.newInstance();

              final long tm = System.currentTimeMillis();
              new IOCBeanManagerLifecycle().resetBeanManager();
              final BootstrapInjectionContext ctx = bs.bootstrapContainer();
              ((SimpleCreationalContext)ctx.getRootContext()).finish();

              System.out.println("bootstrapped simulated container in " + (System.currentTimeMillis() - tm) + "ms");
            }
            catch (GenerationException e) {
              throw e;
            }
            catch (Exception e) {
              throw new RuntimeException("failed to run in emulated mode", e);
            }
          }
        });

        iocClientTestCase.setForcePureJava(true);
      }

      super.run(notifier);
    }
    else {
View Full Code Here

            return Description.createTestDescription(getTestClass().getJavaClass(), method.getName());
          }

          @Override
          public void run(RunNotifier notifier) {
            final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

            Description description = getDescription();

            notifier.fireTestStarted(description);

            TestResult result = new TestResult();

            try {
              if (SIMULATED) {
                System.setProperty("errai.simulatedClient", "true");
                try {
                  iocClientTestCase.gwtSetUp();
                  method.invoke(getInstance());
                }
                finally {
                  System.setProperty("errai.simulatedClient", "false");
                }

              }
              else {
                iocClientTestCase.setName(method.getName());
                JUnitShell.runTest(iocClientTestCase, result);
              }
            }
            catch (GenerationException e) {
              notifier.fireTestFailure(new Failure(description, e));
View Full Code Here

    child.run(notifier);
  }

  @Override
  public void run(RunNotifier notifier) {
    final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

    if (SIMULATED) {
      TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(1);

        @Override
        public TaskManager get() {
          return new TaskManager() {
            @Override
            public void execute(Runnable task) {
              service.execute(task);
            }

            @Override
            public AsyncTask scheduleRepeating(TimeUnit unit, int interval, Runnable task) {
              final ScheduledFuture<?> future =
                      service.scheduleAtFixedRate(task, unit.toMillis(interval), 0,
                              java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public AsyncTask schedule(TimeUnit unit, int interval, Runnable task) {
              final ScheduledFuture<?> future =
                      service.schedule(task, unit.toMillis(interval), java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public void requestStop() {
            }
          };
        }
      });

      if (instance instanceof IOCClientTestCase) {
        iocClientTestCase.setInitializer(new IOCClientTestCase.ContainerBootstrapper() {
          @Override
          public void bootstrap() {
            try {
              String rootPackage = iocClientTestCase.getModulePackage();
              List<String> packages = new ArrayList<String>();
              for (Package p : Package.getPackages()) {
                String packageName = p.getName();
                if (packageName.startsWith(rootPackage)) {
                  packages.add(packageName);
                }
              }

            packages.add("org.jboss.errai.ioc.client.api.builtin");

              MockIOCGenerator mockIOCGenerator = new MockIOCGenerator(packages);

              Class<? extends Bootstrapper> cls = mockIOCGenerator.generate();
              Bootstrapper bs = cls.newInstance();

              long tm = System.currentTimeMillis();
              new IOCBeanManagerLifecycle().resetBeanManager();
              BootstrapperInjectionContext ctx = bs.bootstrapContainer();
              ctx.getRootContext().finish();

              System.out.println("bootstrapped simulated container in " + (System.currentTimeMillis() - tm) + "ms");
            }
            catch (GenerationException e) {
              throw e;
            }
            catch (Exception e) {
              throw new RuntimeException("failed to run in emulated mode", e);
            }
          }
        });

        iocClientTestCase.setForcePureJava(true);
      }

      super.run(notifier);
    }
    else {
View Full Code Here

            return Description.createTestDescription(getTestClass().getJavaClass(), method.getName());
          }

          @Override
          public void run(RunNotifier notifier) {
            final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

            Description description = getDescription();

            notifier.fireTestStarted(description);
            TestResult result = new TestResult();

            try {
              if (SIMULATED) {
                System.setProperty("errai.simulatedClient", "true");
                try {
                  iocClientTestCase.gwtSetUp();
                  method.invoke(getInstance());
                }
                finally {
                  System.setProperty("errai.simulatedClient", "false");
                }
              }
              else {
                iocClientTestCase.setName(method.getName());
                JUnitShell.runTest(iocClientTestCase, result);
              }
            }
            catch (GenerationException e) {
              notifier.fireTestFailure(new Failure(description, e));
View Full Code Here

    child.run(notifier);
  }

  @Override
  public void run(RunNotifier notifier) {
    final IOCClientTestCase iocClientTestCase = (IOCClientTestCase) getInstance();

    if (SIMULATED) {
      TaskManagerFactory.setTaskManagerProvider(new TaskManagerProvider() {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(1);

        @Override
        public TaskManager get() {
          return new TaskManager() {
            @Override
            public void execute(Runnable task) {
              service.execute(task);
            }

            @Override
            public AsyncTask scheduleRepeating(TimeUnit unit, int interval, Runnable task) {
              final ScheduledFuture<?> future =
                      service.scheduleAtFixedRate(task, unit.toMillis(interval), 0,
                              java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public AsyncTask schedule(TimeUnit unit, int interval, Runnable task) {
              final ScheduledFuture<?> future =
                      service.schedule(task, unit.toMillis(interval), java.util.concurrent.TimeUnit.MILLISECONDS);


              return new AsyncTask() {
                @Override
                public void cancel(boolean interrupt) {
                  future.cancel(true);
                }

                @Override
                public void setExitHandler(Runnable runnable) {
                }

                @Override
                public boolean isCancelled() {
                  return future.isCancelled();
                }
              };
            }

            @Override
            public void requestStop() {
            }
          };
        }
      });


      if (instance instanceof IOCClientTestCase) {
        iocClientTestCase.setInitializer(new IOCClientTestCase.ContainerBootstrapper() {
          @Override
          public InterfaceInjectionContext bootstrap() {
            try {
              String rootPackage = iocClientTestCase.getModulePackage();
              List<String> packages = new ArrayList<String>();
              for (Package p : Package.getPackages()) {
                String packageName = p.getName();
                if (packageName.startsWith(rootPackage)) {
                  packages.add(packageName);
                }
              }
              MockIOCGenerator mockIOCGenerator = new MockIOCGenerator(packages);

              Class<? extends Bootstrapper> cls = mockIOCGenerator.generate();
              Bootstrapper bs = cls.newInstance();

              long tm = System.currentTimeMillis();
              InterfaceInjectionContext ctx = bs.bootstrapContainer();
              System.out.println("bootstrapped simulated container in " + (System.currentTimeMillis() - tm) + "ms");
              return ctx;
            }
            catch (GenerationException e) {
              throw e;
            }
            catch (Exception e) {
              throw new RuntimeException("failed to run in emulated mode", e);
            }
          }
        });

        iocClientTestCase.setForcePureJava(true);
      }

      super.run(notifier);
    }
    else {
View Full Code Here

TOP

Related Classes of org.jboss.errai.ioc.client.IOCClientTestCase

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.