@Test
  public void testGeoTaggedJpeg() throws Exception {
    InputStream stream =
        Thread.currentThread().getContextClassLoader().getResourceAsStream("testJPEG_GEO.jpg");

    /*
     * The dates in testJPED_GEO.jpg do not contain timezones. If no timezone is specified,
     * the Tika input transformer assumes the local time zone.  Set the system timezone to UTC
     * so we can do assertions.
     */
    TimeZone defaultTimeZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertNotNull(metacard.getMetadata());
    assertThat(
        metacard.getMetadata(), containsString("<meta name=\"Model\" content=\"Canon EOS 40D\"/>"));
    assertThat(metacard.getContentTypeName(), is("image/jpeg"));
    assertThat(convertDate(metacard.getCreatedDate()), is("2009-08-11 09:09:45 UTC"));
    assertThat(convertDate(metacard.getModifiedDate()), is("2009-10-02 23:02:49 UTC"));
    assertThat(
        (String) metacard.getAttribute(Metacard.GEOGRAPHY).getValue(),
        is("POINT(-54.1234 12.54321)"));

    // Reset timezone back to local time zone.
    TimeZone.setDefault(defaultTimeZone);
  }
Exemple #2
0
  /**
   * Takes a packed-stream InputStream, and writes to a JarOutputStream. Internally the entire
   * buffer must be read, it may be more efficient to read the packed-stream to a file and pass the
   * File object, in the alternate method described below.
   *
   * <p>Closes its input but not its output. (The output can accumulate more elements.)
   *
   * @param in an InputStream.
   * @param out a JarOutputStream.
   * @exception IOException if an error is encountered.
   */
  public void unpack(InputStream in0, JarOutputStream out) throws IOException {
    assert (Utils.currentInstance.get() == null);
    TimeZone tz = (_props.getBoolean(Utils.PACK_DEFAULT_TIMEZONE)) ? null : TimeZone.getDefault();

    try {
      Utils.currentInstance.set(this);
      if (tz != null) TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
      final int verbose = _props.getInteger(Utils.DEBUG_VERBOSE);
      BufferedInputStream in = new BufferedInputStream(in0);
      if (Utils.isJarMagic(Utils.readMagic(in))) {
        if (verbose > 0) Utils.log.info("Copying unpacked JAR file...");
        Utils.copyJarFile(new JarInputStream(in), out);
      } else if (_props.getBoolean(Utils.DEBUG_DISABLE_NATIVE)) {
        (new DoUnpack()).run(in, out);
        in.close();
        Utils.markJarFile(out);
      } else {
        (new NativeUnpack(this)).run(in, out);
        in.close();
        Utils.markJarFile(out);
      }
    } finally {
      _nunp = null;
      Utils.currentInstance.set(null);
      if (tz != null) TimeZone.setDefault(tz);
    }
  }
  @Test
  public void testOpenOffice() throws Exception {
    InputStream stream =
        Thread.currentThread().getContextClassLoader().getResourceAsStream("testOpenOffice2.odt");

    /*
     * The dates in testOpenOffice2.odt do not contain timezones. If no timezone is specified,
     * the Tika input transformer assumes the local time zone.  Set the system timezone to UTC
     * so we can do assertions.
     */
    TimeZone defaultTimeZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertThat(metacard.getTitle(), is("Test OpenOffice2 Document"));
    assertThat(convertDate(metacard.getCreatedDate()), is("2007-09-14 11:06:08 UTC"));
    assertThat(convertDate(metacard.getModifiedDate()), is("2013-02-13 06:52:10 UTC"));
    assertNotNull(metacard.getMetadata());
    assertThat(
        metacard.getMetadata(),
        containsString("This is a sample Open Office document, written in NeoOffice 2.2.1"));
    assertThat(metacard.getContentTypeName(), is("application/vnd.oasis.opendocument.text"));

    // Reset timezone back to local time zone.
    TimeZone.setDefault(defaultTimeZone);
  }
  @Test
  public void testCommentedJpeg() throws Exception {
    InputStream stream =
        Thread.currentThread()
            .getContextClassLoader()
            .getResourceAsStream("testJPEG_commented.jpg");

    /*
     * The dates in testJPEG_commented.jpg do not contain timezones. If no timezone is specified,
     * the Tika input transformer assumes the local time zone.  Set the system timezone to UTC
     * so we can do assertions.
     */
    TimeZone defaultTimeZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

    Metacard metacard = transform(stream);
    assertNotNull(metacard);
    assertThat(metacard.getTitle(), is("Tosteberga \u00C4ngar"));
    assertNotNull(metacard.getMetadata());
    assertThat(
        metacard.getMetadata(),
        containsString("<meta name=\"Keywords\" content=\"bird watching\"/>"));
    assertThat(metacard.getContentTypeName(), is("image/jpeg"));
    assertThat(convertDate(metacard.getCreatedDate()), is("2010-07-28 11:02:00 UTC"));

    // Reset timezone back to local time zone.
    TimeZone.setDefault(defaultTimeZone);
  }
  public void testFrom103_1() throws Exception {
    TimeZone defaultTZ = TimeZone.getDefault();

    // use UTC for this test
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

    copyFromClasspathToFile(
        "/org/sonatype/nexus/configuration/upgrade/103-1/nexus-103.xml", getNexusConfiguration());

    // trick: copying by nexus.xml the tasks.xml too
    copyFromClasspathToFile(
        "/org/sonatype/nexus/configuration/upgrade/103-1/tasks.xml",
        new File(new File(getNexusConfiguration()).getParentFile(), "tasks.xml"));

    Configuration configuration =
        configurationUpgrader.loadOldConfiguration(new File(getNexusConfiguration()));

    // set back to the default timezone
    TimeZone.setDefault(defaultTZ);

    assertEquals(Configuration.MODEL_VERSION, configuration.getVersion());

    // 6 repos 3 groups
    assertEquals(6 + 3, configuration.getRepositories().size());

    assertEquals(2, configuration.getRepositoryGrouping().getPathMappings().size());

    resultIsFine("/org/sonatype/nexus/configuration/upgrade/103-1/nexus-103.xml", configuration);
    securityResultIsFine(
        "/org/sonatype/nexus/configuration/upgrade/103-1/security-configuration-103.xml");
  }
 @Issue("JENKINS-15816")
 @SuppressWarnings({"unchecked", "rawtypes"})
 @Test
 public void timezoneOfID() throws Exception {
   TimeZone origTZ = TimeZone.getDefault();
   try {
     final Run r;
     String id;
     TimeZone.setDefault(TimeZone.getTimeZone("America/Chicago"));
     ExecutorService svc = Executors.newSingleThreadExecutor();
     try {
       r =
           svc.submit(
                   new Callable<Run>() {
                     @Override
                     public Run call() throws Exception {
                       return new Run(new StubJob(), 1234567890) {};
                     }
                   })
               .get();
       TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));
       id = r.getId();
       assertEquals(
           id,
           svc.submit(
                   new Callable<String>() {
                     @Override
                     public String call() throws Exception {
                       return r.getId();
                     }
                   })
               .get());
     } finally {
       svc.shutdown();
     }
     TimeZone.setDefault(TimeZone.getTimeZone("America/New_York"));
     svc = Executors.newSingleThreadExecutor();
     try {
       assertEquals(id, r.getId());
       assertEquals(
           id,
           svc.submit(
                   new Callable<String>() {
                     @Override
                     public String call() throws Exception {
                       return r.getId();
                     }
                   })
               .get());
     } finally {
       svc.shutdown();
     }
   } finally {
     TimeZone.setDefault(origTZ);
   }
 }
 /** Some checks for the getLastMillisecond() method. */
 public void testGetLastMillisecond() {
   Locale saved = Locale.getDefault();
   Locale.setDefault(Locale.UK);
   TimeZone savedZone = TimeZone.getDefault();
   TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
   Second s = new Second(1, 1, 1, 1, 1, 1970);
   assertEquals(61999L, s.getLastMillisecond());
   Locale.setDefault(saved);
   TimeZone.setDefault(savedZone);
 }
 /** Some checks for the getFirstMillisecond() method. */
 public void testGetFirstMillisecond() {
   Locale saved = Locale.getDefault();
   Locale.setDefault(Locale.UK);
   TimeZone savedZone = TimeZone.getDefault();
   TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
   Second s = new Second(15, 43, 15, 1, 4, 2006);
   assertEquals(1143902595000L, s.getFirstMillisecond());
   Locale.setDefault(saved);
   TimeZone.setDefault(savedZone);
 }
