private Person randomPersonWithId() {
   return Person.Builder.newInstance()
       .id(UUID.randomUUID().toString())
       .name(RandomStringUtils.randomAlphabetic(10))
       .homeTown(RandomStringUtils.randomAlphabetic(10))
       .build();
 }
  public UserCachedService() {

    User preloadedUser =
        new User()
            .setId(PRELOADED_USER_ID)
            .setFirstName("FirstName-" + RandomStringUtils.randomAlphabetic(5))
            .setLastName("LastName-" + RandomStringUtils.randomAlphabetic(5));

    users.add(preloadedUser);
  }
Beispiel #3
0
 public static JavassistDynamicBean json() {
   return new JavassistDynamicBean(
       "com.geccocrawler.gecco.dynamic.JsonBean"
           + RandomStringUtils.randomAlphabetic(6)
           + System.nanoTime(),
       JavassistDynamicBean.JsonBean);
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.adorsys.platform.domain.service.ApplicationInitService#initProviders
  * ()
  */
 @Override
 public boolean initProviders(UserAccount account) {
   if (Provider.countProviders() < 1) {
     Provider provider =
         new Provider(
             "Hsimo",
             "Franklin",
             "bp",
             "email",
             "site",
             "76699918",
             "phone",
             "fax",
             Gender.MALE,
             "",
             "",
             "Ubipharma");
     provider.setTaxPayersNumber("taxPayersNumber_" + RandomStringUtils.randomAlphabetic(5));
     provider.setExchangeKey("Provider_exchangeKey");
     // provider.setAccount(account);
     provider.persist();
     Logger LOG = LoggerFactory.getLogger(Provider.class);
     LOG.debug("[provider Initialise Succefully ]");
     return true;
   }
   return false;
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.adorsys.platform.domain.service.ApplicationInitService#initDrugStores
  * ()
  */
 @Override
 public boolean initDrugStores(UserAccount account) {
   if (DrugStore.countDrugStores() <= 0) {
     DrugStore drugStore =
         new DrugStore(
             "gakam",
             "clovis",
             "bp",
             "email",
             "site",
             "77166381",
             "phone",
             "fax",
             Gender.MALE,
             "",
             "",
             "Pharmacie de l'alliance");
     drugStore.setTaxPayersNumber("taxPayersNumber_" + RandomStringUtils.randomAlphabetic(5));
     drugStore.setExchangeKey("drugStore_exchangeKey");
     drugStore.persist();
     Logger LOG = LoggerFactory.getLogger(DrugStore.class);
     LOG.debug("[DrugStore Initialise Succefully ]");
   }
   return true;
 }
Beispiel #6
0
  protected void populateParams() {

    try {
      if (StringUtils.isNotBlank(minRows)) {
        this.setDynamicAttribute(null, "minRows", minRows);
      }
      if (StringUtils.isNotBlank(maxRows)) {
        this.setDynamicAttribute(null, "maxRows", maxRows);
      }
      if (StringUtils.isNotBlank(afterAdd)) {
        this.setDynamicAttribute(null, "afterAdd", afterAdd);
      }
    } catch (JspException e) {
      e.printStackTrace();
    }

    super.populateParams();

    DynamicTable uiBean = ((DynamicTable) component);
    if (id == null) {
      // 设置ID随机
      uiBean.setId("dynamictable_" + RandomStringUtils.randomAlphabetic(10));
    }
    if (cssClass == null) {
      uiBean.setCssClass("table table-striped table-condensed");
    }
  }
Beispiel #7
0
  @Test
  @Ignore("Phantomjs not installed on our build server")
  public void testWide() throws InterruptedException, URISyntaxException {

    Configuration conf = new Configuration();
    conf.getChart().setType(ChartType.COLUMN);
    conf.getChart().setMarginRight(200);
    Legend legend = conf.getLegend();
    legend.setLayout(LayoutDirection.VERTICAL);
    legend.setHorizontalAlign(HorizontalAlign.RIGHT);
    legend.setVerticalAlign(VerticalAlign.MIDDLE);
    legend.setBorderWidth(0);

    Random r = new Random();

    for (int i = 0; i < 20; i++) {
      String name = RandomStringUtils.randomAlphabetic(r.nextInt(20));
      DataSeries dataSeries = new DataSeries(name);
      dataSeries.add(new DataSeriesItem(name, r.nextInt(100)));
      conf.addSeries(dataSeries);
    }

    SVGGenerator instance = SVGGenerator.getInstance();
    String generatedSVG = instance.generate(conf, 1200, 400);

    Assert.assertTrue(generatedSVG.contains("width=\"1200\""));
    Assert.assertTrue(generatedSVG.contains("height=\"400\""));

    SVGGenerator.getInstance().destroy();
  }
 @Test
 public void test03_SearchNodeTypeNotMatch() {
   String keyword = RandomStringUtils.randomAlphabetic(20);
   info("Search Node Type when no Node type match with keyword");
   magNode.doNodeTypeSearch(keyword);
   waitForTextPresent(magNode.MESSAGE_FOR_NOT_MATCH_KEYWORD);
 }
 /**
  * Generate a list of random alphabetic strings
  *
  * @param size
  * @param strLength
  * @return
  */
 public List<String> newRandomDataList(int size, int strLength) {
   List<String> dataList = new ArrayList<String>();
   for (int i = 0; i < size; i++) {
     dataList.add(RandomStringUtils.randomAlphabetic(strLength));
   }
   return dataList;
 }
Beispiel #10
0
  @Test
  public void getLocaleReturnsPlayerLocale() {
    connection.setPlayer(new Player());
    String expected = RandomStringUtils.randomAlphabetic(5);
    connection.getPlayer().setLocale(expected);

    String locale = connection.getLocale();

    assertThat(locale, equalTo(expected));
  }
Beispiel #11
0
  @Test
  public void getLocaleWithoutPlayerReturnsServerLocale() {
    connection.setPlayer(null);
    String expected = RandomStringUtils.randomAlphabetic(5);
    when(configuration.getServerLocale()).thenReturn(expected);

    String locale = connection.getLocale();

    assertThat(locale, equalTo(expected));
  }
Beispiel #12
0
  @Test
  public void testRegistrationWhenLoggedIn() {
    WebDriver driver = driverService.getSharedWebDriver();
    LoginPage.autoLogin(driver);
    RegistrationPage registrationPage = RegistrationPage.open(driver);
    registrationPage.register(RandomStringUtils.randomAlphabetic(15));

    assertTrue(driver.findElements(By.cssSelector(".alert-success")).isEmpty());
    assertEquals(urlFor("/"), driver.getCurrentUrl());
  }
Beispiel #13
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 public static <X> X buildMockObject(Class<X> clazz) {
   X x = null;
   try {
     x = clazz.newInstance();
     for (Method method : clazz.getDeclaredMethods()) {
       String mn = method.getName();
       if (mn.startsWith("set")) {
         Class[] parameters = method.getParameterTypes();
         if (parameters.length == 1) {
           Method getMethod =
               MethodUtils.getAccessibleMethod(clazz, "get" + mn.substring(3), null);
           if (getMethod != null) {
             if (getMethod.getName().equals("getId")) {
               continue;
             }
             Object value = null;
             Class parameter = parameters[0];
             if (parameter.isAssignableFrom(String.class)) {
               Column column = getMethod.getAnnotation(Column.class);
               int columnLength = 32;
               if (column != null && column.length() < columnLength) {
                 columnLength = column.length();
               }
               Size size = getMethod.getAnnotation(Size.class);
               if (size != null && size.min() < columnLength) {
                 columnLength = size.min();
               }
               value = RandomStringUtils.randomAlphabetic(columnLength);
             } else if (parameter.isAssignableFrom(Date.class)) {
               value = new Date();
             } else if (parameter.isAssignableFrom(BigDecimal.class)) {
               value = new BigDecimal(new Random().nextDouble());
             } else if (parameter.isAssignableFrom(Integer.class)) {
               value = new Random().nextInt();
             } else if (parameter.isAssignableFrom(Boolean.class)) {
               value = new Random().nextBoolean();
             } else if (parameter.isEnum()) {
               Method m = parameter.getDeclaredMethod("values", null);
               Object[] result = (Object[]) m.invoke(parameter.getEnumConstants()[0], null);
               value = result[new Random().nextInt(result.length)];
             }
             if (value != null) {
               MethodUtils.invokeMethod(x, mn, value);
               logger.debug("{}={}", method.getName(), value);
             }
           }
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return x;
 }
 /**
  * Try to enable a dummy WYSIWYG editor plugin from the administration.
  *
  * @since 3.3M2
  */
 @Test
 public void testEnablePlugin() {
   String pluginName = RandomStringUtils.randomAlphabetic(5);
   Assert.assertFalse(wysiwygSection.getEnabledPlugins().contains(pluginName));
   wysiwygSection.enablePlugin(pluginName);
   wysiwygSection.clickSave();
   // Reload the administration section.
   getDriver().navigate().refresh();
   wysiwygSection = new WYSIWYGEditorAdministrationSectionPage();
   Assert.assertTrue(wysiwygSection.getEnabledPlugins().contains(pluginName));
 }
Beispiel #15
0
  @Test
  public void getLocaleWhenPlayerDoesNotHaveALocaleReturnsServerLocale() {
    Player player = new Player();
    player.setLocale("");
    connection.setPlayer(player);
    String expected = RandomStringUtils.randomAlphabetic(5);
    when(configuration.getServerLocale()).thenReturn(expected);

    String locale = connection.getLocale();

    assertThat(locale, equalTo(expected));
  }
 public void noTransactionNoPipeline() {
   Jedis jedis = pool.getResource();
   try {
     for (int i = 0; i < rowCount; i++) {
       String key = RandomStringUtils.randomAlphabetic(8);
       jedis.set(key, RandomStringUtils.randomNumeric(5));
       jedis.expire(key, 5 * 60);
     }
   } catch (Exception e) {
     pool.returnResource(jedis);
   }
 }
Beispiel #17
0
  @Test
  public void testRegistrationWithSessionStoredPassword() {
    WebDriver driver = driverService.getSharedCleanedWebDriver();
    String randomName = RandomStringUtils.randomAlphabetic(15);

    RegistrationPage registrationPage = RegistrationPage.open(driver);
    registrationPage.register(randomName, "", randomName);
    assertFalse(driver.findElements(By.cssSelector(".alert-error")).isEmpty());

    registrationPage.register(randomName, randomName + "@localhost", "");
    assertTrue(driver.findElements(By.cssSelector(".alert-error")).isEmpty());
  }
Beispiel #18
0
  @Test
  public void testRegistrationOfTakenLogin() {
    WebDriver driver = driverService.getSharedCleanedWebDriver();
    String randomName = RandomStringUtils.randomAlphabetic(15);

    RegistrationPage registrationPage = RegistrationPage.open(driver);
    registrationPage.register(randomName);
    assertTrue(driver.findElements(By.cssSelector(".alert-error")).isEmpty());

    driver.manage().deleteAllCookies();
    registrationPage = RegistrationPage.open(driver);
    registrationPage.register(randomName);
    assertFalse(driver.findElements(By.cssSelector(".alert-error")).isEmpty());
  }
 public void pipelineWithoutTransaction() {
   Jedis jedis = pool.getResource();
   try {
     Pipeline p = jedis.pipelined();
     for (int i = 0; i < rowCount; i++) {
       String key = RandomStringUtils.randomAlphabetic(8);
       p.set(key, RandomStringUtils.randomNumeric(5));
       p.expire(key, 5 * 60);
     }
     p.sync();
   } catch (Exception e) {
     pool.returnResource(jedis);
   }
 }
Beispiel #20
0
  public PartitionableThing createRandomThing(Map<String, ?> attributes) {

    String id = RandomStringUtils.randomAlphabetic(10);
    String version = RandomStringUtils.randomAlphabetic(10);

    PartitionableThing record = new PartitionableThing(attributes);

    record.setId(id);
    record.setVersion(version);

    Connection connection = getConnection();

    Factory db = getFactory(connection);
    db.execute(
        "insert into things (id, version,entry_date) values (?,?,?)",
        id,
        version,
        record.getEntryDate());

    closeConnection(connection, true);

    return record;
  }
 public static org.npc.testmodel.api.Product buildNewApiProduct() {
   return (new org.npc.testmodel.api.Product())
       .setDescription("")
       .setLookupCode(RandomStringUtils.randomAlphabetic(PRODUCT_LOOKUP_CODE_LENGTH))
       .setPrice(-1.0)
       .setItemType(-1)
       .setCost(-1.0)
       .setQuantity(MIN_PRODUCT_COUNT + random.nextInt(MAX_PRODUCT_COUNT - MIN_PRODUCT_COUNT))
       .setReorderPoint(-1)
       .setRestockLevel(-1)
       .setParentItem(-1)
       .setExtendedDescription("")
       .setActive(-1)
       .setMSRP(-1.00)
       .setCreatedOn(LocalDateTime.now().minusDays(random.nextInt(DAYS_IN_FIVE_YEARS)));
 }
  @Test
  public final void givenNewHometown_whenUpdate_thenNewHometownPersisted() {
    // create and insert person document
    JsonDocument doc = insertRandomPersonDocument();

    // update person
    Person expected = converter.fromDocument(doc);
    String updatedHomeTown = RandomStringUtils.randomAlphabetic(12);
    expected.setHomeTown(updatedHomeTown);
    personService.update(expected);

    // check results
    JsonDocument actual = bucket.get(expected.getId());
    assertNotNull(actual);
    assertNotNull(actual.content());
    assertEquals(expected.getHomeTown(), actual.content().getString("homeTown"));

    // cleanup
    bucket.remove(expected.getId());
  }
Beispiel #23
0
  protected void populateParams() {
    // 此段落必须放在super.populateParams()之前
    try {
      if (StringUtils.isNotBlank(autoValidate)) {
        this.setDynamicAttribute(null, "autoValidate", autoValidate);
      }
    } catch (JspException e) {
      e.printStackTrace();
    }

    super.populateParams();
    UIBean uiBean = ((UIBean) component);

    if (id == null) {
      String formid = "form_" + RandomStringUtils.randomAlphabetic(10);
      uiBean.setId(formid);
      // 将id属性设置到pageContext中,便于前端JS代码进行对象分组控制
      pageContext.setAttribute("closestFormId", formid);
    }
    if (this.theme == null) {
      uiBean.setTheme("bootstrap");
    }
  }
  @Test
  public final void givenPersons_whenUpdateBulk_thenPersonsAreUpdated() {

    List<String> ids = new ArrayList<>();

    // add some person documents
    for (int i = 0; i < 5; i++) {
      ids.add(insertRandomPersonDocument().id());
    }

    // load persons from Couchbase
    List<Person> persons = new ArrayList<>();
    for (String id : ids) {
      persons.add(converter.fromDocument(bucket.get(id)));
    }

    // modify persons
    for (Person person : persons) {
      person.setHomeTown(RandomStringUtils.randomAlphabetic(10));
    }

    // perform bulk update
    personService.updateBulk(persons);

    // check results
    for (Person person : persons) {
      JsonDocument doc = bucket.get(person.getId());
      assertEquals(person.getName(), doc.content().getString("name"));
      assertEquals(person.getHomeTown(), doc.content().getString("homeTown"));
    }

    // cleanup
    for (String id : ids) {
      bucket.remove(id);
    }
  }
Beispiel #25
0
  @Override
  public void run() {

    ChukasaModel chukasaModel = chukasaModelManagementComponent.get(adaptiveBitrateStreaming);
    String streamPath = chukasaModel.getStreamPath();
    String tempEncPath = chukasaModel.getTempEncPath();
    int tsPacketLength = chukasaModel.getHlsConfiguration().getMpeg2TsPacketLength();

    int seqTsEnc = 0; // getSeqTsEnc();
    seqTsEnc = chukasaModel.getSeqTsEnc();
    if (chukasaModel.getChukasaSettings().getStreamingType() == StreamingType.OKKAKE) {
      seqTsEnc = chukasaModel.getSeqTsOkkake() - 1;
    }
    if (chukasaModel.isFlagLastTs()) {
      seqTsEnc = chukasaModel.getSeqTsLast();
    }

    Key sKey;
    Cipher c;
    FileOutputStream keyOut;
    FileWriter ivOut;
    FileInputStream fis;
    BufferedInputStream bis;
    FileOutputStream fos;
    CipherOutputStream cos;

    try {
      Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

      sKey = makeKey(128); // Key length is 128bit
      c = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC");

      c.init(Cipher.ENCRYPT_MODE, sKey);

      // Set Key File Name at random
      String keyPre = RandomStringUtils.randomAlphabetic(10);
      keyOut = new FileOutputStream(streamPath + FILE_SEPARATOR + keyPre + seqTsEnc + ".key");

      chukasaModel.getKeyArrayList().add(keyPre);
      chukasaModel = chukasaModelManagementComponent.update(adaptiveBitrateStreaming, chukasaModel);

      byte[] keyOutByte = sKey.getEncoded();
      keyOut.write(keyOutByte);
      keyOut.close();

      byte[] iv = c.getIV();

      String ivHex = "";
      for (int i = 0; i < iv.length; i++) {
        String ivHexTmp = String.format("%02x", iv[i]).toUpperCase();
        ivHex = ivHex + ivHexTmp;
      }

      String ivPre = RandomStringUtils.randomAlphabetic(10);
      ivOut = new FileWriter(streamPath + FILE_SEPARATOR + ivPre + seqTsEnc + ".iv");
      ivOut.write(ivHex);
      ivOut.close();

      chukasaModel.getIvArrayList().add(ivHex);
      chukasaModel = chukasaModelManagementComponent.update(adaptiveBitrateStreaming, chukasaModel);

      fis =
          new FileInputStream(
              tempEncPath
                  + FILE_SEPARATOR
                  + chukasaModel.getChukasaConfiguration().getStreamFileNamePrefix()
                  + seqTsEnc
                  + chukasaModel.getHlsConfiguration().getStreamExtension());
      bis = new BufferedInputStream(fis);
      fos =
          new FileOutputStream(
              streamPath
                  + FILE_SEPARATOR
                  + chukasaModel.getChukasaConfiguration().getStreamFileNamePrefix()
                  + seqTsEnc
                  + chukasaModel.getHlsConfiguration().getStreamExtension());
      cos = new CipherOutputStream(fos, c);
      if (chukasaModel.getChukasaSettings().getStreamingType() == StreamingType.OKKAKE) {
        // TODO:
        fis =
            new FileInputStream(
                tempEncPath
                    + FILE_SEPARATOR
                    + "fileSequenceEncoded"
                    + seqTsEnc
                    + chukasaModel.getHlsConfiguration().getStreamExtension());
        bis = new BufferedInputStream(fis);
        fos =
            new FileOutputStream(
                streamPath
                    + FILE_SEPARATOR
                    + chukasaModel.getChukasaConfiguration().getStreamFileNamePrefix()
                    + seqTsEnc
                    + chukasaModel.getHlsConfiguration().getStreamExtension());
        cos = new CipherOutputStream(fos, c);
      }

      byte[] buf = new byte[tsPacketLength];

      int ch;
      while ((ch = bis.read(buf)) != -1) {
        cos.write(buf, 0, ch);
      }
      cos.close();
      fos.close();
      bis.close();
      fis.close();

    } catch (InvalidKeyException e) {
      e.printStackTrace();
    } catch (NoSuchPaddingException e) {
      e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    } catch (NoSuchProviderException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 /**
  * RtAssignees can check if user is NOT assignee for this repo.
  *
  * @throws Exception Exception If some problem inside
  */
 @Test
 public void checkUserIsNotAssigneeForRepo() throws Exception {
   MatcherAssert.assertThat(
       RtAssigneesITCase.repo().assignees().check(RandomStringUtils.randomAlphabetic(Tv.TEN)),
       Matchers.is(false));
 }
 private Person randomPerson() {
   return Person.Builder.newInstance()
       .name(RandomStringUtils.randomAlphabetic(10))
       .homeTown(RandomStringUtils.randomAlphabetic(10))
       .build();
 }