private String getValidPassword() {
   StringBuffer password = new StringBuffer(com.ajr.rhrn.Properties.minPasswordLength);
   for (int i = 0; i < com.ajr.rhrn.Properties.minPasswordLength; i++) {
     password.append("a");
   }
   return password.toString();
 }
  @Test
  public void testToStringOrder() {

    Map<String, JobParameter> props = parameters.getParameters();
    StringBuffer stringBuilder = new StringBuffer();
    for (Entry<String, JobParameter> entry : props.entrySet()) {
      stringBuilder.append(entry.toString() + ";");
    }

    String string1 = stringBuilder.toString();

    Map<String, JobParameter> parameterMap = new HashMap<String, JobParameter>();
    parameterMap.put("string.key2", new JobParameter("value2"));
    parameterMap.put("string.key1", new JobParameter("value1"));
    parameterMap.put("long.key2", new JobParameter(2L));
    parameterMap.put("long.key1", new JobParameter(1L));
    parameterMap.put("double.key2", new JobParameter(2.2));
    parameterMap.put("double.key1", new JobParameter(1.1));
    parameterMap.put("date.key2", new JobParameter(date2));
    parameterMap.put("date.key1", new JobParameter(date1));

    JobParameters testProps = new JobParameters(parameterMap);

    props = testProps.getParameters();
    stringBuilder = new StringBuffer();
    for (Entry<String, JobParameter> entry : props.entrySet()) {
      stringBuilder.append(entry.toString() + ";");
    }
    String string2 = stringBuilder.toString();

    assertEquals(string1, string2);
  }
  @Test
  public void testImportStudents() throws Exception {

    // Given
    StudentDirectoryServiceImpl studentDirectoryService = new StudentDirectoryServiceImpl();

    StudentDAO studentDAO = mock(StudentDAO.class);
    studentDirectoryService.setStudentDAO(studentDAO);

    MultipartFile multipartFile = mock(MultipartFile.class);

    StringBuffer buffer = new StringBuffer();
    buffer.append("Bart, Simpson\n");
    buffer.append("Lisa, Simpson");
    InputStream stream =
        new ByteArrayInputStream(buffer.toString().getBytes(StandardCharsets.UTF_8));
    when(multipartFile.getInputStream()).thenReturn(stream);

    // When
    studentDirectoryService.importStudents(multipartFile);

    // Then
    ArgumentCaptor<Student> studentCaptor = ArgumentCaptor.forClass(Student.class);
    verify(studentDAO, times(2)).createStudent(studentCaptor.capture());

    assertEquals("Bart", studentCaptor.getAllValues().get(0).getFirstName());
    assertEquals("Simpson", studentCaptor.getAllValues().get(0).getLastName());

    assertEquals("Lisa", studentCaptor.getAllValues().get(1).getFirstName());
    assertEquals("Simpson", studentCaptor.getAllValues().get(1).getLastName());
  }
 private String getValidUsername() {
   StringBuffer username = new StringBuffer(com.ajr.rhrn.Properties.minUsernameLength);
   for (int i = 0; i < com.ajr.rhrn.Properties.minUsernameLength; i++) {
     username.append("a");
   }
   return username.toString();
 }
 private String getValidActivity() {
   StringBuffer activity = new StringBuffer(com.ajr.rhrn.Properties.minActivityLength);
   for (int i = 0; i < com.ajr.rhrn.Properties.minActivityLength; i++) {
     activity.append("a");
   }
   return activity.toString();
 }
 private String getValidTitle() {
   StringBuffer title = new StringBuffer(com.ajr.rhrn.Properties.minTitleLength);
   for (int i = 0; i < com.ajr.rhrn.Properties.minTitleLength; i++) {
     title.append("a");
   }
   return title.toString();
 }
    @Override
    public String toString(
        boolean qOption, boolean hOption, boolean tOption, List<StorageType> types) {
      if (tOption) {
        StringBuffer result = new StringBuffer();
        result.append(hOption ? HUMAN : BYTES);

        for (StorageType type : types) {
          result.append(type.toString());
          result.append(" ");
        }
        return result.toString();
      }

      if (qOption) {
        if (hOption) {
          return (HUMAN + WITH_QUOTAS);
        } else {
          return (BYTES + WITH_QUOTAS);
        }
      } else {
        if (hOption) {
          return (HUMAN + NO_QUOTAS);
        } else {
          return (BYTES + NO_QUOTAS);
        }
      }
    }
  private JFreeChart getChart() {
    final Calendar now = Calendar.getInstance();
    final DefaultCategoryDataset sourceSet = new DefaultCategoryDataset();
    final boolean legend = false;
    final boolean tooltips = false;
    final boolean urls = false;

    final StringBuffer stringBuffer = new StringBuffer();
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {

        now.add(Calendar.DAY_OF_YEAR, 1);

        stringBuffer.setLength(0);

        sourceSet.addValue(
            new Integer(stringBuffer.append(i).append(j).toString()),
            String.valueOf(i),
            now.getTime());
      }
    }

    return ChartFactory.createBarChart(
        "fooTitle",
        "fooYLabel",
        "fooXLabel",
        sourceSet,
        PlotOrientation.VERTICAL,
        legend,
        tooltips,
        urls);
  }
 private String getValidLocation() {
   StringBuffer location = new StringBuffer(com.ajr.rhrn.Properties.minLocationLength);
   for (int i = 0; i < com.ajr.rhrn.Properties.minLocationLength; i++) {
     location.append("a");
   }
   return location.toString();
 }
