public void testFoo() { final URL url = MissingValueTypeTestCase.class.getResource("InvalidValueType"); assertNotNull(url); ClassLoader cl = new ClassLoader(MissingValueTypeTestCase.class.getClassLoader()) { @Override public Enumeration<URL> getResources(String name) throws IOException { if (name.equals("META-INF/services/" + ValueType.class.getName())) { return Collections.enumeration(Collections.singleton(url)); } else { return super.getResources(name); } } }; ValueTypeFactory factory = new ValueTypeFactory(cl); ValueType<Custom> custom = factory.get(Custom.class); assertNotNull(custom); }
public void testObjectName() throws Exception { ValueType<ObjectName> propertiesVT = factory.get(ObjectName.class); ObjectName name = propertiesVT.parse(ObjectName.class, "foo:bar=juu"); assertEquals(new ObjectName("foo", "bar", "juu"), name); } }
public CommandFactory(ClassLoader loader) throws NullPointerException { this(new ValueTypeFactory(loader)); }
} else { effectiveType = declaredType; valueType = factory.get(declaredType); if (valueType == null) { throw new IllegalValueTypeException("Type " + declaredType.getName() + " is not handled at the moment");
public CommandFactory(ClassLoader loader) throws NullPointerException { this(new ValueTypeFactory(loader)); }
public void testFile() throws Exception { ValueType<File> fileVT = factory.get(File.class); File tmp = File.createTempFile("foo", ".bar"); tmp.deleteOnExit(); File f = fileVT.parse(tmp.getAbsolutePath()); assertNotNull(f); assertEquals(f, tmp); }
public CommandFactory(ClassLoader loader) throws NullPointerException { this(new ValueTypeFactory(loader)); }
public void testProperties() throws Exception { ValueType<Properties> propertiesVT = factory.get(Properties.class); Properties props = propertiesVT.parse("org.apache.jackrabbit.repository.conf=repository" + "-in-memory.xml;org.apache.jackrabbit.repository.home=/home/ehugonnet/tmp/crash/jcr/target" + "/test-classes/conf/transient"); assertNotNull(props); assertEquals(2, props.size()); assertEquals("repository-in-memory.xml", props.get("org.apache.jackrabbit.repository.conf")); assertEquals("/home/ehugonnet/tmp/crash/jcr/target/test-classes/conf/transient", props.get("org.apache.jackrabbit.repository.home")); }
public void testBoolean() throws Exception { ValueType<Boolean> booleanVT = factory.get(Boolean.class); assertEquals(Boolean.class, booleanVT.getType()); boolean b = booleanVT.parse("false"); assertEquals(false, b); }
public void testString() throws Exception { ValueType<String> stringVT = factory.get(String.class); assertEquals(String.class, stringVT.getType()); String s = stringVT.parse("abc"); assertEquals("abc", s); }
public void testInteger() throws Exception { ValueType<Integer> stringVT = factory.get(Integer.class); assertEquals(Integer.class, stringVT.getType()); int i = stringVT.parse("123"); assertEquals(123, i); }
public void testEnum() throws Exception { ValueType<Enum> stringVT = factory.<Enum, Color>get(Color.class); assertEquals(Enum.class, stringVT.getType()); Color red = stringVT.parse(Color.class, "RED"); assertEquals(Color.RED, red); }
} else { effectiveType = declaredType; valueType = factory.get(declaredType); if (valueType == null) { throw new IllegalValueTypeException("Type " + declaredType.getName() + " is not handled at the moment");
} else { effectiveType = declaredType; valueType = factory.get(declaredType); if (valueType == null) { throw new IllegalValueTypeException("Type " + declaredType.getName() + " is not handled at the moment");