Java Code Examples for org.springframework.beans.PropertyAccessor

The following are top voted examples for showing how to use org.springframework.beans.PropertyAccessor. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Sound.je   File: EntitySearch.java   View source code 6 votes vote down vote up
/**
 * This follows a path (like object.childobject.value), to its end value, so it can compare the values of two
 * paths.
 * This method follows the path recursively until it reaches the end value.
 *
 * @param object object to search
 * @param path   path of value
 * @return result
 */
private Object deepValue(final Object object, final String path) {
    final List<String> paths = new LinkedList<>(Arrays.asList(path.split("\\.")));
    final String currentPath = paths.get(0);

    final PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(object);
    Object field = accessor.getPropertyValue(currentPath);

    paths.remove(0);

    if ((field != null) && (!paths.isEmpty())) {
        field = deepValue(field, String.join(".", paths));
    }

    return field;
}
 
Example 2
Project: Sound.je   File: FormParse.java   View source code 6 votes vote down vote up
/**
 * Write the value to the existingEntity field with the name of key
 *
 * @param <T>            Type of the entity
 * @param existingEntity The entity we are changing
 * @param key            The key we are changing
 * @param value          The new value
 */
private <T extends BaseEntity> void writeToEntity(T existingEntity, String key, Object value) {
    final PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(existingEntity);

    if (accessor.getPropertyType(key) != null) {
        try {
            if (value.getClass().equals(JSONObject.class) &&
                    ((JSONObject) value).has("_isMap") &&
                    ((JSONObject) value).get("_isMap").equals(true)) {
                writeArrayMapToEntity(accessor, key, (JSONObject) value);
            } else if (value.getClass().equals(JSONObject.class)) {
                writeObjectToEntity(accessor, key, (JSONObject) value);
            } else if (value.getClass().equals(JSONArray.class)) {
                writeArrayToEntity(accessor, key, (JSONArray) value);
            } else if (isFieldValid(accessor, key, existingEntity.getClass())) {
                writeValueToEntity(accessor, key, value);
            }
        } catch (JSONException e) {
            logger.info("[FormParse] [writeToEntity] Unable To Process JSON", e);
        }
    }
}
 
Example 3
Project: summerb   File: QueryNarrowerStrategyFieldBased.java   View source code 6 votes vote down vote up
protected boolean hasRestrictionOnField(Query query, String fieldName) {
	for (Restriction<PropertyAccessor> restriction : query.getRestrictions()) {
		if (restriction instanceof FieldCondition) {
			if (fieldName.equals(((FieldCondition) restriction).getFieldName())) {
				return true;
			}
		} else if (restriction instanceof DisjunctionCondition) {
			for (Query subQuery : ((DisjunctionCondition) restriction).getQueries()) {
				if (hasRestrictionOnField(subQuery, fieldName)) {
					return true;
				}
			}
		}
	}
	return false;
}
 
Example 4
Project: spring-rich-client   File: AbstractPropertyAccessStrategy.java   View source code 6 votes vote down vote up
/**
 * Returns the index of the last nested property separator in the given
 * property path, ignoring dots in keys (like "map[my.key]").
 */
protected int getLastPropertySeparatorIndex(String propertyPath) {
	boolean inKey = false;
	for (int i = propertyPath.length() - 1; i >= 0; i--) {
		switch (propertyPath.charAt(i)) {
		case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
			inKey = true;
			break;
		case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
			return i;
		case PropertyAccessor.NESTED_PROPERTY_SEPARATOR_CHAR:
			if (!inKey) {
				return i;
			}
			break;
		}
	}
	return -1;
}
 