Example #10
0
 @Test
 public void testprintClass()
     throws NoSuchFieldException, SecurityException, IllegalArgumentException,
         IllegalAccessException {
   UMLArrows arrows = UMLArrows.getInstance();
   Field supers = UMLArrows.class.getDeclaredField("supers");
   supers.setAccessible(true);
   Field interfaces = UMLArrows.class.getDeclaredField("interfaces");
   interfaces.setAccessible(true);
   Field uses = UMLArrows.class.getDeclaredField("uses");
   uses.setAccessible(true);
   Field fields = UMLArrows.class.getDeclaredField("fields");
   fields.setAccessible(true);
   Field fieldbuffer = UMLArrows.class.getDeclaredField("fieldBuffer");
   fieldbuffer.setAccessible(true);
   Field methodbuffer = UMLArrows.class.getDeclaredField("methodBuffer");
   methodbuffer.setAccessible(true);
   Field className = UMLArrows.class.getDeclaredField("className");
   className.setAccessible(true);
   className.set(arrows, "test");
   supers.set(arrows, "");
   interfaces.set(arrows, new ArrayList<String>());
   uses.set(arrows, new ArrayList<String>());
   fields.set(arrows, new ArrayList<String>());
   StringBuffer fTemp = new StringBuffer();
   fTemp.append("I was thinking about this buffer and it was a good idea.");
   StringBuffer mTemp = new StringBuffer();
   mTemp.append("This is a powerful MethodBuffer.");
   fieldbuffer.set(arrows, fTemp);
   methodbuffer.set(arrows, mTemp);
   arrows.printClass();
   assertEquals(
       "   test [\n     shape=\"record\"      label = \"{test|I was thinking about this buffer and it was a good idea.|This is a powerful MethodBuffer.\n}\"\n];\n",
       outContent.toString());
 }
 private String getValidIdentifier() {
   StringBuffer identifier = new StringBuffer(com.ajr.rhrn.Properties.minIdentifierLength);
   for (int i = 0; i < com.ajr.rhrn.Properties.minIdentifierLength; i++) {
     identifier.append("a");
   }
   return identifier.toString();
 }
