Package com.google.enterprise.connector.mock

Examples of com.google.enterprise.connector.mock.MockRepositoryPropertyList


      MockRepositoryDocument doc = store.getDocByID(ids[j]);// if no
      // 'content'
      // defined,
      // doc==null
      if (doc != null) {
        MockRepositoryPropertyList pl = doc.getProplist();
        MockRepositoryProperty p = pl.getProperty("acl");
        if (p != null) { // If doc contains acls
          String[] acl = p.getValues();
          for (int i = 0; i < acl.length; i++) {
            if (claimant.equals(acl[i])) {
              add(doc);
            }
          }
        } else if (pl.getProperty("google:ispublic") != null) {
          if (pl.getProperty("google:ispublic").getValue().equals(
              "true")) {
            add(doc);
          }
        }
      }
View Full Code Here


    try {
      jo = new JSONObject(input);
    } catch (JSONException e) {
      throw new IllegalArgumentException("test input can not be parsed");
    }
    MockRepositoryPropertyList pl = new MockRepositoryPropertyList(jo);

    {
      MockRepositoryProperty testProp = pl.getProperty("xyzzy");
      Property testJCRProp = new MockJcrProperty(testProp);
      Assert.assertEquals("skeedle", testJCRProp.getString());
      Assert.assertEquals(PropertyType.STRING, testJCRProp.getType());
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("baz");
      Property testJCRProp = new MockJcrProperty(testProp);
      Assert.assertEquals(42, testJCRProp.getLong());
      Assert.assertEquals(PropertyType.LONG, testJCRProp.getType());
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("abc");
      Property testJCRProp = new MockJcrProperty(testProp);
      try {
        testJCRProp.getLong();
        // shouldn't get here - previous line should throw exception
        Assert.assertFalse(true);
      } catch (Exception e) {
        // Specifically, ValueFormatException should be thrown
        Assert.assertTrue(e instanceof ValueFormatException);
      }
      Value[] vs = testJCRProp.getValues();
      Assert.assertEquals(PropertyType.LONG, testJCRProp.getType());
      Assert.assertEquals(5, vs.length);
      Assert.assertEquals(2, vs[0].getLong());
      Assert.assertEquals(3, vs[1].getLong());
      Assert.assertEquals(5, vs[2].getLong());
      Assert.assertEquals(7, vs[3].getLong());
      Assert.assertEquals(11, vs[4].getLong());
      Assert.assertEquals(PropertyType.LONG, vs[4].getType());
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("def");
      Property testJCRProp = new MockJcrProperty(testProp);
      Value[] vs = testJCRProp.getValues();
      Assert.assertEquals(PropertyType.DATE, testJCRProp.getType());
      Assert.assertEquals(3, vs.length);
      Calendar date = vs[0].getDate();
      Calendar expected = Calendar.getInstance();
      expected.setTimeInMillis(10 * 1000);
      Assert.assertTrue(date.equals(expected));
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("ghi");
      Property testJCRProp = new MockJcrProperty(testProp);
      Value[] vs = testJCRProp.getValues();
      Assert.assertEquals(PropertyType.LONG, testJCRProp.getType());
      Assert.assertEquals(0, vs.length);
    }
View Full Code Here

   * @throws RepositoryException
   */
  public void testSimpleDoc() throws RepositoryException {
    MockRepositoryDocument mrd = new MockRepositoryDocument(
        new MockRepositoryDateTime(50000), "docid2", "now is the time",
        new MockRepositoryPropertyList());
    Node n = new MockJcrNode(mrd);
    Property p = n.getProperty("jcr:content");
    Assert.assertNotNull(p);
    String content = p.getString();
    logger.info("Content is \"" + content + "\"");
View Full Code Here

    try {
      jo = new JSONObject(input);
    } catch (JSONException e) {
      throw new IllegalArgumentException("test input can not be parsed");
    }
    MockRepositoryPropertyList pl = new MockRepositoryPropertyList(jo);

    {
      MockRepositoryProperty testProp = pl.getProperty("xyzzy");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      Value v = p.nextValue();
      Assert.assertEquals("skeedle", v.toString());
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("baz");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      Value v = p.nextValue();
      Assert.assertEquals("42", v.toString());
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("abc");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      int counter = 0;
      Value v = null;
      while ((v = p.nextValue()) != null) {
        String res = v.toString();
        switch (counter) {
        case 0:
          Assert.assertEquals("2", res);
          break;
        case 1:
          Assert.assertEquals("3", res);
          break;
        case 2:
          Assert.assertEquals("5", res);
          break;
        case 3:
          Assert.assertEquals("7", res);
          break;
        case 4:
          Assert.assertEquals("11", res);
          break;
        }
        counter++;
      }
      Assert.assertEquals(5, counter);
    }

    {
      // TODO: date test
    }

    {
      MockRepositoryProperty testProp = pl.getProperty("ghi");
      MockJcrProperty testJCRProp = new MockJcrProperty(testProp);
      Property p = new JcrProperty(testJCRProp);
      Value v = p.nextValue();
      Assert.assertNull(v);
    }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.mock.MockRepositoryPropertyList

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.