Exemple #9
0
 /** Some checks for the getLastMillisecond() method. */
 @Test
 public void testGetLastMillisecond() {
   Locale saved = Locale.getDefault();
   Locale.setDefault(Locale.UK);
   TimeZone savedZone = TimeZone.getDefault();
   TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
   Millisecond m = new Millisecond(750, 1, 1, 1, 1, 1, 1970);
   assertEquals(61750L, m.getLastMillisecond());
   Locale.setDefault(saved);
   TimeZone.setDefault(savedZone);
 }
  void test2() {
    Locale defaultLocale = Locale.getDefault();
    TimeZone reservedTimeZone = TimeZone.getDefault();
    Date d = new Date(2005 - 1900, Calendar.DECEMBER, 22);
    String formatted;

    TimeZone tz;
    SimpleDateFormat df;

    try {
      for (int i = 0; i < TIMEZONES.length; i++) {
        tz = TimeZone.getTimeZone(TIMEZONES[i]);
        TimeZone.setDefault(tz);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(OSAKA));
        Locale.setDefault(defaultLocale);
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_OSAKA[i])) {
          throw new RuntimeException(
              "TimeZone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_OSAKA[i]);
        }

        df.parse(DISPLAY_NAMES_OSAKA[i]);

        Locale.setDefault(KYOTO);
        df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance());
        System.out.println(formatted = df.format(d));
        if (!formatted.equals(DISPLAY_NAMES_KYOTO[i])) {
          throw new RuntimeException(
              "Timezone "
                  + TIMEZONES[i]
                  + ": formatted zone names mismatch. "
                  + formatted
                  + " should match with "
                  + DISPLAY_NAMES_KYOTO[i]);
        }
        df.parse(DISPLAY_NAMES_KYOTO[i]);
      }
    } catch (ParseException pe) {
      throw new RuntimeException("parse error occured" + pe);
    } finally {
      // restore the reserved locale and time zone
      Locale.setDefault(defaultLocale);
      TimeZone.setDefault(reservedTimeZone);
    }
  }
  /** @see HL7Util#parseHL7Time(String) */
  @Test
  @SuppressWarnings("deprecation")
  @Verifies(value = "should handle 0615", method = "parseHL7Time(String)")
  public void parseHL7Time_shouldHandle0615() throws Exception {
    // set tz to be a __non DST__ timezone so this junit test works everywhere and always
    TimeZone originalTimeZone = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("EAT"));

    Date parsedDate = HL7Util.parseHL7Time("0615");
    Assert.assertEquals(6, parsedDate.getHours());
    Assert.assertEquals(15, parsedDate.getMinutes());

    // reset the timezone
    TimeZone.setDefault(originalTimeZone);
  }
  /**
   * Sets the <code>TimeZone</code> that is returned by the <code>getDefault</code> method. If
   * <code>zone</code> is null, reset the default to the value it had originally when the VM first
   * started.
   *
   * @param tz the new default time zone
   * @stable ICU 2.0
   */
  public static synchronized void setDefault(TimeZone tz) {
    defaultZone = tz;
    java.util.TimeZone jdkZone = null;
    if (defaultZone instanceof JavaTimeZone) {
      jdkZone = ((JavaTimeZone) defaultZone).unwrap();
    } else {
      // Keep java.util.TimeZone default in sync so java.util.Date
      // can interoperate with com.ibm.icu.util classes.

      if (tz != null) {
        if (tz instanceof com.ibm.icu.impl.OlsonTimeZone) {
          // Because of the lack of APIs supporting historic
          // zone offset/dst saving in JDK TimeZone,
          // wrapping ICU TimeZone with JDK TimeZone will
          // cause historic offset calculation in Calendar/Date.
          // JDK calendar implementation calls getRawOffset() and
          // getDSTSavings() when the instance of JDK TimeZone
          // is not an instance of JDK internal TimeZone subclass
          // (sun.util.calendar.ZoneInfo).  Ticket#6459
          String icuID = tz.getID();
          jdkZone = java.util.TimeZone.getTimeZone(icuID);
          if (!icuID.equals(jdkZone.getID())) {
            // JDK does not know the ID..
            jdkZone = null;
          }
        }
        if (jdkZone == null) {
          jdkZone = TimeZoneAdapter.wrap(tz);
        }
      }
    }
    java.util.TimeZone.setDefault(jdkZone);
  }