Example #12
0
  // Do some simple concurrent testing
  public void testConcurrentSimple() throws InterruptedException {
    final NonBlockingIdentityHashMap<String, String> nbhm =
        new NonBlockingIdentityHashMap<String, String>();
    final String[] keys = new String[20000];
    for (int i = 0; i < 20000; i++) keys[i] = "k" + i;

    // In 2 threads, add & remove even & odd elements concurrently
    Thread t1 =
        new Thread() {
          public void run() {
            work_helper(nbhm, "T1", 1, keys);
          }
        };
    t1.start();
    work_helper(nbhm, "T0", 0, keys);
    t1.join();

    // In the end, all members should be removed
    StringBuffer buf = new StringBuffer();
    buf.append("Should be emptyset but has these elements: {");
    boolean found = false;
    for (String x : nbhm.keySet()) {
      buf.append(" ").append(x);
      found = true;
    }
    if (found) System.out.println(buf + " }");
    assertThat("concurrent size=0", nbhm.size(), is(0));
    for (String x : nbhm.keySet()) {
      assertTrue("No elements so never get here", false);
    }
  }
 @Test
 public void getRequestURLWithDefaultsAndHttps() {
   request.setScheme("https");
   request.setServerPort(443);
   StringBuffer requestURL = request.getRequestURL();
   assertEquals("https://localhost", requestURL.toString());
 }
 @Test
 public void testBigContent() throws Exception {
   StringBuffer buffer = new StringBuffer();
   for (int i = 0; i < 1000; i++) buffer.append("abcdefghijklmnopqrstuvwxyz");
   crawler.addPage(root, PathParser.parse("BigPage"), buffer.toString());
   String content = root.getChildPage("BigPage").getData().getContent();
   assertTrue(buffer.toString().equals(content));
 }
 public static StringBuffer sbWinners(StringBuffer sb, NameVotingSystem.NameVote[] winners) {
   for (int i = 0; i < winners.length; i++) {
     sb.append(winners[i].name);
     sb.append(": ");
     sb.append(winners[i].rating);
   }
   return sb;
 }
  /**
   * Note that there can be several Changelogs inside a directory tree. The {@link
   * ChangeLogWriter#writeChangeLog()} code assumes that the full path to the ChangeLog file and the
   * full path to the file for which to generate a ChangeLog entry have the same ancestor (with some
   * potential overlap).
   *
   * <p>Consider the following example:
   *
   * <p>1. The ChangeLog file is <project-root>/src/ChangeLog 2. The currently open editor contains
   * code of <project-root>/src/org/eclipse/example/Test.java
   *
   * <p>In the above case entries in <project-root>/src/ChangeLog *should* be of the form: <code>
   *
   * YYYY-MM-DD  Author Name  <*****@*****.**>
   *
   *    * org/eclipse/example/Test.java: new File
   *
   * </code> Similarly, if the ChangeLog file is in <project-root>/ChangeLog and the currently open
   * file is <project-root>/src/org/eclipse/example/Sun.java, generated entries in
   * <project-root>/ChangeLog would look like (note the "src" path is added in this case): <code>
   *
   * YYYY-MM-DD  Author Name  <*****@*****.**>
   *
   *    * src/org/eclipse/example/Sun.java: new File
   *
   * </code> Test for method {@link
   * org.eclipse.linuxtools.internal.changelog.core.ChangeLogWriter#writeChangeLog()}
   */
  @Test
  public void testWriteChangeLog() throws Exception {
    // We want paths up to the ChangeLog file to overlap

    final String pathRelativeToChangeLog = "eclipse/example/test/NewCoffeeMaker.java";
    clogWriter.setEntryFilePath(CHANGELOG_FILE_PATH + pathRelativeToChangeLog);

    // Will show up surrounded by "(" and ")" in ChangeLog
    String guessedFunctionName = "bazinga";
    clogWriter.setGuessedFName(guessedFunctionName);

    // set GNU formatter
    clogWriter.setFormatter(new GNUFormat());

    // Open a document and get the IEditorPart
    IEditorPart editorContent = EditorHelper.openEditor(changelogFile);
    clogWriter.setChangelog(editorContent);

    // set date/author line
    String authorName = "Test Author";
    String email = "*****@*****.**";
    clogWriter.setDateLine(clogWriter.getFormatter().formatDateLine(authorName, email));

    // full absolute path to ChangeLog file (relative to project root)
    clogWriter.setChangelogLocation(changelogFilePath);

    // Write changelog to buffer - need to save for persistence
    clogWriter.writeChangeLog();

    // above written content is not persistent yet; save it to make it persistent
    clogWriter.getChangelog().doSave(null);

    // Today's date in ISO format
    Calendar c = new GregorianCalendar();
    String isoDate = String.format("%1$tY-%1$tm-%1$td", c);

    // Construct the changelog entry by hand and match it with what has been written
    String expectedChangeLogEntry = isoDate + "  " + authorName + "  <" + email + ">\n\n";
    expectedChangeLogEntry +=
        "\t* " + pathRelativeToChangeLog + " (" + guessedFunctionName + "): \n\n";

    String expectedContent = expectedChangeLogEntry + changeLogContent;

    // Read in content written to file
    StringBuffer actualContent = new StringBuffer();
    try (BufferedReader br =
        new BufferedReader(
            new InputStreamReader(new FileInputStream(changelogFile.getLocation().toFile())))) {
      String line;
      while ((line = br.readLine()) != null) {
        actualContent.append(line + "\n");
      }
    }
    // Assert proper content has been added
    assertEquals(expectedContent, actualContent.toString());
    EditorHelper.closeEditor(editorContent);
  }