Example 5
Project: spring-rich-client   File: AbstractNestedMemberPropertyAccessor.java   View source code 6 votes vote down vote up
public boolean isReadableProperty(String propertyPath) {
	if (PropertyAccessorUtils.isNestedProperty(propertyPath)) {
		String baseProperty = getBasePropertyName(propertyPath);
		String childPropertyPath = getChildPropertyPath(propertyPath);
		if (!super.isReadableProperty(baseProperty)) {
			return false;
		}
		else {
			return ((PropertyAccessor) childPropertyAccessors.get(baseProperty))
					.isReadableProperty(childPropertyPath);
		}
	}
	else {
		return super.isReadableProperty(propertyPath);
	}
}
 
Example 6
Project: spring-rich-client   File: PropertyAccessorUtils.java   View source code 6 votes vote down vote up
public static int getNestingLevel(String propertyName) {
    propertyName = getPropertyName(propertyName);
    int nestingLevel = 0;
    boolean inKey = false;
    for (int i = 0; i < propertyName.length(); i++) {
        switch (propertyName.charAt(i)) {
        case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
            if (!inKey) {
                nestingLevel++;
            }
        case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
            inKey = !inKey;
        }
    }
    return nestingLevel;
}
 
Example 7
Project: spring-richclient   File: AbstractPropertyAccessStrategy.java   View source code 6 votes vote down vote up
/**
 * Returns the index of the last nested property separator in the given
 * property path, ignoring dots in keys (like "map[my.key]").
 */
protected int getLastPropertySeparatorIndex(String propertyPath) {
	boolean inKey = false;
	for (int i = propertyPath.length() - 1; i >= 0; i--) {
		switch (propertyPath.charAt(i)) {
		case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
			inKey = true;
			break;
		case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
			return i;
		case PropertyAccessor.NESTED_PROPERTY_SEPARATOR_CHAR:
			if (!inKey) {
				return i;
			}
			break;
		}
	}
	return -1;
}
 
Example 8
Project: spring-richclient   File: AbstractNestedMemberPropertyAccessor.java   View source code 6 votes vote down vote up
public boolean isReadableProperty(String propertyPath) {
	if (PropertyAccessorUtils.isNestedProperty(propertyPath)) {
		String baseProperty = getBasePropertyName(propertyPath);
		String childPropertyPath = getChildPropertyPath(propertyPath);
		if (!super.isReadableProperty(baseProperty)) {
			return false;
		}
		else {
			return ((PropertyAccessor) childPropertyAccessors.get(baseProperty))
					.isReadableProperty(childPropertyPath);
		}
	}
	else {
		return super.isReadableProperty(propertyPath);
	}
}
 
Example 9
Project: spring-richclient   File: PropertyAccessorUtils.java   View source code 6 votes vote down vote up
public static int getNestingLevel(String propertyName) {
    propertyName = getPropertyName(propertyName);
    int nestingLevel = 0;
    boolean inKey = false;
    for (int i = 0; i < propertyName.length(); i++) {
        switch (propertyName.charAt(i)) {
        case PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR:
            if (!inKey) {
                nestingLevel++;
            }
        case PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR:
            inKey = !inKey;
        }
    }
    return nestingLevel;
}
 
Example 10
Project: jdal   File: CompositeBinder.java   View source code 6 votes vote down vote up
public void autobind(Object view) {
	BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(getModel());
	PropertyAccessor  viewPropertyAccessor = new DirectFieldAccessor(view);
	// iterate on model properties
	for (PropertyDescriptor pd : bw.getPropertyDescriptors()) {
		String propertyName = pd.getName();
		if ( !ignoredProperties.contains(propertyName) && viewPropertyAccessor.isReadableProperty(propertyName)) {
			Object control = viewPropertyAccessor.getPropertyValue(propertyName);
			if (control != null) {
				if (log.isDebugEnabled()) 
					log.debug("Found control: " + control.getClass().getSimpleName() + 
							" for property: " + propertyName);
				bind(control, propertyName);
			}
		}
	}
}
 
