Package com.google.enterprise.connector.mock

Examples of com.google.enterprise.connector.mock.MockRepositoryProperty$PropertyType


      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


   * or throws a suitable <code>java.security.AccessControlException</code>
   * otherwise.
   */
  private void checkPermission(String userId, MockRepositoryDocument doc)
      throws AccessControlException {
    MockRepositoryProperty property = doc.getProplist().getProperty("acl");
    if (property == null) {
      return;
    }
    String[] values = property.getValues();
    for (int i = 0; i < values.length; i++) {
      String aclEntry = values[i];
      // Extract the scope type and compare.
      int scopeTokPos = aclEntry.indexOf(MockRepositoryProperty.SCOPE_TYPE_SEP);
      if (scopeTokPos != -1) {
View Full Code Here

  }

  private void init() {
    propList = new LinkedList<MockJcrProperty>();
    // Convert the special MockRepositoryDocument schema to a JCR property list
    MockRepositoryProperty p = null;
    // content
    try {
      p = new MockRepositoryProperty("jcr:content", doc.getContentStream());
    } catch (FileNotFoundException e) {
      LOGGER.severe(e.toString());
    }
    if (p != null) {
      propList.add(new MockJcrProperty(p));
    }
    // modified date
    p = new MockRepositoryProperty("jcr:lastModified",
        MockRepositoryProperty.PropertyType.DATE, Integer.toString(doc
            .getTimeStamp().getTicks()));
    propList.add(new MockJcrProperty(p));
    // docid
    p = new MockRepositoryProperty("jcr:uuid", doc.getDocID());
    propList.add(new MockJcrProperty(p));
    // acl
    MockRepositoryProperty aclProp = doc.getProplist().getProperty("acl");
    if (aclProp != null) {
      addAclProperty(MockRepositoryProperty.USER_SCOPE, aclProp, propList,
          SpiConstants.PROPNAME_ACLUSERS,
          SpiConstants.USER_ROLES_PROPNAME_PREFIX);
      addAclProperty(MockRepositoryProperty.GROUP_SCOPE, aclProp, propList,
          SpiConstants.PROPNAME_ACLGROUPS,
          SpiConstants.GROUP_ROLES_PROPNAME_PREFIX);
    }
    // acldeny
    MockRepositoryProperty aclDenyProp =
        doc.getProplist().getProperty("acldeny");
    if (aclDenyProp != null) {
      addAclProperty(MockRepositoryProperty.USER_SCOPE, aclDenyProp, propList,
          SpiConstants.PROPNAME_ACLDENYUSERS, null);
      addAclProperty(MockRepositoryProperty.GROUP_SCOPE, aclDenyProp, propList,
View Full Code Here

        // the propList.
        newAclScopes.add("\"" + scopeId + "\"");
        if (rolesStr != null) {
          // Create a multi-value property for the scope's roles.
          List<String> rolesList = Arrays.asList(rolesStr.split(",", 0));
          MockRepositoryProperty newRolesProp = new MockRepositoryProperty(
              rolesPrefix + scopeId,
              "{type:string, value:" + rolesList.toString() + "}");
          propList.add(new MockJcrProperty(newRolesProp));
        }
      }
    }

    if (newAclScopes.size() > 0) {
      MockRepositoryProperty newAclProp = new MockRepositoryProperty(propName,
          "{type:string, value:" + newAclScopes.toString() + "}");
      propList.add(new MockJcrProperty(newAclProp));
    }
  }
View Full Code Here

      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

        assertEquals(1, t.getAbstractTransactionAction().size());
       
        UpdateType u = (UpdateType) t.getAbstractTransactionAction().get(0);
        assertEquals(1, u.getProperty().size());
       
        PropertyType p = u.getProperty().get(0);
        assertEquals("population", p.getValueReference().getValue().getLocalPart());
        assertEquals("4070000", p.getValue());
       
        Id id = (Id) u.getFilter();
        assertNotNull(id);
        assertTrue(id.getIDs().contains("BuiltUpA_1M.10131"));
    }
View Full Code Here

        }

        // persistence-context-properties
        PersistenceProperty[] properties = annotation.properties();
        for (PersistenceProperty property : properties) {
            PropertyType propertyType = persistenceContextRef.addNewPersistenceProperty();
            XsdStringType propertyName = propertyType.addNewName();
            propertyName.setStringValue(property.name());
            XsdStringType propertyValue = propertyType.addNewValue();
            propertyValue.setStringValue(property.value());
        }

        // injection targets
        if (method != null || field != null) {
View Full Code Here

        if (dataSource.getPropertyArray() == null || dataSource.getPropertyArray().length == 0) {
            String[] properties = dsDefinition.properties();
            if (properties != null) {
                for (String property : properties) {
                    String[] tokens = property.split("=");
                    PropertyType propertyType = dataSource.addNewProperty();
                    propertyType.addNewName().setStringValue(tokens[0]);
                    propertyType.addNewValue().setStringValue(tokens[1]);                   
                }              
            }
        }
       
        return dataSource;
View Full Code Here

   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setProperty(PropertyType newProperty) {
    PropertyType oldProperty = property;
    property = newProperty == null ? PROPERTY_EDEFAULT : newProperty;
    boolean oldPropertyESet = propertyESet;
    propertyESet = true;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, _40Package.VALUE_TYPE__PROPERTY, oldProperty, property, !oldPropertyESet));
View Full Code Here

   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void unsetProperty() {
    PropertyType oldProperty = property;
    boolean oldPropertyESet = propertyESet;
    property = PROPERTY_EDEFAULT;
    propertyESet = false;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.UNSET, _40Package.VALUE_TYPE__PROPERTY, oldProperty, PROPERTY_EDEFAULT, oldPropertyESet));
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.mock.MockRepositoryProperty$PropertyType

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.