Example #17
0
  /**
   * Tests that '\n', '\r' and '\r\n' are treated as record delims when using bzip just like they
   * are when using uncompressed text
   */
  @Test
  public void testRecordDelims() throws Exception {
    String[] inputData =
        new String[] {
          "1\t2\r3\t4", // '\r' case - this will be split into two tuples
          "5\t6\r", // '\r\n' case
          "7\t8", // '\n' case
          "9\t10\r" // '\r\n' at the end of file
        };

    // bzip compressed input
    File in = File.createTempFile("junit", ".bz2");
    String compressedInputFileName = in.getAbsolutePath();
    in.deleteOnExit();
    String clusterCompressedFilePath = Util.removeColon(compressedInputFileName);

    String unCompressedInputFileName = "testRecordDelims-uncomp.txt";
    Util.createInputFile(cluster, unCompressedInputFileName, inputData);

    try {
      CBZip2OutputStream cos = new CBZip2OutputStream(new FileOutputStream(in));
      for (int i = 0; i < inputData.length; i++) {
        StringBuffer sb = new StringBuffer();
        sb.append(inputData[i]).append("\n");
        byte bytes[] = sb.toString().getBytes();
        cos.write(bytes);
      }
      cos.close();

      Util.copyFromLocalToCluster(cluster, compressedInputFileName, clusterCompressedFilePath);

      // pig script to read uncompressed input
      String script = "a = load '" + unCompressedInputFileName + "';";
      PigServer pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
      pig.registerQuery(script);
      Iterator<Tuple> it1 = pig.openIterator("a");

      // pig script to read compressed input
      script = "a = load '" + Util.encodeEscape(clusterCompressedFilePath) + "';";
      pig.registerQuery(script);
      Iterator<Tuple> it2 = pig.openIterator("a");

      while (it1.hasNext()) {
        Tuple t1 = it1.next();
        Tuple t2 = it2.next();
        Assert.assertEquals(t1, t2);
      }

      Assert.assertFalse(it2.hasNext());

    } finally {
      in.delete();
      Util.deleteFile(cluster, unCompressedInputFileName);
      Util.deleteFile(cluster, clusterCompressedFilePath);
    }
  }
Example #18
0
  @Test
  public void test() throws IOException, SAXException {
    byte[] expected = StreamUtils.readStream(getClass().getResourceAsStream("expected.xml"));
    String result = Main.runSmooksTransform();

    StringBuffer s1 = StreamUtils.trimLines(new ByteArrayInputStream(expected));
    StringBuffer s2 = StreamUtils.trimLines(new ByteArrayInputStream(result.getBytes()));

    assertEquals("Expected:\n" + s1 + "\nActual:\n" + s2, s1.toString(), s2.toString());
  }