Example 11
Project: syndesis   File: UniquePropertyValidator.java   View source code 5 votes vote down vote up
@Override
public boolean isValid(final WithId<?> value, final ConstraintValidatorContext context) {
    if (value == null) {
        return true;
    }

    final PropertyAccessor bean = new BeanWrapperImpl(value);

    final String propertyValue = String.valueOf(bean.getPropertyValue(property));

    @SuppressWarnings({"rawtypes", "unchecked"})
    final Class<WithId> modelClass = (Class) value.getKind().modelClass;

    @SuppressWarnings("unchecked")
    final Set<String> ids = dataManager.fetchIdsByPropertyValue(modelClass, property, propertyValue);

    final boolean isUnique = ids.isEmpty() || value.getId().map(id -> ids.contains(id)).orElse(false);

    if (!isUnique) {
        if (ids.stream().allMatch(id -> consideredValidByException(modelClass, id))) {
            return true;
        }

        context.disableDefaultConstraintViolation();
        context.unwrap(HibernateConstraintValidatorContext.class).addExpressionVariable("nonUnique", propertyValue)
            .buildConstraintViolationWithTemplate(context.getDefaultConstraintMessageTemplate())
            .addPropertyNode(property).addConstraintViolation();
    }

    return isUnique;
}
 
Example 12
Project: Sound.je   File: FormParse.java   View source code 5 votes vote down vote up
/**
 * Write normal value to entity.
 *
 * @param accessor The accessor for the existing entity
 * @param key      The fields name we are overwriting
 * @param value    The new value
 */
private void writeValueToEntity(final PropertyAccessor accessor,
                                final String key,
                                final Object value) {
    final ResolvableType type = accessor.getPropertyTypeDescriptor(key).getResolvableType();

    accessor.setPropertyValue(key, parseValue(value, type));
}
 
Example 13
Project: Sound.je   File: FormParse.java   View source code 5 votes vote down vote up
/**
 * Is the field editable according to the SchemaView annotation
 *
 * @param accessor the accessor
 * @param key      the key
 * @return boolean boolean
 */
private Boolean isFieldEditable(final PropertyAccessor accessor, final String key) {
    final SchemaView schemaView = accessor.getPropertyTypeDescriptor(key).getAnnotation(SchemaView.class);

    if (schemaView != null) {
        final boolean isLocked = schemaView.locked() && accessor.getPropertyValue(key) != null;
        final boolean isVisible = schemaView.visible();

        return !isLocked && isVisible;
    }

    return false;
}
 
Example 14
Project: spring4-understanding   File: NestedPathTag.java   View source code 5 votes vote down vote up
/**
 * Set the path that this tag should apply.
 * <p>E.g. "customer" to allow bind paths like "address.street"
 * rather than "customer.address.street".
 * @see BindTag#setPath
 */
public void setPath(String path) {
	if (path == null) {
		path = "";
	}
	if (path.length() > 0 && !path.endsWith(PropertyAccessor.NESTED_PROPERTY_SEPARATOR)) {
		path += PropertyAccessor.NESTED_PROPERTY_SEPARATOR;
	}
	this.path = path;
}
 
Example 15
Project: spring4-understanding   File: AbstractDataBoundFormElementTag.java   View source code 5 votes vote down vote up
/**
 * Get the {@link BindStatus} for this tag.
 */
protected BindStatus getBindStatus() throws JspException {
	if (this.bindStatus == null) {
		// HTML escaping in tags is performed by the ValueFormatter class.
		String nestedPath = getNestedPath();
		String pathToUse = (nestedPath != null ? nestedPath + getPath() : getPath());
		if (pathToUse.endsWith(PropertyAccessor.NESTED_PROPERTY_SEPARATOR)) {
			pathToUse = pathToUse.substring(0, pathToUse.length() - 1);
		}
		this.bindStatus = new BindStatus(getRequestContext(), pathToUse, false);
	}
	return this.bindStatus;
}
 
