Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/config/ApplicationConfigurationTest.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/config/ApplicationConfigurationTest.java?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/config/ApplicationConfigurationTest.java (added) +++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/config/ApplicationConfigurationTest.java Mon Mar 11 17:39:42 2013 @@ -0,0 +1,78 @@ +/* + * Copyright 2001-2009 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.config; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.commons.configuration.ConfigurationException; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author <a href="mailto:[email protected]">Kurt T Stam</a> + */ +public class ApplicationConfigurationTest +{ + @Test + public void readPropertyFromFile() throws ConfigurationException + { + try { + long refreshDelay = AppConfig.getConfiguration().getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY); + System.out.println("refreshDelay=" + refreshDelay); + Assert.assertEquals(2000l, refreshDelay); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void readNonExistingProperty() throws ConfigurationException + { + long defaultValue = 3000l; + try { + long nonexisting = AppConfig.getConfiguration().getLong("nonexisting.property",defaultValue); + System.out.println("nonexisting=" + nonexisting); + Assert.assertEquals(3000l, nonexisting); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void testURLFormats() throws MalformedURLException, URISyntaxException { + + URI file = new URI("file:/tmp/"); + String path = file.getSchemeSpecificPart(); + Assert.assertEquals("/tmp/", path); + + URI fileInJar = new URI("jar:file:/tmp/my.jar!/"); + String path1 = fileInJar.getSchemeSpecificPart(); + Assert.assertEquals("file:/tmp/my.jar!/", path1); + + URI fileInZip = new URI("zip:D:/bea/tmp/_WL_user/JuddiEAR/nk4cwv/war/WEB-INF/lib/juddi-core-3.0.1.jar!"); + String path2 = fileInZip.getSchemeSpecificPart(); + Assert.assertEquals("D:/bea/tmp/_WL_user/JuddiEAR/nk4cwv/war/WEB-INF/lib/juddi-core-3.0.1.jar!", path2); + + URI fileInVfszip = new URI("vfsfile:/tmp/SOA%20Platform/jbossesb-registry.sar/juddi_custom_install_data/root_Publisher.xml"); + String path3 = fileInVfszip.getSchemeSpecificPart(); + Assert.assertEquals("/tmp/SOA Platform/jbossesb-registry.sar/juddi_custom_install_data/root_Publisher.xml", path3); + + } + +}
Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/keygen/KeyGeneratorTest.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/keygen/KeyGeneratorTest.java?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/keygen/KeyGeneratorTest.java (added) +++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/keygen/KeyGeneratorTest.java Mon Mar 11 17:39:42 2013 @@ -0,0 +1,76 @@ +/* + * Copyright 2001-2009 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.keygen; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.juddi.config.Property; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author <a href="mailto:[email protected]">Kurt T Stam</a> + */ +public class KeyGeneratorTest +{ + private Log logger = LogFactory.getLog(this.getClass()); + + + @Test() + public void testNonExisitingKeyGeneratorClass() + { + System.setProperty(Property.JUDDI_KEYGENERATOR, "org.apache.juddi.keygen.FooGenerator"); + try { + KeyGeneratorFactory.getKeyGenerator(); + Assert.fail("This should have thrown an exception because this class does not exist."); + } catch (Exception e) { + String message = e.getMessage(); + Assert.assertEquals("The specified Key Generator class 'org.apache.juddi.keygen.FooGenerator' was not found on classpath.", message); + } + } + + @Test() + public void testGeneratorInterface() + { + System.setProperty(Property.JUDDI_KEYGENERATOR, "org.apache.juddi.keygen.KeyGenerator"); + try { + KeyGeneratorFactory.getKeyGenerator(); + Assert.fail("This should have thrown an exception because you cannot instantiate an interface."); + } catch (Exception e) { + String message = e.getMessage(); + Assert.assertEquals("The specified Key Generator class 'org.apache.juddi.keygen.KeyGenerator' cannot be instantiated.", message); + } + } + /** + * The DefaultKeyGenerator + * @throws ConfigurationException + */ + @Test + public void testDefaultKeyGenerator() + { + System.setProperty(Property.JUDDI_KEYGENERATOR, "org.apache.juddi.keygen.DefaultKeyGenerator"); + try { + KeyGenerator keyGenerator = KeyGeneratorFactory.getKeyGenerator(); + Assert.assertEquals(org.apache.juddi.keygen.DefaultKeyGenerator.class, keyGenerator.getClass()); + String key = keyGenerator.generate(); + Assert.assertNotNull(key); + } catch (Exception e) { + logger.error(e.getMessage(),e); + Assert.fail("unexpected"); + } + } + +} Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/rmi/JNDIRegistrationTest.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/rmi/JNDIRegistrationTest.java?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/rmi/JNDIRegistrationTest.java (added) +++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/rmi/JNDIRegistrationTest.java Mon Mar 11 17:39:42 2013 @@ -0,0 +1,58 @@ +/* + * Copyright 2001-2010 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.rmi; + +import org.apache.commons.configuration.ConfigurationException; +import org.junit.Assert; +import org.junit.Test; +import org.mockejb.jndi.MockContextFactory; + +/** + * @author <a href="mailto:[email protected]">Kurt T Stam</a> + */ +public class JNDIRegistrationTest +{ + @Test + public void registerToJNDI_AnonymousPort() throws ConfigurationException + { + try { + MockContextFactory.setAsInitial(); + //register all jUDDI services, under an anonymous port + JNDIRegistration.getInstance().register(0); + JNDIRegistration.getInstance().unregister(); + + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + } + + @Test + public void registerToJNDI_UserDefinedPort() throws ConfigurationException + { + try { + MockContextFactory.setAsInitial(); + //register all jUDDI services, under an use defined port + JNDIRegistration.getInstance().register(34567); + JNDIRegistration.getInstance().unregister(); + + } catch (Exception e) { + e.printStackTrace(); + Assert.fail(); + } + } + + +} Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java (added) +++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/SubscriptionNotifierTest.java Mon Mar 11 17:39:42 2013 @@ -0,0 +1,119 @@ +/* + * Copyright 2001-2009 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.subscription; + +import java.net.MalformedURLException; +import java.rmi.RemoteException; +import java.util.Collection; +import java.util.Date; + +import javax.xml.datatype.DatatypeConfigurationException; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.juddi.api.impl.API_010_PublisherTest; +import org.apache.juddi.api.impl.UDDIInquiryImpl; +import org.apache.juddi.api.impl.UDDIPublicationImpl; +import org.apache.juddi.api.impl.UDDISecurityImpl; +import org.apache.juddi.api.impl.UDDISubscriptionImpl; +import org.apache.juddi.model.Subscription; +import org.apache.juddi.model.UddiEntityPublisher; +import org.apache.juddi.v3.tck.TckBindingTemplate; +import org.apache.juddi.v3.tck.TckBusiness; +import org.apache.juddi.v3.tck.TckBusinessService; +import org.apache.juddi.v3.tck.TckPublisher; +import org.apache.juddi.v3.tck.TckSecurity; +import org.apache.juddi.v3.tck.TckSubscription; +import org.apache.juddi.v3.tck.TckTModel; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.uddi.sub_v3.GetSubscriptionResults; +import org.uddi.sub_v3.SubscriptionResultsList; +import org.uddi.v3_service.DispositionReportFaultMessage; + +/** + * @author <a href="mailto:[email protected]">Kurt T Stam</a> + */ +public class SubscriptionNotifierTest +{ + private static Log logger = LogFactory.getLog(SubscriptionNotifierTest.class); + private static API_010_PublisherTest api010 = new API_010_PublisherTest(); + private static TckTModel tckTModel = new TckTModel(new UDDIPublicationImpl(), new UDDIInquiryImpl()); + private static TckBusiness tckBusiness = new TckBusiness(new UDDIPublicationImpl(), new UDDIInquiryImpl()); + private static TckBusinessService tckBusinessService = new TckBusinessService(new UDDIPublicationImpl(), new UDDIInquiryImpl()); + private static TckBindingTemplate tckBindingTemplate = new TckBindingTemplate(new UDDIPublicationImpl(), new UDDIInquiryImpl()); + private static TckSubscription tckSubscription = new TckSubscription(new UDDISubscriptionImpl(), new UDDISecurityImpl()); + + private static String authInfoJoe = null; + + @BeforeClass + public static void setup() { + logger.debug("Getting auth token.."); + try { + api010.saveJoePublisher(); + authInfoJoe = TckSecurity.getAuthToken(new UDDISecurityImpl(), TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword()); + tckTModel.saveJoePublisherTmodel(authInfoJoe); + tckBusiness.saveJoePublisherBusiness(authInfoJoe); + tckBusinessService.saveJoePublisherService(authInfoJoe); + //tckBindingTemplate.saveJoePublisherBinding(authInfoJoe); + tckSubscription.saveJoePublisherSubscription(authInfoJoe); + //tckSubscription.getJoePublisherSubscriptionResults(authInfoJoe); + } catch (RemoteException e) { + logger.error(e.getMessage(), e); + Assert.fail("Could not obtain authInfo token."); + } + } + @Test + public void testGetSubscriptionResults() + throws ConfigurationException, MalformedURLException, DispositionReportFaultMessage, DatatypeConfigurationException + { + SubscriptionNotifier notifier = new SubscriptionNotifier(); + notifier.cancel(); + Collection<Subscription> subscriptions = notifier.getAllAsyncSubscriptions(); + Assert.assertEquals(1, subscriptions.size()); + Subscription subscription = subscriptions.iterator().next(); + GetSubscriptionResults getSubscriptionResults = notifier.buildGetSubscriptionResults(subscription, new Date(new Date().getTime() + 60000l)); + getSubscriptionResults.setSubscriptionKey(subscription.getSubscriptionKey()); + UddiEntityPublisher publisher = new UddiEntityPublisher(); + publisher.setAuthorizedName(subscription.getAuthorizedName()); + SubscriptionResultsList resultList = notifier.getSubscriptionImpl().getSubscriptionResults(getSubscriptionResults, publisher); + logger.info("Expecting the resultList to be null: " + resultList.getServiceList()); + Assert.assertNull(resultList.getServiceList()); + tckBusinessService.updateJoePublisherService(authInfoJoe, "updated description"); + resultList = notifier.getSubscriptionImpl().getSubscriptionResults(getSubscriptionResults, publisher); + //We're expecting a changed service + logger.info("Expecting the resultList to have 1 service: " + resultList.getServiceList()); + Assert.assertNotNull(resultList.getServiceList()); + //We should detect these changes. + boolean hasChanges = notifier.resultListContainsChanges(resultList); + Assert.assertTrue(hasChanges); + System.out.print(resultList); + notifier.notify(getSubscriptionResults,resultList,new Date()); + } + + + @AfterClass + public static void teardown() { + tckSubscription.deleteJoePublisherSubscription(authInfoJoe); + //tckBindingTemplate.deleteJoePublisherBinding(authInfoJoe); + tckBusinessService.deleteJoePublisherService(authInfoJoe); + tckBusiness.deleteJoePublisherBusiness(authInfoJoe); + tckTModel.deleteJoePublisherTmodel(authInfoJoe); + } + +} Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/notify/NotifierTest.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/notify/NotifierTest.java?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/notify/NotifierTest.java (added) +++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/subscription/notify/NotifierTest.java Mon Mar 11 17:39:42 2013 @@ -0,0 +1,93 @@ +/* +cd .. * Copyright 2001-2009 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.juddi.subscription.notify; + +import java.lang.reflect.InvocationTargetException; +import java.net.URISyntaxException; + +import junit.framework.Assert; + +import org.apache.juddi.api_v3.AccessPointType; +import org.apache.juddi.model.BindingTemplate; +import org.apache.juddi.model.TmodelInstanceInfo; +import org.junit.Test; + +/** + * @author <a href="mailto:[email protected]">Kurt T Stam</a> + */ +public class NotifierTest +{ + @Test + public void testHTTPNotifier() throws IllegalArgumentException, SecurityException, URISyntaxException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { + BindingTemplate bindingTemplate = new BindingTemplate(); + bindingTemplate.setEntityKey("uddi:uddi.joepublisher.com:bindingnotifier"); + bindingTemplate.setAccessPointType(AccessPointType.END_POINT.toString()); + bindingTemplate.setAccessPointUrl("http://localhost:12345/tcksubscriptionlistener"); + TmodelInstanceInfo instanceInfo = new TmodelInstanceInfo(); + instanceInfo.setTmodelKey("uddi:uddi.org:transport:http"); + bindingTemplate.getTmodelInstanceInfos().add(instanceInfo); + + Notifier notifier = new NotifierFactory().getNotifier(bindingTemplate); + + Assert.assertEquals(HTTPNotifier.class, notifier.getClass()); + } + @Test + public void testSMTPNotifier() throws IllegalArgumentException, SecurityException, URISyntaxException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { + BindingTemplate bindingTemplate = new BindingTemplate(); + bindingTemplate.setEntityKey("uddi:uddi.joepublisher.com:bindingnotifier"); + bindingTemplate.setAccessPointType(AccessPointType.END_POINT.toString()); + bindingTemplate.setAccessPointUrl("mailto:[email protected]"); + TmodelInstanceInfo instanceInfo = new TmodelInstanceInfo(); + instanceInfo.setTmodelKey("uddi:uddi.org:transport:smtp"); + bindingTemplate.getTmodelInstanceInfos().add(instanceInfo); + + Notifier notifier = new NotifierFactory().getNotifier(bindingTemplate); + + Assert.assertEquals(SMTPNotifier.class, notifier.getClass()); + } + //Expected error because we can't connect to the registry on localhost:11099 + @Test(expected=java.lang.reflect.InvocationTargetException.class) + public void testRMINotifier() throws IllegalArgumentException, SecurityException, URISyntaxException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { + BindingTemplate bindingTemplate = new BindingTemplate(); + bindingTemplate.setEntityKey("uddi:uddi.joepublisher.com:bindingnotifier"); + bindingTemplate.setAccessPointType(AccessPointType.END_POINT.toString()); + bindingTemplate.setAccessPointUrl("rmi://localhost:11099/tcksubscriptionlistener"); + TmodelInstanceInfo instanceInfo = new TmodelInstanceInfo(); + instanceInfo.setTmodelKey("uddi:uddi.org:transport:rmi"); + bindingTemplate.getTmodelInstanceInfos().add(instanceInfo); + + Notifier notifier = new NotifierFactory().getNotifier(bindingTemplate); + + Assert.assertEquals(RMINotifier.class, notifier.getClass()); + } + //Expected error because we did not specify a correct InitialContext + @Test(expected=java.lang.reflect.InvocationTargetException.class) + public void testJNDIRMINotifier() throws IllegalArgumentException, SecurityException, URISyntaxException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { + BindingTemplate bindingTemplate = new BindingTemplate(); + bindingTemplate.setEntityKey("uddi:uddi.joepublisher.com:bindingnotifier"); + bindingTemplate.setAccessPointType(AccessPointType.END_POINT.toString()); + bindingTemplate.setAccessPointUrl("jndi-rmi://localhost:11099/tcksubscriptionlistener"); + TmodelInstanceInfo instanceInfo = new TmodelInstanceInfo(); + instanceInfo.setTmodelKey("uddi:uddi.org:transport:jndi-rmi"); + bindingTemplate.getTmodelInstanceInfos().add(instanceInfo); + + Notifier notifier = new NotifierFactory().getNotifier(bindingTemplate); + + Assert.assertEquals(JNDI_RMINotifier.class, notifier.getClass()); + } + + + +} Added: juddi/trunk/juddi-core/src/test/java/org/apache/juddi/util/JPAUtil.java URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/java/org/apache/juddi/util/JPAUtil.java?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/java/org/apache/juddi/util/JPAUtil.java (added) +++ juddi/trunk/juddi-core/src/test/java/org/apache/juddi/util/JPAUtil.java Mon Mar 11 17:39:42 2013 @@ -0,0 +1,156 @@ +/* + * Copyright 2001-2008 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.juddi.util; + +import javax.persistence.EntityTransaction; +import javax.persistence.EntityManager; + +import javax.persistence.Query; +import java.util.List; + +import org.apache.juddi.config.PersistenceManager; + + +/** + * @author <a href="mailto:[email protected]">Jeff Faath</a> + * + * Example use: + public void test() { + Object object = JPAUtil.getEntity(Tmodel.class, "uddi:juddi.apache.org:joepublisher:kEYGENERATOR"); + System.out.println("object=" + object); + } + */ +public class JPAUtil { + //TODO Comment from Code Review: This class does not seem to be in use. Do we need it? + + public static void persistEntity(Object uddiEntity, Object entityKey) { + EntityManager em = PersistenceManager.getEntityManager(); + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + + Object existingUddiEntity = em.find(uddiEntity.getClass(), entityKey); + if (existingUddiEntity != null) + em.remove(existingUddiEntity); + + em.persist(uddiEntity); + + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + em.close(); + } + } + + public static Object getEntity(Class<?> entityClass, Object entityKey) { + EntityManager em = PersistenceManager.getEntityManager(); + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + + Object obj = em.find(entityClass, entityKey); + + tx.commit(); + return obj; + } finally { + if (tx.isActive()) { + tx.rollback(); + } + em.close(); + } + } + + public static void deleteEntity(Class<?> entityClass, Object entityKey) { + EntityManager em = PersistenceManager.getEntityManager(); + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + + Object obj = em.find(entityClass, entityKey); + em.remove(obj); + + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + em.close(); + } + } + + public static List<?> runQuery(String qry, int maxRows, int listHead) { + EntityManager em = PersistenceManager.getEntityManager(); + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + Query q = em.createQuery(qry); + q.setMaxResults(maxRows); + q.setFirstResult(listHead); + List<?> ret = q.getResultList(); + tx.commit(); + return ret; + } finally { + if (tx.isActive()) { + tx.rollback(); + } + em.close(); + } + + } + + public static void runUpdateQuery(String qry) { + EntityManager em = PersistenceManager.getEntityManager(); + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + + Query q = em.createQuery(qry); + q.executeUpdate(); + + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + em.close(); + } + } + + public static void removeAuthTokens() { + + EntityManager em = PersistenceManager.getEntityManager(); + EntityTransaction tx = em.getTransaction(); + try { + tx.begin(); + + Query qry = em.createQuery("delete from AuthToken"); + qry.executeUpdate(); + + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + em.close(); + } + + } + +} Added: juddi/trunk/juddi-core/src/test/resources/META-INF/orm.xml URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/resources/META-INF/orm.xml?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/resources/META-INF/orm.xml (added) +++ juddi/trunk/juddi-core/src/test/resources/META-INF/orm.xml Mon Mar 11 17:39:42 2013 @@ -0,0 +1,225 @@ +<entity-mappings + xmlns="http://java.sun.com/xml/ns/persistence/orm" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" + version="1.0"> + + <sequence-generator name="juddi_sequence" sequence-name="juddi_sequence"/> + + <entity class="org.apache.juddi.model.Address"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.AddressLine"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.BindingDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.BusinessDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.BusinessIdentifier"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.BusinessName"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.CategoryBag"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.Contact"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.ContactDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.DiscoveryUrl"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.Email"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.InstanceDetailsDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.InstanceDetailsDocDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.KeyedReference"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.KeyedReferenceGroup"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.OverviewDoc"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.OverviewDocDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.PersonName"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.Phone"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.ServiceDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.ServiceName"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.SubscriptionMatch"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.TmodelDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.TmodelIdentifier"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.TmodelInstanceInfo"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.TmodelInstanceInfoDescr"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + + <entity class="org.apache.juddi.model.TransferTokenKey"> + <attributes> + <id name="id"> + <generated-value generator="juddi_sequence" strategy="AUTO"/> + </id> + </attributes> + </entity> + +</entity-mappings> Added: juddi/trunk/juddi-core/src/test/resources/META-INF/persistence.xml URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/resources/META-INF/persistence.xml?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/resources/META-INF/persistence.xml (added) +++ juddi/trunk/juddi-core/src/test/resources/META-INF/persistence.xml Mon Mar 11 17:39:42 2013 @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> + <persistence-unit name="juddiDatabase" transaction-type="RESOURCE_LOCAL"> + <provider>org.hibernate.ejb.HibernatePersistence</provider> + + <!-- entity classes --> + <class>org.apache.juddi.model.Address</class> + <class>org.apache.juddi.model.AddressLine</class> + <class>org.apache.juddi.model.AuthToken</class> + <class>org.apache.juddi.model.BindingCategoryBag</class> + <class>org.apache.juddi.model.BindingDescr</class> + <class>org.apache.juddi.model.BindingTemplate</class> + <class>org.apache.juddi.model.BusinessCategoryBag</class> + <class>org.apache.juddi.model.BusinessDescr</class> + <class>org.apache.juddi.model.BusinessEntity</class> + <class>org.apache.juddi.model.BusinessIdentifier</class> + <class>org.apache.juddi.model.BusinessName</class> + <class>org.apache.juddi.model.BusinessService</class> + <class>org.apache.juddi.model.CanonicalizationMethod</class> + <class>org.apache.juddi.model.CategoryBag</class> + <class>org.apache.juddi.model.Clerk</class> + <class>org.apache.juddi.model.ClientSubscriptionInfo</class> + <class>org.apache.juddi.model.Contact</class> + <class>org.apache.juddi.model.ContactDescr</class> + <class>org.apache.juddi.model.DiscoveryUrl</class> + <class>org.apache.juddi.model.Email</class> + <class>org.apache.juddi.model.InstanceDetailsDescr</class> + <class>org.apache.juddi.model.InstanceDetailsDocDescr</class> + <class>org.apache.juddi.model.KeyedReference</class> + <class>org.apache.juddi.model.KeyedReferenceGroup</class> + <class>org.apache.juddi.model.KeyDataValue</class> + <class>org.apache.juddi.model.KeyInfo</class> + <class>org.apache.juddi.model.Node</class> + <class>org.apache.juddi.model.ObjectType</class> + <class>org.apache.juddi.model.ObjectTypeContent</class> + <class>org.apache.juddi.model.OverviewDoc</class> + <class>org.apache.juddi.model.OverviewDocDescr</class> + <class>org.apache.juddi.model.PersonName</class> + <class>org.apache.juddi.model.Phone</class> + <class>org.apache.juddi.model.Publisher</class> + <class>org.apache.juddi.model.PublisherAssertion</class> + <class>org.apache.juddi.model.PublisherAssertionId</class> + <class>org.apache.juddi.model.Reference</class> + <class>org.apache.juddi.model.ServiceCategoryBag</class> + <class>org.apache.juddi.model.ServiceDescr</class> + <class>org.apache.juddi.model.ServiceName</class> + <class>org.apache.juddi.model.ServiceProjection</class> + <class>org.apache.juddi.model.ServiceProjectionId</class> + <class>org.apache.juddi.model.Signature</class> + <class>org.apache.juddi.model.SignatureMethod</class> + <class>org.apache.juddi.model.SignatureTransform</class> + <class>org.apache.juddi.model.SignatureTransformDataValue</class> + <class>org.apache.juddi.model.SignatureValue</class> + <class>org.apache.juddi.model.SignedInfo</class> + <class>org.apache.juddi.model.Subscription</class> + <class>org.apache.juddi.model.SubscriptionChunkToken</class> + <class>org.apache.juddi.model.SubscriptionMatch</class> + <class>org.apache.juddi.model.Tmodel</class> + <class>org.apache.juddi.model.TmodelCategoryBag</class> + <class>org.apache.juddi.model.TmodelDescr</class> + <class>org.apache.juddi.model.TmodelIdentifier</class> + <class>org.apache.juddi.model.TmodelInstanceInfo</class> + <class>org.apache.juddi.model.TmodelInstanceInfoDescr</class> + <class>org.apache.juddi.model.TransferToken</class> + <class>org.apache.juddi.model.TransferTokenKey</class> + <class>org.apache.juddi.model.UddiEntity</class> + <class>org.apache.juddi.model.UddiEntityPublisher</class> + + <properties> + <property name="hibernate.archive.autodetection" value="class"/> + <property name="hibernate.hbm2ddl.auto" value="update"/> + <property name="hibernate.show_sql" value="false"/> + + <!-- derby connection properties --> + <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/> + <property name="hibernate.connection.driver_class" value="org.apache.derby.jdbc.EmbeddedDriver"/> + <property name="hibernate.connection.url" value="jdbc:derby:memory:juddi-derby-test-db;create=true"/> + <property name="hibernate.connection.username" value=""/> + <property name="hibernate.connection.password" value=""/> + + <!-- mysql connection properties + + <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" /> + <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" /> + <property name="hibernate.connection.username" value="juddiv3" /> + <property name="hibernate.connection.password" value="" /> + <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/juddiv3" /> +--> + + <!-- connection pool properties --> + <property name="hibernate.dbcp.maxActive" value="100"/> + <property name="hibernate.dbcp.maxIdle" value="30"/> + <property name="hibernate.dbcp.maxWait" value="10000"/> + + </properties> + </persistence-unit> +</persistence> Added: juddi/trunk/juddi-core/src/test/resources/juddi-users-encrypted.xml URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/resources/juddi-users-encrypted.xml?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/resources/juddi-users-encrypted.xml (added) +++ juddi/trunk/juddi-core/src/test/resources/juddi-users-encrypted.xml Mon Mar 11 17:39:42 2013 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<juddi-users> + <user userid="anou_mana" password="+j/kXkZJftwTFTBH6Cf6IQ=="/> + <user userid="bozo" password="Na2Ait+2aW0="/> + <user userid="sviens" password="+j/kXkZJftwTFTBH6Cf6IQ=="/> +</juddi-users> \ No newline at end of file Added: juddi/trunk/juddi-core/src/test/resources/juddi-users.xml URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/resources/juddi-users.xml?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/resources/juddi-users.xml (added) +++ juddi/trunk/juddi-core/src/test/resources/juddi-users.xml Mon Mar 11 17:39:42 2013 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<juddi-users> + <user userid="anou_mana" password="password" /> + <user userid="bozo" password="clown" /> + <user userid="sviens" password="password" /> +</juddi-users> \ No newline at end of file Added: juddi/trunk/juddi-core/src/test/resources/juddiv3.properties URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/resources/juddiv3.properties?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/resources/juddiv3.properties (added) +++ juddi/trunk/juddi-core/src/test/resources/juddiv3.properties Mon Mar 11 17:39:42 2013 @@ -0,0 +1,82 @@ +################################################################ +# jUDDI-v3.0 configuration. # +################################################################ +# Note that the property settings in this # +# file can be overriden by system parameters # +# # +################################################################ +# The ${juddi.server.baseurl} token can be referenced in accessPoints and will be resolved at runtime. +juddi.server.baseurl=http://localhost:8080/juddiv3 +# +juddi.root.publisher=root +# +juddi.seed.always=false +# +# Name of the persistence unit to use (the default, "juddiDatabase" refers to the unit compiled into the juddi library) +juddi.persistenceunit.name=juddiDatabase +# +# Check-the-time-stamp-on-this-file Interval in milli seconds +juddi.configuration.reload.delay=2000 +# +# Default locale +juddi.locale=en_US +# +#The UDDI Operator Contact Email Address [email protected] +# +# The maximum name size and maximum number +# of name elements allows in several of the +# FindXxxx and SaveXxxx UDDI functions. +juddi.maxNameLength=255 +juddi.maxNameElementsAllowed=5 +# +# +# The maximum number of rows returned in a find_* operation. Each call can set +# this independently, but this property defines a global maximum. +juddi.maxRows=1000 +# The maximum number of "IN" clause parameters. Some RDMBS limit the number of +# parameters allowed in a SQL "IN" clause. +juddi.maxInClause=1000 +# +# The maximum number of UDDI artifacts allowed +# per publisher. A value of '-1' indicates any +# number of artifacts is valid (These values can be +# overridden at the individual publisher level). +juddi.maxBusinessesPerPublisher=25 +juddi.maxServicesPerBusiness=20 +juddi.maxBindingsPerService=10 +juddi.maxTModelsPerPublisher=100 +# +# Days before a transfer request expires +juddi.transfer.expiration.days=3 +# +# Days before a subscription expires +juddi.subscription.expiration.days=30 +# +# Minutes before a "chunked" subscription call expires +juddi.subscription.chunkexpiration.minutes=5 +# +# jUDDI Authentication module to use +juddi.authenticator = org.apache.juddi.v3.auth.JUDDIAuthenticator +# +# jUDDI UUIDGen implementation to use +juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen +# +# jUDDI Cryptor implementation to use +juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor +# +# jUDDI Key Generator to use +juddi.keygenerator=org.apache.juddi.keygen.DefaultKeyGenerator +# +# Specifies whether the inquiry API requires authentication +juddi.authenticate.Inquiry=false +# +# Specifies the interval at which the notification timer triggers +juddi.notification.interval=5000 +# Specifies the amount of time to wait before the notification timer initially fires +juddi.notification.start.buffer=0 + + + +# Duration of time for tokens to expire +juddi.auth.token.Timeout=15 \ No newline at end of file Added: juddi/trunk/juddi-core/src/test/resources/log4j.xml URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/test/resources/log4j.xml?rev=1455249&view=auto ============================================================================== --- juddi/trunk/juddi-core/src/test/resources/log4j.xml (added) +++ juddi/trunk/juddi-core/src/test/resources/log4j.xml Mon Mar 11 17:39:42 2013 @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> +<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> + + <!-- ================================= --> + <!-- Preserve messages in a local file --> + <!-- ================================= --> + + <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <param name="Threshold" value="DEBUG"/> + + <layout class="org.apache.log4j.PatternLayout"> + <!-- The default pattern: Date Priority [Category] Message\n --> + <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/> + </layout> + </appender> + + <logger name="org"> + <level value="INFO"/> + </logger> + + <logger name="org.hibernate"> + <level value="WARN"/> + </logger> + + <logger name="com"> + <level value="INFO"/> + </logger> + + <root> + <appender-ref ref="CONSOLE"/> + </root> + + +</log4j:configuration> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