Example #19
0
  @Test
  public void testParseRequiredFlag() throws IOException, JDOMException {
    final StringBuffer configXml = new StringBuffer();
    configXml.append("<config>");
    configXml.append("  <user-fields>");
    configXml.append("    <first-name required='true' />");
    configXml.append("    <initials required='false' />");
    configXml.append("    <birthday/>");
    configXml.append("  </user-fields>");
    configXml.append("</config>");
    final Element configEl = JDOMUtil.parseDocument(configXml.toString()).getRootElement();

    final UserStoreConfig config = UserStoreConfigParser.parse(configEl);

    final Collection<UserStoreUserFieldConfig> allUserFieldConfigs = config.getUserFieldConfigs();

    for (final UserStoreUserFieldConfig userFieldConfig : allUserFieldConfigs) {
      if (userFieldConfig.getType().getName().equals("first-name")) {
        assertEquals(true, userFieldConfig.isRequired());
      } else if (userFieldConfig.getType().getName().equals("initials")) {
        assertEquals(false, userFieldConfig.isRequired());
      } else if (userFieldConfig.getType().getName().equals("birthday")) {
        assertEquals(false, userFieldConfig.isRequired());
      }
    }
  }
  @Test
  public void testAudioMD_noMD5() throws Exception {

    Fits fits = new Fits();

    // First generate the FITS output
    File input = new File("testfiles/test.wav");
    FitsOutput fitsOut = fits.examine(input);

    XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
    String actualXmlStr = serializer.outputString(fitsOut.getFitsXml());

    // Read in the expected XML file
    Scanner scan = new Scanner(new File("testfiles/output/FITS_test_wav_NO_MD5.xml"));
    String expectedXmlStr = scan.useDelimiter("\\Z").next();
    scan.close();

    // Set up XMLUnit
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setNormalizeWhitespace(true);

    Diff diff = new Diff(expectedXmlStr, actualXmlStr);

    // Initialize attributes or elements to ignore for difference checking
    diff.overrideDifferenceListener(
        new IgnoreNamedElementsDifferenceListener(
            "version",
            "toolversion",
            "dateModified",
            "fslastmodified",
            "lastmodified",
            "startDate",
            "startTime",
            "timestamp",
            "fitsExecutionTime",
            "executionTime",
            "filepath",
            "location"));

    DetailedDiff detailedDiff = new DetailedDiff(diff);

    // Display any Differences
    List<Difference> diffs = detailedDiff.getAllDifferences();
    if (!diff.identical()) {
      StringBuffer differenceDescription = new StringBuffer();
      differenceDescription.append(diffs.size()).append(" differences");

      System.out.println(differenceDescription.toString());
      for (Difference difference : diffs) {
        System.out.println(difference.toString());
      }
    }

    assertTrue("Differences in XML", diff.identical());
  }
Example #21
0
  /** Tests the end-to-end writing and reading of a BZip file. */
  @Test
  public void testBzipInPig() throws Exception {
    PigServer pig = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());

    File in = File.createTempFile("junit", ".bz2");
    in.deleteOnExit();

    File out = File.createTempFile("junit", ".bz2");
    out.delete();
    String clusterOutput = Util.removeColon(out.getAbsolutePath());

    CBZip2OutputStream cos = new CBZip2OutputStream(new FileOutputStream(in));
    for (int i = 1; i < 100; i++) {
      StringBuffer sb = new StringBuffer();
      sb.append(i).append("\n").append(-i).append("\n");
      byte bytes[] = sb.toString().getBytes();
      cos.write(bytes);
    }
    cos.close();

    pig.registerQuery(
        "AA = load '"
            + Util.generateURI(Util.encodeEscape(in.getAbsolutePath()), pig.getPigContext())
            + "';");
    pig.registerQuery("A = foreach (group (filter AA by $0 > 0) all) generate flatten($1);");
    pig.registerQuery("store A into '" + Util.encodeEscape(clusterOutput) + "';");
    FileSystem fs =
        FileSystem.get(ConfigurationUtil.toConfiguration(pig.getPigContext().getProperties()));
    FSDataInputStream is = fs.open(new Path(clusterOutput + "/part-r-00000.bz2"));
    CBZip2InputStream cis = new CBZip2InputStream(is, -1, out.length());

    // Just a sanity check, to make sure it was a bzip file; we
    // will do the value verification later
    assertEquals(100, cis.read(new byte[100]));
    cis.close();

    pig.registerQuery("B = load '" + Util.encodeEscape(clusterOutput) + "';");

    Iterator<Tuple> i = pig.openIterator("B");
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    while (i.hasNext()) {
      Integer val = DataType.toInteger(i.next().get(0));
      map.put(val, val);
    }

    assertEquals(new Integer(99), new Integer(map.keySet().size()));

    for (int j = 1; j < 100; j++) {
      assertEquals(new Integer(j), map.get(j));
    }

    in.delete();
    Util.deleteFile(cluster, clusterOutput);
  }