Exemple #13
0
  protected void tearDown() throws Exception {
    // System.err.println("++++++ TESTS END (" + getName() + ") ++++++");
    TimeZone.setDefault(saveTZ);

    TestUtil.dropTable(con, "testtimezone");
    TestUtil.closeDB(con);
  }
  @Test
  public void testWerkzaamheden() {
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
    ReisadviesHandle handle = new ReisadviesHandle();
    List<ReisMogelijkheid> mogelijkheden =
        handle.getModel(getClass().getResourceAsStream("/reisadvies/reisadvies-werkzaamheden.xml"));
    Assert.assertNotNull(mogelijkheden);
    Assert.assertEquals(1, mogelijkheden.size());
    ReisMogelijkheid intercity = mogelijkheden.get(0);
    Assert.assertNotNull(intercity.getMeldingen());
    ReisDeel reisDeel = intercity.getReisDelen().get(0);
    Assert.assertNotNull(reisDeel.getReisDetails());

    ReisDeel assenGroningen = intercity.getReisDelen().get(1);
    Assert.assertEquals("2012_gn_asn_25feb_4mrt", assenGroningen.getGeplandeStoringId());
    Assert.assertNotNull(assenGroningen.getReisDetails());
    Assert.assertEquals(1, assenGroningen.getReisDetails().size());
    Assert.assertEquals("Fiets meenemen niet mogelijk", assenGroningen.getReisDetails().get(0));
    Assert.assertEquals("TRAIN", assenGroningen.getReisSoort());
    Assert.assertEquals(0, assenGroningen.getRitNummer());
    Assert.assertEquals("VOLGENS-PLAN", assenGroningen.getStatus());
    Assert.assertEquals("NS", assenGroningen.getVervoerder());
    Assert.assertEquals("Snelbus i.p.v. Trein", assenGroningen.getVervoerType());
    Assert.assertNotNull(assenGroningen.getReisStops());
    Assert.assertEquals(2, assenGroningen.getReisStops().size());
  }
  @Test
  public void parseRelativeDate() throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    DateQuery query = new DateQuery(DateQuery.Type.DATE);
    TimeZone tz = TimeZone.getTimeZone("UTC");

    query.parseDate("+2mi", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getMinute(2) + "-" + getMinute(3) + ")", query.toString());

    query.parseDate("+2minute", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getMinute(2) + "-" + getMinute(3) + ")", query.toString());

    query.parseDate("+2minutes", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getMinute(2) + "-" + getMinute(3) + ")", query.toString());

    query.parseDate("+2h", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getHour(2) + "-" + getHour(3) + ")", query.toString());

    query.parseDate("+2hour", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getHour(2) + "-" + getHour(3) + ")", query.toString());

    query.parseDate("+2hours", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getHour(2) + "-" + getHour(3) + ")", query.toString());

    query.parseDate("+2d", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getDate(2) + "-" + getDate(3) + ")", query.toString());

    query.parseDate("+2day", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getDate(2) + "-" + getDate(3) + ")", query.toString());

    query.parseDate("+2days", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getDate(2) + "-" + getDate(3) + ")", query.toString());

    query.parseDate("+2w", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getWeek(2) + "-" + getWeek(3) + ")", query.toString());

    query.parseDate("+2week", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getWeek(2) + "-" + getWeek(3) + ")", query.toString());

    query.parseDate("+2weeks", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getWeek(2) + "-" + getWeek(3) + ")", query.toString());

    query.parseDate("+2m", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getMonth(2) + "-" + getMonth(3) + ")", query.toString());

    query.parseDate("+2month", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getMonth(2) + "-" + getMonth(3) + ")", query.toString());

    query.parseDate("+2months", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getMonth(2) + "-" + getMonth(3) + ")", query.toString());

    query.parseDate("+2y", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getYear(2) + "-" + getYear(3) + ")", query.toString());

    query.parseDate("+2year", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getYear(2) + "-" + getYear(3) + ")", query.toString());

    query.parseDate("+2years", tz, Locale.ENGLISH);
    Assert.assertEquals("Q(DATE:DATE," + getYear(2) + "-" + getYear(3) + ")", query.toString());
  }
  @Test
  public void parseAbsoluteMDate() throws Exception {
    TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
    DateQuery query = new DateQuery(DateQuery.Type.MDATE);
    TimeZone tz = TimeZone.getTimeZone("UTC");
    String expected = "Q(DATE:MDATE,201001230000-201001240000)";

    query.parseDate("1/23/2010", tz, Locale.ENGLISH);
    Assert.assertEquals(expected, query.toString());

    query.parseDate("23/1/2010", tz, Locale.FRENCH);
    Assert.assertEquals(expected, query.toString());

    query.parseDate("23.1.2010", tz, Locale.GERMAN);
    Assert.assertEquals(expected, query.toString());

    query.parseDate("23/1/2010", tz, Locale.ITALIAN);
    Assert.assertEquals(expected, query.toString());

    query.parseDate("2010/1/23", tz, Locale.JAPANESE);
    Assert.assertEquals(expected, query.toString());

    query.parseDate("2010. 1. 23", tz, Locale.KOREAN);
    Assert.assertEquals(expected, query.toString());
  }