Example 16
Project: fiat   File: GoogleDirectoryUserRolesProvider.java   View source code 5 votes vote down vote up
private Directory getDirectoryService() {
  HttpTransport httpTransport = new NetHttpTransport();
  JacksonFactory jacksonFactory = new JacksonFactory();
  GoogleCredential credential = getGoogleCredential();

  PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(credential);
  accessor.setPropertyValue("serviceAccountUser", config.getAdminUsername());
  accessor.setPropertyValue("serviceAccountScopes", SERVICE_ACCOUNT_SCOPES);

  return new Directory.Builder(httpTransport, jacksonFactory, credential)
      .setApplicationName("Spinnaker-Fiat")
      .build();
}
 
Example 17
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideEnableFallback() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.enableFallback:true");
	assertThat(accessor.getPropertyValue("enableFallback")).isEqualTo(Boolean.TRUE);
}
 
Example 18
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideNormalPrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.normalPrefix:normal/");
	assertThat(accessor.getPropertyValue("normalPrefix")).isEqualTo("normal/");
}
 
Example 19
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideMobilePrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.mobilePrefix:mob/");
	assertThat(accessor.getPropertyValue("mobilePrefix")).isEqualTo("mob/");
}
 
Example 20
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideTabletPrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.tabletPrefix:tab/");
	assertThat(accessor.getPropertyValue("tabletPrefix")).isEqualTo("tab/");
}
 
Example 21
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideNormalSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.normalSuffix:.nor");
	assertThat(accessor.getPropertyValue("normalSuffix")).isEqualTo(".nor");
}
 
Example 22
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideMobileSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.mobileSuffix:.mob");
	assertThat(accessor.getPropertyValue("mobileSuffix")).isEqualTo(".mob");
}
 
Example 23
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideTabletSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.tabletSuffix:.tab");
	assertThat(accessor.getPropertyValue("tabletSuffix")).isEqualTo(".tab");
}
 
Example 24
Project: https-github.com-g0t4-jenkins2-course-spring-boot   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor(
		String... configuration) {
	load(configuration);
	LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context
			.getBean("deviceDelegatingJspViewResolver",
					LiteDeviceDelegatingViewResolver.class);
	return new DirectFieldAccessor(liteDeviceDelegatingViewResolver);
}
 
Example 25
Project: syndesis-rest   File: UniquePropertyValidator.java   View source code 5 votes vote down vote up
@Override
public boolean isValid(final WithId<?> value, final ConstraintValidatorContext context) {
    if (value == null) {
        return true;
    }

    final PropertyAccessor bean = new BeanWrapperImpl(value);

    final String propertyValue = String.valueOf(bean.getPropertyValue(property));

    @SuppressWarnings({"rawtypes", "unchecked"})
    final Class<WithId> modelClass = (Class) value.getKind().modelClass;

    @SuppressWarnings("unchecked")
    final Set<String> ids = dataManager.fetchIdsByPropertyValue(modelClass, property, propertyValue);

    final boolean isUnique = ids.isEmpty() || value.getId().map(id -> ids.contains(id)).orElse(false);

    if (!isUnique) {
        if (ids.stream().allMatch(id -> consideredValidByException(modelClass, id))) {
            return true;
        }

        context.disableDefaultConstraintViolation();
        context.unwrap(HibernateConstraintValidatorContext.class).addExpressionVariable("nonUnique", propertyValue)
            .buildConstraintViolationWithTemplate(context.getDefaultConstraintMessageTemplate())
            .addPropertyNode(property).addConstraintViolation();
    }

    return isUnique;
}
 
Example 26
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideEnableFallback() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.enableFallback:true");
	assertThat(accessor.getPropertyValue("enableFallback")).isEqualTo(Boolean.TRUE);
}
 
Example 27
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideNormalPrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.normalPrefix:normal/");
	assertThat(accessor.getPropertyValue("normalPrefix")).isEqualTo("normal/");
}
 
Example 28
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideMobilePrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.mobilePrefix:mob/");
	assertThat(accessor.getPropertyValue("mobilePrefix")).isEqualTo("mob/");
}
 