Example #22
0
  private String readFile(String file) throws Exception {
    FileReader reader = new FileReader(new File(file));
    BufferedReader br = new BufferedReader(reader);
    StringBuffer buffer = new StringBuffer();
    String line = br.readLine();
    while (line != null) {
      buffer.append(line);
      line = br.readLine();
    }

    return buffer.toString();
  }
  /**
   * Test the use of default text.
   *
   * @throws Exception
   */
  @Test
  public void canWriteChangeLogToEmptyChangeLogButWithSomeDefaultContent() throws Exception {
    // set GNU formatter
    clogWriter.setFormatter(new GNUFormat());

    // Open up a new ChangeLog file at newPathToChangeLog with empty content
    // and get the IEditorPart
    InputStream newFileInputStream = new ByteArrayInputStream("".getBytes()); // no content
    String destinationPath = "/this/is/some/random/path";
    IFile emptyChangeLogFile =
        project.addFileToProject(destinationPath, CHANGELOG_FILE_NAME, newFileInputStream);
    IEditorPart editorContent = EditorHelper.openEditor(emptyChangeLogFile);
    clogWriter.setChangelog(editorContent);

    String authorName = "Test Author";
    String email = "*****@*****.**";
    clogWriter.setDateLine(clogWriter.getFormatter().formatDateLine(authorName, email));
    clogWriter.setChangelogLocation(destinationPath + "/" + CHANGELOG_FILE_NAME);

    // Set some default content
    String defaultContent = "Removed.";
    clogWriter.setDefaultContent(defaultContent);

    String relativePathOfChangedFile = "path/to/file/for/new/entry/test.c";
    clogWriter.setEntryFilePath(destinationPath + "/" + relativePathOfChangedFile);

    clogWriter.setGuessedFName("");

    // Write changelog to buffer - need to save for persistence
    clogWriter.writeChangeLog();

    // above written content is not persistent yet; save it to make it persistent
    clogWriter.getChangelog().doSave(null);

    // Construct the changelog entry by hand and match it with what has been written
    String expectedChangeLogEntry = new GNUFormat().formatDateLine(authorName, email);
    expectedChangeLogEntry += "\t* " + relativePathOfChangedFile + ": " + defaultContent + "\n";

    // Read in content written to file
    StringBuffer actualContent = new StringBuffer();
    try (BufferedReader br =
        new BufferedReader(
            new InputStreamReader(
                new FileInputStream(emptyChangeLogFile.getLocation().toFile())))) {
      String line;
      while ((line = br.readLine()) != null) {
        actualContent.append(line + "\n");
      }
    }
    // Assert proper content has been added
    assertEquals(expectedChangeLogEntry, actualContent.toString());
    EditorHelper.closeEditor(editorContent);
  }
Example #24
0
  @Test
  public void testLongLangRoundTrip() throws Exception {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 512; i++) {
      sb.append(Character.toChars('A' + (i % 26)));
    }
    URI subj = new URIImpl(EXAMPLE_NS + PICASSO);
    URI pred = new URIImpl(EXAMPLE_NS + PAINTS);
    Literal obj = new LiteralImpl("guernica" + sb.toString(), "es");

    testValueRoundTrip(subj, pred, obj);
  }