Exemple #17
0
  public static void main(final String[] args) {
    if (args.length >= 2) {
      final String localeSetting = args[0];
      System.out.println("Setting Locale to " + localeSetting + "\n");
      Locale.setDefault(new Locale(localeSetting));

      final String timezoneSetting = args[1];
      System.out.println("Setting TimeZone to " + timezoneSetting + "\n");
      TimeZone.setDefault(TimeZone.getTimeZone(timezoneSetting));
    }

    final Locale locale = Locale.getDefault();
    System.out.println("Locale");
    System.out.println("Code: " + locale.toString());
    try {
      System.out.println("Country: " + locale.getISO3Country());
    } catch (final MissingResourceException e) {
      System.out.println("Country: " + e.getMessage());
    }
    try {
      System.out.println("Language: " + locale.getISO3Language());
    } catch (final MissingResourceException e) {
      System.out.println("Language: " + e.getMessage());
    }

    System.out.println("\nTimezone");
    final TimeZone timezone = TimeZone.getDefault();
    System.out.println("Code: " + timezone.getID());
    System.out.println("Name: " + timezone.getDisplayName());
    System.out.println("Offset: " + timezone.getRawOffset() / (1000 * 60 * 60));
    System.out.println("DST: " + timezone.getDSTSavings() / (1000 * 60 * 60));
  }
 @Factory(dataProvider = "databases", dataProviderClass = DBTest.class)
 public ModifySecurityDbSecurityMasterWorkerRemoveTest(
     String databaseType, String databaseVersion) {
   super(databaseType, databaseVersion);
   s_logger.info("running testcases for {}", databaseType);
   TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
 }
 @Test
 public void parseDateFallback() throws Exception {
   TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
   DateQuery query = new DateQuery(DateQuery.Type.DATE);
   query.parseDate("1/23/2010", TimeZone.getTimeZone("UTC"), Locale.GERMAN);
   Assert.assertEquals("Q(DATE:DATE,201001230000-201001240000)", query.toString());
 }
 protected void tearDown() throws Exception {
   DateTimeUtils.setCurrentMillisSystem();
   DateTimeZone.setDefault(zone);
   java.util.TimeZone.setDefault(zone.toTimeZone());
   Locale.setDefault(locale);
   zone = null;
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
   */
  @Override
  public void afterPropertiesSet() throws Exception {
    String timeZone = jobService.getKylinConfig().getTimeZone();
    TimeZone tzone = TimeZone.getTimeZone(timeZone);
    TimeZone.setDefault(tzone);

    final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    String serverMode = kylinConfig.getServerMode();

    if (Constant.SERVER_MODE_JOB.equals(serverMode.toLowerCase())
        || Constant.SERVER_MODE_ALL.equals(serverMode.toLowerCase())) {
      logger.info("Initializing Job Engine ....");

      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    DefaultScheduler scheduler = DefaultScheduler.getInstance();
                    scheduler.init(new JobEngineConfig(kylinConfig), new ZookeeperJobLock());
                    if (!scheduler.hasStarted()) {
                      logger.error("scheduler has not been started");
                      System.exit(1);
                    }
                  } catch (Exception e) {
                    throw new RuntimeException(e);
                  }
                }
              })
          .start();
    }
  }
  @Override
  public void onStartup(final ServletContext servletContext) throws ServletException {
    try {
      // Force the timezone of application to UTC (required for Hibernate/JDBC)
      TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

      final Context initialContext = new InitialContext();

      final String logLocation =
          (String)
              initialContext.lookup("java:comp/env/osp/osgpAdapterDomainPublicLighting/log-config");
      LogbackConfigurer.initLogging(logLocation);

      final AnnotationConfigWebApplicationContext rootContext =
          new AnnotationConfigWebApplicationContext();
      rootContext.register(ApplicationContext.class);

      servletContext.addListener(new ContextLoaderListener(rootContext));

    } catch (final NamingException e) {
      throw new ServletException("naming exception", e);
    } catch (final FileNotFoundException e) {
      throw new ServletException("Logging file not found", e);
    } catch (final JoranException e) {
      throw new ServletException("Logback exception", e);
    }
  }
