Package javax.jcr

Examples of javax.jcr.Property


    }

    @Override
    public Property setProperty(final String name, final BigDecimal value) throws RepositoryException {
        ItemData itemData = ItemData.newProperty(getPath() + "/" + name);
        Property property = new MockProperty(itemData, getSession());
        property.setValue(value);
        getMockedSession().addItem(itemData);
        return property;
    }
View Full Code Here


    @Test
    public void testStringArray() throws RepositoryException {
        String[] value1 = new String[] { "aaa", "bbb" };
        this.node1.setProperty("prop1", value1);
        Property prop1 = this.node1.getProperty("prop1");

        Value[] values = prop1.getValues();
        for (int i = 0; i < values.length; i++) {
            assertEquals("value #" + i, value1[i], values[i].getString());
        }

        String[] value2 = new String[] { "cc" };
        prop1.setValue(value2);
        values = prop1.getValues();
        for (int i = 0; i < values.length; i++) {
            assertEquals("value #" + i, value2[i], values[i].getString());
        }

        assertTrue(prop1.isMultiple());
        assertTrue(prop1.getDefinition().isMultiple());
        assertArrayEquals(new long[] { 2 }, prop1.getLengths());
    }
View Full Code Here

    }

    @Test
    public void testBoolean() throws RepositoryException {
        this.node1.setProperty("prop1", true);
        Property prop1 = this.node1.getProperty("prop1");
        assertEquals(true, prop1.getBoolean());
        assertEquals(true, prop1.getValue().getBoolean());

        prop1.setValue(false);
        assertEquals(false, prop1.getBoolean());
        assertEquals(false, prop1.getValue().getBoolean());
    }
View Full Code Here

    }

    @Test
    public void testDouble() throws RepositoryException {
        this.node1.setProperty("prop1", 1.5d);
        Property prop1 = this.node1.getProperty("prop1");
        assertEquals(1.5d, prop1.getDouble(), 0.001d);
        assertEquals(1.5d, prop1.getValue().getDouble(), 0.001d);

        prop1.setValue(Double.MAX_VALUE);
        assertEquals(Double.MAX_VALUE, prop1.getDouble(), 0.001d);
        assertEquals(Double.MAX_VALUE, prop1.getValue().getDouble(), 0.001d);
    }
View Full Code Here

    }

    @Test
    public void testLong() throws RepositoryException {
        this.node1.setProperty("prop1", 5L);
        Property prop1 = this.node1.getProperty("prop1");
        assertEquals(5L, prop1.getLong());
        assertEquals(5L, prop1.getValue().getLong());

        prop1.setValue(Long.MAX_VALUE);
        assertEquals(Long.MAX_VALUE, prop1.getLong());
        assertEquals(Long.MAX_VALUE, prop1.getValue().getLong());
    }
View Full Code Here

    }

    @Test
    public void testBigDecimal() throws RepositoryException {
        this.node1.setProperty("prop1", new BigDecimal("1.5"));
        Property prop1 = this.node1.getProperty("prop1");
        assertEquals(new BigDecimal("1.5"), prop1.getDecimal());
        assertEquals(new BigDecimal("1.5"), prop1.getValue().getDecimal());

        prop1.setValue(new BigDecimal("99999999.99999"));
        assertEquals(new BigDecimal("99999999.99999"), prop1.getDecimal());
        assertEquals(new BigDecimal("99999999.99999"), prop1.getValue().getDecimal());
    }
View Full Code Here

    @Test
    public void testCalendar() throws RepositoryException {
        Calendar value1 = Calendar.getInstance();

        this.node1.setProperty("prop1", value1);
        Property prop1 = this.node1.getProperty("prop1");
        assertEquals(value1, prop1.getDate());
        assertEquals(value1, prop1.getValue().getDate());

        Calendar value2 = Calendar.getInstance();
        value2.add(Calendar.MONTH, -1);

        prop1.setValue(value2);
        assertEquals(value2, prop1.getDate());
        assertEquals(value2, prop1.getValue().getDate());
    }
View Full Code Here

    @Test
    public void testBinary() throws RepositoryException, IOException {
        byte[] value1 = new byte[] { 0x01, 0x01, 0x03 };

        this.node1.setProperty("prop1", new BinaryValue(value1).getBinary());
        Property prop1 = this.node1.getProperty("prop1");
        assertArrayEquals(value1, IOUtils.toByteArray(prop1.getBinary().getStream()));
        assertArrayEquals(value1, IOUtils.toByteArray(prop1.getValue().getBinary().getStream()));

        byte[] value2 = new byte[] { 0x04, 0x05, 0x06 };

        prop1.setValue(new BinaryValue(value2).getBinary());
        assertArrayEquals(value2, IOUtils.toByteArray(prop1.getBinary().getStream()));
        assertArrayEquals(value2, IOUtils.toByteArray(prop1.getValue().getBinary().getStream()));
    }
View Full Code Here

    @Test
    public void testInputStream() throws RepositoryException, IOException {
        byte[] value1 = new byte[] { 0x01, 0x01, 0x03 };

        this.node1.setProperty("prop1", new ByteArrayInputStream(value1));
        Property prop1 = this.node1.getProperty("prop1");
        assertArrayEquals(value1, IOUtils.toByteArray(prop1.getStream()));

        byte[] value2 = new byte[] { 0x04, 0x05, 0x06 };

        prop1.setValue(new ByteArrayInputStream(value2));
        assertArrayEquals(value2, IOUtils.toByteArray(prop1.getValue().getStream()));
    }
View Full Code Here

    }

    @Test
    public void testValue() throws RepositoryException {
        this.node1.setProperty("prop1", this.session.getValueFactory().createValue("value1"));
        Property prop1 = this.node1.getProperty("prop1");
        assertEquals("value1", prop1.getString());
        assertEquals("value1", prop1.getValue().getString());

        prop1.setValue(this.session.getValueFactory().createValue("value2"));
        assertEquals("value2", prop1.getString());
        assertEquals("value2", prop1.getValue().getString());

        assertFalse(prop1.isMultiple());
        assertFalse(prop1.getDefinition().isMultiple());
        assertEquals(6, prop1.getLength());
    }
View Full Code Here

TOP

Related Classes of javax.jcr.Property

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.