Example #25
0
  @Test
  public void testLongURIRoundTrip() throws Exception {
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 512; i++) {
      sb.append(Character.toChars('A' + (i % 26)));
    }
    URI subj = new URIImpl(EXAMPLE_NS + PICASSO);
    URI pred = new URIImpl(EXAMPLE_NS + PAINTS);
    URI obj = new URIImpl(EXAMPLE_NS + GUERNICA + sb.toString());

    testValueRoundTrip(subj, pred, obj);
  }
 @Override
 public void doSetup(final ManagementClient managementClient) throws Exception {
   try {
     dsAddress = createDataSource(false, jndiDs);
     dsXaAddress = createDataSource(true, jndiXaDs);
     StringBuffer sb = cleanStats(dsAddress).append(cleanStats(dsXaAddress));
     if (sb.length() > 0) fail(sb.toString());
   } catch (Throwable e) {
     removeDss();
     throw new Exception(e);
   }
 }
Example #27
0
 @Test
 public void testaddToMethodBufferNothing()
     throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException,
         SecurityException {
   String toAdd = "";
   UMLArrows arrows = UMLArrows.getInstance();
   Field methodBuffer = UMLArrows.class.getDeclaredField("methodBuffer");
   methodBuffer.setAccessible(true);
   StringBuffer currentBuffer = (StringBuffer) methodBuffer.get(arrows);
   String newBuffer = (currentBuffer.toString() + toAdd);
   arrows.addToMethodBuffer(toAdd);
   assertEquals(newBuffer, methodBuffer.get(arrows).toString());
 }
Example #28
0
 @Test
 public void testaddToFieldBufferSymbols()
     throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException,
         SecurityException {
   String toAdd = "(#)^%@#%^@#$)@#$*@#&$)@!_)*";
   UMLArrows arrows = UMLArrows.getInstance();
   Field fieldBuffer = UMLArrows.class.getDeclaredField("fieldBuffer");
   fieldBuffer.setAccessible(true);
   StringBuffer currentBuffer = (StringBuffer) fieldBuffer.get(arrows);
   String newBuffer = (currentBuffer.toString() + toAdd);
   arrows.addToFieldBuffer(toAdd);
   assertEquals(newBuffer, fieldBuffer.get(arrows).toString());
 }
Example #29
0
  @Test
  public void testParseMissingUserElement() throws IOException, JDOMException {
    final StringBuffer configXml = new StringBuffer();
    configXml.append("<config>");
    configXml.append("</config>");
    final Element configEl = JDOMUtil.parseDocument(configXml.toString()).getRootElement();

    try {
      UserStoreConfigParser.parse(configEl);
      fail("An exception should have been thrown.");
    } catch (Exception ex) {
      assertEquals(InvalidUserStoreConfigException.class.getName(), ex.getClass().getName());
    }
  }
Example #30
0
  @Test
  public void testOtsi() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.linkText("Kandidaadid")).click();
    // Warning: waitForTextPresent may require manual changes
    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if (driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    driver.findElement(By.id("nimi")).clear();
    driver.findElement(By.id("nimi")).sendKeys("Magdalena");
    try {
      assertEquals("Magdalena", driver.findElement(By.id("nimi")).getAttribute("value"));
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
    driver.findElement(By.id("sButton")).click();
    // Warning: waitForTextPresent may require manual changes
    for (int second = 0; ; second++) {
      if (second >= 60) fail("timeout");
      try {
        if (driver
            .findElement(By.cssSelector("BODY"))
            .getText()
            .matches("^[\\s\\S]*Magdalena Malejeva[\\s\\S]*$")) break;
      } catch (Exception e) {
      }
      Thread.sleep(1000);
    }

    // Warning: verifyTextNotPresent may require manual changes
    try {
      assertFalse(
          driver
              .findElement(By.cssSelector("BODY"))
              .getText()
              .matches("^[\\s\\S]*Vana Kala[\\s\\S]*$"));
    } catch (Error e) {
      verificationErrors.append(e.toString());
    }
  }