Exemple #23
0
  @SuppressWarnings("unchecked")
  public List<Task> getWeekTasksStat(String name, String momin, Date startWeek) {
    Query query;
    List<Task> list;
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

    query =
        em.createQuery(
            "select from "
                + Task.class.getName()
                + " t where t.mominId = :momin AND  name =:name AND  t.date >= :start  AND  t.date  < :end order by date asc");
    query.setParameter("name", name);

    Task.moveToDay(startWeek, -1);
    startWeek.setHours(0);
    startWeek.setMinutes(0);
    startWeek.setSeconds(0);
    Date end = CalendarUtil.copyDate(startWeek);
    CalendarUtil.addDaysToDate(end, 7);
    query.setParameter("momin", momin);
    query.setParameter("start", startWeek);
    //	    end.setTime(end.getTime()-2000);
    query.setParameter("end", end);
    list = query.getResultList();

    //	    if(group == null)
    //	    	getCache().put(keyWeek, list);

    return list;
  }
 protected void setUp() throws Exception {
   DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
   zone = DateTimeZone.getDefault();
   locale = Locale.getDefault();
   DateTimeZone.setDefault(LONDON);
   java.util.TimeZone.setDefault(LONDON.toTimeZone());
   Locale.setDefault(Locale.UK);
 }