Example 29
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideTabletPrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.tabletPrefix:tab/");
	assertThat(accessor.getPropertyValue("tabletPrefix")).isEqualTo("tab/");
}
 
Example 30
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideNormalSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.normalSuffix:.nor");
	assertThat(accessor.getPropertyValue("normalSuffix")).isEqualTo(".nor");
}
 
Example 31
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideMobileSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.mobileSuffix:.mob");
	assertThat(accessor.getPropertyValue("mobileSuffix")).isEqualTo(".mob");
}
 
Example 32
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideTabletSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.tabletSuffix:.tab");
	assertThat(accessor.getPropertyValue("tabletSuffix")).isEqualTo(".tab");
}
 
Example 33
Project: spring-boot-concourse   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
private PropertyAccessor getLiteDeviceDelegatingViewResolverAccessor(
		String... configuration) {
	this.context = new AnnotationConfigEmbeddedWebApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context, configuration);
	this.context.register(Config.class, WebMvcAutoConfiguration.class,
			HttpMessageConvertersAutoConfiguration.class,
			PropertyPlaceholderAutoConfiguration.class,
			DeviceDelegatingViewResolverConfiguration.class);
	this.context.refresh();
	LiteDeviceDelegatingViewResolver liteDeviceDelegatingViewResolver = this.context
			.getBean("deviceDelegatingViewResolver",
					LiteDeviceDelegatingViewResolver.class);
	return new DirectFieldAccessor(liteDeviceDelegatingViewResolver);
}
 
Example 34
Project: kc-rice   File: ReferenceLinker.java   View source code 5 votes vote down vote up
/**
* Gets index of property name.
*
* <p>
*     Returns the index number of the location of the given property name.
* </p>
*
* @param propertyName name of property to find index of.
* @return index number representing location of property name.
*/
private Integer extractIndex(String propertyName) {
    int firstIndex = propertyName.indexOf(PropertyAccessor.PROPERTY_KEY_PREFIX_CHAR);
    int lastIndex = propertyName.lastIndexOf(PropertyAccessor.PROPERTY_KEY_SUFFIX_CHAR);
    if (firstIndex != -1 && lastIndex != -1) {
        String indexValue = propertyName.substring(firstIndex + 1, lastIndex);
        try {
            int index = Integer.parseInt(indexValue);
            return Integer.valueOf(index);
        } catch (NumberFormatException e) {
            // if we encounter this then it wasn't really an index, ignore
        }
    }
    return null;
}
 
Example 35
Project: contestparser   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideEnableFallback() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.enableFallback:true");
	assertEquals(true, accessor.getPropertyValue("enableFallback"));
}
 
Example 36
Project: contestparser   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideNormalPrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.normalPrefix:normal/");
	assertEquals("normal/", accessor.getPropertyValue("normalPrefix"));
}
 
Example 37
Project: contestparser   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideMobilePrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.mobilePrefix:mob/");
	assertEquals("mob/", accessor.getPropertyValue("mobilePrefix"));
}
 
Example 38
Project: contestparser   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideTabletPrefix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.tabletPrefix:tab/");
	assertEquals("tab/", accessor.getPropertyValue("tabletPrefix"));
}
 
Example 39
Project: contestparser   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideNormalSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.normalSuffix:.nor");
	assertEquals(".nor", accessor.getPropertyValue("normalSuffix"));
}
 
Example 40
Project: contestparser   File: DeviceDelegatingViewResolverAutoConfigurationTests.java   View source code 5 votes vote down vote up
@Test
public void overrideMobileSuffix() throws Exception {
	PropertyAccessor accessor = getLiteDeviceDelegatingViewResolverAccessor(
			"spring.mobile.devicedelegatingviewresolver.enabled:true",
			"spring.mobile.devicedelegatingviewresolver.mobileSuffix:.mob");
	assertEquals(".mob", accessor.getPropertyValue("mobileSuffix"));
}