-
Notifications
You must be signed in to change notification settings - Fork 228
/
TestInfinispanConfigFileRemoteCache.java
101 lines (73 loc) · 3.55 KB
/
TestInfinispanConfigFileRemoteCache.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
package org.teiid.resource.adapter.infinispan.hotrod;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.Properties;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.teiid.core.util.PropertiesUtils;
import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.Version;
@SuppressWarnings("nls")
public class TestInfinispanConfigFileRemoteCache {
private static InfinispanManagedConnectionFactory factory = null;
@BeforeClass
public static void beforeEachClass() throws Exception {
RemoteInfinispanTestHelper.startServer();
System.out.println("Hostaddress " + RemoteInfinispanTestHelper.hostAddress());
// read in the properties template file and set the server host:port and then save for use
File f = new File("./src/test/resources/jdg.properties");
Properties props = PropertiesUtils.load(f.getAbsolutePath());
props.setProperty("infinispan.client.hotrod.server_list", RemoteInfinispanTestHelper.hostAddress() + ":" + RemoteInfinispanTestHelper.hostPort());
PropertiesUtils.print("./target/hotrod-client.properties", props);
factory = new InfinispanManagedConnectionFactory();
factory.setHotRodClientPropertiesFile("./target/hotrod-client.properties");
factory.setCacheTypeMap(RemoteInfinispanTestHelper.PERSON_CACHE_NAME + ":" + RemoteInfinispanTestHelper.PERSON_CLASS.getName()+ ";" + RemoteInfinispanTestHelper.PKEY_COLUMN);
}
@AfterClass
public static void closeConnection() throws Exception {
RemoteInfinispanTestHelper.releaseServer();
}
@Test
public void testConnection() throws Exception {
try {
ObjectConnection conn = factory.createConnectionFactory().getConnection();
Class<?> clz = conn.getCacheClassType();
assertEquals(RemoteInfinispanTestHelper.PERSON_CLASS, clz);
Class<?> t = conn.getCacheKeyClassType();
assertNull(t);
assertEquals(RemoteInfinispanTestHelper.PKEY_COLUMN, conn.getPkField());
assertNotNull(conn.getCache());
assertEquals("Support For Compare is false", conn.getVersion().compareTo(Version.getVersion("6.6")) >= 0, false );
// assertEquals("Version doesn't start with 7.2", conn.getVersion().startsWith("7.2"));
conn.cleanUp();
} finally {
factory.cleanUp();
RemoteInfinispanTestHelper.releaseServer();
}
}
}