Exemple #25
0
  public List<TaskSeed> getSeedToUpdate() { // TODO use of cursor
    TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
    Query query =
        em.createQuery("select from " + TaskSeed.class.getName() + " s order by s.update asc ");

    List<TaskSeed> list = new ArrayList((List<Task>) query.getResultList());
    return list;
  }
 @Before
 public void setUp() throws Exception {
   synchronized (TimeZone.class) {
     systemTimeZone = TimeZone.getDefault();
     TimeZone.setDefault(TimeZone.getTimeZone("GMT-5:00"));
     format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
   }
 }
 protected void tearDown() throws Exception {
   DateTimeUtils.setCurrentMillisSystem();
   DateTimeZone.setDefault(originalDateTimeZone);
   TimeZone.setDefault(originalTimeZone);
   Locale.setDefault(originalLocale);
   originalDateTimeZone = null;
   originalTimeZone = null;
   originalLocale = null;
 }
 protected void setUp() throws Exception {
   DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
   originalDateTimeZone = DateTimeZone.getDefault();
   originalTimeZone = TimeZone.getDefault();
   originalLocale = Locale.getDefault();
   DateTimeZone.setDefault(LONDON);
   TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
   Locale.setDefault(Locale.UK);
 }
 protected void setUp() throws Exception {
   DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
   originalDateTimeZone = DateTimeZone.getDefault();
   originalTimeZone = TimeZone.getDefault();
   originalLocale = Locale.getDefault();
   DateTimeZone.setDefault(PARIS);
   TimeZone.setDefault(PARIS.toTimeZone());
   Locale.setDefault(Locale.FRANCE);
 }
Exemple #30
0
  @Test
  public void producedZipFilesAreTimezoneAgnostic() throws Exception {
    HashCode referenceHash = writeSimpleJarAndGetHash();
    TimeZone previousDefault = TimeZone.getDefault();
    try {
      String[] availableIDs = TimeZone.getAvailableIDs();
      assertThat(availableIDs.length, Matchers.greaterThan(1));

      for (String timezoneID : availableIDs) {
        TimeZone timeZone = TimeZone.getTimeZone(timezoneID);
        TimeZone.setDefault(timeZone);

        assertThat(writeSimpleJarAndGetHash(), Matchers.equalTo(referenceHash));
      }
    } finally {
      TimeZone.setDefault(previousDefault);
    }
  }